graph_analysis
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
graph_analysis::gui::GraphWidget Class Reference

Base-class for visual representations of a "Graph" in this framework. More...

#include <GraphWidget.hpp>

Inheritance diagram for graph_analysis::gui::GraphWidget:
Inheritance graph
[legend]
Collaboration diagram for graph_analysis::gui::GraphWidget:
Collaboration graph
[legend]

Public Types

typedef std::map< const graph_analysis::Edge::Ptr, EdgeItemBase * > EdgeItemMap
 
typedef std::map< const graph_analysis::Vertex::Ptr, VertexItemBase * > VertexItemMap
 
typedef std::map< const graph_analysis::Vertex::Ptr, QPointF > VertexItemCoordinateCache
 

Public Slots

virtual void shuffle ()
 
virtual void refresh (bool all=true)
 
virtual void updateVisualization ()
 
void setVertexVisible (int id, bool show)
 
void setEdgeVisible (int id, bool show)
 
void activateViewportMargins (int areaFlag)
 
void setTopMarginHeight (int width)
 
void setBottomMarginHeight (int width)
 
void setLeftMarginWidth (int width)
 
void setRightMarginWidth (int width)
 

Signals

void currentStatus (QString, int)
 

Public Member Functions

 GraphWidget (const graph_analysis::BaseGraph::Ptr &graph, QWidget *parent=NULL)
 
virtual ~GraphWidget ()
 
virtual QString getClassName () const
 
void registerEdgeItem (const graph_analysis::Edge::Ptr &e, EdgeItemBase *i)
 
void registerVertexItem (const graph_analysis::Vertex::Ptr &v, VertexItemBase *i)
 
void deregisterEdgeItem (const graph_analysis::Edge::Ptr &e, EdgeItemBase *i)
 
void deregisterVertexItem (const graph_analysis::Vertex::Ptr &v, VertexItemBase *i)
 
QVector< QPointF > getEdgePoints (VertexItemBase *firstItem, VertexItemBase *secondItem) const
 
void vertexPositionHasChanged (VertexItemBase *item)
 
void cacheVertexItemPosition (const graph_analysis::Vertex::Ptr v, QPointF p)
 
virtual void updateEdgePositions (VertexItemBase *item)
 
graph_analysis::BaseGraph::Ptr graph () const
 getter method for retrieving the underlying base graph More...
 
virtual void setGraph (const graph_analysis::BaseGraph::Ptr &graph)
 setter method for updating the underlying base graph More...
 
virtual void update ()
 
VertexItemCoordinateCache getCurrentLayout () const
 
void cacheCurrentLayout ()
 
void applyCachedLayout ()
 
VertexItemCoordinateCache applyLayout (const VertexItemCoordinateCache &coordinates)
 
virtual void populateCanvas ()
 
void setFocusedElement (const GraphElement::Ptr &element)
 
GraphElement::Ptr getFocusedElement () const
 
void clearFocus ()
 
bool isFocused (const GraphElement::Ptr &element) const
 
virtual void clearVisualization ()
 
virtual void updateStatus (const std::string &msg, int timeInMS=10)
 
void play (const PlayerConfiguration &conf)
 
void saveScene ()
 

Protected Member Functions

void wheelEvent (QWheelEvent *event)
 qt mouse wheel spin callback More...
 
void scaleView (qreal scaleFactor)
 scales scene (zooms into or out of the scene) More...
 
void keyPressEvent (QKeyEvent *)
 
void mousePressEvent (QMouseEvent *)
 
void mouseReleaseEvent (QMouseEvent *)
 
void mouseDoubleClickEvent (QMouseEvent *event)
 
qreal horizonalScalingFactor () const
 
qreal verticalScalingFactor () const
 
virtual void resizeEvent (QResizeEvent *event)
 

Protected Attributes

QGraphicsScene * mpScene
 
graph_analysis::BaseGraph::Ptr mpGraph
 shared pointer of the conceptual, underlying graph More...
 
