VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkControlPointsItem.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 00027 #ifndef __vtkControlPointsItem_h 00028 #define __vtkControlPointsItem_h 00029 00030 #include "vtkPlot.h" 00031 #include "vtkCommand.h" // For vtkCommand enum 00032 00033 class vtkCallbackCommand; 00034 class vtkContext2D; 00035 class vtkPoints2D; 00036 class vtkTransform2D; 00037 00038 class VTK_CHARTS_EXPORT vtkControlPointsItem: public vtkPlot 00039 { 00040 public: 00041 vtkTypeMacro(vtkControlPointsItem, vtkPlot); 00042 virtual void PrintSelf(ostream &os, vtkIndent indent); 00043 00044 enum { 00045 CurrentPointChangedEvent = vtkCommand::UserEvent, 00046 CurrentPointEditEvent 00047 }; 00048 00051 virtual void GetBounds(double bounds[4]); 00052 00054 00057 vtkSetVector4Macro(UserBounds, double); 00058 vtkGetVector4Macro(UserBounds, double) 00060 00064 virtual bool Paint(vtkContext2D *painter); 00065 00067 void SelectPoint(vtkIdType pointId); 00068 00072 void SelectPoint(double* currentPoint); 00073 00075 void SelectAllPoints(); 00076 00078 void DeselectPoint(vtkIdType pointId); 00079 00083 void DeselectPoint(double* currentPoint); 00084 00086 void DeselectAllPoints(); 00087 00090 void ToggleSelectPoint(vtkIdType pointId); 00091 00095 void ToggleSelectPoint(double* currentPoint); 00096 00098 virtual bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max); 00099 00102 vtkIdType FindPoint(double* pos); 00103 00107 bool IsOverPoint(double* pos, vtkIdType pointId); 00108 00111 vtkIdType GetControlPointId(double* pos); 00112 00114 00116 vtkGetMacro(StrokeMode, bool); 00118 00120 00124 vtkSetMacro(SwitchPointsMode, bool); 00125 vtkGetMacro(SwitchPointsMode, bool); 00127 00131 virtual vtkIdType AddPoint(double* newPos); 00132 00136 virtual vtkIdType RemovePoint(double* pos); 00137 00139 virtual int GetNumberOfPoints()const = 0; 00140 00142 00144 virtual void GetControlPoint(vtkIdType index, double *point) = 0; 00145 // Description: 00146 // Sets the x and y coordinates as well as the midpoint and sharpness 00147 // of the control point corresponding to the index. 00148 virtual void SetControlPoint(vtkIdType index, double *point) = 0; 00150 00152 vtkIdType GetCurrentPoint()const; 00153 00155 void SetCurrentPoint(vtkIdType index); 00156 00159 void ResetBounds(); 00160 00161 protected: 00162 vtkControlPointsItem(); 00163 virtual ~vtkControlPointsItem(); 00164 00165 static void CallComputePoints(vtkObject* sender, unsigned long event, void* receiver, void* params); 00166 00168 00170 virtual void ComputePoints(); 00171 virtual unsigned long int GetControlPointsMTime() =0; 00173 00175 virtual bool Hit(const vtkContextMouseEvent &mouse); 00176 00179 bool ClampPos(double pos[2]); 00180 00182 00184 void DrawUnselectedPoints(vtkContext2D* painter); 00185 void DrawSelectedPoints(vtkContext2D* painter); 00186 virtual void DrawPoint(vtkContext2D* painter, vtkIdType index); 00188 00190 00191 virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse); 00192 virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse); 00194 00196 virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse); 00197 00198 void MoveCurrentPoint(const vtkVector2f& newPos); 00199 vtkIdType MovePoint(vtkIdType point, const vtkVector2f& newPos); 00200 void MovePoints(float tX, float tY); 00201 void Stroke(const vtkVector2f& newPos); 00202 virtual void EditPoint(float vtkNotUsed(tX), float vtkNotUsed(tY)); 00204 virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse); 00205 00206 vtkCallbackCommand* Callback; 00207 vtkIdType CurrentPoint; 00208 00209 double Bounds[4]; 00210 double UserBounds[4]; 00211 00212 vtkTransform2D* Transform; 00213 float ScreenPointRadius; 00214 float ItemPointRadius2; 00215 00216 bool StrokeMode; 00217 bool SwitchPointsMode; 00218 bool MouseMoved; 00219 bool EnforceValidFunction; 00220 vtkIdType PointToDelete; 00221 bool PointAboutToBeDeleted; 00222 vtkIdType PointToToggle; 00223 bool PointAboutToBeToggled; 00224 private: 00225 vtkControlPointsItem(const vtkControlPointsItem &); // Not implemented. 00226 void operator=(const vtkControlPointsItem &); // Not implemented. 00227 00228 vtkIdType RemovePointId(vtkIdType pointId); 00229 void ComputeBounds(); 00230 }; 00231 00232 #endif