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
42ce42ea
Commit
42ce42ea
authored
Jan 13, 2017
by
Samuel Jackson
Browse files
Refs #18043 Fix line appearing outside of integration range.
parent
c2f96f11
Changes
4
Hide whitespace changes
Inline
Side-by-side
MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/ProjectionSurface.h
View file @
42ce42ea
...
...
@@ -352,6 +352,8 @@ private:
void
drawMaskShapes
(
QPainter
&
painter
)
const
;
/// Draw the selection rectangle to the surface
void
drawSelectionRect
(
QPainter
&
painter
)
const
;
/// Check if a peak is visible at a given point
bool
peakVisibleAtPoint
(
const
QPointF
&
point
)
const
;
/// Get the current input controller
MantidQt
::
MantidWidgets
::
InputController
*
getController
()
const
;
...
...
MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2DCollection.h
View file @
42ce42ea
...
...
@@ -53,6 +53,7 @@ public:
void
keyPressEvent
(
QKeyEvent
*
);
bool
selectAtXY
(
int
x
,
int
y
,
bool
edit
=
true
);
bool
selectAtXY
(
const
QPointF
&
point
,
bool
edit
=
true
);
void
deselectAtXY
(
int
x
,
int
y
);
bool
selectIn
(
const
QRect
&
rect
);
void
removeCurrentShape
();
...
...
MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp
View file @
42ce42ea
...
...
@@ -515,20 +515,54 @@ void ProjectionSurface::setPeakVisibility() const {
}
}
/** Check a peak is visible at the given point
*
* Will return true if any peak in any overlay was found to be positioned at
* the given point.
*
* @param point :: the point to check for peaks
* @return true if any peaks was found at the given point
*/
bool
ProjectionSurface
::
peakVisibleAtPoint
(
const
QPointF
&
point
)
const
{
bool
visible
=
false
;
for
(
const
auto
po
:
m_peakShapes
)
{
po
->
selectAtXY
(
point
);
auto
markers
=
po
->
getSelectedPeakMarkers
();
visible
=
std
::
any_of
(
markers
.
begin
(),
markers
.
end
(),
[](
PeakMarker2D
*
marker
)
{
return
marker
->
isVisible
();
});
if
(
visible
)
return
true
;
}
return
false
;
}
/**
* Draw a line between peak markers being compared
* @param painter :: The QPainter object to draw the line with
*/
void
ProjectionSurface
::
drawPeakComparisonLine
(
QPainter
&
painter
)
const
{
if
(
!
m_selectedMarkers
.
first
.
isNull
()
&&
!
m_selectedMarkers
.
second
.
isNull
())
{
QTransform
transform
;
auto
windowRect
=
getSurfaceBounds
();
windowRect
.
findTransform
(
transform
,
painter
.
viewport
());
auto
p1
=
transform
.
map
(
m_selectedMarkers
.
first
);
auto
p2
=
transform
.
map
(
m_selectedMarkers
.
second
);
painter
.
setPen
(
Qt
::
red
);
painter
.
drawLine
(
p1
,
p2
);
}
const
auto
&
firstOrigin
=
m_selectedMarkers
.
first
;
const
auto
&
secondOrigin
=
m_selectedMarkers
.
second
;
// Check is user has selected enough peaks
if
(
firstOrigin
.
isNull
()
||
secondOrigin
.
isNull
())
return
;
// Check if the integration range is such that some peaks are visible
if
(
!
peakVisibleAtPoint
(
firstOrigin
)
||
!
peakVisibleAtPoint
(
secondOrigin
))
return
;
// Draw line between peaks
QTransform
transform
;
auto
windowRect
=
getSurfaceBounds
();
windowRect
.
findTransform
(
transform
,
painter
.
viewport
());
auto
p1
=
transform
.
map
(
firstOrigin
);
auto
p2
=
transform
.
map
(
secondOrigin
);
painter
.
setPen
(
Qt
::
red
);
painter
.
drawLine
(
p1
,
p2
);
}
/**
...
...
MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp
View file @
42ce42ea
...
...
@@ -300,13 +300,20 @@ void Shape2DCollection::touchShapeOrControlPointAt(int x, int y) {
* Select a shape which contains a point (x,y) of the screen.
*/
bool
Shape2DCollection
::
selectAtXY
(
int
x
,
int
y
,
bool
edit
)
{
const
auto
point
=
m_transform
.
inverted
().
map
(
QPointF
(
x
,
y
));
return
selectAtXY
(
point
,
edit
);
}
/**
* Select a shape which contains a point (x, y) of the world.
*/
bool
Shape2DCollection
::
selectAtXY
(
const
QPointF
&
point
,
bool
edit
)
{
if
(
edit
)
{
// if shape has to be edited (resized) it must be the only selection
deselectAll
();
}
QPointF
p
=
m_transform
.
inverted
().
map
(
QPointF
(
x
,
y
));
foreach
(
Shape2D
*
shape
,
m_shapes
)
{
bool
picked
=
shape
->
selectAt
(
p
);
bool
picked
=
shape
->
selectAt
(
p
oint
);
if
(
picked
)
{
addToSelection
(
shape
);
return
true
;
...
...
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