graph_analysis::GraphElement::Ptr mpFocusedElement
 
int mWithViewportMargins
 
int mLeftMarginWidth
 
int mRightMarginWidth
 
int mTopMarginHeight
 
int mBottomMarginHeight
 
QWidget * mpLeftMarginArea
 
QWidget * mpRightMarginArea
 
QWidget * mpTopMarginArea
 
QWidget * mpBottomMarginArea
 
EdgeItemMap mEdgeItemMap
 
VertexItemMap mVertexItemMap
 
VertexItemCoordinateCache mItemCoordinateCache
 

Friends

class Player
 

Detailed Description

Base-class for visual representations of a "Graph" in this framework.

A Qt-Widget using a qgraphicsview as a canvas. this class does not draw anything yet, but provides the infrastructure for handling with a graph. is intended to obtain a shared pointer to a graph which is stored elsewhere. this allows multiple independent visualizations of the same basegraph.

Member Typedef Documentation

◆ EdgeItemMap

a mapping from an "Edge" in the graph to a responsible visualizing "Item" on the scene.

◆ VertexItemCoordinateCache

this is used to store where a Vertex element had its responsible VertexItem positioned on the scene. can be queried after a "clearVisualization()" to reposition newly created items in the same canvas location as before.

cannot store the pointer to a VertexItem directly as this pointer will change after repopulation of the canvas.

◆ VertexItemMap

a mapping from an "Vertex" in the graph to a responsible visualizing "Item" on the scene.

Constructor & Destructor Documentation

◆ GraphWidget()

graph_analysis::gui::GraphWidget::GraphWidget ( const graph_analysis::BaseGraph::Ptr &  graph,
QWidget *  parent = NULL 
)

constructor

◆ ~GraphWidget()

graph_analysis::gui::GraphWidget::~GraphWidget ( )
virtual

destructor

Member Function Documentation

◆ activateViewportMargins

void graph_analysis::gui::GraphWidget::activateViewportMargins ( int  areaFlag)
slot

◆ applyCachedLayout()

void graph_analysis::gui::GraphWidget::applyCachedLayout ( )

◆ applyLayout()

GraphWidget::VertexItemCoordinateCache graph_analysis::gui::GraphWidget::applyLayout ( const VertexItemCoordinateCache &  coordinates)

Apply the given layout (via coordinates)

Returns
the actually applied layout, i.e. which does not contain already removed vertices

◆ cacheCurrentLayout()

void graph_analysis::gui::GraphWidget::cacheCurrentLayout ( )

Cache the current view

◆ cacheVertexItemPosition()

void graph_analysis::gui::GraphWidget::cacheVertexItemPosition ( const graph_analysis::Vertex::Ptr  v,
QPointF  p 
)

when a vertex changed its position, it can be stored

allows restoring the layout after automatic re-population using.

◆ clearFocus()

void graph_analysis::gui::GraphWidget::clearFocus ( )

◆ clearVisualization()

void graph_analysis::gui::GraphWidget::clearVisualization ( )
virtual

Clear visualization and scene not(!) the underlying graph

◆ currentStatus

void graph_analysis::gui::GraphWidget::currentStatus ( QString  ,
int   
)
signal

◆ deregisterEdgeItem()

void graph_analysis::gui::GraphWidget::deregisterEdgeItem ( const graph_analysis::Edge::Ptr &  e,
EdgeItemBase *  i 
)

to be called after an existing "EdgeItem" is removed from the canvas

◆ deregisterVertexItem()

void graph_analysis::gui::GraphWidget::deregisterVertexItem ( const graph_analysis::Vertex::Ptr &  v,
VertexItemBase *  i 
)

to be called after an existing "VertexItem" is removed from the canvas

◆ getClassName()

virtual QString graph_analysis::gui::GraphWidget::getClassName ( ) const
inlinevirtual

◆ getCurrentLayout()

GraphWidget::VertexItemCoordinateCache graph_analysis::gui::GraphWidget::getCurrentLayout ( ) const

