19 #ifndef vtkControlPointsItem_h
20 #define vtkControlPointsItem_h
24 #include "vtkChartsCoreModule.h"
30 VTK_ABI_NAMESPACE_BEGIN
33 class vtkControlPointsAddPointItem;
60 void GetBounds(
double bounds[4])
override;
68 vtkSetVector4Macro(UserBounds,
double);
69 vtkGetVector4Macro(UserBounds,
double);
78 vtkSetVector4Macro(ValidBounds,
double);
79 vtkGetVector4Macro(ValidBounds,
double);
87 vtkGetMacro(ScreenPointRadius,
float);
88 vtkSetMacro(ScreenPointRadius,
float);
96 vtkGetMacro(DrawPoints,
bool);
97 vtkSetMacro(DrawPoints,
bool);
98 vtkBooleanMacro(DrawPoints,
bool);
118 void SelectPoint(
double* currentPoint);
123 void SelectAllPoints();
135 void DeselectPoint(
double* currentPoint);
140 void DeselectAllPoints();
146 void ToggleSelectPoint(
vtkIdType pointId);
153 void ToggleSelectPoint(
double* currentPoint);
163 vtkIdType GetNumberOfSelectedPoints()
const;
176 bool IsOverPoint(
double* pos,
vtkIdType pointId);
181 vtkIdType GetControlPointId(
double* pos);
188 void GetControlPointsIds(
vtkIdTypeArray* ids,
bool excludeFirstAndLast =
false)
const;
196 vtkSetMacro(StrokeMode,
bool);
197 vtkGetMacro(StrokeMode,
bool);
207 vtkSetMacro(SwitchPointsMode,
bool);
208 vtkGetMacro(SwitchPointsMode,
bool);
216 vtkSetMacro(EndPointsXMovable,
bool);
217 vtkGetMacro(EndPointsXMovable,
bool);
218 vtkSetMacro(EndPointsYMovable,
bool);
219 vtkGetMacro(EndPointsYMovable,
bool);
220 virtual bool GetEndPointsMovable();
228 vtkSetMacro(EndPointsRemovable,
bool);
229 vtkGetMacro(EndPointsRemovable,
bool);
237 vtkSetMacro(ShowLabels,
bool);
238 vtkGetMacro(ShowLabels,
bool);
245 vtkSetStringMacro(LabelFormat);
246 vtkGetStringMacro(LabelFormat);
254 virtual vtkIdType AddPoint(
double* newPos) = 0;
261 virtual vtkIdType RemovePoint(
double* pos) = 0;
272 void RemoveCurrentPoint();
277 virtual vtkIdType GetNumberOfPoints()
const = 0;
324 void SpreadPoints(
float factor,
bool dontSpreadFirstAndLast =
false);
341 vtkGetObjectMacro(SelectedPointPen,
vtkPen);
349 vtkGetObjectMacro(SelectedPointBrush,
vtkBrush);
359 vtkGetMacro(UseAddPointItem,
bool);
360 vtkSetMacro(UseAddPointItem,
bool);
361 vtkBooleanMacro(UseAddPointItem,
bool);
396 void StartInteraction();
397 void StartInteractionIfNotStarted();
399 void EndInteraction();
400 int GetInteractionsCount()
const;
401 virtual void emitEvent(
unsigned long event,
void* params =
nullptr) = 0;
403 static void CallComputePoints(
404 vtkObject* sender,
unsigned long event,
void* receiver,
void* params);
411 virtual void ComputePoints();
427 bool ClampValidDataPos(
double pos[2]);
428 bool ClampValidScreenPos(
double pos[2]);
441 void SetCurrentPointPos(
const vtkVector2f& newPos);
450 virtual void EditPoint(
float vtkNotUsed(tX),
float vtkNotUsed(tY));
463 bool IsEndPointPicked();
468 bool IsPointRemovable(
vtkIdType pointId);
476 virtual void ComputeBounds(
double* bounds);
481 int BlockUpdates = 0;
482 int StartedInteractions = 0;
483 int StartedChanges = 0;
486 double Bounds[4] = { 0., -1., 0., -1. };
487 double UserBounds[4] = { 0., -1., 0., -1. };
488 double ValidBounds[4] = { 0., -1., 0., -1. };
491 float ScreenPointRadius = 6.f;
493 bool DrawPoints =
true;
494 bool StrokeMode =
false;
495 bool SwitchPointsMode =
false;
496 bool MouseMoved =
false;
497 bool EnforceValidFunction =
true;
499 bool PointAboutToBeDeleted =
false;
501 bool PointAboutToBeToggled =
false;
502 bool InvertShadow =
false;
503 bool EndPointsXMovable =
true;
504 bool EndPointsYMovable =
true;
505 bool EndPointsRemovable =
true;
506 bool ShowLabels =
false;
507 char* LabelFormat =
nullptr;
513 void ComputeBounds();
517 bool UseAddPointItem =
false;
520 VTK_ABI_NAMESPACE_END
vtkNew< vtkCallbackCommand > Callback
data structure to represent key events.
abstract base class for most VTK objects
vtkTypeUInt32 vtkMTimeType
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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.
virtual bool KeyReleaseEvent(const vtkContextKeyEvent &key)
Key release event.
Abstract class for control points items.
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
dynamic, self-adjusting array of vtkIdType
vtkNew< vtkBrush > SelectedPointBrush
vtkNew< vtkPen > SelectedPointPen
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is inside the item.
vtkNew< vtkTransform2D > ControlPointsTransform
Class for drawing 2D primitives to a graphical context.
supports function callbacks
a vtkContextItem that draws handles around a point of a piecewise function
provides a brush that fills shapes drawn by vtkContext2D.
data structure to represent mouse events.
virtual bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max)
Select all points in the specified rectangle.
a simple class to control print indentation
represent and manipulate 2D points
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Abstract class for 2D plots.
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
Key press event.
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
Mouse button double click event.