Tulip  5.7.2
Large graphs analysis and drawing
tlp::View Class Referenceabstract

#include <View.h>

+ Inheritance diagram for tlp::View:
+ Collaboration diagram for tlp::View:

Public Slots

void addRedrawTrigger (tlp::Observable *)
virtual void applySettings ()
virtual void centerView (bool graphChanged=false)
virtual bool checkOnClose ()
void clearRedrawTriggers ()
virtual void draw ()=0
void emitDrawNeededSignal ()
virtual bool getNodeOrEdgeAtViewportPos (int, int, node &, edge &) const
virtual void refresh ()
void removeRedrawTrigger (tlp::Observable *)
void setCurrentInteractor (tlp::Interactor *currentInteractor)
void setGraph (tlp::Graph *graph)
virtual void setInteractors (const std::list< tlp::Interactor * > &)
virtual void setState (const tlp::DataSet &)
virtual void setupUi ()=0
void treatEvent (const Event &) override
virtual void undoCallback ()


void drawNeeded ()
void graphSet (tlp::Graph *)
void interactorsChanged ()

Public Member Functions

 View ()
 ~View () override
std::string category () const override
virtual QGraphicsItem * centralItem () const
virtual std::list< QWidget * > configurationWidgets () const
tlp::InteractorcurrentInteractor () const
tlp::Graphgraph () const
virtual QGraphicsView * graphicsView () const =0
std::string icon () const override
const std::list< Interactor * > & interactors () const
virtual bool interactorsEnabled () const
virtual bool rebuildSceneOnShowEvent ()
virtual void resetGraphicsScene ()
void setShowContextMenu (bool show)
bool showContextMenu (const QPoint &point, const QPointF &scenePoint)
virtual QPixmap snapshot (const QSize &outputSize=QSize()) const =0
virtual tlp::DataSet state () const
void treatEvents (const std::vector< Event > &events) override
QSet< tlp::Observable * > triggers () const
- Public Member Functions inherited from tlp::Plugin
virtual std::string author () const =0
virtual std::string date () const =0
void declareDeprecatedName (const std::string &oldName)
std::string deprecatedName ()
virtual std::string group () const =0
virtual int id () const
virtual std::string info () const =0
virtual std::string major () const
virtual std::string minor () const
virtual std::string name () const =0
virtual std::string programmingLanguage () const
virtual std::string release () const =0
virtual std::string tulipMajor () const
virtual std::string tulipMinor () const
virtual std::string tulipRelease () const =0
- Public Member Functions inherited from tlp::Observable
void addListener (Observable &listener) const
void addListener (Observable *const listener) const
void addObserver (Observable &observer) const
void addObserver (Observable *const observer) const
unsigned int countListeners () const
unsigned int countObservers () const
unsigned int getReceived () const
unsigned int getSent () const
void removeListener (Observable &listener) const
void removeListener (Observable *const listener) const
void removeObserver (Observable &observer) const
void removeObserver (Observable *const observer) const

Protected Slots

void activateTooltipAndUrlManager (QWidget *)
virtual void currentInteractorChanged (tlp::Interactor *)
virtual void fillContextMenu (QMenu *, const QPointF &)
void fillContextMenu (QMenu *menu, edge e)
void fillContextMenu (QMenu *menu, node n)
virtual void graphChanged (tlp::Graph *)=0
virtual void graphDeleted (tlp::Graph *parentGraph)=0
virtual void interactorsInstalled (const std::list< tlp::Interactor * > &interactors)
void toggleInteractors (const bool activate, const std::unordered_set< const char * > &exceptions)

Protected Member Functions

DataSet getState (Graph *graph)
void saveState ()
- Protected Member Functions inherited from tlp::Observable
 Observable (const Observable &)
bool hasOnlookers () const
void observableDeleted ()
Observableoperator= (const Observable &)
void sendEvent (const Event &message)
virtual void treatEvent (const Event &message)

Additional Inherited Members

- Static Public Member Functions inherited from tlp::Observable
static void disableEventNotification ()
static void enableEventNotification ()
static tlp::node getNode (const tlp::Observable *obs)
static ObservablegetObject (tlp::node n)
static const tlp::VectorGraph & getObservableGraph ()
static unsigned int getScheduled (tlp::node n)
static void holdObservers ()
static bool isAlive (tlp::node n)
static unsigned int observersHoldCounter ()
static void unholdObservers ()
- Protected Attributes inherited from tlp::Plugin
std::string oldName

Detailed Description

View plugins provide a way to dynamically add to a Tulip plateform various ways to visualize a graph.