Current layout in item coordinates

◆ getEdgePoints()

QVector< QPointF > graph_analysis::gui::GraphWidget::getEdgePoints ( VertexItemBase *  firstItem,
VertexItemBase *  secondItem 
) const

takes the "connector" and the "boundingRect" of both items and tries to create a line between the intersection point of the connecting line and the boundingRects

used to establish sensible coordinated to re-draw edges after their vertices changed position

◆ getFocusedElement()

GraphElement::Ptr graph_analysis::gui::GraphWidget::getFocusedElement ( ) const
inline

◆ graph()

graph_analysis::BaseGraph::Ptr graph_analysis::gui::GraphWidget::graph ( ) const

getter method for retrieving the underlying base graph

◆ horizonalScalingFactor()

qreal graph_analysis::gui::GraphWidget::horizonalScalingFactor ( ) const
inlineprotected

Compute the horizontal scaling factor, typically same as the vertical scaling factor for this widget

◆ isFocused()

bool graph_analysis::gui::GraphWidget::isFocused ( const GraphElement::Ptr &  element) const
inline

◆ keyPressEvent()

void graph_analysis::gui::GraphWidget::keyPressEvent ( QKeyEvent *  event)
protected

◆ mouseDoubleClickEvent()

void graph_analysis::gui::GraphWidget::mouseDoubleClickEvent ( QMouseEvent *  event)
protected

◆ mousePressEvent()

void graph_analysis::gui::GraphWidget::mousePressEvent ( QMouseEvent *  event)
protected

◆ mouseReleaseEvent()

void graph_analysis::gui::GraphWidget::mouseReleaseEvent ( QMouseEvent *  event)
protected

◆ play()

void graph_analysis::gui::GraphWidget::play ( const PlayerConfiguration &  conf)

Play the incremental build up / or deconstruction of a graph

Parameters
confPlayerConfiguration

◆ populateCanvas()

virtual void graph_analysis::gui::GraphWidget::populateCanvas ( )
inlinevirtual

trigger the creation of individual QGraphicsItems based on the referenced BaseGraph for this instance of a graph widget.

Reimplemented in graph_analysis::gui::BaseGraphView.

◆ refresh

void graph_analysis::gui::GraphWidget::refresh ( bool  all = true)
virtualslot

◆ registerEdgeItem()

void graph_analysis::gui::GraphWidget::registerEdgeItem ( const graph_analysis::Edge::Ptr &  e,
EdgeItemBase *  i 
)

to be called after a new "EdgeItem" is added to the canvas

◆ registerVertexItem()

void graph_analysis::gui::GraphWidget::registerVertexItem ( const graph_analysis::Vertex::Ptr &  v,
VertexItemBase *  i 
)

to be called after a new "VertexItem" is added to the canvas

◆ resizeEvent()

void graph_analysis::gui::GraphWidget::resizeEvent ( QResizeEvent *  event)
protectedvirtual

Allow to compute the margins if needed

◆ saveScene()

void graph_analysis::gui::GraphWidget::saveScene ( )

Call a dialog to save the current scene

◆ scaleView()

void graph_analysis::gui::GraphWidget::scaleView ( qreal  scaleFactor)
protected

scales scene (zooms into or out of the scene)

◆ setBottomMarginHeight

void graph_analysis::gui::GraphWidget::setBottomMarginHeight ( int  width)
slot

◆ setEdgeVisible

void graph_analysis::gui::GraphWidget::setEdgeVisible ( int  id,
bool  show 
)
slot

◆ setFocusedElement()

void graph_analysis::gui::GraphWidget::setFocusedElement ( const GraphElement::Ptr &  element)

infrastructure for showing information about the currently hovered edge/vertex in the statusbar

◆ setGraph()

void graph_analysis::gui::GraphWidget::setGraph ( const graph_analysis::BaseGraph::Ptr &  graph)
virtual

setter method for updating the underlying base graph

◆ setLeftMarginWidth

