VTK  9.0.1
vtkGraphItem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: TestDiagram.cxx
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
28 #ifndef vtkGraphItem_h
29 #define vtkGraphItem_h
30 
31 #include "vtkContextItem.h"
32 #include "vtkViewsInfovisModule.h" // For export macro
33 
34 #include "vtkColor.h" // For color types in API
35 #include "vtkNew.h" // For vtkNew ivars
36 #include "vtkVector.h" // For vector types in API
37 
38 class vtkGraph;
39 class vtkImageData;
42 class vtkTooltipItem;
43 
44 class VTKVIEWSINFOVIS_EXPORT vtkGraphItem : public vtkContextItem
45 {
46 public:
47  static vtkGraphItem* New();
48  vtkTypeMacro(vtkGraphItem, vtkContextItem);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
52 
55  virtual void SetGraph(vtkGraph* graph);
56  vtkGetObjectMacro(Graph, vtkGraph);
58 
63 
65 
69  virtual void StopLayoutAnimation();
71 
75  virtual void UpdateLayout();
76 
77 protected:
79  ~vtkGraphItem() override;
80 
85  bool Paint(vtkContext2D* painter) override;
86 
92  virtual void RebuildBuffers();
93 
98  virtual void PaintBuffers(vtkContext2D* painter);
99 
108  virtual bool IsDirty();
109 
115 
121 
129 
134  virtual float EdgeWidth(vtkIdType edge, vtkIdType point);
135 
142 
150 
156  virtual float VertexSize(vtkIdType vertex);
157 
163 
170  virtual int VertexMarker(vtkIdType vertex);
171 
178 
184 
188  static void ProcessEvents(
189  vtkObject* caller, unsigned long event, void* clientData, void* callerData);
190 
194  virtual vtkIdType HitVertex(const vtkVector2f& pos);
195 
197 
200  bool MouseMoveEvent(const vtkContextMouseEvent& event) override;
201  bool MouseLeaveEvent(const vtkContextMouseEvent& event) override;
202  bool MouseEnterEvent(const vtkContextMouseEvent& event) override;
203  bool MouseButtonPressEvent(const vtkContextMouseEvent& event) override;
204  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& event) override;
205  bool MouseWheelEvent(const vtkContextMouseEvent& event, int delta) override;
207 
211  bool Hit(const vtkContextMouseEvent& event) override;
212 
216  virtual void PlaceTooltip(vtkIdType v);
217 
218 private:
219  vtkGraphItem(const vtkGraphItem&) = delete;
220  void operator=(const vtkGraphItem&) = delete;
221 
222  struct Internals;
223  Internals* Internal;
224 
225  vtkGraph* Graph;
226  vtkMTimeType GraphBuildTime;
227  vtkNew<vtkImageData> Sprite;
229  vtkNew<vtkTooltipItem> Tooltip;
230 };
231 
232 #endif
vtkGraphItem::New
static vtkGraphItem * New()
vtkGraphItem::VertexPosition
virtual vtkVector2f VertexPosition(vtkIdType vertex)
Returns the position of each vertex.
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:35
vtkGraphItem::StopLayoutAnimation
virtual void StopLayoutAnimation()
vtkGraphItem::MouseButtonPressEvent
bool MouseButtonPressEvent(const vtkContextMouseEvent &event) override
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
vtkGraphItem::VertexColor
virtual vtkColor4ub VertexColor(vtkIdType vertex)
Returns the color of each vertex.
vtkIncrementalForceLayout
incremental force-directed layout.
Definition: vtkIncrementalForceLayout.h:40
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkGraphItem::MouseMoveEvent
bool MouseMoveEvent(const vtkContextMouseEvent &event) override
Handle mouse events.
vtkGraphItem::vtkGraphItem
vtkGraphItem()
vtkGraphItem::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGraphItem::MouseButtonReleaseEvent
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &event) override
Mouse button release event.
vtkGraphItem::EdgeWidth
virtual float EdgeWidth(vtkIdType edge, vtkIdType point)
Returns the edge width.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
vtkVector.h
vtkTooltipItem
takes care of drawing 2D axes
Definition: vtkTooltipItem.h:40
vtkGraphItem::EdgeColor
virtual vtkColor4ub EdgeColor(vtkIdType edge, vtkIdType point)
Returns the edge color.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:53
vtkGraphItem::GetLayout
virtual vtkIncrementalForceLayout * GetLayout()
Exposes the incremental graph layout for updating parameters.
vtkContextItem.h
vtkGraphItem::EdgePosition
virtual vtkVector2f EdgePosition(vtkIdType edge, vtkIdType point)
Returns the edge control point positions.
vtkGraphItem::NumberOfEdgePoints
virtual vtkIdType NumberOfEdgePoints(vtkIdType edge)
Returns the number of edge control points for a particular edge.
vtkGraphItem::PaintBuffers
virtual void PaintBuffers(vtkContext2D *painter)
Efficiently draws the contents of the buffers built in RebuildBuffers.
vtkGraphItem::VertexTooltip
virtual vtkStdString VertexTooltip(vtkIdType vertex)
Returns the tooltip for each vertex.
vtkGraphItem::NumberOfVertices
virtual vtkIdType NumberOfVertices()
Returns the number of vertices in the graph.
vtkX3D::point
@ point
Definition: vtkX3D.h:242
vtkGraphItem::StartLayoutAnimation
virtual void StartLayoutAnimation(vtkRenderWindowInteractor *interactor)
Begins or ends the layout animation.
vtkGraphItem::PlaceTooltip
virtual void PlaceTooltip(vtkIdType v)
Change the position of the tooltip based on the vertex hovered.
vtkGraphItem::ProcessEvents
static void ProcessEvents(vtkObject *caller, unsigned long event, void *clientData, void *callerData)
Process events and dispatch to the appropriate member functions.
vtkGraphItem::Paint
bool Paint(vtkContext2D *painter) override
Paints the graph.
vtkColor.h
vtkGraphItem::HitVertex
virtual vtkIdType HitVertex(const vtkVector2f &pos)
Return index of hit vertex, or -1 if no hit.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkGraphItem::SetGraph
virtual void SetGraph(vtkGraph *graph)
The graph that this item draws.
vtkNew< vtkImageData >
vtkGraphItem::NumberOfEdges
virtual vtkIdType NumberOfEdges()
Returns the number of edges in the graph.
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:74
vtkGraphItem::RebuildBuffers
virtual void RebuildBuffers()
Builds a cache of data from the graph by calling the virtual functions such as VertexColor(),...
vtkGraphItem::~vtkGraphItem
~vtkGraphItem() override
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:32
vtkGraphItem::UpdateLayout
virtual void UpdateLayout()
Incrementally updates the graph layout.
vtkGraphItem::MouseWheelEvent
bool MouseWheelEvent(const vtkContextMouseEvent &event, int delta) override
Mouse wheel event, positive delta indicates forward movement of the wheel.
vtkNew.h
vtkGraphItem::MouseEnterEvent
bool MouseEnterEvent(const vtkContextMouseEvent &event) override
Mouse enter event.
vtkGraphItem::VertexSize
virtual float VertexSize(vtkIdType vertex)
Returns the vertex size in pixels, which is remains the same at any zoom level.
vtkGraphItem::VertexMarker
virtual int VertexMarker(vtkIdType vertex)
Returns the marker type for each vertex, as defined in vtkMarkerUtilities.
vtkColor4ub
Definition: vtkColor.h:265
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:35
vtkGraph
Base class for graph data types.
Definition: vtkGraph.h:290
vtkGraphItem::Hit
bool Hit(const vtkContextMouseEvent &event) override
Whether this graph item is hit.
vtkVector2f
Definition: vtkVector.h:433
vtkGraphItem
A 2D graphics item for rendering a graph.
Definition: vtkGraphItem.h:45
vtkGraphItem::MouseLeaveEvent
bool MouseLeaveEvent(const vtkContextMouseEvent &event) override
Mouse leave event.
vtkGraphItem::IsDirty
virtual bool IsDirty()
Returns true if the underlying vtkGraph has been modified since the last RebuildBuffers,...
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293