BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskDrawingContext.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/MaskDrawingContext.cpp
6 //! @brief Implements class MaskDrawingContext
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
17 
19  : m_current_activity(MaskEditorFlags::PAN_ZOOM_MODE)
20  , m_mask_value(MaskEditorFlags::MASK_ON)
21  , m_drawing_in_progress(false)
22 {
23 }
24 
25 MaskEditorFlags::Activity MaskDrawingContext::getActivityType() const
26 {
27  return m_current_activity;
28 }
29 
30 void MaskDrawingContext::setActivityType(MaskEditorFlags::Activity value)
31 {
32  m_current_activity = value;
33 }
34 
35 void MaskDrawingContext::setMaskValue(MaskEditorFlags::MaskValue value)
36 {
37  m_mask_value = value;
38 }
39 
41 {
43 }
44 
46 {
48 }
49 
51 {
55 }
56 
58 {
60 }
61 
63 {
65 }
66 
68 {
70 }
71 
73 {
75 }
76 
78 {
80 }
81 
83 {
85 }
86 
88 {
90 }
91 
93 {
95 }
96 
98 {
99  return m_drawing_in_progress;
100 }
101 
103 {
104  m_drawing_in_progress = value;
105 }
106 
108 {
109  return bool(m_mask_value);
110 }
111 
112 //! Returns true, if proposed activity requires the cancel of drawing
113 //! i.e. there is an ungoing polygon drawing, but user wants to start other drawing
115  MaskEditorFlags::Activity proposed_new_activity) const
116 {
117  return isDrawingInProgress() && isPolygonMode()
118  && proposed_new_activity >= MaskEditorFlags::PAN_ZOOM_MODE;
119 }
120 
121 //! Returns model type corresponding to current activity.
122 
124 {
125  if (isRectangleMode())
126  return RectangleItem::M_TYPE;
127  if (isEllipseMode())
128  return EllipseItem::M_TYPE;
129  if (isROIMode())
131  return "";
132 }
133 
134 //! Returns model row corresponding to given activity. All shapes, except ROI, will be added
135 //! on top of each other. ROI shape will be added at the bottom.
136 
138 {
139  if (isROIMode())
140  return -1;
141  return 0;
142 }
Defines class MaskDrawingContext.
Defines MaskItems classes.
static constexpr auto M_TYPE
Definition: MaskItems.h:167
QString activityToModelType() const
Returns model type corresponding to current activity.
MaskEditorFlags::MaskValue m_mask_value
int activityToRow() const
Returns model row corresponding to given activity. All shapes, except ROI, will be added on top of ea...
void setDrawingInProgress(bool value)
MaskEditorFlags::Activity getActivityType() const
void setActivityType(MaskEditorFlags::Activity value)
bool isActivityRequiresDrawingCancel(MaskEditorFlags::Activity proposed_new_activity) const
Returns true, if proposed activity requires the cancel of drawing i.e. there is an ungoing polygon dr...
bool isVerticalLineMode() const
bool isRectangleShapeMode() const
bool isHorizontalLineMode() const
bool isRectangleMode() const
MaskEditorFlags::Activity m_current_activity
bool isDrawingInProgress() const
void setMaskValue(MaskEditorFlags::MaskValue value)
bool isSelectionMode() const
Help class to define various flags for MaskEditor operation.
static constexpr auto M_TYPE
Definition: MaskItems.h:61
static constexpr auto M_TYPE
Definition: MaskItems.h:83