void graph_analysis::gui::GraphWidget::setLeftMarginWidth ( int  width)
slot

◆ setRightMarginWidth

void graph_analysis::gui::GraphWidget::setRightMarginWidth ( int  width)
slot

◆ setTopMarginHeight

void graph_analysis::gui::GraphWidget::setTopMarginHeight ( int  width)
slot

◆ setVertexVisible

void graph_analysis::gui::GraphWidget::setVertexVisible ( int  id,
bool  show 
)
slot

◆ shuffle

void graph_analysis::gui::GraphWidget::shuffle ( )
virtualslot

◆ update()

void graph_analysis::gui::GraphWidget::update ( )
virtual

Update the current view

◆ updateEdgePositions()

void graph_analysis::gui::GraphWidget::updateEdgePositions ( VertexItemBase *  item)
virtual

update all edges associated with the given vertex after a position change

the default implementation tries to draw a line between the intersection points of the "connectors" and the "boundingRect" of each item of the edge.

◆ updateStatus()

void graph_analysis::gui::GraphWidget::updateStatus ( const std::string &  msg,
int  timeInMS = 10 
)
virtual

Display a message status in the status bar

Parameters
msgMessage in the statusbar
timeInMSTime in milliseconds

◆ updateVisualization

void graph_analysis::gui::GraphWidget::updateVisualization ( )
virtualslot

◆ vertexPositionHasChanged()

void graph_analysis::gui::GraphWidget::vertexPositionHasChanged ( VertexItemBase *  item)

to be called by a VertexItem when its position on the canvas changed.

◆ verticalScalingFactor()

qreal graph_analysis::gui::GraphWidget::verticalScalingFactor ( ) const
inlineprotected

Compute the vertical scaling factor, typically same as the horizontal scaling factor for this widget

◆ wheelEvent()

void graph_analysis::gui::GraphWidget::wheelEvent ( QWheelEvent *  event)
protected

qt mouse wheel spin callback

Friends And Related Function Documentation

◆ Player

friend class Player
friend

Member Data Documentation

◆ mBottomMarginHeight

int graph_analysis::gui::GraphWidget::mBottomMarginHeight
protected

◆ mEdgeItemMap

EdgeItemMap graph_analysis::gui::GraphWidget::mEdgeItemMap
protected

◆ mItemCoordinateCache

VertexItemCoordinateCache graph_analysis::gui::GraphWidget::mItemCoordinateCache
protected

◆ mLeftMarginWidth

int graph_analysis::gui::GraphWidget::mLeftMarginWidth
protected

◆ mpBottomMarginArea

QWidget* graph_analysis::gui::GraphWidget::mpBottomMarginArea
protected

◆ mpFocusedElement

graph_analysis::GraphElement::Ptr graph_analysis::gui::GraphWidget::mpFocusedElement
protected

this is (was?) used to display the name of the last focused element in the status bar.

◆ mpGraph

graph_analysis::BaseGraph::Ptr graph_analysis::gui::GraphWidget::mpGraph
protected

shared pointer of the conceptual, underlying graph

◆ mpLeftMarginArea

QWidget* graph_analysis::gui::GraphWidget::mpLeftMarginArea
protected

◆ mpRightMarginArea

QWidget* graph_analysis::gui::GraphWidget::mpRightMarginArea
protected

◆ mpScene

QGraphicsScene* graph_analysis::gui::GraphWidget::mpScene
protected

◆ mpTopMarginArea

QWidget* graph_analysis::gui::GraphWidget::mpTopMarginArea
protected

◆ mRightMarginWidth

int graph_analysis::gui::GraphWidget::mRightMarginWidth
protected

◆ mTopMarginHeight

int graph_analysis::gui::GraphWidget::mTopMarginHeight
protected

◆ mVertexItemMap

VertexItemMap graph_analysis::gui::GraphWidget::mVertexItemMap
protected

◆ mWithViewportMargins

int graph_analysis::gui::GraphWidget::mWithViewportMargins
protected

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