A view takes the following elements as inputs:

  • A graph which contains the data to be displayed.
  • A state (tlp::DataSet) which contains initialization parameters.

As an output, a View must provide a QGraphicsView instance where all drawing is done. User interaction on a View is handled by the tlp::Interactor class. Several interactors can be installed on the same view but there can be only one active interactor at the same time. In the end, the view can provide several configuration widgets used to set up additional parameters.

When a View gets created, the following methods will always be called in the following order:

  • The constructor. Basically, you don't want to do anything in this method as View instance may be created at Tulip startup when the plugin system gets initialized. Subsequent methods will be called in order for the view to build UI elements
  • View::setupUi(). Notifies the view it can now build GUI components since every part of its initial state should be valid by now. Once this method is called, any call to View::graphicsView() is expected to return a valid pointer object.
  • View::setGraph. Sets the graph that is meant to be visualized in the View's panel.
  • View::setState(). Sets initial data. This method may be used to restore a previously backed-up state retrieved from the View::state() method.
  • View::interactorsInstalled(). Notifies the view of the available interactors. Interactors objects taken from the list have already been initialized.

Once the View is initialized, none of the previously mentioned methods, except View::setGraph(), can be called again. View::setGraph method may be called again to notify the view that another graph should be displayed (this may be a sub/parent graph of the previously displayed graph or a graph coming from a totally different hierarchy)

Views are meant to be managed by an overleying system. As a consequence, a view may not decide directly when to redraw. Thus, you should never call the View::draw() method. To notify the overleying system that your view needs to be redrawn, emit the View::drawNeeded() signal instead.

A tlp::View subclass automatically inherits from the tlp::Observable interface. The tlp::View interface also automatically listn to its active graph to trigger handling trigger when this graph gets deleted. When the graph associated to a View gets deleted, the View::graphDeleted() callback is triggered.

See also
graphDeleted() for more information.

Definition at line 95 of file View.h.

Constructor & Destructor Documentation

◆ View()

tlp::View::View ( )

Default constructor.

Code of this method should almost be a no-op. Subsequent calls on other methods should allow you to setup your view.

◆ ~View()

tlp::View::~View ( )

Destructor View's GUI components (graphics view, configuration widgets) responsibility belongs to the overleying system. Thus, the View is not in charge of deleting its graphics view. View's interactors are already deleted in the top class.

Member Function Documentation

◆ activateTooltipAndUrlManager

void tlp::View::activateTooltipAndUrlManager ( QWidget *  )

activate the management of tooltips and urls through the context menu

Qwidgetthe widget to manage.

◆ addRedrawTrigger

void tlp::View::addRedrawTrigger ( tlp::Observable )

Registers a new trigger for automatic view drawing. Triggers are tlp::Observable subclasses. Once registered, the view will listen to the trigger's events and emit the drawNeeded signal each time the Observable::treatEvents() callback is run. For more information about the Observable system,.

See also
This is a convenience function. However, using triggers prevent from performign extra checks on the data structure to know if a redraw must me made or not. For more control over event handling, you will have to implement your own treatEvent/treatEvents callback.
If your tlp::View subclass overloads the treatEvents method. You must make sure to call the View::treatEvents method in order to keep the triggers system working.

◆ applySettings

virtual void tlp::View::applySettings ( )

This method applies settings changed in the configuration widgets This method may be called from the overleying system in various situations. The View is expected to apply settings in an optimized way to prevent extra redraws. By default, this method does nothing.

◆ category()

std::string tlp::View::category ( ) const

A string identifier for a plugin used for categorization purposes.

std::string the category of the plugin.

Implements tlp::Plugin.

Definition at line 123 of file View.h.

◆ centerView

virtual void tlp::View::centerView ( bool  graphChanged = false)

Reset the visualization to the center. This method is called after major changes into the data structure. At this point, the user point of view should be reset and brought back to a point where all the data can be seen.

It is expected for the view to be redrawn when calling centerView For a 3D visualization, this method could be implemented by centering the camera. For a table, this could be done by setting the scroll bar to the top position etc... By default, this method calls draw().

◆ centralItem()

virtual QGraphicsItem* tlp::View::centralItem ( ) const

defines which item is considered as the central item in the view. The central item is considered to be a background item that will be set as parent of every graphics item added by the workspace into the view. By default, this method returns nullptr, which means that no central item is defined.

Reimplemented in tlp::ViewWidget.

◆ checkOnClose

virtual bool tlp::View::checkOnClose ( )

allow to add some check when a user want to close a view.

true if the view can be closed, false if not

Definition at line 365 of file View.h.

