VTK  9.3.1
vtkGraphItem.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
22 #ifndef vtkGraphItem_h
23 #define vtkGraphItem_h
24 
25 #include "vtkContextItem.h"
26 #include "vtkViewsInfovisModule.h" // For export macro
27 
28 #include "vtkColor.h" // For color types in API
29 #include "vtkNew.h" // For vtkNew ivars
30 #include "vtkVector.h" // For vector types in API
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkGraph;
34 class vtkImageData;
37 class vtkTooltipItem;
38 
39 class VTKVIEWSINFOVIS_EXPORT vtkGraphItem : public vtkContextItem
40 {
41 public:
42  static vtkGraphItem* New();
43  vtkTypeMacro(vtkGraphItem, vtkContextItem);
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
47 
50  virtual void SetGraph(vtkGraph* graph);
51  vtkGetObjectMacro(Graph, vtkGraph);
53 
57  virtual vtkIncrementalForceLayout* GetLayout();
58 
60 
63  virtual void StartLayoutAnimation(vtkRenderWindowInteractor* interactor);
64  virtual void StopLayoutAnimation();
66 
70  virtual void UpdateLayout();
71 
72 protected:
73  vtkGraphItem();
74  ~vtkGraphItem() override;
75 
80  bool Paint(vtkContext2D* painter) override;
81 
87  virtual void RebuildBuffers();
88 
93  virtual void PaintBuffers(vtkContext2D* painter);
94 
103  virtual bool IsDirty();
104 
109  virtual vtkIdType NumberOfVertices();
110 
115  virtual vtkIdType NumberOfEdges();
116 
123  virtual vtkIdType NumberOfEdgePoints(vtkIdType edge);
124 
129  virtual float EdgeWidth(vtkIdType edge, vtkIdType point);
130 
136  virtual vtkColor4ub EdgeColor(vtkIdType edge, vtkIdType point);
137 
144  virtual vtkVector2f EdgePosition(vtkIdType edge, vtkIdType point);
145 
151  virtual float VertexSize(vtkIdType vertex);
152 
157  virtual vtkColor4ub VertexColor(vtkIdType vertex);
158 
165  virtual int VertexMarker(vtkIdType vertex);
166 
172  virtual vtkVector2f VertexPosition(vtkIdType vertex);
173 
178  virtual vtkStdString VertexTooltip(vtkIdType vertex);
179 
183  static void ProcessEvents(
184  vtkObject* caller, unsigned long event, void* clientData, void* callerData);
185 
189  virtual vtkIdType HitVertex(const vtkVector2f& pos);
190 
192 
195  bool MouseMoveEvent(const vtkContextMouseEvent& event) override;
196  bool MouseLeaveEvent(const vtkContextMouseEvent& event) override;
197  bool MouseEnterEvent(const vtkContextMouseEvent& event) override;
198  bool MouseButtonPressEvent(const vtkContextMouseEvent& event) override;
199  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& event) override;
200  bool MouseWheelEvent(const vtkContextMouseEvent& event, int delta) override;
202 
206  bool Hit(const vtkContextMouseEvent& event) override;
207 
211  virtual void PlaceTooltip(vtkIdType v);
212 
213 private:
214  vtkGraphItem(const vtkGraphItem&) = delete;
215  void operator=(const vtkGraphItem&) = delete;
216 
217  struct Internals;
218  Internals* Internal;
219 
220  vtkGraph* Graph;
221  vtkMTimeType GraphBuildTime;
222  vtkNew<vtkImageData> Sprite;
224  vtkNew<vtkTooltipItem> Tooltip;
225 };
226 
227 VTK_ABI_NAMESPACE_END
228 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
abstract base class for most VTK objects
Definition: vtkObject.h:51
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
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:315
Base class for graph data types.
Definition: vtkGraph.h:280
platform-independent render window interaction including picking and frame rate control.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
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:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
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:39
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.