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
3e64d779
Commit
3e64d779
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
m_current_item now unique_ptr
parent
bdc9210a
No related branches found
No related tags found
1 merge request
!2127
simplifications in mask context
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Mask/MaskGraphicsScene.cpp
+17
-17
17 additions, 17 deletions
GUI/View/Mask/MaskGraphicsScene.cpp
GUI/View/Mask/MaskGraphicsScene.h
+1
-1
1 addition, 1 deletion
GUI/View/Mask/MaskGraphicsScene.h
with
18 additions
and
18 deletions
GUI/View/Mask/MaskGraphicsScene.cpp
+
17
−
17
View file @
3e64d779
...
@@ -153,7 +153,7 @@ void MaskGraphicsScene::cancelCurrentDrawing()
...
@@ -153,7 +153,7 @@ void MaskGraphicsScene::cancelCurrentDrawing()
{
{
if
(
m_drawing_in_progress
)
{
if
(
m_drawing_in_progress
)
{
ASSERT
(
m_currentItem
);
ASSERT
(
m_currentItem
);
m_maskContainerModel
->
removeMask
(
dynamic_cast
<
MaskItem
*>
(
m_currentItem
));
m_maskContainerModel
->
removeMask
(
m_currentItem
.
get
(
));
m_drawing_in_progress
=
false
;
m_drawing_in_progress
=
false
;
}
}
}
}
...
@@ -297,7 +297,7 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
...
@@ -297,7 +297,7 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
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
if
(
IShapeDisplay
*
view
=
m_ItemToView
[
m_currentItem
])
if
(
IShapeDisplay
*
view
=
m_ItemToView
[
m_currentItem
.
get
()
])
view
->
setSelected
(
true
);
view
->
setSelected
(
true
);
}
else
{
}
else
{
// drawing ended without item to be draw (too short mouse move)
// drawing ended without item to be draw (too short mouse move)
...
@@ -565,7 +565,7 @@ void MaskGraphicsScene::setDrawingInProgress(bool value)
...
@@ -565,7 +565,7 @@ void MaskGraphicsScene::setDrawingInProgress(bool value)
if
(
value
)
if
(
value
)
gProjectDocument
.
value
()
->
setModified
();
// manual mask creation
gProjectDocument
.
value
()
->
setModified
();
// manual mask creation
else
else
m_currentItem
=
nullptr
;
m_currentItem
.
release
()
;
}
}
//! Sets the state of all views in pan&zoom mode.
//! Sets the state of all views in pan&zoom mode.
...
@@ -631,10 +631,10 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
...
@@ -631,10 +631,10 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
ASSERT_NEVER
;
ASSERT_NEVER
;
m_maskContainerModel
->
insertMask
(
0
,
newMaskItem
);
m_maskContainerModel
->
insertMask
(
0
,
newMaskItem
);
m_currentItem
=
newMaskItem
;
// downcast MaskItem* -> MaskRoot*
m_currentItem
.
reset
(
newMaskItem
);
if
(
m_activity
!=
MaskEditorFlags
::
ROI_MODE
)
if
(
m_activity
!=
MaskEditorFlags
::
ROI_MODE
)
dynamic_cast
<
MaskItem
*>
(
m_currentItem
)
->
setMaskValue
(
m_mask_value
);
dynamic_cast
<
MaskItem
*>
(
m_currentItem
.
get
()
)
->
setMaskValue
(
m_mask_value
);
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
}
}
...
@@ -646,13 +646,13 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
...
@@ -646,13 +646,13 @@ void MaskGraphicsScene::processRectangleOrEllipseItem(QGraphicsSceneMouseEvent*
const
qreal
ymin
=
m_adaptor
->
fromSceneY
(
std
::
min
(
click_pos
.
y
(),
mouse_pos
.
y
()));
const
qreal
ymin
=
m_adaptor
->
fromSceneY
(
std
::
min
(
click_pos
.
y
(),
mouse_pos
.
y
()));
const
qreal
ymax
=
m_adaptor
->
fromSceneY
(
std
::
max
(
click_pos
.
y
(),
mouse_pos
.
y
()));
const
qreal
ymax
=
m_adaptor
->
fromSceneY
(
std
::
max
(
click_pos
.
y
(),
mouse_pos
.
y
()));
if
(
auto
*
rectItem
=
dynamic_cast
<
RectangleItem
*>
(
m_currentItem
))
{
if
(
auto
*
rectItem
=
dynamic_cast
<
RectangleItem
*>
(
m_currentItem
.
get
()
))
{
// RectangleItem or RegionOfInterestItem
// RectangleItem or RegionOfInterestItem
rectItem
->
setXLow
(
xmin
);
rectItem
->
setXLow
(
xmin
);
rectItem
->
setYLow
(
ymax
);
rectItem
->
setYLow
(
ymax
);
rectItem
->
setXUp
(
xmax
);
rectItem
->
setXUp
(
xmax
);
rectItem
->
setYUp
(
ymin
);
rectItem
->
setYUp
(
ymin
);
}
else
if
(
auto
*
ellItem
=
dynamic_cast
<
EllipseItem
*>
(
m_currentItem
))
{
}
else
if
(
auto
*
ellItem
=
dynamic_cast
<
EllipseItem
*>
(
m_currentItem
.
get
()
))
{
ellItem
->
setXCenter
((
xmax
+
xmin
)
/
2
);
ellItem
->
setXCenter
((
xmax
+
xmin
)
/
2
);
ellItem
->
setYCenter
((
ymax
+
ymin
)
/
2
);
ellItem
->
setYCenter
((
ymax
+
ymin
)
/
2
);
ellItem
->
setXRadius
((
xmax
-
xmin
)
/
2
);
ellItem
->
setXRadius
((
xmax
-
xmin
)
/
2
);
...
@@ -672,13 +672,13 @@ void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event)
...
@@ -672,13 +672,13 @@ void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event)
PolygonItem
*
new_poly
=
new
PolygonItem
;
PolygonItem
*
new_poly
=
new
PolygonItem
;
m_maskContainerModel
->
insertMask
(
0
,
new_poly
);
m_maskContainerModel
->
insertMask
(
0
,
new_poly
);
new_poly
->
setMaskValue
(
m_mask_value
);
new_poly
->
setMaskValue
(
m_mask_value
);
m_currentItem
=
new_poly
;
m_currentItem
.
reset
(
new_poly
)
;
m_selectionModel
->
clearSelection
();
m_selectionModel
->
clearSelection
();
m_selectionModel
->
select
(
m_maskContainerModel
->
indexOfItem
(
m_currentItem
),
m_selectionModel
->
select
(
m_maskContainerModel
->
indexOfItem
(
m_currentItem
.
get
()
),
QItemSelectionModel
::
Select
);
QItemSelectionModel
::
Select
);
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
}
}
ASSERT
(
dynamic_cast
<
PolygonItem
*>
(
m_currentItem
));
ASSERT
(
dynamic_cast
<
PolygonItem
*>
(
m_currentItem
.
get
()
));
if
(
PolygonDisplay
*
polygon
=
currentPolygon
())
{
if
(
PolygonDisplay
*
polygon
=
currentPolygon
())
{
if
(
polygon
->
closePolygonIfNecessary
())
{
if
(
polygon
->
closePolygonIfNecessary
())
{
...
@@ -691,7 +691,7 @@ void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event)
...
@@ -691,7 +691,7 @@ void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event)
const
QPointF
click_pos
=
event
->
buttonDownScenePos
(
Qt
::
LeftButton
);
const
QPointF
click_pos
=
event
->
buttonDownScenePos
(
Qt
::
LeftButton
);
const
double
x
=
m_adaptor
->
fromSceneX
(
click_pos
.
x
());
const
double
x
=
m_adaptor
->
fromSceneX
(
click_pos
.
x
());
const
double
y
=
m_adaptor
->
fromSceneY
(
click_pos
.
y
());
const
double
y
=
m_adaptor
->
fromSceneY
(
click_pos
.
y
());
dynamic_cast
<
PolygonItem
*>
(
m_currentItem
)
->
addPoint
(
x
,
y
);
dynamic_cast
<
PolygonItem
*>
(
m_currentItem
.
get
()
)
->
addPoint
(
x
,
y
);
updateScene
();
updateScene
();
}
}
...
@@ -707,10 +707,10 @@ void MaskGraphicsScene::processLineItem(QGraphicsSceneMouseEvent* event)
...
@@ -707,10 +707,10 @@ void MaskGraphicsScene::processLineItem(QGraphicsSceneMouseEvent* event)
processHorizontalLineItem
(
click_pos
);
processHorizontalLineItem
(
click_pos
);
m_selectionModel
->
clearSelection
();
m_selectionModel
->
clearSelection
();
m_selectionModel
->
select
(
m_maskContainerModel
->
indexOfItem
(
m_currentItem
),
m_selectionModel
->
select
(
m_maskContainerModel
->
indexOfItem
(
m_currentItem
.
get
()
),
QItemSelectionModel
::
Select
);
QItemSelectionModel
::
Select
);
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
m_maskContainerModel
->
maskContItem
()
->
updateMaskNames
();
dynamic_cast
<
MaskItem
*>
(
m_currentItem
)
->
setMaskValue
(
m_mask_value
);
dynamic_cast
<
MaskItem
*>
(
m_currentItem
.
get
()
)
->
setMaskValue
(
m_mask_value
);
emit
lineItemProcessed
();
emit
lineItemProcessed
();
...
@@ -721,7 +721,7 @@ void MaskGraphicsScene::processVerticalLineItem(const QPointF& pos)
...
@@ -721,7 +721,7 @@ void MaskGraphicsScene::processVerticalLineItem(const QPointF& pos)
{
{
VerticalLineItem
*
item
=
new
VerticalLineItem
;
VerticalLineItem
*
item
=
new
VerticalLineItem
;
m_maskContainerModel
->
insertMask
(
0
,
item
);
m_maskContainerModel
->
insertMask
(
0
,
item
);
m_currentItem
=
item
;
m_currentItem
.
reset
(
item
)
;
item
->
setPosX
(
m_adaptor
->
fromSceneX
(
pos
.
x
()));
item
->
setPosX
(
m_adaptor
->
fromSceneX
(
pos
.
x
()));
}
}
...
@@ -729,7 +729,7 @@ void MaskGraphicsScene::processHorizontalLineItem(const QPointF& pos)
...
@@ -729,7 +729,7 @@ void MaskGraphicsScene::processHorizontalLineItem(const QPointF& pos)
{
{
HorizontalLineItem
*
item
=
new
HorizontalLineItem
;
HorizontalLineItem
*
item
=
new
HorizontalLineItem
;
m_maskContainerModel
->
insertMask
(
0
,
item
);
m_maskContainerModel
->
insertMask
(
0
,
item
);
m_currentItem
=
dynamic_cast
<
MaskRoot
*>
(
item
);
m_currentItem
.
reset
(
item
);
item
->
setPosY
(
m_adaptor
->
fromSceneY
(
pos
.
y
()));
item
->
setPosY
(
m_adaptor
->
fromSceneY
(
pos
.
y
()));
}
}
...
@@ -740,7 +740,7 @@ void MaskGraphicsScene::processMaskAllItem(QGraphicsSceneMouseEvent* event)
...
@@ -740,7 +740,7 @@ void MaskGraphicsScene::processMaskAllItem(QGraphicsSceneMouseEvent* event)
setDrawingInProgress
(
true
);
setDrawingInProgress
(
true
);
MaskAllItem
*
item
=
new
MaskAllItem
;
MaskAllItem
*
item
=
new
MaskAllItem
;
m_maskContainerModel
->
insertMask
(
0
,
item
);
m_maskContainerModel
->
insertMask
(
0
,
item
);
m_currentItem
=
item
;
m_currentItem
.
reset
(
item
)
;
m_selectionModel
->
clearSelection
();
m_selectionModel
->
clearSelection
();
setDrawingInProgress
(
false
);
setDrawingInProgress
(
false
);
}
}
...
@@ -778,6 +778,6 @@ void MaskGraphicsScene::setZValues()
...
@@ -778,6 +778,6 @@ void MaskGraphicsScene::setZValues()
PolygonDisplay
*
MaskGraphicsScene
::
currentPolygon
()
const
PolygonDisplay
*
MaskGraphicsScene
::
currentPolygon
()
const
{
{
if
(
m_drawing_in_progress
&&
m_activity
==
MaskEditorFlags
::
POLYGON_MODE
&&
m_currentItem
)
if
(
m_drawing_in_progress
&&
m_activity
==
MaskEditorFlags
::
POLYGON_MODE
&&
m_currentItem
)
return
dynamic_cast
<
PolygonDisplay
*>
(
m_ItemToView
[
m_currentItem
]);
return
dynamic_cast
<
PolygonDisplay
*>
(
m_ItemToView
[
m_currentItem
.
get
()
]);
return
nullptr
;
return
nullptr
;
}
}
This diff is collapsed.
Click to expand it.
GUI/View/Mask/MaskGraphicsScene.h
+
1
−
1
View file @
3e64d779
...
@@ -119,7 +119,7 @@ private:
...
@@ -119,7 +119,7 @@ private:
bool
m_block_selection
=
false
;
bool
m_block_selection
=
false
;
bool
m_mouse_is_pressed
=
false
;
bool
m_mouse_is_pressed
=
false
;
Data2DItem
*
m_data2DItem
=
nullptr
;
Data2DItem
*
m_data2DItem
=
nullptr
;
MaskRoot
*
m_currentItem
=
nullptr
;
std
::
unique_ptr
<
MaskItem
>
m_currentItem
;
QPointF
m_mouse_position
;
QPointF
m_mouse_position
;
bool
m_drawing_in_progress
;
bool
m_drawing_in_progress
;
MaskEditorFlags
::
MaskValue
m_mask_value
;
MaskEditorFlags
::
MaskValue
m_mask_value
;
...
...
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