21 #include <QDoubleValidator>
34 m_associatedPlane(nullptr),
35 m_pickingHub(pickingHub) {
42 dipDoubleSpinBox->setValue(
s_dip);
43 dipDirDoubleSpinBox->setValue(
s_dipDir);
44 upwardCheckBox->setChecked(
s_upward);
46 wDoubleSpinBox->setValue(
s_width);
48 cxAxisDoubleSpinBox->setValue(
s_center.
x);
49 cyAxisDoubleSpinBox->setValue(
s_center.
y);
50 czAxisDoubleSpinBox->setValue(
s_center.
z);
52 connect(pickCenterToolButton, &QCheckBox::toggled,
this,
54 connect(upwardCheckBox, &QCheckBox::toggled,
this,
56 connect(dipDoubleSpinBox,
57 static_cast<void (QDoubleSpinBox::*)(
double)
>(
58 &QDoubleSpinBox::valueChanged),
60 connect(dipDirDoubleSpinBox,
61 static_cast<void (QDoubleSpinBox::*)(
double)
>(
62 &QDoubleSpinBox::valueChanged),
64 connect(nxDoubleSpinBox,
65 static_cast<void (QDoubleSpinBox::*)(
double)
>(
66 &QDoubleSpinBox::valueChanged),
68 connect(nyDoubleSpinBox,
69 static_cast<void (QDoubleSpinBox::*)(
double)
>(
70 &QDoubleSpinBox::valueChanged),
72 connect(nzDoubleSpinBox,
73 static_cast<void (QDoubleSpinBox::*)(
double)
>(
74 &QDoubleSpinBox::valueChanged),
77 connect(buttonBox, &QDialogButtonBox::accepted,
this,
79 connect(buttonBox, &QDialogButtonBox::rejected,
this,
80 &ccPlaneEditDlg::deleteLater);
83 connect(
this, &QDialog::finished, [&]() {
84 if (pickCenterToolButton->isChecked())
85 pickCenterToolButton->setChecked(
false);
90 assert(!pickCenterToolButton->isChecked());
96 s_dip = dipDoubleSpinBox->value();
97 s_dipDir = dipDirDoubleSpinBox->value();
98 s_upward = upwardCheckBox->isChecked();
99 s_width = wDoubleSpinBox->value();
101 s_center.
x = cxAxisDoubleSpinBox->value();
102 s_center.
y = cyAxisDoubleSpinBox->value();
103 s_center.
z = czAxisDoubleSpinBox->value();
135 double dip = dipDoubleSpinBox->value();
136 double dipDir = dipDirDoubleSpinBox->value();
137 bool upward = upwardCheckBox->isChecked();
142 nxDoubleSpinBox->blockSignals(
true);
143 nyDoubleSpinBox->blockSignals(
true);
144 nzDoubleSpinBox->blockSignals(
true);
146 nxDoubleSpinBox->setValue(Nd.
x);
147 nyDoubleSpinBox->setValue(Nd.
y);
148 nzDoubleSpinBox->setValue(Nd.
z);
150 nxDoubleSpinBox->blockSignals(
false);
151 nyDoubleSpinBox->blockSignals(
false);
152 nzDoubleSpinBox->blockSignals(
false);
157 Nd.
x = nxDoubleSpinBox->value();
158 Nd.
y = nyDoubleSpinBox->value();
159 Nd.
z = nzDoubleSpinBox->value();
165 dipDoubleSpinBox->blockSignals(
true);
166 dipDirDoubleSpinBox->blockSignals(
true);
167 upwardCheckBox->blockSignals(
true);
169 dipDoubleSpinBox->setValue(dip);
170 dipDirDoubleSpinBox->setValue(dipDir);
171 upwardCheckBox->setChecked(Nd.
z >= 0);
173 dipDoubleSpinBox->blockSignals(
false);
174 dipDirDoubleSpinBox->blockSignals(
false);
175 upwardCheckBox->blockSignals(
false);
185 "Can't start the picking process (another tool is using "
193 pickCenterToolButton->blockSignals(
true);
194 pickCenterToolButton->setChecked(state);
195 pickCenterToolButton->blockSignals(
false);
203 cxAxisDoubleSpinBox->setValue(pi.
P3D.
x);
204 cyAxisDoubleSpinBox->setValue(pi.
P3D.
y);
205 czAxisDoubleSpinBox->setValue(pi.
P3D.
z);
207 pickCenterToolButton->setChecked(
false);
220 nxDoubleSpinBox->blockSignals(
true);
221 nyDoubleSpinBox->blockSignals(
true);
222 nzDoubleSpinBox->blockSignals(
true);
224 nxDoubleSpinBox->setValue(N.
x);
225 nyDoubleSpinBox->setValue(N.
y);
226 nzDoubleSpinBox->setValue(N.
z);
228 nxDoubleSpinBox->blockSignals(
false);
229 nyDoubleSpinBox->blockSignals(
false);
230 nzDoubleSpinBox->blockSignals(
false);
240 wDoubleSpinBox->setValue(plane->
getXWidth());
241 hDoubleSpinBox->setValue(plane->
getYWidth());
244 cxAxisDoubleSpinBox->setValue(C.
x);
245 cyAxisDoubleSpinBox->setValue(C.
y);
246 czAxisDoubleSpinBox->setValue(C.
z);
255 double dip = dipDoubleSpinBox->value();
256 double dipDir = dipDirDoubleSpinBox->value();
257 bool upward = upwardCheckBox->isChecked();
274 bool needToApplyTrans =
false;
275 bool needToApplyRot =
false;
278 std::numeric_limits<PointCoordinateType>::epsilon());
279 needToApplyTrans = needToApplyRot || ((C - Cd).norm2d() != 0);
281 if (needToApplyTrans) {
283 needToApplyTrans =
true;
285 if (needToApplyRot) {
289 PC_ONE - std::numeric_limits<PointCoordinateType>::epsilon()) {
297 rotation = rotZ * rotX;
302 trans = rotation * trans;
304 if (needToApplyTrans) {
307 if (needToApplyRot || needToApplyTrans) {
310 CVLog::Print(
"[Plane edit] Applied transformation matrix:");
constexpr PointCoordinateType PC_ONE
'1' as a PointCoordinateType value
Vector3Tpl< PointCoordinateType > CCVector3
Default 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.
static MainWindow * TheInstance()
Returns the unique instance of this object.
void addToDB(const QStringList &filenames, QString fileFilter=QString(), bool displayDialog=true)
void updatePropertiesView()
Updates the 'Properties' view.
void normalize()
Sets vector norm to unity.
Type dot(const Vector3Tpl &v) const
Dot product.
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.
static ccGLMatrixTpl< float > FromToRotation(const Vector3Tpl< float > &from, const Vector3Tpl< float > &to)
Creates a transformation matrix that rotates a vector to another.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
void initFromParameters(T alpha_rad, const Vector3Tpl< T > &axis3D, const Vector3Tpl< T > &t3D)
Inits transformation from a rotation axis, an angle and a translation.
Float version of ccGLMatrixTpl.
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
virtual void redrawDisplay(bool forceRedraw=true, bool only2D=false)
Redraws associated display.
static CCVector3 ConvertDipAndDipDirToNormal(PointCoordinateType dip_deg, PointCoordinateType dipDir_deg, bool upward=true)
static void ConvertNormalToDipAndDipDir(const CCVector3 &N, PointCoordinateType &dip_deg, PointCoordinateType &dipDir_deg)
Converts a normal vector to geological 'dip direction & dip' parameters.
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.
virtual void onItemPicked(const PickedItem &pi)
Inherited from ccPickingListener.
ccPickingHub * m_pickingHub
Picking hub.
void initWithPlane(ccPlane *plane)
Links this dialog with an existing plane.
virtual ~ccPlaneEditDlg()
Destructor.
void saveParamsAndAccept()
void pickPointAsCenter(bool)
void updatePlane(ccPlane *plane)
Updates a plane with the current parameters.
ccPlane * m_associatedPlane
Associated plane (if any)
void onDipDirModified(bool)
void onNormalChanged(double)
void onDipDirChanged(double)
ccPlaneEditDlg(ccPickingHub *pickingHub, QWidget *parent)
Default constructor.
CCVector3 getCenter() const
Returns the center.
CCVector3 getNormal() const override
Returns the entity normal.
void setXWidth(PointCoordinateType w, bool autoUpdate=true)
Sets 'X' width.
PointCoordinateType getXWidth() const
Returns 'X' width.
PointCoordinateType getYWidth() const
Returns 'Y' width.
void setYWidth(PointCoordinateType h, bool autoUpdate=true)
Sets 'Y' width.
__host__ __device__ float2 fabs(float2 v)
static CCVector3d s_center(0, 0, 0)
float DegreesToRadians(int degrees)
Convert degrees to radians.