◆ clearRedrawTriggers

void tlp::View::clearRedrawTriggers ( )

Clears the list of attached triggers This method removes all triggers associated to the View.

From the moment this method is called, no update on previous triggers will be considered. Even if this is called during an Observable::holdObservers()

◆ configurationWidgets()

virtual std::list<QWidget *> tlp::View::configurationWidgets ( ) const
a list of widgets that can be used to set up the view. Since several widgets can be retrieved, user will be able to select them from a combo box where each widget will be identified by its windowsTitle.
See also
This method must not instantiate configuration widgets on the fly.

Reimplemented in tlp::GlMainView.

◆ currentInteractor()

tlp::Interactor* tlp::View::currentInteractor ( ) const
The currently active interactor. The active interactor is the one that currently receive user inputs.
See also
This method may return a nullptr pointer if no interactor is currently active.

◆ currentInteractorChanged

virtual void tlp::View::currentInteractorChanged ( tlp::Interactor )

Callback method after setCurrentInteractor() was called. At this point, a call to View::currentInteractor() is considered valid and return the newly active interactor.

The interactor passed down to this method MAY BE a nullptr pointer ! This means that no current interactor should be set.

◆ draw

virtual void tlp::View::draw ( )
pure virtualslot

Asks the view to draw. A call to draw() means that internal data has most probably been modified and that the View should take that into account when drawing.

◆ drawNeeded

void tlp::View::drawNeeded ( )

Inform the overlying subsystem that this view needs to be drawn.

Depending on the overlying implementation, a subsequent call to draw might not be immediate.

◆ emitDrawNeededSignal

void tlp::View::emitDrawNeededSignal ( )

This function emit the signal drawNeeded.

◆ fillContextMenu [1/3]

