OpenWalnut  1.5.0dev
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
WQtNetworkEditorView Class Reference

This class extends the basic functionality of QGraphicsView to allow comfortable panning and zooming. More...

#include <WQtNetworkEditorView.h>

+ Inheritance diagram for WQtNetworkEditorView:
+ Collaboration diagram for WQtNetworkEditorView:

Signals

void loadAction ()
 Emitted whenever the user caused a load event. More...
 
void dragDrop (QDropEvent *event)
 Emitted whenever the user drops something into the widget. More...
 

Public Member Functions

 WQtNetworkEditorView (QWidget *parent=NULL)
 Constructs empty view. More...
 
void focusOn (QGraphicsItem *item)
 The Item to focus on. More...
 
void ensureVisibleSmooth (QGraphicsItem *item, int xmargin=50, int ymargin=50)
 Improved version of QGraphicsView::ensureVisible for smooth scrolling. More...
 
void setGlobalAddMenu (QMenu *menu)
 Set the given menu as new global add-modules menu. More...
 

Protected Member Functions

virtual void mouseDoubleClickEvent (QMouseEvent *event)
 Double clicked into the view. More...
 
virtual void mousePressEvent (QMouseEvent *event)
 Mouse button pressed. More...
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 Mouse button released. More...
 
virtual void mouseMoveEvent (QMouseEvent *event)
 Mouse moved. More...
 
virtual void wheelEvent (QWheelEvent *event)
 Mouse wheel used. More...
 
virtual void resizeEvent (QResizeEvent *event)
 View resized. More...
 
void keyPressEvent (QKeyEvent *event)
 Key pressed. More...
 
void leaveEvent (QEvent *event)
 Mouse leaves the widget. More...
 
virtual void dropEvent (QDropEvent *event)
 Handles the drop event for a tree item. More...
 
void moveBy (const QPointF &delta)
 Move scene in the view by delta units. More...
 
void moveTo (const QPointF &target)
 Move scrollarea to absolute position. More...
 

Private Slots

void autoPanTick (qreal value)
 Called every tick of the auto pan timer. More...
 

Private Attributes

QPoint m_lastPanPoint
 To keep track of mouse movement, cache last known mouse event point. More...
 
bool m_panning
 If true, we are in pan mode. More...
 
QMenum_addMenu
 The menu containing the add actions in m_addModuleActionList. More...
 
QPoint m_autoPanTarget
 Auto-pan vector. More...
 
QPoint m_autoPanOrig
 Origin of auto-pan movement for proper interpolation. More...
 
QTimeLine * m_autoPanTimer
 Auto-pan timer. More...
 

Detailed Description

This class extends the basic functionality of QGraphicsView to allow comfortable panning and zooming.

Definition at line 36 of file WQtNetworkEditorView.h.

Constructor & Destructor Documentation

◆ WQtNetworkEditorView()

WQtNetworkEditorView::WQtNetworkEditorView ( QWidget *  parent = NULL)
explicit

Constructs empty view.

Parameters
parentparent widgets containing the view

Definition at line 40 of file WQtNetworkEditorView.cpp.

References autoPanTick(), m_addMenu, m_autoPanTimer, and m_panning.

+ Here is the call graph for this function:

Member Function Documentation

◆ autoPanTick

void WQtNetworkEditorView::autoPanTick ( qreal  value)
privateslot

Called every tick of the auto pan timer.

Parameters
value

Definition at line 109 of file WQtNetworkEditorView.cpp.

References m_autoPanOrig, m_autoPanTarget, and moveTo().

Referenced by WQtNetworkEditorView().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dragDrop

void WQtNetworkEditorView::dragDrop ( QDropEvent *  event)
signal

Emitted whenever the user drops something into the widget.

Parameters
eventevent containing further info on the dropped item.

Referenced by dropEvent().

+ Here is the caller graph for this function:

◆ dropEvent()

void WQtNetworkEditorView::dropEvent ( QDropEvent *  event)
protectedvirtual

Handles the drop event for a tree item.

Parameters
eventthe event.

Definition at line 275 of file WQtNetworkEditorView.cpp.

References dragDrop().

◆ ensureVisibleSmooth()

void WQtNetworkEditorView::ensureVisibleSmooth ( QGraphicsItem item,
int  xmargin = 50,
int  ymargin = 50 
)

Improved version of QGraphicsView::ensureVisible for smooth scrolling.

Parameters
itemthe item to make visible.
xmarginthe margin to ensure between item border and visible scene border (x direction)
ymarginthe margin to ensure between item border and visible scene border (y direction)

Definition at line 69 of file WQtNetworkEditorView.cpp.

References m_autoPanOrig, m_autoPanTarget, and m_autoPanTimer.

Referenced by focusOn(), and WQtNetworkItem::mouseReleaseEvent().

+ Here is the caller graph for this function:

◆ focusOn()

void WQtNetworkEditorView::focusOn ( QGraphicsItem item)

The Item to focus on.

Use this instead of QGraphicsView::ensureVisible.

Parameters
itemthe item.

Definition at line 63 of file WQtNetworkEditorView.cpp.

