VTK  9.4.20250102
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
32VTK_ABI_NAMESPACE_BEGIN
33class vtkGraph;
34class vtkImageData;
37class vtkTooltipItem;
38
39class VTKVIEWSINFOVIS_EXPORT vtkGraphItem : public vtkContextItem
40{
41public:
42 static vtkGraphItem* New();
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
50 virtual void SetGraph(vtkGraph* graph);
51 vtkGetObjectMacro(Graph, vtkGraph);
53
58
60
64 virtual void StopLayoutAnimation();
66
70 virtual void UpdateLayout();
71
72protected:
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
110
116
124
129 virtual float EdgeWidth(vtkIdType edge, vtkIdType point);
130
137
145
151 virtual float VertexSize(vtkIdType vertex);
152
158
165 virtual int VertexMarker(vtkIdType vertex);
166
173
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;
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
213private:
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;
225};
226
227VTK_ABI_NAMESPACE_END
228#endif
Class for drawing 2D primitives to a graphical context.
base class for items that are part of a vtkContextScene.
data structure to represent mouse events.
A 2D graphics item for rendering a graph.
virtual void RebuildBuffers()
Builds a cache of data from the graph by calling the virtual functions such as VertexColor(),...
virtual void PlaceTooltip(vtkIdType v)
Change the position of the tooltip based on the vertex hovered.
virtual void UpdateLayout()
Incrementally updates the graph layout.
static vtkGraphItem * New()
virtual vtkIdType HitVertex(const vtkVector2f &pos)
Return index of hit vertex, or -1 if no hit.
bool MouseLeaveEvent(const vtkContextMouseEvent &event) override
Handle mouse events.
virtual vtkIdType NumberOfEdges()
Returns the number of edges in the graph.
virtual float EdgeWidth(vtkIdType edge, vtkIdType point)
Returns the edge width.
virtual void SetGraph(vtkGraph *graph)
The graph that this item draws.
virtual void StopLayoutAnimation()
Begins or ends the layout animation.
bool MouseButtonPressEvent(const vtkContextMouseEvent &event) override
Handle mouse events.
bool Hit(const vtkContextMouseEvent &event) override
Whether this graph item is hit.
virtual vtkColor4ub EdgeColor(vtkIdType edge, vtkIdType point)
Returns the edge color.
virtual float VertexSize(vtkIdType vertex)
Returns the vertex size in pixels, which is remains the same at any zoom level.
static void ProcessEvents(vtkObject *caller, unsigned long event, void *clientData, void *callerData)
Process events and dispatch to the appropriate member functions.
virtual void StartLayoutAnimation(vtkRenderWindowInteractor *interactor)
Begins or ends the layout animation.
~vtkGraphItem() override
virtual vtkIncrementalForceLayout * GetLayout()
Exposes the incremental graph layout for updating parameters.
bool MouseWheelEvent(const vtkContextMouseEvent &event, int delta) override
Handle mouse events.
virtual vtkIdType NumberOfVertices()
Returns the number of vertices in the graph.
virtual void PaintBuffers(vtkContext2D *painter)
Efficiently draws the contents of the buffers built in RebuildBuffers.
virtual bool IsDirty()
Returns true if the underlying vtkGraph has been modified since the last RebuildBuffers,...
virtual vtkIdType NumberOfEdgePoints(vtkIdType edge)
Returns the number of edge control points for a particular edge.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int VertexMarker(vtkIdType vertex)
Returns the marker type for each vertex, as defined in vtkMarkerUtilities.
bool MouseMoveEvent(const vtkContextMouseEvent &event) override
Handle mouse events.
virtual vtkVector2f EdgePosition(vtkIdType edge, vtkIdType point)
Returns the edge control point positions.
virtual vtkStdString VertexTooltip(vtkIdType vertex)
Returns the tooltip for each vertex.
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &event) override
Handle mouse events.
virtual vtkVector2f VertexPosition(vtkIdType vertex)
Returns the position of each vertex.
bool Paint(vtkContext2D *painter) override
Paints the graph.
bool MouseEnterEvent(const vtkContextMouseEvent &event) override
Handle mouse events.
virtual vtkColor4ub VertexColor(vtkIdType vertex)
Returns the color of each vertex.
Base class for graph data types.
Definition vtkGraph.h:340
topologically and geometrically regular array of data
incremental force-directed layout.
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract base class for most VTK objects
Definition vtkObject.h:162
platform-independent render window interaction including picking and frame rate control.
Wrapper around std::string to keep symbols short.
takes care of drawing 2D axes
int vtkIdType
Definition vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270