virtual void tlp::View::fillContextMenu ( QMenu *  ,
const QPointF &   

fills the context menu with entries related to the view. This method is called whenever the context menu is displayed on the panel.

QMenuThe popup menu that will be displayed. This menu should be populated with context action related to the panel.

◆ fillContextMenu [2/3]

void tlp::View::fillContextMenu ( QMenu *  menu,
edge  e 

fills the context menu with entries related to the edge.

◆ fillContextMenu [3/3]

void tlp::View::fillContextMenu ( QMenu *  menu,
node  n 

fills the context menu with entries related to the node.

◆ getNodeOrEdgeAtViewportPos

virtual bool tlp::View::getNodeOrEdgeAtViewportPos ( int  ,
int  ,
node ,
) const

indicate which node or edge is under the (x, y) position in graphicsView()->viewport()

xthe x axis coordinate
ythe y axis coordinate
non return will give the found node
eon return will give the found edge
true if a node or edge has been found, false if not

Definition at line 377 of file View.h.

◆ getState()

DataSet tlp::View::getState ( Graph graph)

retrieve the view saved state associated to the graph

if there is no saved state for the graph, the saved state of the nearest parent graph which have a saved state will be returned or an empty DataSet if not.

◆ graph()

tlp::Graph* tlp::View::graph ( ) const
the graph displayed by the view.
This method MUST return the same graph pointer that was previously passed down to setGraph.

◆ graphChanged

virtual void tlp::View::graphChanged ( tlp::Graph )
protectedpure virtualslot

Callback method after setGraph() was called. At this point, a call to View::graph() is considered valid and return the lastly set graph.

◆ graphDeleted

virtual void tlp::View::graphDeleted ( tlp::Graph parentGraph)
protectedpure virtualslot

Called when the graph associated to the view gets deleted. This method should call setGraph to input a new graph pointer (nullptr or valid)

parentGraphThe parent of the graph that was just deleted. If there is no parent available (eg. the graph was root), parentGraph is nullptr

◆ graphicsView()

virtual QGraphicsView* tlp::View::graphicsView ( ) const
pure virtual
the View's panel as a QGraphicsView instance.
This method MUST ALWAYS return the same instance of a QGraphicsView.

Implemented in tlp::ViewWidget.

◆ graphSet

void tlp::View::graphSet ( tlp::Graph )

Emitted after the setGraph method has been called.

This signal is emitted from the non-virtual View::setGraph() method thus cannot be prevented.

◆ icon()

std::string tlp::View::icon ( ) const

The icon (preferably a thumbnail) of the plugin.

std::string the icon path

Reimplemented from tlp::Plugin.

Definition at line 126 of file View.h.

◆ interactors()

const std::list<Interactor *>& tlp::View::interactors ( ) const
The list of interactors installed on this view. The list is always the same as the one given when View::setInteractors() was called.
See also

Definition at line 153 of file View.h.

◆ interactorsEnabled()

virtual bool tlp::View::interactorsEnabled ( ) const

interactorsEnabled indicates if interactors are enabled or not

true if interactors are enabled, false instead

Definition at line 169 of file View.h.

◆ interactorsInstalled

virtual void tlp::View::interactorsInstalled ( const std::list< tlp::Interactor * > &  interactors)

Callback method after setInteractors() was called. At this point, a call to View::interactors() is considered valid.

◆ refresh

virtual void tlp::View::refresh ( )

Refresh the View's panel. Calling refresh() means that no internal data has been modified. This can happen when the view's panel gets resized, restored etc.

Definition at line 308 of file View.h.

◆ removeRedrawTrigger

void tlp::View::removeRedrawTrigger ( tlp::Observable )

Removes a trigger from the list of registered triggers. Event coming from this trigger will no longer trigger the drawNeeded signal.

See also

◆ saveState()

void tlp::View::saveState ( )

Save view state associated to the current graph.

◆ setCurrentInteractor

void tlp::View::setCurrentInteractor ( tlp::Interactor currentInteractor)

defines the active interactor that will receive user inputs.

This method will first remove the previously active interactor (if any) using Interactor::uninstall()
Calling this will trigger the View::currentInteractorChanged() callback for custom handling.
Calling View::setCurrentInteractor(nullptr) will only remove the previous current interactor.

◆ setGraph

void tlp::View::setGraph ( tlp::Graph graph)

Defines the graph that should be displayed by the View.

Calling setGraph triggers the View::graphChanged() callback for custom handling.
This method and its subsequent callback might be called several times.

◆ setInteractors

virtual void tlp::View::setInteractors ( const std::list< tlp::Interactor * > &  )

defines the list of interactors available on this View

Calling this will trigger the View::interactorsInstalled() callback for custom handling.

◆ setShowContextMenu()

void tlp::View::setShowContextMenu ( bool  show)

This method allows to control the display of the context menu.

showa bool indicating if the context menu must be displayed or not.

Definition at line 234 of file View.h.

◆ setState

virtual void tlp::View::setState ( const tlp::DataSet )

Restores the state of the view. DataSet passed down to this method can come from a previous backup or be generated by the overlaying system. It's up to the view to use this data or not.

Reimplemented in tlp::GlMainView.

◆ setupUi

virtual void tlp::View::setupUi ( )
pure virtualslot

Sets up GUI elements belonging to the View. This method is called once the initial state as been set (using setGraph and setState) and is called only once.

◆ showContextMenu()

bool tlp::View::showContextMenu ( const QPoint &  point,
const QPointF &  scenePoint 

This method is called whenever the context menu is required on the view.

pointThe screen coordinates where the context menu should be displayed.
true or false whether the context menu has been shown or not

◆ snapshot()

virtual QPixmap tlp::View::snapshot ( const QSize &  outputSize = QSize()) const
pure virtual

Takes a snapshot of the view's screen and saves it into the given pixmap. The snapshot is scaled to outputSize. If a null size is given, the snapshot is to be on a 1:1 ratio.

A non-null pixmap of the snapshot was correctly taken.

Implemented in tlp::ViewWidget, and tlp::GlMainView.

◆ state()

virtual tlp::DataSet tlp::View::state ( ) const

Backup the state of the view. This method is used to restore the View's parameters when it's re-opened.

Reimplemented in tlp::GlMainView.

◆ toggleInteractors

void tlp::View::toggleInteractors ( const bool  activate,
const std::unordered_set< const char * > &  exceptions 

Activate or deactivate interactors in the view.

activateset to true (resp. false) to enable (resp. disable) interactors
exceptionsa set of interactor names whose bevahior has to be left unchanged

◆ treatEvent

void tlp::View::treatEvent ( const Event )

This method is inherited from tlp::Observable and allows the view to trigger custom callback when its associated graph gets deleted.

When overriding this method. You MUST always make a call to View::treatEvent before doing anything in order to keep this callback working.

◆ treatEvents()

void tlp::View::treatEvents ( const std::vector< Event > &  events)

reimplemented from tlp::Observable to provide the triggers mechanism.

See also

Reimplemented from tlp::Observable.

◆ triggers()

QSet<tlp::Observable *> tlp::View::triggers ( ) const
The list of currently registered triggers.
See also

◆ undoCallback

virtual void tlp::View::undoCallback ( )

This method is a callback to notify the panel that the pop() method (undo) has just been called on the graph. By default, this method will make a call to centerView()