References ensureVisibleSmooth().

Referenced by WQtNetworkEditor::event(), and WQtNetworkItem::moveFinished().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ keyPressEvent()

void WQtNetworkEditorView::keyPressEvent ( QKeyEvent *  event)
protected

Key pressed.

Parameters
eventcontains event information.

Definition at line 258 of file WQtNetworkEditorView.cpp.

◆ leaveEvent()

void WQtNetworkEditorView::leaveEvent ( QEvent event)
protected

Mouse leaves the widget.

Parameters
eventthe event

Definition at line 128 of file WQtNetworkEditorView.cpp.

References m_lastPanPoint.

◆ loadAction

void WQtNetworkEditorView::loadAction ( )
signal

Emitted whenever the user caused a load event.

Referenced by mouseDoubleClickEvent().

+ Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void WQtNetworkEditorView::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual

Double clicked into the view.

Parameters
eventcontains event information.

Definition at line 141 of file WQtNetworkEditorView.cpp.

References loadAction(), and m_addMenu.

◆ mouseMoveEvent()

void WQtNetworkEditorView::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

Mouse moved.

Parameters
eventcontains event information.

Definition at line 211 of file WQtNetworkEditorView.cpp.

References m_lastPanPoint, m_panning, and moveBy().

+ Here is the call graph for this function:

◆ mousePressEvent()

void WQtNetworkEditorView::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

Mouse button pressed.

Parameters
eventcontains event information.

Definition at line 167 of file WQtNetworkEditorView.cpp.

References m_lastPanPoint, and m_panning.

◆ mouseReleaseEvent()

void WQtNetworkEditorView::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

Mouse button released.

Parameters
eventcontains event information.

Definition at line 193 of file WQtNetworkEditorView.cpp.

References m_addMenu, m_lastPanPoint, and m_panning.

◆ moveBy()

void WQtNetworkEditorView::moveBy ( const QPointF &  delta)
protected

Move scene in the view by delta units.

Parameters
deltamove vector.

Definition at line 114 of file WQtNetworkEditorView.cpp.

Referenced by mouseMoveEvent().

+ Here is the caller graph for this function:

◆ moveTo()

void WQtNetworkEditorView::moveTo ( const QPointF &  target)
protected

Move scrollarea to absolute position.

Parameters
targetthe new scroll position

Definition at line 122 of file WQtNetworkEditorView.cpp.

Referenced by autoPanTick().

+ Here is the caller graph for this function:

◆ resizeEvent()

void WQtNetworkEditorView::resizeEvent ( QResizeEvent *  event)
protectedvirtual

View resized.

This automatically updates the virtual center for zooming after resize

Parameters
eventcontains event information.

Definition at line 252 of file WQtNetworkEditorView.cpp.

◆ setGlobalAddMenu()

void WQtNetworkEditorView::setGlobalAddMenu ( QMenu menu)

Set the given menu as new global add-modules menu.

Can be NULL to disable.

Parameters
menuthe menu to set.

Definition at line 58 of file WQtNetworkEditorView.cpp.

References m_addMenu.

Referenced by WQtControlPanel::createCompatibleButtons().

+ Here is the caller graph for this function:

◆ wheelEvent()

void WQtNetworkEditorView::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Mouse wheel used.

Parameters
eventcontains event information.

Definition at line 230 of file WQtNetworkEditorView.cpp.

Member Data Documentation

◆ m_addMenu

QMenu* WQtNetworkEditorView::m_addMenu
private

The menu containing the add actions in m_addModuleActionList.

Definition at line 174 of file WQtNetworkEditorView.h.

Referenced by mouseDoubleClickEvent(), mouseReleaseEvent(), setGlobalAddMenu(), and WQtNetworkEditorView().

◆ m_autoPanOrig

QPoint WQtNetworkEditorView::m_autoPanOrig
private

Origin of auto-pan movement for proper interpolation.

Definition at line 184 of file WQtNetworkEditorView.h.

Referenced by autoPanTick(), and ensureVisibleSmooth().

◆ m_autoPanTarget

QPoint WQtNetworkEditorView::m_autoPanTarget
private

Auto-pan vector.

Definition at line 179 of file WQtNetworkEditorView.h.

Referenced by autoPanTick(), and ensureVisibleSmooth().

◆ m_autoPanTimer

QTimeLine* WQtNetworkEditorView::m_autoPanTimer
private

Auto-pan timer.

Definition at line 189 of file WQtNetworkEditorView.h.

Referenced by ensureVisibleSmooth(), and WQtNetworkEditorView().

◆ m_lastPanPoint

QPoint WQtNetworkEditorView::m_lastPanPoint
private

To keep track of mouse movement, cache last known mouse event point.

Definition at line 164 of file WQtNetworkEditorView.h.

Referenced by leaveEvent(), mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ m_panning

bool WQtNetworkEditorView::m_panning
private

If true, we are in pan mode.

Definition at line 169 of file WQtNetworkEditorView.h.

Referenced by mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and WQtNetworkEditorView().


The documentation for this class was generated from the following files: