12 #include <QDialogButtonBox>
15 #include <QMainWindow>
16 #include <QVBoxLayout>
25 class ImportDialog :
public QDialog {
29 m_dipLabel(new QLabel),
30 m_dipDirLabel(new QLabel),
31 m_sizeLabel(new QLabel),
32 m_dipDirCombo(new QComboBox),
33 m_dipCombo(new QComboBox) {
34 QVBoxLayout* vbox =
new QVBoxLayout;
41 m_planeSize =
new QLineEdit(
"2.0");
42 m_planeSize->setValidator(
new QDoubleValidator(
45 QDialogButtonBox* buttonBox =
new QDialogButtonBox(
46 QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
47 QObject::connect(buttonBox, &QDialogButtonBox::accepted,
this,
49 QObject::connect(buttonBox, &QDialogButtonBox::rejected,
this,
52 vbox->addWidget(m_dipLabel);
53 vbox->addWidget(m_dipCombo);
54 vbox->addWidget(m_dipDirLabel);
55 vbox->addWidget(m_dipDirCombo);
56 vbox->addWidget(m_sizeLabel);
57 vbox->addWidget(m_planeSize);
58 vbox->addWidget(buttonBox);
63 void setLabels(
const QStringList& labels) {
64 Q_ASSERT(labels.count() == 3);
66 m_dipLabel->setText(labels.at(0));
67 m_dipDirLabel->setText(labels.at(1));
68 m_sizeLabel->setText(labels.at(2));
71 int dipDirComboScalarFieldIndex() {
72 return m_dipDirCombo->currentData().toInt();
75 int dipComboScalarFieldIndex() {
return m_dipCombo->currentData().toInt(); }
77 double planeSize() {
return m_planeSize->text().toDouble(); }
81 QLabel* m_dipDirLabel;
84 QComboBox* m_dipDirCombo;
85 QComboBox* m_dipCombo;
87 QLineEdit* m_planeSize;
100 "Please select a point cloud containing your field data (this "
101 "can be loaded from a text file)",
108 "Please select a point cloud containing your field data (this "
109 "can be loaded from a text file)",
119 foliationDialog.setLabels(
120 {QObject::tr(
"Dip Field:",
"ccCompassImport"),
121 QObject::tr(
"Dip-Direction Field:",
"ccCompassImport"),
122 QObject::tr(
"Plane Size",
"ccCompassImport")});
124 int result = foliationDialog.exec();
126 if (
result == QDialog::Rejected) {
131 const int dipSF = foliationDialog.dipComboScalarFieldIndex();
132 const int dipDirSF = foliationDialog.dipDirComboScalarFieldIndex();
133 const double size = foliationDialog.planeSize();
135 if (dipSF == dipDirSF) {
137 "Error: Dip and Dip-Direction scalar fields must be different!",
143 for (
unsigned p = 0; p < cld->
size(); p++) {
151 .arg(
static_cast<int>(dip), 2, 10, QChar(
'0'))
152 .arg(
static_cast<int>(dipdir), 3, 10, QChar(
'0')));
155 app->
addToDB(plane,
false,
true,
false,
false);
164 bool needToApplyTrans =
false;
165 bool needToApplyRot =
false;
168 std::numeric_limits<PointCoordinateType>::epsilon());
169 needToApplyTrans = needToApplyRot || ((C - Cd).norm2d() != 0);
171 if (needToApplyTrans) {
173 needToApplyTrans =
true;
175 if (needToApplyRot) {
179 PC_ONE - std::numeric_limits<PointCoordinateType>::epsilon()) {
189 rotation = rotZ * rotX;
194 trans = rotation * trans;
196 if (needToApplyTrans) {
199 if (needToApplyRot || needToApplyTrans) {
214 "Please select a point cloud containing your field data (this "
215 "can be loaded from a text file)",
222 "Please select a point cloud containing your field data (this "
223 "can be loaded from a text file)",
233 lineationDialog.setLabels(
234 {QObject::tr(
"Trend Field:",
"ccCompassImport"),
235 QObject::tr(
"Plunge Field:",
"ccCompassImport"),
236 QObject::tr(
"Display Length",
"ccCompassImport")});
238 int result = lineationDialog.exec();
240 if (
result == QDialog::Rejected) {
245 const int dipSF = lineationDialog.dipComboScalarFieldIndex();
246 const int dipDirSF = lineationDialog.dipDirComboScalarFieldIndex();
247 const double size = lineationDialog.planeSize();
249 if (dipSF == dipDirSF) {
251 "Error: Trend and plunge scalar fields must be different!",
257 for (
unsigned p = 0; p < cld->
size(); p++) {
286 lineation->
setName(QStringLiteral(
"%1->%2")
288 .arg(qRound(trend)));
290 app->
addToDB(lineation,
false,
true,
false,
false);
constexpr PointCoordinateType PC_ONE
'1' as a PointCoordinateType value
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Type dot(const Vector3Tpl &v) const
Dot product.
virtual void showNameIn3D(bool state)
Sets whether name should be displayed in 3D.
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 bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
void updateMetadata() override
static CCVector3 ConvertDipAndDipDirToNormal(PointCoordinateType dip_deg, PointCoordinateType dipDir_deg, bool upward=true)
virtual void setName(const QString &name)
Sets object name.
CCVector3 getCenter() const
Returns the center.
CCVector3 getNormal() const override
Returns the entity normal.
void setXWidth(PointCoordinateType w, bool autoUpdate=true)
Sets 'X' width.
void setYWidth(PointCoordinateType h, bool autoUpdate=true)
Sets 'Y' width.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
virtual const CCVector3d & getGlobalShift() const
Returns the shift applied to original coordinates.
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
unsigned getNumberOfScalarFields() const
Returns the number of associated (and active) scalar fields.
unsigned size() const override
const char * getScalarFieldName(int index) const
Returns the name of a specific scalar field.
const CCVector3 * getPoint(unsigned index) const override
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
Main application interface (for plugins)
virtual QMainWindow * getMainWindow()=0
Returns main window.
virtual const ccHObject::Container & getSelectedEntities() const =0
Returns currently selected entities ("read only")
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
__host__ __device__ int2 abs(int2 v)
void importFoliations(ecvMainAppInterface *app)
void importLineations(ecvMainAppInterface *app)
float DegreesToRadians(int degrees)
Convert degrees to radians.