31 #ifndef vtkControlPointsItem_h
32 #define vtkControlPointsItem_h
36 #include "vtkChartsCoreModule.h"
44 class vtkControlPointsAddPointItem;
71 void GetBounds(
double bounds[4])
override;
79 vtkSetVector4Macro(UserBounds,
double);
80 vtkGetVector4Macro(UserBounds,
double);
89 vtkSetVector4Macro(ValidBounds,
double);
90 vtkGetVector4Macro(ValidBounds,
double);
98 vtkGetMacro(ScreenPointRadius,
float);
99 vtkSetMacro(ScreenPointRadius,
float);
107 vtkGetMacro(DrawPoints,
bool);
108 vtkSetMacro(DrawPoints,
bool);
109 vtkBooleanMacro(DrawPoints,
bool);
129 void SelectPoint(
double* currentPoint);
134 void SelectAllPoints();
146 void DeselectPoint(
double* currentPoint);
151 void DeselectAllPoints();
157 void ToggleSelectPoint(
vtkIdType pointId);
164 void ToggleSelectPoint(
double* currentPoint);
174 vtkIdType GetNumberOfSelectedPoints()
const;
187 bool IsOverPoint(
double* pos,
vtkIdType pointId);
192 vtkIdType GetControlPointId(
double* pos);
199 void GetControlPointsIds(
vtkIdTypeArray* ids,
bool excludeFirstAndLast =
false)
const;
207 vtkSetMacro(StrokeMode,
bool);
208 vtkGetMacro(StrokeMode,
bool);
218 vtkSetMacro(SwitchPointsMode,
bool);
219 vtkGetMacro(SwitchPointsMode,
bool);
227 vtkSetMacro(EndPointsXMovable,
bool);
228 vtkGetMacro(EndPointsXMovable,
bool);
229 vtkSetMacro(EndPointsYMovable,
bool);
230 vtkGetMacro(EndPointsYMovable,
bool);
231 virtual bool GetEndPointsMovable();
239 vtkSetMacro(EndPointsRemovable,
bool);
240 vtkGetMacro(EndPointsRemovable,
bool);
248 vtkSetMacro(ShowLabels,
bool);
249 vtkGetMacro(ShowLabels,
bool);
256 vtkSetStringMacro(LabelFormat);
257 vtkGetStringMacro(LabelFormat);
265 virtual vtkIdType AddPoint(
double* newPos) = 0;
272 virtual vtkIdType RemovePoint(
double* pos) = 0;
283 void RemoveCurrentPoint();
288 virtual vtkIdType GetNumberOfPoints()
const = 0;
335 void SpreadPoints(
float factor,
bool dontSpreadFirstAndLast =
false);
352 vtkGetObjectMacro(SelectedPointPen,
vtkPen);
360 vtkGetObjectMacro(SelectedPointBrush,
vtkBrush);
370 vtkGetMacro(UseAddPointItem,
bool);
371 vtkSetMacro(UseAddPointItem,
bool);
372 vtkBooleanMacro(UseAddPointItem,
bool);
407 void StartInteraction();
408 void StartInteractionIfNotStarted();
410 void EndInteraction();
411 int GetInteractionsCount()
const;
412 virtual void emitEvent(
unsigned long event,
void* params =
nullptr) = 0;
414 static void CallComputePoints(
415 vtkObject* sender,
unsigned long event,
void* receiver,
void* params);
422 virtual void ComputePoints();
438 bool ClampValidDataPos(
double pos[2]);
439 bool ClampValidScreenPos(
double pos[2]);
452 void SetCurrentPointPos(
const vtkVector2f& newPos);
461 virtual void EditPoint(
float vtkNotUsed(tX),
float vtkNotUsed(tY));
474 bool IsEndPointPicked();
479 bool IsPointRemovable(
vtkIdType pointId);
487 virtual void ComputeBounds(
double* bounds);
492 int BlockUpdates = 0;
493 int StartedInteractions = 0;
494 int StartedChanges = 0;
497 double Bounds[4] = { 0., -1., 0., -1. };
498 double UserBounds[4] = { 0., -1., 0., -1. };
499 double ValidBounds[4] = { 0., -1., 0., -1. };
502 float ScreenPointRadius = 6.f;
504 bool DrawPoints =
true;
505 bool StrokeMode =
false;
506 bool SwitchPointsMode =
false;
507 bool MouseMoved =
false;
508 bool EnforceValidFunction =
true;
510 bool PointAboutToBeDeleted =
false;
512 bool PointAboutToBeToggled =
false;
513 bool InvertShadow =
false;
514 bool EndPointsXMovable =
true;
515 bool EndPointsYMovable =
true;
516 bool EndPointsRemovable =
true;
517 bool ShowLabels =
false;
518 char* LabelFormat =
nullptr;
524 void ComputeBounds();
528 bool UseAddPointItem =
false;
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.