28#ifndef vtkControlPointsItem_h
29#define vtkControlPointsItem_h
33#include "vtkChartsCoreModule.h"
41class vtkControlPointsAddPointItem;
76 vtkSetVector4Macro(UserBounds,
double);
77 vtkGetVector4Macro(UserBounds,
double);
86 vtkSetVector4Macro(ValidBounds,
double);
87 vtkGetVector4Macro(ValidBounds,
double);
95 vtkGetMacro(ScreenPointRadius,
float);
96 vtkSetMacro(ScreenPointRadius,
float);
104 vtkGetMacro(DrawPoints,
bool);
105 vtkSetMacro(DrawPoints,
bool);
106 vtkBooleanMacro(DrawPoints,
bool);
204 vtkSetMacro(StrokeMode,
bool);
205 vtkGetMacro(StrokeMode,
bool);
215 vtkSetMacro(SwitchPointsMode,
bool);
216 vtkGetMacro(SwitchPointsMode,
bool);
224 vtkSetMacro(EndPointsXMovable,
bool);
225 vtkGetMacro(EndPointsXMovable,
bool);
226 vtkSetMacro(EndPointsYMovable,
bool);
227 vtkGetMacro(EndPointsYMovable,
bool);
236 vtkSetMacro(EndPointsRemovable,
bool);
237 vtkGetMacro(EndPointsRemovable,
bool);
245 vtkSetMacro(ShowLabels,
bool);
246 vtkGetMacro(ShowLabels,
bool);
253 vtkSetStringMacro(LabelFormat);
254 vtkGetStringMacro(LabelFormat);
349 vtkGetObjectMacro(SelectedPointPen,
vtkPen);
367 vtkGetMacro(UseAddPointItem,
bool);
368 vtkSetMacro(UseAddPointItem,
bool);
369 vtkBooleanMacro(UseAddPointItem,
bool);
409 virtual void emitEvent(
unsigned long event,
void* params =
nullptr) = 0;
412 vtkObject* sender,
unsigned long event,
void* receiver,
void* params);
458 virtual void EditPoint(
float vtkNotUsed(tX),
float vtkNotUsed(tY));
489 int BlockUpdates = 0;
490 int StartedInteractions = 0;
491 int StartedChanges = 0;
494 double Bounds[4] = { 0., -1., 0., -1. };
495 double UserBounds[4] = { 0., -1., 0., -1. };
496 double ValidBounds[4] = { 0., -1., 0., -1. };
499 float ScreenPointRadius = 6.f;
501 bool DrawPoints =
true;
502 bool StrokeMode =
false;
503 bool SwitchPointsMode =
false;
504 bool MouseMoved =
false;
505 bool EnforceValidFunction =
true;
507 bool PointAboutToBeDeleted =
false;
509 bool PointAboutToBeToggled =
false;
510 bool InvertShadow =
false;
511 bool EndPointsXMovable =
true;
512 bool EndPointsYMovable =
true;
513 bool EndPointsRemovable =
true;
514 bool ShowLabels =
false;
515 char* LabelFormat =
nullptr;
521 void ComputeBounds();
525 bool UseAddPointItem =
false;
provides a brush that fills shapes drawn by vtkContext2D.
supports function callbacks
Class for drawing 2D primitives to a graphical context.
data structure to represent key events.
data structure to represent mouse events.
Abstract class for control points items.
void SetCurrentPoint(vtkIdType index)
Sets the current point selected.
vtkNew< vtkCallbackCommand > Callback
virtual vtkIdType RemovePoint(double *pos)=0
Remove a point of the function.
virtual void DrawPoint(vtkContext2D *painter, vtkIdType index)
Internal function that paints a collection of points and optionally excludes some.
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Mouse and key events.
static void CallComputePoints(vtkObject *sender, unsigned long event, void *receiver, void *params)
vtkNew< vtkBrush > SelectedPointBrush
void SpreadPoints(float factor, bool dontSpreadFirstAndLast=false)
Utility function to spread all the control points of a given factor If dontSpreadFirstAndLast is true...
bool IsEndPointPicked()
Return true if any of the end points is current point or part of the selection.
~vtkControlPointsItem() override
bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse) override
Mouse and key events.
virtual void ComputeBounds(double *bounds)
Compute the bounds for this item.
void DeselectPoint(double *currentPoint)
Utility function that unselects a point providing its coordinates.
virtual void GetControlPoint(vtkIdType index, double *point) const =0
Returns the x and y coordinates as well as the midpoint and sharpness of the control point correspond...
vtkIdType GetCurrentPoint() const
Returns the current point ID selected or -1 if there is no point current.
bool Paint(vtkContext2D *painter) override
Paint the points with a fixed size (cosmetic) which doesn't depend on the scene zoom factor.
void AddPointId(vtkIdType addedPointId)
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Mouse and key events.
void ToggleSelectPoint(double *currentPoint)
Utility function that toggles the selection a point providing its coordinates.
vtkPlot * GetAddPointItem()
Item dedicated to add point, to be added below all other items.
void ToggleSelectPoint(vtkIdType pointId)
Toggle the selection of a point by its ID.
virtual void SetControlPoint(vtkIdType index, double *point)=0
Sets the x and y coordinates as well as the midpoint and sharpness of the control point corresponding...
void MovePoints(const vtkVector2f &translation, bool dontMoveFirstAndLast=false)
Utility function to move all the control points of the given translation If dontMoveFirstAndLast is t...
void StartInteractionIfNotStarted()
void ResetBounds()
Recompute the bounds next time they are requested.
bool IsPointRemovable(vtkIdType pointId)
Return true if the point is removable.
bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max) override
Select all points in the specified rectangle.
virtual void ComputePoints()
Must be reimplemented by subclasses to calculate the points to draw.
virtual bool GetEndPointsMovable()
If EndPointsMovable is false, the two end points will not be moved.
vtkIdType RemovePoint(vtkIdType pointId)
Remove a point give its id.
bool KeyPressEvent(const vtkContextKeyEvent &key) override
Mouse and key events.
void GetBounds(double bounds[4]) override
Bounds of the item, typically the bound of all the control points except if custom bounds have been s...
vtkVector2f GetSelectionCenterOfMass() const
void MoveCurrentPoint(const vtkVector2f &translation)
void SpreadPoints(float factor, vtkIdTypeArray *pointIds)
Spread the points referred by pointIds If factor > 0, points are moved away from each other.
virtual vtkIdType AddPoint(double *newPos)=0
Add a point to the function.
virtual void emitEvent(unsigned long event, void *params=nullptr)=0
vtkIdType FindPoint(double *pos)
Returns the vtkIdType of the point given its coordinates and a tolerance based on the screen point si...
void RemoveCurrentPoint()
Remove the current point.
void SelectPoint(double *currentPoint)
Utility function that selects a point providing its coordinates.
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y are within the bounds or on a control point.
void Stroke(const vtkVector2f &newPos)
virtual std::string GetControlPointLabel(vtkIdType index)
Generate label for a control point.
virtual vtkMTimeType GetControlPointsMTime()=0
Must be reimplemented by subclasses to calculate the points to draw.
void SelectAllPoints()
Select all the points.
vtkIdType SetPointPos(vtkIdType point, const vtkVector2f &newPos)
void DrawUnselectedPoints(vtkContext2D *painter)
Internal function that paints a collection of points and optionally excludes some.
bool IsOverPoint(double *pos, vtkIdType pointId)
Returns true if pos is above the pointId point, false otherwise.
vtkIdType MovePoint(vtkIdType point, const vtkVector2f &translation)
void DeselectAllPoints()
Unselect all the previously selected points.
void DrawSelectedPoints(vtkContext2D *painter)
Internal function that paints a collection of points and optionally excludes some.
virtual vtkIdType GetNumberOfPoints() const =0
Returns the total number of points.
vtkVector2f GetCenterOfMass(vtkIdTypeArray *pointIDs) const
bool ClampValidDataPos(double pos[2])
Clamp the given 2D pos into the bounds of the function.
void SetCurrentPointPos(const vtkVector2f &newPos)
void SelectPoint(vtkIdType pointId)
Select a point by its ID.
bool KeyReleaseEvent(const vtkContextKeyEvent &key) override
Mouse and key events.
vtkIdType GetControlPointId(double *pos)
Returns the id of the control point exactly matching pos, -1 if not found.
void MovePoints(const vtkVector2f &translation, vtkIdTypeArray *pointIds)
Move the points referred by pointIds by a given translation.
int GetInteractionsCount() const
vtkIdType GetNumberOfSelectedPoints() const
Return the number of selected points.
void GetControlPointsIds(vtkIdTypeArray *ids, bool excludeFirstAndLast=false) const
Utility function that returns an array of all the control points IDs Typically: [0,...
vtkNew< vtkTransform2D > ControlPointsTransform
void DeselectPoint(vtkIdType pointId)
Unselect a point by its ID.
bool ClampValidScreenPos(double pos[2])
Clamp the given 2D pos into the bounds of the function.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkNew< vtkPen > SelectedPointPen
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse and key events.
virtual void EditPoint(float vtkNotUsed(tX), float vtkNotUsed(tY))
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Allocate and hold a VTK object.
abstract base class for most VTK objects
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
a vtkContextItem that draws handles around a point of a piecewise function
Abstract class for 2D plots.
represent and manipulate 2D points
vtkTypeUInt32 vtkMTimeType