Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
28e5c094
Commit
28e5c094
authored
Sep 14, 2021
by
Whitfield, Ross
Browse files
Get control points working
parent
97b648aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
qt/widgets/instrumentview/src/Shape2D.cpp
View file @
28e5c094
...
...
@@ -48,8 +48,15 @@ void Shape2D::draw(QPainter &painter) const {
painter
.
setPen
(
QPen
(
m_color
,
0
));
this
->
drawShape
(
painter
);
if
(
m_editing
||
m_selected
)
{
auto
center
=
m_boundingRect
.
center
();
QRectF
drawRect
=
m_boundingRect
.
translated
(
-
center
).
toQRectF
();
painter
.
save
();
double
rotation
=
20
;
painter
.
rotate
(
rotation
);
painter
.
translate
(
QTransform
().
rotate
(
-
rotation
).
map
(
center
));
painter
.
setPen
(
QPen
(
QColor
(
255
,
255
,
255
,
100
),
0
));
painter
.
drawRect
(
m_boundingRect
.
toQRectF
());
painter
.
drawRect
(
drawRect
);
painter
.
restore
();
size_t
np
=
NCommonCP
;
double
rsize
=
2
;
int
alpha
=
100
;
...
...
@@ -88,8 +95,13 @@ QPointF Shape2D::getControlPoint(size_t i) const {
throw
std
::
range_error
(
"Control point index is out of range"
);
}
if
(
i
<
4
)
return
m_boundingRect
.
vertex
(
i
);
if
(
i
<
4
)
{
auto
center
=
m_boundingRect
.
center
();
QPointF
vertex
=
m_boundingRect
.
vertex
(
i
);
double
rotation
=
20
;
vertex
=
QTransform
().
rotate
(
rotation
).
map
(
vertex
-
center
)
+
center
;
return
vertex
;
}
return
getShapeControlPoint
(
i
-
NCommonCP
);
}
...
...
@@ -100,7 +112,9 @@ void Shape2D::setControlPoint(size_t i, const QPointF &pos) {
}
if
(
i
<
4
)
{
m_boundingRect
.
setVertex
(
i
,
pos
);
auto
center
=
m_boundingRect
.
center
();
double
rotation
=
20
;
m_boundingRect
.
setVertex
(
i
,
QTransform
().
rotate
(
-
rotation
).
map
(
pos
-
center
)
+
center
);
refit
();
}
...
...
@@ -381,7 +395,9 @@ Shape2DRectangle::Shape2DRectangle(const QPointF &p0, const QSizeF &size) { m_bo
bool
Shape2DRectangle
::
selectAt
(
const
QPointF
&
p
)
const
{
if
(
m_fill_color
!=
QColor
())
{
// filled rectangle
return
contains
(
p
);
auto
center
=
m_boundingRect
.
center
();
double
rotation
=
20
;
return
contains
(
QTransform
().
rotate
(
-
rotation
).
map
(
p
-
center
)
+
center
);
}
RectF
outer
(
m_boundingRect
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment