20 : QDialog(parent, Qt::Tool),
21 Ui::BoundingBoxEditorDialog(),
22 m_baseBoxIsMinimal(false),
23 m_showInclusionWarning(true) {
28 xDoubleSpinBox->setMinimum(-1.0e9);
29 yDoubleSpinBox->setMinimum(-1.0e9);
30 zDoubleSpinBox->setMinimum(-1.0e9);
31 xDoubleSpinBox->setMaximum(1.0e9);
32 yDoubleSpinBox->setMaximum(1.0e9);
33 zDoubleSpinBox->setMaximum(1.0e9);
35 dxDoubleSpinBox->setMinimum(0.0);
36 dyDoubleSpinBox->setMinimum(0.0);
37 dzDoubleSpinBox->setMinimum(0.0);
38 dxDoubleSpinBox->setMaximum(1.0e9);
39 dyDoubleSpinBox->setMaximum(1.0e9);
40 dzDoubleSpinBox->setMaximum(1.0e9);
42 connect(keepSquareCheckBox, &QCheckBox::toggled,
this,
44 connect(okPushButton, &QPushButton::clicked,
this,
46 connect(cancelPushButton, &QPushButton::clicked,
this,
48 connect(defaultPushButton, &QPushButton::clicked,
this,
50 connect(lastPushButton, &QPushButton::clicked,
this,
52 connect(fromClipboardPushButton, &QPushButton::clicked,
this,
54 connect(toClipboardPushButton, &QPushButton::clicked,
this,
57 connect(pointTypeComboBox,
58 static_cast<void (QComboBox::*)(
int)
>(
59 &QComboBox::currentIndexChanged),
62 connect(xDoubleSpinBox,
63 static_cast<void (QDoubleSpinBox::*)(
double)
>(
64 &QDoubleSpinBox::valueChanged),
66 connect(yDoubleSpinBox,
67 static_cast<void (QDoubleSpinBox::*)(
double)
>(
68 &QDoubleSpinBox::valueChanged),
70 connect(zDoubleSpinBox,
71 static_cast<void (QDoubleSpinBox::*)(
double)
>(
72 &QDoubleSpinBox::valueChanged),
75 connect(dxDoubleSpinBox,
76 static_cast<void (QDoubleSpinBox::*)(
double)
>(
77 &QDoubleSpinBox::valueChanged),
79 connect(dyDoubleSpinBox,
80 static_cast<void (QDoubleSpinBox::*)(
double)
>(
81 &QDoubleSpinBox::valueChanged),
83 connect(dzDoubleSpinBox,
84 static_cast<void (QDoubleSpinBox::*)(
double)
>(
85 &QDoubleSpinBox::valueChanged),
88 connect(xOriXDoubleSpinBox,
89 static_cast<void (QDoubleSpinBox::*)(
double)
>(
90 &QDoubleSpinBox::valueChanged),
92 connect(xOriYDoubleSpinBox,
93 static_cast<void (QDoubleSpinBox::*)(
double)
>(
94 &QDoubleSpinBox::valueChanged),
96 connect(xOriZDoubleSpinBox,
97 static_cast<void (QDoubleSpinBox::*)(
double)
>(
98 &QDoubleSpinBox::valueChanged),
100 connect(yOriXDoubleSpinBox,
101 static_cast<void (QDoubleSpinBox::*)(
double)
>(
102 &QDoubleSpinBox::valueChanged),
104 connect(yOriYDoubleSpinBox,
105 static_cast<void (QDoubleSpinBox::*)(
double)
>(
106 &QDoubleSpinBox::valueChanged),
108 connect(yOriZDoubleSpinBox,
109 static_cast<void (QDoubleSpinBox::*)(
double)
>(
110 &QDoubleSpinBox::valueChanged),
112 connect(zOriXDoubleSpinBox,
113 static_cast<void (QDoubleSpinBox::*)(
double)
>(
114 &QDoubleSpinBox::valueChanged),
116 connect(zOriYDoubleSpinBox,
117 static_cast<void (QDoubleSpinBox::*)(
double)
>(
118 &QDoubleSpinBox::valueChanged),
120 connect(zOriZDoubleSpinBox,
121 static_cast<void (QDoubleSpinBox::*)(
double)
>(
122 &QDoubleSpinBox::valueChanged),
125 defaultPushButton->setVisible(
false);
132 assert(defaultDim < 3);
133 assert(pivotType >= 0 && pivotType < 3);
136 if (W.
x != W.
y || W.
x != W.
z) {
137 if (defaultDim < 0) {
140 if (W.
u[1] > W.
u[defaultDim]) defaultDim = 1;
141 if (W.
u[2] > W.
u[defaultDim]) defaultDim = 2;
144 CCVector3 newW(W.
u[defaultDim], W.
u[defaultDim], W.
u[defaultDim]);
149 box =
ccBBox(A, A + newW);
154 box =
ccBBox(C - newW / 2.0, C + newW / 2.0);
159 box =
ccBBox(B - newW, B);
166 return keepSquareCheckBox->isChecked();
170 if (state) keepSquareCheckBox->setChecked(
true);
171 keepSquareCheckBox->setDisabled(state);
182 bool hideX = (state && dim == 0);
183 bool hideY = (state && dim == 1);
184 bool hideZ = (state && dim == 2);
186 xDoubleSpinBox->setHidden(hideX);
187 dxDoubleSpinBox->setHidden(hideX);
188 xLabel->setHidden(hideX);
190 yDoubleSpinBox->setHidden(hideY);
191 dyDoubleSpinBox->setHidden(hideY);
192 yLabel->setHidden(hideY);
194 zDoubleSpinBox->setHidden(hideZ);
195 dzDoubleSpinBox->setHidden(hideZ);
196 zLabel->setHidden(hideZ);
211 bool exclude =
false;
244 if (oriGroupBox->isVisible()) {
254 "Invalid axes definition: at least two vectors are "
278 return QDialog::exec();
326 switch (pointTypeComboBox->currentIndex()) {
348 xDoubleSpinBox->blockSignals(
true);
349 yDoubleSpinBox->blockSignals(
true);
350 zDoubleSpinBox->blockSignals(
true);
352 switch (pointTypeComboBox->currentIndex()) {
356 xDoubleSpinBox->setValue(A.
x);
357 yDoubleSpinBox->setValue(A.
y);
358 zDoubleSpinBox->setValue(A.
z);
363 xDoubleSpinBox->setValue(C.
x);
364 yDoubleSpinBox->setValue(C.
y);
365 zDoubleSpinBox->setValue(C.
z);
370 xDoubleSpinBox->setValue(B.
x);
371 yDoubleSpinBox->setValue(B.
y);
372 zDoubleSpinBox->setValue(B.
z);
379 xDoubleSpinBox->blockSignals(
false);
380 yDoubleSpinBox->blockSignals(
false);
381 zDoubleSpinBox->blockSignals(
false);
386 dxDoubleSpinBox->blockSignals(
true);
387 dyDoubleSpinBox->blockSignals(
true);
388 dzDoubleSpinBox->blockSignals(
true);
393 fabs(W.
x - W.
z) * 1.0e-6 < 1.0);
394 dxDoubleSpinBox->setValue(W.
x);
395 dyDoubleSpinBox->setValue(W.
y);
396 dzDoubleSpinBox->setValue(W.
z);
398 dxDoubleSpinBox->blockSignals(
false);
399 dyDoubleSpinBox->blockSignals(
false);
400 dzDoubleSpinBox->blockSignals(
false);
405 oriGroupBox->setVisible(state);
407 resize(QSize(600, state ? 400 : 250));
415 xOriXDoubleSpinBox->setValue(
X.x);
416 xOriYDoubleSpinBox->setValue(
X.y);
417 xOriZDoubleSpinBox->setValue(
X.z);
422 yOriXDoubleSpinBox->setValue(Y.
x);
423 yOriYDoubleSpinBox->setValue(Y.
y);
424 yOriZDoubleSpinBox->setValue(Y.
z);
429 zOriXDoubleSpinBox->setValue(Z.
x);
430 zOriYDoubleSpinBox->setValue(Z.
y);
431 zOriZDoubleSpinBox->setValue(Z.
z);
438 X =
CCVector3d(xOriXDoubleSpinBox->value(), xOriYDoubleSpinBox->value(),
439 xOriZDoubleSpinBox->value());
441 Y =
CCVector3d(yOriXDoubleSpinBox->value(), yOriYDoubleSpinBox->value(),
442 yOriZDoubleSpinBox->value());
444 Z =
CCVector3d(zOriXDoubleSpinBox->value(), zOriYDoubleSpinBox->value(),
445 zOriZDoubleSpinBox->value());
454 QDoubleSpinBox* vecSpinBoxes[3] = {
nullptr,
nullptr,
nullptr};
456 if (oriXCheckBox->isChecked()) {
458 vecSpinBoxes[0] = xOriXDoubleSpinBox;
459 vecSpinBoxes[1] = xOriYDoubleSpinBox;
460 vecSpinBoxes[2] = xOriZDoubleSpinBox;
461 }
else if (oriYCheckBox->isChecked()) {
463 vecSpinBoxes[0] = yOriXDoubleSpinBox;
464 vecSpinBoxes[1] = yOriYDoubleSpinBox;
465 vecSpinBoxes[2] = yOriZDoubleSpinBox;
466 }
else if (oriZCheckBox->isChecked()) {
468 vecSpinBoxes[0] = zOriXDoubleSpinBox;
469 vecSpinBoxes[1] = zOriYDoubleSpinBox;
470 vecSpinBoxes[2] = zOriZDoubleSpinBox;
475 for (
int i = 0; i < 3; ++i) {
476 vecSpinBoxes[i]->blockSignals(
true);
477 vecSpinBoxes[i]->setValue(N.
u[i]);
478 vecSpinBoxes[i]->blockSignals(
false);
483 QClipboard* clipboard = QApplication::clipboard();
485 QString clipText = clipboard->text();
486 if (!clipText.isEmpty()) {
487 bool success =
false;
500 CVLog::Error(
"Failed to extract matrix from clipboard");
509 QClipboard* clipboard = QApplication::clipboard();
524 clipboard->setText(matrix.
toString());
Vector3Tpl< double > CCVector3d
Double 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
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.
void normalize()
Sets vector norm to unity.
double norm2d() const
Returns vector square norm (forces double precision output)
Vector3Tpl cross(const Vector3Tpl &v) const
Cross product.
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
void updateYWidth(double)
void showBoxAxes(bool state)
Whether to display or not the box axes.
void updateCurrentBBox(double dummy=0.0)
Updates current box based on the dialog state.
void toClipboardClicked()
void updateZWidth(double)
void forceKeepSquare(bool state)
Forces the 'keep square' mode.
void updateXWidth(double)
ccBBox m_baseBBox
Base box (invalid if none)
void onAxisValueChanged(double)
Slot called anytime a component of the box axes is modified.
void getBoxAxes(CCVector3d &X, CCVector3d &Y, CCVector3d &Z)
Returns the box axes.
void fromClipboardClicked()
void squareModeActivated(bool)
void checkBaseInclusion()
Checks if currentBox includes baseBox.
bool m_baseBoxIsMinimal
Whether base box is minimal or not.
void set2DMode(bool state, unsigned char dim)
Sets 2D mode (the line 'dim' will be hidden)
void reflectChanges(int dummy=0)
Reflects changes on bbox.
ccBBox m_initBBox
Box state at dialog start.
ccBBox m_currentBBox
Current box.
ccBoundingBoxEditorDlg(QWidget *parent=0)
Default constructor.
void setBaseBBox(const ccBBox &box, bool isMinimal=true)
Sets the (minimal) base box.
bool m_showInclusionWarning
Whether to show 'inclusion' warning or not.
bool keepSquare() const
Returns whether 'keep square' mode is enabled or not.
void setBoxAxes(const CCVector3 &X, const CCVector3 &Y, const CCVector3 &Z)
Sets the box axes.
QString toString(int precision=12, QChar separator=' ') const
Returns matrix as a string.
Vector3Tpl< T > getTranslationAsVec3D() const
Returns a copy of the translation as a CCVector3.
void setColumn(unsigned index, const Vector3Tpl< T > &v)
Sets the content of a given column.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
Vector3Tpl< T > getColumnAsVec3D(unsigned index) const
Returns a copy of a given column as a CCVector3.
static ccGLMatrixTpl< float > FromString(const QString &matText, bool &success)
Converts a 'text' matrix to a ccGLMatrix.
Float version of ccGLMatrixTpl.
Vector3Tpl< T > getDiagVec() const
Returns diagonal vector.
Vector3Tpl< T > getCenter() const
Returns center.
bool contains(const Vector3Tpl< T > &P) const
Returns whether a points is inside the box or not.
const Vector3Tpl< T > & maxCorner() const
Returns max corner (const)
const Vector3Tpl< T > & minCorner() const
Returns min corner (const)
bool isValid() const
Returns whether bounding box is valid or not.
__host__ __device__ float2 fabs(float2 v)
void MakeSquare(ccBBox &box, int pivotType, int defaultDim=-1)