Mantid
Loading...
Searching...
No Matches
SampleShapeHelpers.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//--------------------------------------
10// Includes
11//--------------------------------------
12#include <QGroupBox>
13#include <QLineEdit>
14#include <QWidget>
15
16//--------------------------------------
17// Qt forward declarations
18//--------------------------------------
19class QComboBox;
20class QRadioButton;
21class QLabel;
22
29namespace MantidQt {
30namespace CustomDialogs {
31
32// Forward declartion
33class ShapeDetails;
34
38class PointGroupBox : public QGroupBox {
39 Q_OBJECT
40
41public:
42 // Default constructor
43 PointGroupBox(QWidget *parent = nullptr);
44
46 QString write3DElement(const QString &elem_name) const;
47
48private slots:
49 // Switch to cartesian coordinates
50 void changeToCartesian();
51 // Switch to spherical coordinates
52 void changeToSpherical();
53
54private:
55 // Labels for fields
57 // Edit fields (also used for r,theta,phi) if in spherical mode
58 QLineEdit *m_midx, *m_midy, *m_midz;
59 // Unit choice boxes (x is used for r in spherical mode)
60 QComboBox *m_xunits, *m_yunits, *m_zunits;
61 // Radio button selection for coordinates
62 QRadioButton *m_cartesian, *m_spherical;
63 // The current coordinate system (0 = cartesian, 1 = spherical)
65};
66
72struct Operation {
74 Operation(int op = 0) : binaryop(op) {}
75
77 QString toString(const QString &left, const QString &right) const;
78
81};
82
90 virtual ~BaseInstantiator() = default;
92 virtual ShapeDetails *createInstance() const = 0;
93
94private:
99};
100
104template <class T> struct ShapeDetailsInstantiator : public BaseInstantiator {
108 ShapeDetails *createInstance() const override { return static_cast<ShapeDetails *>(new T); }
109
110private:
115};
116
120class ShapeDetails : public QWidget {
121 Q_OBJECT
122
123public:
125 ShapeDetails(QWidget *parent = nullptr) : QWidget(parent), m_idvalue(""), m_isComplement(false) {}
127 ~ShapeDetails() override = default;
128
130 virtual QString writeXML() const = 0;
131
133 QString getShapeID() const { return m_idvalue; }
134
136 static QComboBox *createLengthUnitsCombo();
137 // Units enum
138 enum Unit { millimetre = 0, centimetre = 1, metre = 2 };
139 // Convert a string value from the given unit to metres
140 static QString convertToMetres(const QString &value, Unit start_unit);
141
143 void setComplementFlag(bool flag);
145 bool getComplementFlag() const;
146
147protected:
149 QString m_idvalue;
150
151private:
154};
155
160 Q_OBJECT
161
162private:
164 static int g_nspheres;
165
166public:
168 SphereDetails(QWidget *parent = nullptr);
169
171 ~SphereDetails() override { --g_nspheres; }
172
173 // Write the XML definition of a sphere
174 QString writeXML() const override;
175
176private:
178 QLineEdit *m_radius_box;
180 QComboBox *m_runits;
183};
184
189 Q_OBJECT
190
191private:
193 static int g_ncylinders;
194
195public:
197 CylinderDetails(QWidget *parent = nullptr);
198
201
202 // Write the XML definition of a sphere
203 QString writeXML() const override;
204
205private:
208 // Unit choice boxes
209 QComboBox *m_runits, *m_hunits;
212};
213
218 Q_OBJECT
219
220private:
222 static int g_ninfcyls;
223
224public:
226 InfiniteCylinderDetails(QWidget *parent = nullptr);
227
230
231 // Write the XML definition of a sphere
232 QString writeXML() const override;
233
234private:
236 QLineEdit *m_radius_box;
237 // Unit choice boxes
238 QComboBox *m_runits;
241};
242
247 Q_OBJECT
248
249private:
251 static int g_ncylrings;
252
253public:
255 SliceOfCylinderRingDetails(QWidget *parent = nullptr);
256
259
261 QString writeXML() const override;
262
263private:
266 // Unit choice boxes
267 QComboBox *m_iunits, *m_ounits, *m_dunits;
268};
269
273class ConeDetails : public ShapeDetails {
274 Q_OBJECT
275
276private:
278 static int g_ncones;
279
280public:
282 ConeDetails(QWidget *parent = nullptr);
283
285 ~ConeDetails() override { --g_ncones; }
286
288 QString writeXML() const override;
289
290private:
293 // Unit choice boxes
294 QComboBox *m_hunits;
297};
298
303 Q_OBJECT
304
305private:
307 static int g_ninfcones;
308
309public:
311 InfiniteConeDetails(QWidget *parent = nullptr);
312
315
317 QString writeXML() const override;
318
319private:
321 QLineEdit *m_angle_box;
324};
325
330 Q_OBJECT
331
332private:
334 static int g_ninfplanes;
335
336public:
338 InfinitePlaneDetails(QWidget *parent = nullptr);
339
342
344 QString writeXML() const override;
345
346private:
349};
350
355 Q_OBJECT
356
357private:
359 static int g_ncuboids;
360
361public:
363 CuboidDetails(QWidget *parent = nullptr);
364
366 ~CuboidDetails() override { --g_ncuboids; }
367
369 QString writeXML() const override;
370
371private:
374};
375
380 Q_OBJECT
381
382private:
384 static int g_nhexahedrons;
385
386public:
388 HexahedronDetails(QWidget *parent = nullptr);
389
392
394 QString writeXML() const override;
395
396private:
400};
401
402// /**
403// * A widget to define a torus
404// */
405// class TorusDetails : public ShapeDetails
406// {
407// Q_OBJECT
408
409// private:
410// /// The number of objects that currently exist
411// static int g_ntori;
412
413// public:
414// ///Default constructor
415// TorusDetails(QWidget *parent = 0);
416
417// ///Default destructor
418// ~TorusDetails() { --g_ntori; }
419
420// /// Write the XML definition of a sphere
421// QString writeXML() const;
422
423// private:
424// /// Radius values
425// QLineEdit *m_tube_rad, *m_inner_rad;
426// //Unit choice boxes
427// QComboBox *m_tunits, *m_iunits;
428// /// Corner points
429// PointGroupBox *m_centre, *m_axis;
430// };
431} // namespace CustomDialogs
432} // namespace MantidQt
double value
The value of the point.
Definition: FitMW.cpp:51
double left
Definition: LineProfile.cpp:80
double right
Definition: LineProfile.cpp:81
QLineEdit * m_height_box
Line edits to enter values.
QString writeXML() const override
Write the XML definition of a sphere.
~ConeDetails() override
Default destructor.
PointGroupBox * m_tippoint
Centre and axis point boxes.
static int g_ncones
The number of objects that currently exist.
A widget to define an infinite plane.
PointGroupBox * m_left_frt_bot
Corner points.
~CuboidDetails() override
Default destructor.
QString writeXML() const override
Write the XML definition of a sphere.
static int g_ncuboids
The number of objects that currently exist.
static int g_ncylinders
The number of objects that currently exist.
QString writeXML() const override
Write the XML definition.
QLineEdit * m_radius_box
Line edits to enter values.
PointGroupBox * m_lower_centre
Centre and axis point boxes.
~CylinderDetails() override
Default destructor.
A widget to define a hexahedron.
static int g_nhexahedrons
The number of objects that currently exist.
PointGroupBox * m_left_bck_bot
Corner points.
~HexahedronDetails() override
Default destructor.
QString writeXML() const override
Write the XML definition of a sphere.
A widget to define an infinite cone.
PointGroupBox * m_tippoint
Centre and axis point boxes.
QLineEdit * m_angle_box
Line edits to enter values.
~InfiniteConeDetails() override
Default destructor.
static int g_ninfcones
The number of objects that currently exist.
QString writeXML() const override
Write the XML definition of a sphere.
A widget to define an infinite cylinder.
QLineEdit * m_radius_box
Line edits to enter values.
QString writeXML() const override
Write the XML definition.
PointGroupBox * m_centre
Centre and axis point boxes.
static int g_ninfcyls
The number of objects that currently exist.
~InfiniteCylinderDetails() override
Default destructor.
A widget to define an infinite plane.
QString writeXML() const override
Write the XML definition of a sphere.
static int g_ninfplanes
The number of objects that currently exist.
~InfinitePlaneDetails() override
Default destructor.
PointGroupBox * m_plane
Centre and axis point boxes.
A custom group box for a 3D point.
QString write3DElement(const QString &elem_name) const
Write the element tag for a 3D point.
The base class for the details widgets.
void setComplementFlag(bool flag)
Set the complement flag.
ShapeDetails(QWidget *parent=nullptr)
Constructor.
bool m_isComplement
Take the complement of the shape.
~ShapeDetails() override=default
Constructor.
QString getShapeID() const
Get the id string.
bool getComplementFlag() const
Get complement flag.
static QComboBox * createLengthUnitsCombo()
Create a new length units box.
virtual QString writeXML() const =0
Write out the XML definition for this shape.
static QString convertToMetres(const QString &value, Unit start_unit)
Convert a string value from the given unit to metres (static)
QString m_idvalue
ID string of this object.
A widget to define an infinite cylinder.
QLineEdit * m_rinner_box
Line edits to enter values.
QString writeXML() const override
Write the XML definition of a sphere.
static int g_ncylrings
The number of objects that currently exist.
static int g_nspheres
The number of objects that currently exist.
~SphereDetails() override
Default destructor.
QString writeXML() const override
Write the XML definition.
QComboBox * m_runits
Radius unit choice.
PointGroupBox * m_centre
Centre point group box.
QLineEdit * m_radius_box
Line edit for radius value.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
Base instantiator to store in a map.
virtual ~BaseInstantiator()=default
Virtual destructor.
BaseInstantiator & operator=(const BaseInstantiator &)
Private assignment operator.
BaseInstantiator(const BaseInstantiator &)
Private copy constructor.
virtual ShapeDetails * createInstance() const =0
Create an instance.
A struct describing a binary operation Note: The constructor takes an integer where 0 = intersection,...
int binaryop
The stored operation.
Operation(int op=0)
Default constructor.
A structure used for holding the type of a details widget.
ShapeDetails * createInstance() const override
Create an instance of this type.
ShapeDetailsInstantiator & operator=(const ShapeDetailsInstantiator &)
Private assignment operator.
ShapeDetailsInstantiator(const ShapeDetailsInstantiator &)
Private copy constructor.