BornAgain  1.19.0
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/coregui/Views/MaskWidgets/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 
16 
18  : m_current_activity(MaskEditorFlags::PAN_ZOOM_MODE)
19  , m_mask_value(MaskEditorFlags::MASK_ON)
20  , m_drawing_in_progress(false)
21 {
22 }
23 
24 MaskEditorFlags::Activity MaskDrawingContext::getActivityType() const
25 {
26  return m_current_activity;
27 }
28 
29 void MaskDrawingContext::setActivityType(MaskEditorFlags::Activity value)
30 {
31  m_current_activity = value;
32 }
33 
34 void MaskDrawingContext::setMaskValue(MaskEditorFlags::MaskValue value)
35 {
36  m_mask_value = value;
37 }
38 
40 {
42 }
43 
45 {
47 }
48 
50 {
54 }
55 
57 {
59 }
60 
62 {
64 }
65 
67 {
69 }
70 
72 {
74 }
75 
77 {
79 }
80 
82 {
84 }
85 
87 {
89 }
90 
92 {
94 }
95 
97 {
98  return m_drawing_in_progress;
99 }
100 
102 {
103  m_drawing_in_progress = value;
104 }
105 
107 {
108  return bool(m_mask_value);
109 }
110 
111 //! return true, if proposed activity requires the cancel of drawing
112 //! i.e. there is an ungoing polygon drawing, but user wants to start other drawing
114  MaskEditorFlags::Activity proposed_new_activity)
115 {
117  && proposed_new_activity >= MaskEditorFlags::PAN_ZOOM_MODE)
118  return true;
119  return false;
120 }
121 
122 //! Returns model type corresponding to current activity.
123 
125 {
126  if (isRectangleMode())
127  return "RectangleMask";
128  if (isEllipseMode())
129  return "EllipseMask";
130  if (isROIMode())
131  return "RegionOfInterest";
132  return "";
133 }
134 
135 //! Returns model row corresponding to given activity. All shapes, except ROI, will be added
136 //! on top of each other. ROI shape will be added at the bottom.
137 
139 {
140  if (isROIMode())
141  return -1;
142  return 0;
143 }
Defines class MaskDrawingContext.
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.
void setDrawingInProgress(bool value)
MaskEditorFlags::Activity getActivityType() const
void setActivityType(MaskEditorFlags::Activity value)
bool isVerticalLineMode() const
bool isRectangleShapeMode() const
bool isActivityRequiresDrawingCancel(MaskEditorFlags::Activity proposed_new_activity)
return true, if proposed activity requires the cancel of drawing i.e.
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.