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
100
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
132 const QString &getShapeID() const { return m_idvalue; }
133
135 static QComboBox *createLengthUnitsCombo();
136 // Units enum
137 enum Unit { millimetre = 0, centimetre = 1, metre = 2 };
138 // Convert a string value from the given unit to metres
139 static QString convertToMetres(const QString &value, Unit start_unit);
140
142 void setComplementFlag(bool flag);
144 bool getComplementFlag() const;
145
146protected:
148 QString m_idvalue;
149
150private:
153};
154
159 Q_OBJECT
160
161private:
163 static int g_nspheres;
164
165public:
167 SphereDetails(QWidget *parent = nullptr);
168
170 ~SphereDetails() override { --g_nspheres; }
171
172 // Write the XML definition of a sphere
173 QString writeXML() const override;
174
175private:
177 QLineEdit *m_radius_box;
179 QComboBox *m_runits;
182};
183
188 Q_OBJECT
189
190private:
192 static int g_ncylinders;
193
194public:
196 CylinderDetails(QWidget *parent = nullptr);
197
200
201 // Write the XML definition of a sphere
202 QString writeXML() const override;
203
204private:
207 // Unit choice boxes
208 QComboBox *m_runits, *m_hunits;
211};
212
217 Q_OBJECT
218
219private:
221 static int g_ninfcyls;
222
223public:
225 InfiniteCylinderDetails(QWidget *parent = nullptr);
226
229
230 // Write the XML definition of a sphere
231 QString writeXML() const override;
232
233private:
235 QLineEdit *m_radius_box;
236 // Unit choice boxes
237 QComboBox *m_runits;
240};
241
246 Q_OBJECT
247
248private:
250 static int g_ncylrings;
251
252public:
254 SliceOfCylinderRingDetails(QWidget *parent = nullptr);
255
258
260 QString writeXML() const override;
261
262private:
265 // Unit choice boxes
266 QComboBox *m_iunits, *m_ounits, *m_dunits;
267};
268
272class ConeDetails : public ShapeDetails {
273 Q_OBJECT
274
275private:
277 static int g_ncones;
278
279public:
281 ConeDetails(QWidget *parent = nullptr);
282
284 ~ConeDetails() override { --g_ncones; }
285
287 QString writeXML() const override;
288
289private:
292 // Unit choice boxes
293 QComboBox *m_hunits;
296};
297
302 Q_OBJECT
303
304private:
306 static int g_ninfcones;
307
308public:
310 InfiniteConeDetails(QWidget *parent = nullptr);
311
314
316 QString writeXML() const override;
317
318private:
320 QLineEdit *m_angle_box;
323};
324
329 Q_OBJECT
330
331private:
333 static int g_ninfplanes;
334
335public:
337 InfinitePlaneDetails(QWidget *parent = nullptr);
338
341
343 QString writeXML() const override;
344
345private:
348};
349
354 Q_OBJECT
355
356private:
358 static int g_ncuboids;
359
360public:
362 CuboidDetails(QWidget *parent = nullptr);
363
365 ~CuboidDetails() override { --g_ncuboids; }
366
368 QString writeXML() const override;
369
370private:
373};
374
379 Q_OBJECT
380
381private:
383 static int g_nhexahedrons;
384
385public:
387 HexahedronDetails(QWidget *parent = nullptr);
388
391
393 QString writeXML() const override;
394
395private:
399};
400
401// /**
402// * A widget to define a torus
403// */
404// class TorusDetails : public ShapeDetails
405// {
406// Q_OBJECT
407
408// private:
409// /// The number of objects that currently exist
410// static int g_ntori;
411
412// public:
413// ///Default constructor
414// TorusDetails(QWidget *parent = 0);
415
416// ///Default destructor
417// ~TorusDetails() { --g_ntori; }
418
419// /// Write the XML definition of a sphere
420// QString writeXML() const;
421
422// private:
423// /// Radius values
424// QLineEdit *m_tube_rad, *m_inner_rad;
425// //Unit choice boxes
426// QComboBox *m_tunits, *m_iunits;
427// /// Corner points
428// PointGroupBox *m_centre, *m_axis;
429// };
430} // namespace CustomDialogs
431} // namespace MantidQt
double value
The value of the point.
Definition FitMW.cpp:51
double left
double right
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.
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.
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.
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,...
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.