Go to the documentation of this file.
31 #ifndef vtkControlPointsItem_h
32 #define vtkControlPointsItem_h
34 #include "vtkChartsCoreModule.h"
74 vtkSetVector4Macro(UserBounds,
double);
75 vtkGetVector4Macro(UserBounds,
double);
84 vtkSetVector4Macro(ValidBounds,
double);
85 vtkGetVector4Macro(ValidBounds,
double);
93 vtkGetMacro(ScreenPointRadius,
float);
94 vtkSetMacro(ScreenPointRadius,
float);
185 bool excludeFirstAndLast =
false)
const;
193 vtkGetMacro(StrokeMode,
bool);
203 vtkSetMacro(SwitchPointsMode,
bool);
204 vtkGetMacro(SwitchPointsMode,
bool);
212 vtkSetMacro(EndPointsXMovable,
bool);
213 vtkGetMacro(EndPointsXMovable,
bool);
214 vtkSetMacro(EndPointsYMovable,
bool);
215 vtkGetMacro(EndPointsYMovable,
bool);
224 vtkSetMacro(EndPointsRemovable,
bool);
225 vtkGetMacro(EndPointsRemovable,
bool);
233 vtkSetMacro(ShowLabels,
bool);
234 vtkGetMacro(ShowLabels,
bool);
241 vtkSetStringMacro(LabelFormat);
242 vtkGetStringMacro(LabelFormat);
268 inline void RemoveCurrentPoint();
337 vtkGetObjectMacro(SelectedPointPen,
vtkPen);
383 virtual void emitEvent(
unsigned long event,
void* params =
nullptr) = 0;
409 double &outX,
double &outY);
411 double &outX,
double &outY);
419 virtual bool ClampPos(
double pos[2],
double bounds[4]);
439 inline vtkVector2f GetSelectionCenterOfMass()
const;
443 virtual void EditPoint(
float vtkNotUsed(tX),
float vtkNotUsed(tY));
484 double UserBounds[4];
485 double ValidBounds[4];
508 void ComputeBounds();
provides a brush that fills shapes drawn by vtkContext2D.
represent and manipulate 2D points
bool EnforceValidFunction
bool IsEndPointPicked()
Return true if any of the end points is current point or part of the selection.
vtkBrush * SelectedPointBrush
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Mouse button down event.
bool IsPointRemovable(vtkIdType pointId)
Return true if the point is removable.
data structure to represent mouse events.
data structure to represent key events.
vtkIdType SetPointPos(vtkIdType point, const vtkVector2f &newPos)
void SelectAllPoints()
Select all the points.
vtkIdType GetNumberOfSelectedPoints() const
Return the number of selected points.
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...
bool PointAboutToBeToggled
virtual vtkIdType GetNumberOfPoints() const =0
Returns the total number of points.
vtkIdType RemovePoint(vtkIdType pointId)
Remove a point give its id.
virtual void ComputePoints()
Must be reimplemented by subclasses to calculate the points to draw.
void DrawSelectedPoints(vtkContext2D *painter)
bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse) override
Mouse button double click event.
void MoveCurrentPoint(const vtkVector2f &translation)
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 DeselectPoint(double *currentPoint)
Utility function that unselects a point providing its coordinates.
bool PointAboutToBeDeleted
virtual void DrawPoint(vtkContext2D *painter, vtkIdType index)
abstract base class for most VTK objects
void StartInteractionIfNotStarted()
void SpreadPoints(float factor, bool dontSpreadFirstAndLast=false)
Utility function to spread all the control points of a given factor If dontSpreadFirstAndLast is true...
void MovePoints(const vtkVector2f &translation, vtkIdTypeArray *pointIds)
Move the points referred by pointIds by a given translation.
Class for drawing 2D primitives to a graphical context.
void SetCurrentPointPos(const vtkVector2f &newPos)
virtual vtkIdType AddPoint(double *newPos)=0
Add a point to the function.
virtual bool GetEndPointsMovable()
Abstract class for 2D plots.
a vtkContextItem that draws handles around a point of a piecewise function
vtkIdType GetControlPointId(double *pos)
Returns the id of the control point exactly matching pos, -1 if not found.
bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max) override
Select all points in the specified rectangle.
~vtkControlPointsItem() override
virtual vtkStdString GetControlPointLabel(vtkIdType index)
Generate label for a control point.
void ToggleSelectPoint(double *currentPoint)
Utility function that toggles the selection a point providing its coordinates.
void DrawUnselectedPoints(vtkContext2D *painter)
Internal function that paints a collection of points and optionally excludes some.
bool Paint(vtkContext2D *painter) override
Paint the points with a fixed size (cosmetic) which doesn't depend on the scene zoom factor.
Abstract class for control points items.
void DeselectPoint(vtkIdType pointId)
Unselect a point by its ID.
virtual void emitEvent(unsigned long event, void *params=nullptr)=0
vtkVector2f GetSelectionCenterOfMass() const
virtual void ComputeBounds(double *bounds)
Compute the bounds for this item.
virtual void EditPoint(float vtkNotUsed(tX), float vtkNotUsed(tY))
virtual vtkIdType RemovePoint(double *pos)=0
Remove a point of the function.
bool KeyPressEvent(const vtkContextKeyEvent &key) override
Key press event.
a simple class to control print indentation
void MovePoints(const vtkVector2f &translation, bool dontMoveFirstAndLast=false)
Utility function to move all the control points of the given translation If dontMoveFirstAndLast is t...
vtkIdType MovePoint(vtkIdType point, const vtkVector2f &translation)
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...
virtual void TransformScreenToData(const double inX, const double inY, double &outX, double &outY)
void ToggleSelectPoint(vtkIdType pointId)
Toggle the selection of a point by its ID.
virtual void TransformDataToScreen(const vtkVector2f &in, vtkVector2f &out)
void SetCurrentPoint(vtkIdType index)
Sets the current point selected.
vtkTransform2D * Transform
void AddPointId(vtkIdType addedPointId)
virtual void TransformDataToScreen(const double inX, const double inY, double &outX, double &outY)
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
void SelectPoint(vtkIdType pointId)
Select a point by its ID.
void SpreadPoints(float factor, vtkIdTypeArray *pointIds)
Spread the points referred by pointIds If factor > 0, points are moved away from each other.
virtual bool ClampPos(double pos[2], double bounds[4])
Clamp the given 2D pos into the bounds of the function.
vtkVector2f GetCenterOfMass(vtkIdTypeArray *pointIDs) const
static void CallComputePoints(vtkObject *sender, unsigned long event, void *receiver, void *params)
void SelectPoint(double *currentPoint)
Utility function that selects a point providing its coordinates.
bool KeyReleaseEvent(const vtkContextKeyEvent &key) override
Key release event.
void DeselectAllPoints()
Unselect all the previously selected points.
dynamic, self-adjusting array of vtkIdType
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Mouse button release event.
vtkPen * SelectedPointPen
vtkIdType GetCurrentPoint() const
Returns the current point ID selected or -1 if there is no point current.
supports function callbacks
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 Stroke(const vtkVector2f &newPos)
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
virtual void TransformScreenToData(const vtkVector2f &in, vtkVector2f &out)
Transform the mouse event in the control-points space.
int GetInteractionsCount() const
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Wrapper around std::string to keep symbols short.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is on a control point.
bool ClampValidDataPos(double pos[2])
bool ClampValidScreenPos(double pos[2])
vtkCallbackCommand * Callback
virtual vtkMTimeType GetControlPointsMTime()=0
void GetControlPointsIds(vtkIdTypeArray *ids, bool excludeFirstAndLast=false) const
Utility function that returns an array of all the control points IDs Typically: [0,...
void ResetBounds()
Recompute the bounds next time they are requested.
vtkTypeUInt32 vtkMTimeType
bool IsOverPoint(double *pos, vtkIdType pointId)
Returns true if pos is above the pointId point, false otherwise.