11 #include <QApplication>
13 #include <QFileDialog>
15 #include <QMessageBox>
47 Ui::PointListPickingDlg(),
50 m_orderedLabelsContainer(0) {
53 exportToolButton->setPopupMode(QToolButton::MenuButtonPopup);
54 QMenu* menu =
new QMenu(exportToolButton);
55 QAction* exportASCII_xyz = menu->addAction(
"x,y,z");
56 QAction* exportASCII_ixyz = menu->addAction(
"local index,x,y,z");
57 QAction* exportASCII_gxyz = menu->addAction(
"global index,x,y,z");
58 QAction* exportASCII_lxyz = menu->addAction(
"label name,x,y,z");
61 exportToolButton->setMenu(menu);
63 tableWidget->verticalHeader()->setSectionResizeMode(
64 QHeaderView::ResizeToContents);
69 connect(cancelToolButton, &QAbstractButton::clicked,
this,
71 connect(revertToolButton, &QAbstractButton::clicked,
this,
73 connect(validToolButton, &QAbstractButton::clicked,
this,
75 connect(exportToolButton, &QAbstractButton::clicked, exportToolButton,
76 &QToolButton::showMenu);
77 connect(exportASCII_xyz, &QAction::triggered,
this,
79 connect(exportASCII_ixyz, &QAction::triggered,
this,
81 connect(exportASCII_gxyz, &QAction::triggered,
this,
83 connect(exportASCII_lxyz, &QAction::triggered,
this,
90 connect(markerSizeSpinBox,
91 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
93 connect(startIndexSpinBox,
94 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
97 connect(showGlobalCoordsCheckBox, &QAbstractButton::clicked,
this,
104 std::vector<cc2DLabel*>& pickedPoints) {
105 pickedPoints.clear();
114 pickedPoints.reserve(
count);
115 }
catch (
const std::bad_alloc&) {
119 for (
unsigned i = 0; i <
count; ++i) {
125 pickedPoints.push_back(label);
131 return static_cast<unsigned>(pickedPoints.size());
145 for (ccHObject::Container::const_iterator it = groups.begin();
146 it != groups.end(); ++it) {
153 std::vector<cc2DLabel*> previousPickedPoints;
156 for (
unsigned i = 0; i <
count; ++i) {
158 previousPickedPoints[i]->getUniqueID());
162 showGlobalCoordsCheckBox->setEnabled(cloud ? cloud->
isShifted() :
false);
212 std::vector<cc2DLabel*> labels;
217 cloud->
setName(
"Picking list");
218 for (
unsigned i = 0; i <
count; ++i) {
230 "Can't export picked points as point cloud: not enough "
244 std::vector<cc2DLabel*> labels;
258 for (
unsigned i = 0; i <
count; ++i) {
295 std::vector<cc2DLabel*> labels;
297 if (
count == 0)
return;
299 ccHObject* lastVisibleLabel = labels.back();
348 unsigned int uValue =
static_cast<unsigned int>(value);
358 if (
size < 1)
return;
374 std::vector<cc2DLabel*> labels;
376 if (
count == 0)
return;
379 settings.beginGroup(
"PointListPickingDlg");
381 settings.value(
"filename",
"picking_list.txt").toString();
389 settings.beginGroup(
"PointListPickingDlg");
390 settings.setValue(
"filename",
filename);
393 FILE* fp = fopen(qPrintable(
filename),
"wt");
396 QString(
"Failed to open file '%1' for saving!").arg(
filename));
404 if (shift.
norm2() != 0 || scale != 1.0) {
405 if (QMessageBox::warning(
this,
"Apply global shift",
406 "Do you want to apply global shift/scale to "
408 QMessageBox::Yes | QMessageBox::No,
409 QMessageBox::Yes) == QMessageBox::No) {
417 unsigned startIndex =
418 static_cast<unsigned>(
std::max(0, startIndexSpinBox->value()));
420 for (
unsigned i = 0; i <
count; ++i) {
421 assert(labels[i]->
size() == 1);
427 fprintf(fp,
"%u,", i + startIndex);
430 fprintf(fp,
"%u,", PP.
index);
433 fprintf(fp,
"%s,", qPrintable(labels[i]->getName()));
440 fprintf(fp,
"%.12f,%.12f,%.12f\n",
441 static_cast<double>(P->
x) / scale - shift.
x,
442 static_cast<double>(P->
y) / scale - shift.
y,
443 static_cast<double>(P->
z) / scale - shift.
z);
453 std::vector<cc2DLabel*> labels;
456 revertToolButton->setEnabled(
count);
457 validToolButton->setEnabled(
count);
458 exportToolButton->setEnabled(
count);
459 countLineEdit->setText(QString::number(
count));
460 tableWidget->setRowCount(
count);
465 int startIndex = startIndexSpinBox->value();
471 bool showAbsolute = showGlobalCoordsCheckBox->isEnabled() &&
472 showGlobalCoordsCheckBox->isChecked();
474 for (
unsigned i = 0; i <
count; ++i) {
481 tableWidget->setVerticalHeaderItem(
482 i,
new QTableWidgetItem(QString(
"%1").arg(i + startIndex)));
489 QString::number(i + startIndex));
492 tableWidget->setItem(i, 0,
493 new QTableWidgetItem(QString(
"%1").arg(PP.
index)));
495 for (
unsigned j = 0; j < 3; ++j)
496 tableWidget->setItem(i, j + 1,
497 new QTableWidgetItem(QString(
"%1").arg(
498 Pd.
u[j], 0,
'f', precision)));
501 tableWidget->scrollToBottom();
519 static_cast<float>(y + 20) /
size.height());
534 QClipboard* clipboard = QApplication::clipboard();
542 startIndexSpinBox->value() +
546 clipboard->setText(QString(
"CC_POINT_#%0(%1;%2;%3)")
548 .arg(P->
x, 0,
'f', precision)
549 .arg(P->
y, 0,
'f', precision)
550 .arg(P->
z, 0,
'f', precision));
Vector3Tpl< double > CCVector3d
Double 3D Vector.
filament::Texture::InternalFormat format
static QString GetFileFilter()
static bool Print(const char *format,...)
Prints out a formatted message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
static MainWindow * TheInstance()
Returns the unique instance of this object.
ccDBRoot * db()
Returns real 'dbRoot' object.
void addToDB(const QStringList &filenames, QString fileFilter=QString(), bool displayDialog=true)
Type norm2() const
Returns vector square norm.
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
2D label (typically attached to points)
bool addPickedPoint(ccGenericPointCloud *cloud, unsigned pointIndex, bool entityCenter=false)
Adds a point to this label.
void setCollapsed(bool state)
Whether to collapse label or not.
void setDisplayedIn2D(bool state)
Whether to display the label in 2D.
unsigned size() const
Returns current size.
void setPosition(float x, float y)
Sets relative position.
void displayPointLegend(bool state)
Whether to display the point(s) legend (title only)
void removeElements(ccHObject::Container &objects)
Removes several elements at once from the DB tree.
void removeElement(ccHObject *object)
Removes an element from the DB tree.
virtual bool isVisible() const
Returns whether entity is visible or not.
virtual void setVisible(bool state)
Sets entity visibility.
static cc2DLabel * To2DLabel(ccHObject *obj)
Converts current object to cc2DLabel (if possible)
Hierarchical CLOUDVIEWER Object.
void removeDependencyWith(ccHObject *otherObject)
Removes any dependency flags with a given object.
void detachChild(ccHObject *child)
Detaches a specific child.
unsigned getChildrenNumber() const
Returns the number of children.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getParent() const
Returns parent object.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
virtual unsigned getUniqueID() const
Returns object unique ID.
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
Point/triangle picking hub.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
void exportToASCII_ixyz()
Exports list to an 'ixyz' ASCII file.
void exportToNewPolyline()
Exports list to a polyline.
void exportToASCII_gxyz()
Exports list to an 'gxyz' ASCII file.
void linkWithCloud(ccPointCloud *cloud)
Associates dialog with cloud.
void removeLastEntry()
Removes last inserted point from list.
void exportToASCII(ExportFormat format)
Exports list to an ASCII file.
ExportFormat
Export format.
void removeEntity(ccHObject *lastVisibleLabel)
unsigned m_lastPreviousID
Last existing label unique ID on load.
ccHObject::Container m_toBeDeleted
ccHObject * m_orderedLabelsContainer
Ordered labels container.
void startIndexChanged(int)
Redraw window when starting index changes.
void exportToASCII_lxyz()
Exports list to an 'lxyz' ASCII file.
ccPointCloud * m_associatedCloud
Associated cloud.
void updateList()
Updates point list widget.
ccPointListPickingDlg(ccPickingHub *pickingHub, QWidget *parent)
Default constructor.
void clearLastLabel(ccHObject *lastVisibleLabel)
void exportToASCII_xyz()
Exports list to an 'xyz' ASCII file.
virtual void processPickedPoint(ccPointCloud *cloud, unsigned pointIndex, int x, int y) override
Generic method to process picked points.
unsigned getPickedPoints(std::vector< cc2DLabel * > &pickedPoints)
Gets current (visible) picked points from the associated cloud.
void markerSizeChanged(int)
Redraw window when marker size changes.
void exportToNewCloud()
Exports list to a new cloud.
void applyAndExit()
Applies changes and exit.
ccHObject::Container m_toBeAdded
void cancelAndExit()
Cancels process and exit.
void stop(bool state) override
Stops process/dialog.
virtual void setGlobalShift(const CCVector3d &shift) override
Sets shift applied to original coordinates (information storage only)
virtual void setGlobalScale(double scale) override
virtual void setGlobalScale(double scale)
CCVector3d toGlobal3d(const Vector3Tpl< T > &Plocal) const
Returns the point back-projected into the original coordinates system.
bool isShifted() const
Returns whether the cloud is shifted or not.
virtual void setGlobalShift(double x, double y, double z)
Sets shift applied to original coordinates (information storage only)
virtual const CCVector3d & getGlobalShift() const
Returns the shift applied to original coordinates.
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.
virtual const CCVector3 * getPoint(unsigned index) const =0
Returns the ith point.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
const CCVector3 * getPoint(unsigned index) const override
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
virtual bool reserve(unsigned n)
Reserves some memory for hosting the point references.
static unsigned s_pickedPointsStartIndex
static bool s_showGlobalCoordsCheckBoxChecked
static const char s_defaultLabelBaseName[]
static const char s_pickedPointContainerName[]
unsigned index
Point/triangle index.
ccGenericPointCloud * cloud
Cloud.
unsigned labelMarkerSize
Label marker size.
unsigned displayedNumPrecision
Displayed numbers precision.