Implements a QGraphicsView the user can interact with to insert graphical markers. Furthermore, the graphics view enables zooming into its content.
More...
#include <QtUtil.h>
|
| MarkerGraphicsView (QWidget *parent) |
| Constructs a MarkerGraphicsView.
|
|
void | EnableActions (bool Enable) |
|
|
auto | contextMenu () const noexcept |
|
bool | HaveMarkersChanged () noexcept |
| Returns whether a marker operation has changed the stored markers. Resets the flag.
|
|
const std::vector< MarkerType > & | GetMarkers () const noexcept |
|
const auto & | GetCurrentImagePos () const noexcept |
|
|
void | SetCurrentImagePos (const QPointF &Pos) |
|
|
void | AddMarker (const QPoint &MarkerPos, const QColor &Color, bool IsUserDeletable=true, MarkerType::IDType ID=-1, std::string Name={}) |
| Adds a marker to the graphics view at position MarkerPos assigning the properties passed as arguments. Affects MarkersChanged .
|
|
void | RemoveMarker (size_t Index, bool OnlyUserDeletableMarkers=false) |
| Removes the n-th marker specified by Index . Affects MarkersChanged .
|
|
void | RemoveMarker (const QPoint &MarkerPos, bool OnlyUserDeletableMarkers=false) |
| Removes markers at the position MarkerPos . Affects MarkersChanged .
|
|
void | RemoveMarker (std::string_view Name, bool OnlyUserDeletableMarkers=false) |
| Removes markers with name Name . Affects MarkersChanged .
|
|
void | RemoveMarkers (bool OnlyUserDeletableMarkers) |
| Removes all markers from the graphics view. Affects MarkersChanged .
|
|
void | setMarkersHidden (bool MarkersHidden) |
| Hides or shows all markers.
|
|
void | RenameMarker (const QPoint &MarkerPos, std::string_view NewName) |
| Assigns a name to the marker at position MarkerPos . Affects MarkersChanged .
|
|
void | SelectMarker (const QPoint &MarkerPos) |
| Selects the marker at position MarkerPos .
|
|
void | DeselectMarkers () |
| Deselects all selected markers.
|
|
|
void | ZoomIn () |
| Zooms in one step.
|
|
void | ZoomOut () |
| Zooms out one step.
|
|
void | ZoomReset () |
| Resets the zoom.
|
|
|
virtual void | mousePressEvent (QMouseEvent *Event) override |
| Adds a marker to the mouse pointer position assigning the highest ID amongst all markers in the graphics view incremented by 1 as the ID.
|
|
virtual void | mouseDoubleClickEvent (QMouseEvent *Event) override |
| Removes the marker at the mouse pointer position if it is user-deletable. Affects MarkersChanged .
|
|
virtual void | wheelEvent (QWheelEvent *Event) override |
| Zooms in or out when Control is pressed on the keyboard at the same time.
|
|
|
void | OnContextMenuRequested (QPoint Position) |
| Shows the context menu at position Position .
|
|
void | OnShowMarkers (bool Checked) |
| If Checked is true, all markers are made visible, otherwise they become hidden.
|
|
void | OnRemoveMarkers (bool) |
| Removes all user-deletable markers. Affects MarkersChanged .
|
|
void | OnSaveMarkers (bool) |
| Asks the user for a file name and saves all markers to a CSV file.
|
|
|
static constexpr double | ZoomFactor = 1.6 |
| Determines the magnification of one zoom step.
|
|
static constexpr double | DeselectedMarkerOpacity = .5 |
| Determines the opacity of a marker which is not selected.
|
|
static constexpr double | SelectedMarkerOpacity = 1 |
| Determines the opacity of a selected marker.
|
|
Implements a QGraphicsView the user can interact with to insert graphical markers. Furthermore, the graphics view enables zooming into its content.
Definition at line 378 of file QtUtil.h.
◆ MarkerGraphicsView()
Util::MarkerGraphicsView::MarkerGraphicsView |
( |
QWidget * |
parent | ) |
|
◆ AddMarker()
void Util::MarkerGraphicsView::AddMarker |
( |
const QPoint & |
MarkerPos, |
|
|
const QColor & |
Color, |
|
|
bool |
IsUserDeletable = true , |
|
|
MarkerType::IDType |
ID = -1 , |
|
|
std::string |
Name = {} |
|
) |
| |
Adds a marker to the graphics view at position MarkerPos
assigning the properties passed as arguments. Affects MarkersChanged
.
- Parameters
-
Definition at line 398 of file QtUtil.cpp.
◆ contextMenu()
auto Util::MarkerGraphicsView::contextMenu |
( |
| ) |
const |
|
inlinenoexcept |
◆ DeselectMarkers()
void Util::MarkerGraphicsView::DeselectMarkers |
( |
| ) |
|
Deselects all selected markers.
Definition at line 506 of file QtUtil.cpp.
◆ EnableActions()
void Util::MarkerGraphicsView::EnableActions |
( |
bool |
Enable | ) |
|
◆ GetCurrentImagePos()
const auto & Util::MarkerGraphicsView::GetCurrentImagePos |
( |
| ) |
const |
|
inlinenoexcept |
◆ GetMarkers()
const std::vector< MarkerType > & Util::MarkerGraphicsView::GetMarkers |
( |
| ) |
const |
|
inlinenoexcept |
◆ HaveMarkersChanged()
bool Util::MarkerGraphicsView::HaveMarkersChanged |
( |
| ) |
|
|
noexcept |
Returns whether a marker operation has changed the stored markers. Resets the flag.
Definition at line 390 of file QtUtil.cpp.
◆ mouseClickEvent
void Util::MarkerGraphicsView::mouseClickEvent |
( |
QPoint |
Position | ) |
|
|
signal |
◆ mouseDoubleClickEvent()
void Util::MarkerGraphicsView::mouseDoubleClickEvent |
( |
QMouseEvent * |
Event | ) |
|
|
overrideprotectedvirtual |
Removes the marker at the mouse pointer position if it is user-deletable. Affects MarkersChanged
.
Definition at line 340 of file QtUtil.cpp.
◆ mousePressEvent()
void Util::MarkerGraphicsView::mousePressEvent |
( |
QMouseEvent * |
Event | ) |
|
|
overrideprotectedvirtual |
Adds a marker to the mouse pointer position assigning the highest ID amongst all markers in the graphics view incremented by 1 as the ID.
Definition at line 317 of file QtUtil.cpp.
◆ OnContextMenuRequested
void Util::MarkerGraphicsView::OnContextMenuRequested |
( |
QPoint |
Position | ) |
|
|
privateslot |
Shows the context menu at position Position
.
Definition at line 535 of file QtUtil.cpp.
◆ OnRemoveMarkers
void Util::MarkerGraphicsView::OnRemoveMarkers |
( |
bool |
| ) |
|
|
privateslot |
Removes all user-deletable markers. Affects MarkersChanged
.
Definition at line 545 of file QtUtil.cpp.
◆ OnSaveMarkers
void Util::MarkerGraphicsView::OnSaveMarkers |
( |
bool |
| ) |
|
|
privateslot |
Asks the user for a file name and saves all markers to a CSV file.
Definition at line 550 of file QtUtil.cpp.
◆ OnShowMarkers
void Util::MarkerGraphicsView::OnShowMarkers |
( |
bool |
Checked | ) |
|
|
privateslot |
If Checked
is true, all markers are made visible, otherwise they become hidden.
Definition at line 540 of file QtUtil.cpp.
◆ RemoveMarker() [1/3]
void Util::MarkerGraphicsView::RemoveMarker |
( |
const QPoint & |
MarkerPos, |
|
|
bool |
OnlyUserDeletableMarkers = false |
|
) |
| |
Removes markers at the position MarkerPos
. Affects MarkersChanged
.
- Parameters
-
MarkerPos | Refer to MarkerType::MarkerPos. |
OnlyUserDeletableMarkers | If true, markers are also removed if they are not user-deletable. If false, non-user-deletable markers are not removed. |
Definition at line 430 of file QtUtil.cpp.
◆ RemoveMarker() [2/3]
void Util::MarkerGraphicsView::RemoveMarker |
( |
size_t |
Index, |
|
|
bool |
OnlyUserDeletableMarkers = false |
|
) |
| |
Removes the n-th marker specified by Index
. Affects MarkersChanged
.
- Parameters
-
Index | Index of the marker to remove |
OnlyUserDeletableMarkers | If true, the marker is also removed if it is not user-deletable. If false, non-user-deletable markers are not removed. |
- Exceptions
-
OutOfRangeException | is thrown if Index exceeds the amount of markers stored in the graphics view. |
Definition at line 413 of file QtUtil.cpp.
◆ RemoveMarker() [3/3]
void Util::MarkerGraphicsView::RemoveMarker |
( |
std::string_view |
Name, |
|
|
bool |
OnlyUserDeletableMarkers = false |
|
) |
| |
Removes markers with name Name
. Affects MarkersChanged
.
- Parameters
-
Name | Refer to MarkerType::Name. |
OnlyUserDeletableMarkers | If true, markers are also removed if they are not user-deletable. If false, non-user-deletable markers are not removed. |
Definition at line 447 of file QtUtil.cpp.
◆ RemoveMarkers()
void Util::MarkerGraphicsView::RemoveMarkers |
( |
bool |
OnlyUserDeletableMarkers | ) |
|
Removes all markers from the graphics view. Affects MarkersChanged
.
- Parameters
-
OnlyUserDeletableMarkers | If true, markers are also removed if they are not user-deletable. If false, non-user-deletable markers are not removed. |
Definition at line 464 of file QtUtil.cpp.
◆ RenameMarker()
void Util::MarkerGraphicsView::RenameMarker |
( |
const QPoint & |
MarkerPos, |
|
|
std::string_view |
NewName |
|
) |
| |
Assigns a name to the marker at position MarkerPos
. Affects MarkersChanged
.
- Parameters
-
Definition at line 489 of file QtUtil.cpp.
◆ SelectMarker()
void Util::MarkerGraphicsView::SelectMarker |
( |
const QPoint & |
MarkerPos | ) |
|
Selects the marker at position MarkerPos
.
- Parameters
-
Definition at line 500 of file QtUtil.cpp.
◆ SetCurrentImagePos()
void Util::MarkerGraphicsView::SetCurrentImagePos |
( |
const QPointF & |
Pos | ) |
|
|
inline |
◆ setMarkersHidden()
void Util::MarkerGraphicsView::setMarkersHidden |
( |
bool |
MarkersHidden | ) |
|
Hides or shows all markers.
- Parameters
-
MarkersHidden | If true, all markers are hidden. If false, all markers become visible. |
Definition at line 481 of file QtUtil.cpp.
◆ wheelEvent()
void Util::MarkerGraphicsView::wheelEvent |
( |
QWheelEvent * |
Event | ) |
|
|
overrideprotectedvirtual |
Zooms in or out when Control is pressed on the keyboard at the same time.
Definition at line 377 of file QtUtil.cpp.
◆ ZoomIn()
void Util::MarkerGraphicsView::ZoomIn |
( |
| ) |
|
◆ ZoomOut()
void Util::MarkerGraphicsView::ZoomOut |
( |
| ) |
|
◆ ZoomReset()
void Util::MarkerGraphicsView::ZoomReset |
( |
| ) |
|
◆ ContextMenu
QMenu* Util::MarkerGraphicsView::ContextMenu |
|
private |
◆ CurrentImagePos
QPointF Util::MarkerGraphicsView::CurrentImagePos |
|
private |
◆ DeselectedMarkerOpacity
constexpr double Util::MarkerGraphicsView::DeselectedMarkerOpacity = .5 |
|
staticconstexprprivate |
Determines the opacity of a marker which is not selected.
Definition at line 383 of file QtUtil.h.
◆ EditMarkersAction
QAction* Util::MarkerGraphicsView::EditMarkersAction |
|
private |
◆ Markers
std::vector<MarkerType> Util::MarkerGraphicsView::Markers |
|
private |
List of the markers.
Definition at line 545 of file QtUtil.h.
◆ MarkersChanged
bool Util::MarkerGraphicsView::MarkersChanged |
|
private |
Holds whether the markers have changed by any of the marker operations.
Definition at line 547 of file QtUtil.h.
◆ MarkersHidden
bool Util::MarkerGraphicsView::MarkersHidden |
|
private |
Determines whether the markers are currently displayed or not.
Definition at line 546 of file QtUtil.h.
◆ RemoveMarkersAction
QAction* Util::MarkerGraphicsView::RemoveMarkersAction |
|
private |
◆ SaveMarkersAction
QAction* Util::MarkerGraphicsView::SaveMarkersAction |
|
private |
◆ SelectedMarkerOpacity
constexpr double Util::MarkerGraphicsView::SelectedMarkerOpacity = 1 |
|
staticconstexprprivate |
Determines the opacity of a selected marker.
Definition at line 384 of file QtUtil.h.
◆ ShowMarkersAction
QAction* Util::MarkerGraphicsView::ShowMarkersAction |
|
private |
◆ ZoomFactor
constexpr double Util::MarkerGraphicsView::ZoomFactor = 1.6 |
|
staticconstexprprivate |
Determines the magnification of one zoom step.
Definition at line 382 of file QtUtil.h.
The documentation for this class was generated from the following files: