VTK
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 =========================================================================*/
34 #ifndef vtkGraphItem_h
35 #define vtkGraphItem_h
36 
37 #include "vtkViewsInfovisModule.h" // For export macro
38 #include "vtkContextItem.h"
39 
40 #include "vtkVector.h" // For vector types in API
41 #include "vtkColor.h" // For color types in API
42 #include "vtkNew.h" // For vtkNew ivars
43 
44 class vtkGraph;
45 class vtkImageData;
48 class vtkTooltipItem;
49 
50 class VTKVIEWSINFOVIS_EXPORT vtkGraphItem : public vtkContextItem
51 {
52 public:
53  static vtkGraphItem *New();
54  vtkTypeMacro(vtkGraphItem, vtkContextItem);
55  void PrintSelf(ostream &os, vtkIndent indent) override;
56 
58 
61  virtual void SetGraph(vtkGraph *graph);
62  vtkGetObjectMacro(Graph, vtkGraph);
64 
68  virtual vtkIncrementalForceLayout *GetLayout();
69 
71 
74  virtual void StartLayoutAnimation(vtkRenderWindowInteractor *interactor);
75  virtual void StopLayoutAnimation();
77 
81  virtual void UpdateLayout();
82 
83 protected:
84  vtkGraphItem();
85  ~vtkGraphItem() override;
86 
91  bool Paint(vtkContext2D *painter) override;
92 
98  virtual void RebuildBuffers();
99 
104  virtual void PaintBuffers(vtkContext2D *painter);
105 
114  virtual bool IsDirty();
115 
120  virtual vtkIdType NumberOfVertices();
121 
126  virtual vtkIdType NumberOfEdges();
127 
134  virtual vtkIdType NumberOfEdgePoints(vtkIdType edge);
135 
140  virtual float EdgeWidth(vtkIdType edge, vtkIdType point);
141 
147  virtual vtkColor4ub EdgeColor(vtkIdType edge, vtkIdType point);
148 
155  virtual vtkVector2f EdgePosition(vtkIdType edge, vtkIdType point);
156 
162  virtual float VertexSize(vtkIdType vertex);
163 
168  virtual vtkColor4ub VertexColor(vtkIdType vertex);
169 
176  virtual int VertexMarker(vtkIdType vertex);
177 
183  virtual vtkVector2f VertexPosition(vtkIdType vertex);
184 
189  virtual vtkStdString VertexTooltip(vtkIdType vertex);
190 
194  static void ProcessEvents(vtkObject *caller, unsigned long event,
195  void *clientData, void *callerData);
196 
200  virtual vtkIdType HitVertex(const vtkVector2f &pos);
201 
203 
206  bool MouseMoveEvent(const vtkContextMouseEvent &event) override;
207  bool MouseLeaveEvent(const vtkContextMouseEvent &event) override;
208  bool MouseEnterEvent(const vtkContextMouseEvent &event) override;
209  bool MouseButtonPressEvent(const vtkContextMouseEvent &event) override;
210  bool MouseButtonReleaseEvent(const vtkContextMouseEvent &event) override;
211  bool MouseWheelEvent(const vtkContextMouseEvent &event, int delta) override;
213 
217  bool Hit(const vtkContextMouseEvent &event) override;
218 
222  virtual void PlaceTooltip(vtkIdType v);
223 
224 private:
225  vtkGraphItem(const vtkGraphItem&) = delete;
226  void operator=(const vtkGraphItem&) = delete;
227 
228  struct Internals;
229  Internals *Internal;
230 
231  vtkGraph *Graph;
232  vtkMTimeType GraphBuildTime;
233  vtkNew<vtkImageData> Sprite;
235  vtkNew<vtkTooltipItem> Tooltip;
236 };
237 
238 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
base class for items that are part of a vtkContextScene.
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
int vtkIdType
Definition: vtkType.h:347
Base class for graph data types.
Definition: vtkGraph.h:287
platform-independent render window interaction including picking and frame rate control.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta)
Mouse wheel event, positive delta indicates forward movement of the wheel.
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Mouse enter event.
A 2D graphics item for rendering a graph.
Definition: vtkGraphItem.h:50
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
takes care of drawing 2D axes
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse)
Mouse leave event.
incremental force-directed layout.