VTK
vtkControlPointsItem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkControlPointsItem.h
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 =========================================================================*/
15 
27 #ifndef __vtkControlPointsItem_h
28 #define __vtkControlPointsItem_h
29 
30 #include "vtkPlot.h"
31 #include "vtkCommand.h" // For vtkCommand enum
32 
33 class vtkCallbackCommand;
34 class vtkContext2D;
35 class vtkPoints2D;
36 class vtkTransform2D;
37 
39 {
40 public:
41  vtkTypeMacro(vtkControlPointsItem, vtkPlot);
42  virtual void PrintSelf(ostream &os, vtkIndent indent);
43 
44  enum {
45  CurrentPointChangedEvent = vtkCommand::UserEvent,
46  CurrentPointEditEvent
47  };
48 
51  virtual void GetBounds(double bounds[4]);
52 
54 
57  vtkSetVector4Macro(UserBounds, double);
58  vtkGetVector4Macro(UserBounds, double)
60 
64  virtual bool Paint(vtkContext2D *painter);
65 
67  void SelectPoint(vtkIdType pointId);
68 
72  void SelectPoint(double* currentPoint);
73 
75  void SelectAllPoints();
76 
78  void DeselectPoint(vtkIdType pointId);
79 
83  void DeselectPoint(double* currentPoint);
84 
86  void DeselectAllPoints();
87 
90  void ToggleSelectPoint(vtkIdType pointId);
91 
95  void ToggleSelectPoint(double* currentPoint);
96 
98  virtual bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max);
99 
102  vtkIdType FindPoint(double* pos);
103 
107  bool IsOverPoint(double* pos, vtkIdType pointId);
108 
111  vtkIdType GetControlPointId(double* pos);
112 
114 
116  vtkGetMacro(StrokeMode, bool);
118 
120 
124  vtkSetMacro(SwitchPointsMode, bool);
125  vtkGetMacro(SwitchPointsMode, bool);
127 
131  virtual vtkIdType AddPoint(double* newPos);
132 
136  virtual vtkIdType RemovePoint(double* pos);
137 
139  virtual int GetNumberOfPoints()const = 0;
140 
142 
144  virtual void GetControlPoint(vtkIdType index, double *point) = 0;
145  // Description:
146  // Sets the x and y coordinates as well as the midpoint and sharpness
147  // of the control point corresponding to the index.
148  virtual void SetControlPoint(vtkIdType index, double *point) = 0;
150 
152  vtkIdType GetCurrentPoint()const;
153 
155  void SetCurrentPoint(vtkIdType index);
156 
159  void ResetBounds();
160 
161 protected:
163  virtual ~vtkControlPointsItem();
164 
165  static void CallComputePoints(vtkObject* sender, unsigned long event, void* receiver, void* params);
166 
168 
170  virtual void ComputePoints();
171  virtual unsigned long int GetControlPointsMTime() =0;
173 
175  virtual bool Hit(const vtkContextMouseEvent &mouse);
176 
179  bool ClampPos(double pos[2]);
180 
182 
184  void DrawUnselectedPoints(vtkContext2D* painter);
185  void DrawSelectedPoints(vtkContext2D* painter);
186  virtual void DrawPoint(vtkContext2D* painter, vtkIdType index);
188 
190 
191  virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
192  virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse);
194 
196  virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
197 
198  void MoveCurrentPoint(const vtkVector2f& newPos);
199  vtkIdType MovePoint(vtkIdType point, const vtkVector2f& newPos);
200  void MovePoints(float tX, float tY);
201  void Stroke(const vtkVector2f& newPos);
202  virtual void EditPoint(float vtkNotUsed(tX), float vtkNotUsed(tY));
204  virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse);
205 
207  vtkIdType CurrentPoint;
208 
209  double Bounds[4];
210  double UserBounds[4];
211 
212  vtkTransform2D* Transform;
213  float ScreenPointRadius;
214  float ItemPointRadius2;
215 
216  bool StrokeMode;
217  bool SwitchPointsMode;
218  bool MouseMoved;
219  bool EnforceValidFunction;
220  vtkIdType PointToDelete;
221  bool PointAboutToBeDeleted;
222  vtkIdType PointToToggle;
223  bool PointAboutToBeToggled;
224 private:
225  vtkControlPointsItem(const vtkControlPointsItem &); // Not implemented.
226  void operator=(const vtkControlPointsItem &); // Not implemented.
227 
228  vtkIdType RemovePointId(vtkIdType pointId);
229  void ComputeBounds();
230 };
231 
232 #endif
#define VTK_CHARTS_EXPORT
abstract base class for most VTK objects
Definition: vtkObject.h:60
Abstract class for control points items.
virtual void GetBounds(double bounds[4])
Definition: vtkPlot.h:213
int vtkIdType
Definition: vtkType.h:255
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:54
supports function callbacks
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:37
represent and manipulate 2D points
Definition: vtkPoints2D.h:34
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:50
virtual void PrintSelf(ostream &os, vtkIndent indent)