Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
a133fe0c
Commit
a133fe0c
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
rename -> m_mask_mode
parent
cdfe6292
No related branches found
No related tags found
1 merge request
!2230
rm hidden "previous mode" feature, and further simplify the MaskGraphicsScene code
Pipeline
#123414
passed
1 year ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Scene/MaskGraphicsScene.cpp
+23
-23
23 additions, 23 deletions
GUI/View/Scene/MaskGraphicsScene.cpp
GUI/View/Scene/MaskGraphicsScene.h
+1
-1
1 addition, 1 deletion
GUI/View/Scene/MaskGraphicsScene.h
with
24 additions
and
24 deletions
GUI/View/Scene/MaskGraphicsScene.cpp
+
23
−
23
View file @
a133fe0c
...
@@ -124,13 +124,13 @@ void MaskGraphicsScene::onActivityChanged(MaskFlags::MaskMode mask_mode)
...
@@ -124,13 +124,13 @@ void MaskGraphicsScene::onActivityChanged(MaskFlags::MaskMode mask_mode)
if
(
!
m_proxy
)
if
(
!
m_proxy
)
return
;
return
;
if
(
m_drawing_in_progress
&&
m_
activity
==
MaskFlags
::
POLYGON_MODE
if
(
m_drawing_in_progress
&&
m_
mask_mode
==
MaskFlags
::
POLYGON_MODE
&&
mask_mode
>=
MaskFlags
::
PAN_ZOOM_MODE
)
&&
mask_mode
>=
MaskFlags
::
PAN_ZOOM_MODE
)
cancelCurrentDrawing
();
cancelCurrentDrawing
();
m_
activity
=
mask_mode
;
m_
mask_mode
=
mask_mode
;
const
bool
zoomMode
=
m_
activity
==
MaskFlags
::
PAN_ZOOM_MODE
;
const
bool
zoomMode
=
m_
mask_mode
==
MaskFlags
::
PAN_ZOOM_MODE
;
// Sets the state of all views in pan&zoom mode.
// Sets the state of all views in pan&zoom mode.
// In pan&zoom mode, the selection is removed, all items cannot receive mouse clicks, and all
// In pan&zoom mode, the selection is removed, all items cannot receive mouse clicks, and all
...
@@ -231,14 +231,14 @@ void MaskGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
...
@@ -231,14 +231,14 @@ void MaskGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
void
MaskGraphicsScene
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
MaskGraphicsScene
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
m_drawing_in_progress
&&
::
isRectangleShapeMode
(
m_
activity
))
{
if
(
m_drawing_in_progress
&&
::
isRectangleShapeMode
(
m_
mask_mode
))
{
processRectangleOrEllipseItem
(
event
);
processRectangleOrEllipseItem
(
event
);
return
;
return
;
}
}
QGraphicsScene
::
mouseMoveEvent
(
event
);
QGraphicsScene
::
mouseMoveEvent
(
event
);
if
((
m_drawing_in_progress
&&
m_
activity
==
MaskFlags
::
POLYGON_MODE
)
if
((
m_drawing_in_progress
&&
m_
mask_mode
==
MaskFlags
::
POLYGON_MODE
)
||
::
isLineMode
(
m_
activity
))
{
||
::
isLineMode
(
m_
mask_mode
))
{
m_mouse_position
=
event
->
scenePos
();
m_mouse_position
=
event
->
scenePos
();
invalidate
();
invalidate
();
}
}
...
@@ -252,7 +252,7 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
...
@@ -252,7 +252,7 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
if
(
!
m_drawing_in_progress
)
if
(
!
m_drawing_in_progress
)
QGraphicsScene
::
mouseReleaseEvent
(
event
);
QGraphicsScene
::
mouseReleaseEvent
(
event
);
else
if
(
::
isRectangleShapeMode
(
m_
activity
))
{
else
if
(
::
isRectangleShapeMode
(
m_
mask_mode
))
{
clearSelection
();
clearSelection
();
if
(
m_currentItem
)
{
if
(
m_currentItem
)
{
// drawing ended up with item drawn, let's make it selected
// drawing ended up with item drawn, let's make it selected
...
@@ -278,19 +278,19 @@ void MaskGraphicsScene::drawForeground(QPainter* painter, const QRectF&)
...
@@ -278,19 +278,19 @@ void MaskGraphicsScene::drawForeground(QPainter* painter, const QRectF&)
if
(
PolygonDisplay
*
polygon
=
currentPolygon
())
{
if
(
PolygonDisplay
*
polygon
=
currentPolygon
())
{
painter
->
setPen
(
QPen
(
Qt
::
black
,
1
,
Qt
::
DashLine
));
painter
->
setPen
(
QPen
(
Qt
::
black
,
1
,
Qt
::
DashLine
));
painter
->
drawLine
(
QLineF
(
polygon
->
lastAddedPoint
(),
m_mouse_position
));
painter
->
drawLine
(
QLineF
(
polygon
->
lastAddedPoint
(),
m_mouse_position
));
}
else
if
(
::
isLineMode
(
m_
activity
))
{
}
else
if
(
::
isLineMode
(
m_
mask_mode
))
{
ASSERT
(
m_adaptor
);
ASSERT
(
m_adaptor
);
const
QRectF
&
plot_scene_rectangle
=
m_adaptor
->
viewportRectangle
();
const
QRectF
&
plot_scene_rectangle
=
m_adaptor
->
viewportRectangle
();
if
(
!
plot_scene_rectangle
.
contains
(
m_mouse_position
))
if
(
!
plot_scene_rectangle
.
contains
(
m_mouse_position
))
return
;
return
;
painter
->
setPen
(
QPen
(
Qt
::
black
,
1
,
Qt
::
DashLine
));
painter
->
setPen
(
QPen
(
Qt
::
black
,
1
,
Qt
::
DashLine
));
if
(
m_
activity
==
MaskFlags
::
VERTICAL_LINE_MODE
)
{
if
(
m_
mask_mode
==
MaskFlags
::
VERTICAL_LINE_MODE
)
{
QPointF
p1
(
m_mouse_position
.
x
(),
plot_scene_rectangle
.
bottom
());
QPointF
p1
(
m_mouse_position
.
x
(),
plot_scene_rectangle
.
bottom
());
QPointF
p2
(
m_mouse_position
.
x
(),
plot_scene_rectangle
.
top
());
QPointF
p2
(
m_mouse_position
.
x
(),
plot_scene_rectangle
.
top
());
painter
->
drawLine
(
QLineF
(
p1
,
p2
));
painter
->
drawLine
(
QLineF
(
p1
,
p2
));
}
}
if
(
m_
activity
==
MaskFlags
::
HORIZONTAL_LINE_MODE
)
{
if
(
m_
mask_mode
==
MaskFlags
::
HORIZONTAL_LINE_MODE
)
{
QPointF
p1
(
plot_scene_rectangle
.
left
(),
m_mouse_position
.
y
());
QPointF
p1
(
plot_scene_rectangle
.
left
(),
m_mouse_position
.
y
());
QPointF
p2
(
plot_scene_rectangle
.
right
(),
m_mouse_position
.
y
());
QPointF
p2
(
plot_scene_rectangle
.
right
(),
m_mouse_position
.
y
());
painter
->
drawLine
(
QLineF
(
p1
,
p2
));
painter
->
drawLine
(
QLineF
(
p1
,
p2
));
...
@@ -487,11 +487,11 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
...
@@ -487,11 +487,11 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
return
;
// selected area is too small => don't create object yet
return
;
// selected area is too small => don't create object yet
MaskItem
*
newMaskItem
;
MaskItem
*
newMaskItem
;
if
(
m_
activity
==
MaskFlags
::
RECTANGLE_MODE
)
if
(
m_
mask_mode
==
MaskFlags
::
RECTANGLE_MODE
)
newMaskItem
=
new
RectangleItem
;
newMaskItem
=
new
RectangleItem
;
else
if
(
m_
activity
==
MaskFlags
::
ELLIPSE_MODE
)
else
if
(
m_
mask_mode
==
MaskFlags
::
ELLIPSE_MODE
)
newMaskItem
=
new
EllipseItem
;
newMaskItem
=
new
EllipseItem
;
else
if
(
m_
activity
==
MaskFlags
::
ROI_MODE
)
else
if
(
m_
mask_mode
==
MaskFlags
::
ROI_MODE
)
newMaskItem
=
new
RegionOfInterestItem
;
newMaskItem
=
new
RegionOfInterestItem
;
else
else
ASSERT_NEVER
;
ASSERT_NEVER
;
...
@@ -500,7 +500,7 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
...
@@ -500,7 +500,7 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
m_currentItem
=
dynamic_cast
<
MaskObject
*>
(
newMaskItem
);
m_currentItem
=
dynamic_cast
<
MaskObject
*>
(
newMaskItem
);
ASSERT
(
m_currentItem
);
ASSERT
(
m_currentItem
);
if
(
m_
activity
!=
MaskFlags
::
ROI_MODE
)
if
(
m_
mask_mode
!=
MaskFlags
::
ROI_MODE
)
dynamic_cast
<
MaskItem
*>
(
m_currentItem
)
->
setMaskValue
(
m_mask_value
);
dynamic_cast
<
MaskItem
*>
(
m_currentItem
)
->
setMaskValue
(
m_mask_value
);
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
...
@@ -534,7 +534,7 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
...
@@ -534,7 +534,7 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
void
MaskGraphicsScene
::
processPolygonItem
(
QGraphicsSceneMouseEvent
*
event
)
void
MaskGraphicsScene
::
processPolygonItem
(
QGraphicsSceneMouseEvent
*
event
)
{
{
ASSERT
(
m_
activity
==
MaskFlags
::
POLYGON_MODE
);
ASSERT
(
m_
mask_mode
==
MaskFlags
::
POLYGON_MODE
);
if
(
!
m_currentItem
)
{
if
(
!
m_currentItem
)
{
setDrawingInProgress
(
true
);
setDrawingInProgress
(
true
);
...
@@ -570,9 +570,9 @@ void MaskGraphicsScene::processLineItem(QGraphicsSceneMouseEvent* event)
...
@@ -570,9 +570,9 @@ void MaskGraphicsScene::processLineItem(QGraphicsSceneMouseEvent* event)
setDrawingInProgress
(
true
);
setDrawingInProgress
(
true
);
QPointF
click_pos
=
event
->
buttonDownScenePos
(
Qt
::
LeftButton
);
QPointF
click_pos
=
event
->
buttonDownScenePos
(
Qt
::
LeftButton
);
if
(
m_
activity
==
MaskFlags
::
VERTICAL_LINE_MODE
)
if
(
m_
mask_mode
==
MaskFlags
::
VERTICAL_LINE_MODE
)
processVerticalLineItem
(
click_pos
);
processVerticalLineItem
(
click_pos
);
if
(
m_
activity
==
MaskFlags
::
HORIZONTAL_LINE_MODE
)
if
(
m_
mask_mode
==
MaskFlags
::
HORIZONTAL_LINE_MODE
)
processHorizontalLineItem
(
click_pos
);
processHorizontalLineItem
(
click_pos
);
emit
dynamic_cast
<
MaskItem
*>
(
m_currentItem
)
->
maskGeometryChanged
();
emit
dynamic_cast
<
MaskItem
*>
(
m_currentItem
)
->
maskGeometryChanged
();
...
@@ -650,11 +650,11 @@ bool MaskGraphicsScene::isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent
...
@@ -650,11 +650,11 @@ bool MaskGraphicsScene::isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent
{
{
if
(
m_drawing_in_progress
)
if
(
m_drawing_in_progress
)
return
false
;
return
false
;
if
(
!::
isRectangleShapeMode
(
m_
activity
))
if
(
!::
isRectangleShapeMode
(
m_
mask_mode
))
return
false
;
return
false
;
if
(
isAreaContains
(
event
,
MaskType
::
SIZEHANDLE
))
if
(
isAreaContains
(
event
,
MaskType
::
SIZEHANDLE
))
return
false
;
return
false
;
if
(
m_
activity
==
MaskFlags
::
ROI_MODE
)
if
(
m_
mask_mode
==
MaskFlags
::
ROI_MODE
)
// only one ROI is allowed
// only one ROI is allowed
for
(
MaskObject
*
item
:
m_ItemToView
.
keys
())
for
(
MaskObject
*
item
:
m_ItemToView
.
keys
())
if
(
dynamic_cast
<
RegionOfInterestItem
*>
(
item
))
if
(
dynamic_cast
<
RegionOfInterestItem
*>
(
item
))
...
@@ -666,7 +666,7 @@ bool MaskGraphicsScene::isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent
...
@@ -666,7 +666,7 @@ bool MaskGraphicsScene::isValidForRectangleShapeDrawing(QGraphicsSceneMouseEvent
bool
MaskGraphicsScene
::
isValidForPolygonDrawing
(
QGraphicsSceneMouseEvent
*
event
)
const
bool
MaskGraphicsScene
::
isValidForPolygonDrawing
(
QGraphicsSceneMouseEvent
*
event
)
const
{
{
if
(
m_
activity
!=
MaskFlags
::
POLYGON_MODE
)
if
(
m_
mask_mode
!=
MaskFlags
::
POLYGON_MODE
)
return
false
;
return
false
;
if
(
!
m_drawing_in_progress
)
if
(
!
m_drawing_in_progress
)
if
(
isAreaContains
(
event
,
MaskType
::
POLYGONPOINT
))
if
(
isAreaContains
(
event
,
MaskType
::
POLYGONPOINT
))
...
@@ -680,7 +680,7 @@ bool MaskGraphicsScene::isValidForLineDrawing(QGraphicsSceneMouseEvent* event) c
...
@@ -680,7 +680,7 @@ bool MaskGraphicsScene::isValidForLineDrawing(QGraphicsSceneMouseEvent* event) c
{
{
if
(
m_drawing_in_progress
)
if
(
m_drawing_in_progress
)
return
false
;
return
false
;
if
(
!::
isLineMode
(
m_
activity
))
if
(
!::
isLineMode
(
m_
mask_mode
))
return
false
;
return
false
;
if
(
QGraphicsItem
*
graphicsItem
=
itemAt
(
event
->
scenePos
(),
QTransform
()))
if
(
QGraphicsItem
*
graphicsItem
=
itemAt
(
event
->
scenePos
(),
QTransform
()))
if
(
graphicsItem
->
type
()
==
MaskType
::
VERTICALLINE
if
(
graphicsItem
->
type
()
==
MaskType
::
VERTICALLINE
...
@@ -695,7 +695,7 @@ bool MaskGraphicsScene::isValidForMaskAllDrawing(QGraphicsSceneMouseEvent*) cons
...
@@ -695,7 +695,7 @@ bool MaskGraphicsScene::isValidForMaskAllDrawing(QGraphicsSceneMouseEvent*) cons
{
{
if
(
m_drawing_in_progress
)
if
(
m_drawing_in_progress
)
return
false
;
return
false
;
if
(
m_
activity
!=
MaskFlags
::
MASKALL_MODE
)
if
(
m_
mask_mode
!=
MaskFlags
::
MASKALL_MODE
)
return
false
;
return
false
;
for
(
MaskObject
*
item
:
m_ItemToView
.
keys
())
for
(
MaskObject
*
item
:
m_ItemToView
.
keys
())
...
@@ -718,7 +718,7 @@ bool MaskGraphicsScene::isAreaContains(QGraphicsSceneMouseEvent* event, MaskType
...
@@ -718,7 +718,7 @@ bool MaskGraphicsScene::isAreaContains(QGraphicsSceneMouseEvent* event, MaskType
PolygonDisplay
*
MaskGraphicsScene
::
currentPolygon
()
const
PolygonDisplay
*
MaskGraphicsScene
::
currentPolygon
()
const
{
{
if
(
m_drawing_in_progress
&&
m_
activity
==
MaskFlags
::
POLYGON_MODE
&&
m_currentItem
)
if
(
m_drawing_in_progress
&&
m_
mask_mode
==
MaskFlags
::
POLYGON_MODE
&&
m_currentItem
)
return
dynamic_cast
<
PolygonDisplay
*>
(
m_ItemToView
[
m_currentItem
]);
return
dynamic_cast
<
PolygonDisplay
*>
(
m_ItemToView
[
m_currentItem
]);
return
nullptr
;
return
nullptr
;
}
}
This diff is collapsed.
Click to expand it.
GUI/View/Scene/MaskGraphicsScene.h
+
1
−
1
View file @
a133fe0c
...
@@ -114,7 +114,7 @@ private:
...
@@ -114,7 +114,7 @@ private:
QPointF
m_mouse_position
;
QPointF
m_mouse_position
;
bool
m_drawing_in_progress
;
bool
m_drawing_in_progress
;
MaskFlags
::
MaskValue
m_mask_value
;
MaskFlags
::
MaskValue
m_mask_value
;
MaskFlags
::
MaskMode
m_
activity
;
MaskFlags
::
MaskMode
m_
mask_mode
;
};
};
#endif // BORNAGAIN_GUI_VIEW_SCENE_MASKGRAPHICSSCENE_H
#endif // BORNAGAIN_GUI_VIEW_SCENE_MASKGRAPHICSSCENE_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment