31 #include <QApplication>
33 #include <QMessageBox>
34 #include <QProgressDialog>
35 #include <QPushButton>
53 Ui::TracePolyLineDlg(),
63 setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
65 connect(saveToolButton, &QToolButton::clicked,
this,
67 connect(resetToolButton, &QToolButton::clicked,
this,
69 connect(continueToolButton, &QToolButton::clicked,
this,
71 connect(validButton, &QToolButton::clicked,
this,
73 connect(cancelButton, &QToolButton::clicked,
this,
76 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
98 widthSpinBox->value() < 2
100 : widthSpinBox->value());
104 validButton->setEnabled(
false);
154 if (clouds.empty() && meshes.empty()) {
168 if (!newVertices->reserve(end_size) || !newPoly->
reserve(end_size)) {
170 "[ccTracePolylineTool::PolylineOverSampling] Not enough "
180 QProgressDialog pDlg(QString(
"Oversampling"),
"Cancel", 0,
181 static_cast<int>(end_size),
186 QCoreApplication::processEvents();
188 for (
unsigned i = 0; i < n_segments; ++i) {
190 newVertices->addPoint(*p1);
192 unsigned i2 = (i + 1) % n_verts;
197 for (
unsigned j = 1; j < steps; j++) {
201 double nearestElementSquareDist = -1.0;
204 for (
size_t c = 0; c < clouds.size(); ++c) {
208 int nearestPointIndex = -1;
209 double nearestSquareDist = 0;
211 nearestPointIndex, nearestSquareDist,
212 snapSizeSpinBox->value(),
213 snapSizeSpinBox->value(),
true)) {
214 if (nearestElementSquareDist < 0 ||
215 nearestSquareDist < nearestElementSquareDist) {
216 nearestElementSquareDist = nearestSquareDist;
217 nearestPoint = *cloud->
getPoint(nearestPointIndex);
223 for (
size_t m = 0; m < meshes.size(); ++m) {
225 int nearestTriIndex = -1;
226 double nearestSquareDist = 0;
230 nearestTriIndex, nearestSquareDist,
232 if (nearestElementSquareDist < 0 ||
233 nearestSquareDist < nearestElementSquareDist) {
234 nearestElementSquareDist = nearestSquareDist;
240 if (nearestElementSquareDist >= 0) {
241 newVertices->addPoint(nearestPoint);
244 if (pDlg.wasCanceled()) {
248 pDlg.setValue(pDlg.value() + 1);
257 newVertices->shrinkToFit();
304 snapSizeSpinBox->blockSignals(
true);
306 snapSizeSpinBox->blockSignals(
false);
308 oversampleSpinBox->blockSignals(
true);
310 oversampleSpinBox->blockSignals(
false);
343 Qt::MouseButtons buttons) {
349 if (buttons != Qt::NoButton) {
431 widthSpinBox->value() < 2
433 : widthSpinBox->value());
458 }
catch (
const std::bad_alloc&) {
476 *firstTipPoint = P2D;
486 (QApplication::keyboardModifiers() & Qt::ControlModifier)) {
500 validButton->setEnabled(
true);
501 saveToolButton->setEnabled(
true);
502 resetToolButton->setEnabled(
true);
503 continueToolButton->setEnabled(
true);
544 "The picking mechanism is already in use. Close the tool using "
552 validButton->setEnabled(
false);
553 saveToolButton->setEnabled(
false);
554 resetToolButton->setEnabled(
false);
555 continueToolButton->setEnabled(
false);
564 unsigned overSampling =
static_cast<unsigned>(oversampleSpinBox->value());
565 if (overSampling > 1) {
Vector2Tpl< double > CCVector2d
Double 2D Vector.
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
static bool Warning(const char *format,...)
Prints out a formatted warning 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.
void addToDB(const QStringList &filenames, QString fileFilter=QString(), bool displayDialog=true)
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
virtual void setTempColor(const ecvColor::Rgb &col, bool autoActivate=true)
Sets current temporary (unique)
virtual void setRedraw(bool state)
Sets entity redraw mode.
virtual bool trianglePicking(const CCVector2d &clickPos, const ccGLCameraParameters &camera, int &nearestTriIndex, double &nearestSquareDist, CCVector3d &nearestPoint, CCVector3d *barycentricCoords=nullptr) const
Brute force triangle picking.
A 3D cloud interface with associated features (color, normals, octree, etc.)
bool pointPicking(const CCVector2d &clickPos, const ccGLCameraParameters &camera, int &nearestPointIndex, double &nearestSquareDist, double pickWidth=2.0, double pickHeight=2.0, bool autoComputeOctree=false)
Point picking (brute force or octree-driven)
static ccGenericPointCloud * ToGenericPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccGenericPointCloud.
QString getViewId() const
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
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 QString getName() const
Returns object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
virtual bool isEnabled() const
Returns whether the object is enabled or not.
Generic overlay dialog interface.
void shortcutTriggered(int key)
Signal emitted when an overridden key shortcut is pressed.
virtual void stop(bool accepted)
Stops process/dialog.
virtual bool start()
Starts process.
virtual bool linkWith(QWidget *win)
Links the overlay dialog with a MDI window.
void addOverridenShortcut(Qt::Key key)
Point/triangle picking hub.
void removeListener(ccPickingListener *listener, bool autoStopPickingIfLast=true)
Removes a listener.
bool addListener(ccPickingListener *listener, bool exclusive=false, bool autoStartPicking=true, ecvDisplayTools::PICKING_MODE mode=ecvDisplayTools::POINT_OR_TRIANGLE_PICKING)
Adds a listener.
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 setForeground(bool state)
Defines if the polyline is drawn in background or foreground.
virtual void setGlobalShift(const CCVector3d &shift) override
Sets shift applied to original coordinates (information storage only)
void set2DMode(bool state)
Defines if the polyline is considered as 2D or 3D.
void importParametersFrom(const ccPolyline &poly)
Copy the parameters from another polyline.
virtual void setGlobalScale(double scale) override
void setColor(const ecvColor::Rgb &col)
Sets the polyline color.
void setWidth(PointCoordinateType width)
Sets the width of the line.
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 * getPointPersistentPtr(unsigned index) override
unsigned size() const override
const CCVector3 * getPoint(unsigned index) const override
bool isClosed() const
Returns whether the polyline is closed or not.
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
unsigned size() const override
Returns the number of points.
virtual bool reserve(unsigned n)
Reserves some memory for hosting the point references.
constexpr Rgb green(0, MAX, 0)
OpenGL camera parameters.
bool project(const CCVector3d &input3D, CCVector3d &output2D, bool *inFrustum=nullptr) const
Projects a 3D point in 2D (+ normalized 'z' coordinate)