Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::UI::Node Class Reference

#include <node.h>

Inheritance diagram for Inkscape::UI::Node:
Inkscape::UI::ListNode Inkscape::UI::SelectableControlPoint Inkscape::UI::ControlPoint

Public Member Functions

 Node (NodeSharedData const &data, Geom::Point const &pos)
 Curve endpoint in an editable path.
 
 Node (Node const &)=delete
 
void move (Geom::Point const &p) override
 Move the control point to new position with side effects.
 
void transform (Geom::Affine const &m) override
 Apply an arbitrary affine transformation to a control point.
 
void fixNeighbors () override
 Affine transforms keep handle invariants for smooth and symmetric nodes, but smooth nodes at ends of linear segments and auto nodes need special treatment.
 
Geom::Rect bounds () const override
 
NodeType type () const
 
void setType (NodeType type, bool update_handles=true)
 Sets the node type and optionally restores the invariants associated with the given type.
 
void showHandles (bool v)
 
void updateHandles ()
 
void pickBestType ()
 Pick the best type for this node, based on the position of its handles.
 
bool isDegenerate () const
 
bool isEndNode () const
 
Handlefront ()
 
Handleback ()
 
HandlehandleToward (Node *to)
 Gets the handle that faces the given adjacent node.
 
NodenodeToward (Handle *h)
 Gets the node in the direction of the given handle.
 
HandlehandleAwayFrom (Node *to)
 Gets the handle that goes in the direction opposite to the given adjacent node.
 
NodenodeAwayFrom (Handle *h)
 Gets the node in the direction opposite to the given handle.
 
NodeListnodeList ()
 
NodeListnodeList () const
 
void sink ()
 Move the node to the bottom of its canvas group.
 
bool _eventHandler (Inkscape::UI::Tools::ToolBase *event_context, CanvasEvent const &event) override
 Customized event handler to catch scroll events needed for selection grow/shrink.
 
Inkscape::SnapCandidatePoint snapCandidatePoint ()
 
- Public Member Functions inherited from Inkscape::UI::SelectableControlPoint
 ~SelectableControlPoint () override
 
bool selected () const
 
void updateState ()
 
virtual void select (bool toselect)
 
- Public Member Functions inherited from Inkscape::UI::ControlPoint
virtual ~ControlPoint ()
 
 ControlPoint (ControlPoint const &other)=delete
 
void operator= (ControlPoint const &other)=delete
 
bool doubleClicked () const
 
void set_selected_appearance (bool selected)
 
Geom::Point const & position () const
 Current position of the control point.
 
virtual void setPosition (Geom::Point const &pos)
 Relocate the control point without side effects.
 
bool visible () const
 
virtual void setVisible (bool v)
 Set the visibility of the control point.
 
void transferGrab (ControlPoint *from, MotionEvent const &event)
 Transfer the grab to another point.
 
State state () const
 
bool mouseovered () const
 

Static Public Member Functions

static NodeType parse_nodetype (char x)
 
static char const * node_type_to_localized_string (NodeType type)
 See also: Handle::handle_type_to_localized_string(NodeType type)
 
- Static Public Member Functions inherited from Inkscape::UI::ControlPoint
static Glib::ustring format_tip (char const *format,...) G_GNUC_PRINTF(1
 

Protected Member Functions

void dragged (Geom::Point &new_pos, MotionEvent const &event) override
 Called while dragging, but before moving the knot to new position.
 
bool grabbed (MotionEvent const &event) override
 Called when the user moves the point beyond the drag tolerance with the first button held down.
 
bool clicked (ButtonReleaseEvent const &event) override
 Called when the control point is clicked, at mouse button release.
 
void _setState (State state) override
 Change the state of the knot.
 
Glib::ustring _getTip (unsigned state) const override
 
Glib::ustring _getDragTip (MotionEvent const &event) const override
 
bool _hasDragTips () const override
 
- Protected Member Functions inherited from Inkscape::UI::SelectableControlPoint
 SelectableControlPoint (SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, Inkscape::CanvasItemCtrlType type, ControlPointSelection &sel, Inkscape::CanvasItemGroup *group=nullptr)
 
void _setState (State state) override
 Change the state of the knot.
 
void dragged (Geom::Point &new_pos, MotionEvent const &event) override
 Called while dragging, but before moving the knot to new position.
 
bool grabbed (MotionEvent const &event) override
 Called when the user moves the point beyond the drag tolerance with the first button held down.
 
void ungrabbed (ButtonReleaseEvent const *event) override
 Called when the control point finishes a drag.
 
bool clicked (ButtonReleaseEvent const &event) override
 Called when the control point is clicked, at mouse button release.
 
- Protected Member Functions inherited from Inkscape::UI::ControlPoint
 ControlPoint (SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, Inkscape::CanvasItemCtrlType type, Inkscape::CanvasItemGroup *group=nullptr)
 Create a regular control point.
 
virtual bool doubleclicked (ButtonReleaseEvent const &event)
 Called when the control point is doubleclicked, at mouse button release.
 
void _handleControlStyling ()
 
void _setSize (unsigned int size)
 
void _setControlType (Inkscape::CanvasItemCtrlType type)
 
void _setAnchor (SPAnchorType anchor)
 

Private Member Functions

void _updateAutoHandles ()
 
void _linearGrow (int dir)
 Select or deselect a node in this node's subpath based on its path distance from this node.
 
Node_next ()
 
Node const * _next () const
 
Node_prev ()
 
Node const * _prev () const
 
Inkscape::SnapSourceType _snapSourceType () const
 
Inkscape::SnapTargetType _snapTargetType () const
 
PathManipulator_pm ()
 
PathManipulator_pm () const
 

Static Private Member Functions

static bool _is_line_segment (Node *first, Node *second)
 Determine whether two nodes are joined by a linear segment.
 

Private Attributes

Handle _front
 Node handle in the backward direction of the path.
 
Handle _back
 Node handle in the forward direction of the path.
 
NodeType _type
 Type of node - cusp, smooth...
 
bool _handles_shown
 
std::optional< Geom::Point_unfixed_pos
 
- Private Attributes inherited from Inkscape::UI::ListNode
ListNodeln_next
 
ListNodeln_prev
 
NodeListln_list
 

Friends

class Handle
 
class NodeList
 
class NodeIterator< Node >
 
class NodeIterator< Node const >
 

Additional Inherited Members

- Public Types inherited from Inkscape::UI::ControlPoint
enum  State { STATE_NORMAL , STATE_MOUSEOVER , STATE_CLICKED }
 Enumeration representing the possible states of the control point, used to determine its appearance. More...
 
- Public Attributes inherited from Inkscape::UI::ControlPoint
SPDesktop *const _desktop
 The desktop this control point resides on.
 
- Static Public Attributes inherited from Inkscape::UI::ControlPoint
static ControlPointmouseovered_point = nullptr
 Holds the currently mouseovered control point.
 
static sigc::signal< void(ControlPoint *)> signal_mouseover_change
 Emitted when the mouseovered point changes.
 
- Static Protected Member Functions inherited from Inkscape::UI::ControlPoint
static Geom::Point const & _last_click_event_point ()
 
static Geom::Point const & _last_drag_origin ()
 
static bool _is_drag_cancelled (MotionEvent const &event)
 
- Protected Attributes inherited from Inkscape::UI::SelectableControlPoint
ControlPointSelection_selection
 
- Protected Attributes inherited from Inkscape::UI::ControlPoint
CanvasItemPtr< Inkscape::CanvasItemCtrl_canvas_item_ctrl
 Visual representation of the control point.
 
State _state = STATE_NORMAL
 
- Static Protected Attributes inherited from Inkscape::UI::ControlPoint
static bool _drag_initiated = false
 

Detailed Description

Definition at line 121 of file node.h.

Constructor & Destructor Documentation

◆ Node() [1/2]

Inkscape::UI::Node::Node ( NodeSharedData const &  data,
Geom::Point const &  pos 
)

Curve endpoint in an editable path.

The method move() keeps node type invariants during translations.

Definition at line 751 of file node.cpp.

References Inkscape::UI::ControlPoint::_canvas_item_ctrl.

◆ Node() [2/2]

Inkscape::UI::Node::Node ( Node const &  )
delete

Member Function Documentation

◆ _eventHandler()

◆ _getDragTip()

◆ _getTip()

◆ _hasDragTips()

bool Inkscape::UI::Node::_hasDragTips ( ) const
inlineoverrideprotectedvirtual

Reimplemented from Inkscape::UI::ControlPoint.

Definition at line 217 of file node.h.

◆ _is_line_segment()

bool Inkscape::UI::Node::_is_line_segment ( Node first,
Node second 
)
staticprivate

Determine whether two nodes are joined by a linear segment.

Definition at line 1725 of file node.cpp.

References _back, _front, _next(), and Inkscape::UI::Handle::isDegenerate().

Referenced by dragged(), fixNeighbors(), Inkscape::UI::Handle::move(), and setType().

◆ _linearGrow()

void Inkscape::UI::Node::_linearGrow ( int  dir)
private

Select or deselect a node in this node's subpath based on its path distance from this node.

Parameters
dirIf negative, shrink selection by one node; if positive, grow by one node.

Definition at line 1213 of file node.cpp.

References Inkscape::UI::SelectableControlPoint::_selection, Geom::bezier_length(), Inkscape::UI::ControlPointSelection::erase(), Inkscape::UI::NodeList::get_iterator(), Inkscape::UI::ControlPointSelection::insert(), Inkscape::UI::NodeIterator< N >::next(), Inkscape::UI::NodeIterator< N >::prev(), Inkscape::UI::NodeIterator< N >::ptr(), and Inkscape::UI::SelectableControlPoint::selected().

Referenced by _eventHandler().

◆ _next() [1/2]

◆ _next() [2/2]

Node const * Inkscape::UI::Node::_next ( ) const
private

Definition at line 763 of file node.cpp.

References _next().

◆ _pm() [1/2]

◆ _pm() [2/2]

PathManipulator & Inkscape::UI::Node::_pm ( ) const
inlineprivate

◆ _prev() [1/2]

◆ _prev() [2/2]

Node const * Inkscape::UI::Node::_prev ( ) const
private

Definition at line 779 of file node.cpp.

References _prev().

◆ _setState()

◆ _snapSourceType()

Inkscape::SnapSourceType Inkscape::UI::Node::_snapSourceType ( ) const
private

◆ _snapTargetType()

Inkscape::SnapTargetType Inkscape::UI::Node::_snapTargetType ( ) const
private

◆ _updateAutoHandles()

◆ back()

◆ bounds()

Geom::Rect Inkscape::UI::Node::bounds ( ) const
overridevirtual

◆ clicked()

bool Inkscape::UI::Node::clicked ( ButtonReleaseEvent const &  event)
overrideprotectedvirtual

Called when the control point is clicked, at mouse button release.

Improperly implementing this method can cause the default context menu not to appear when a control point is right-clicked.

Parameters
eventButton release event
Returns
true if the click had some effect, false if it did nothing.

Reimplemented from Inkscape::UI::ControlPoint.

Definition at line 1535 of file node.cpp.

References _pm(), and Inkscape::UI::SelectableControlPoint::clicked().

◆ dragged()

◆ fixNeighbors()

void Inkscape::UI::Node::fixNeighbors ( )
overridevirtual

Affine transforms keep handle invariants for smooth and symmetric nodes, but smooth nodes at ends of linear segments and auto nodes need special treatment.

Call this function once you have finished called move or transform on ALL nodes that are being transformed in that one operation to avoid problematic bugs.

Reimplemented from Inkscape::UI::ControlPoint.

Definition at line 887 of file node.cpp.

References _back, _front, _is_line_segment(), _next(), _prev(), _type, _unfixed_pos, _updateAutoHandles(), Inkscape::UI::Handle::isDegenerate(), Inkscape::UI::NODE_AUTO, Inkscape::UI::NODE_SMOOTH, Inkscape::UI::ControlPoint::position(), and Inkscape::UI::Handle::setDirection().

◆ front()

◆ grabbed()

bool Inkscape::UI::Node::grabbed ( MotionEvent const &  event)
overrideprotectedvirtual

◆ handleAwayFrom()

Handle * Inkscape::UI::Node::handleAwayFrom ( Node to)

Gets the handle that goes in the direction opposite to the given adjacent node.

Will abort with error if the given node is not adjacent.

Definition at line 1586 of file node.cpp.

References _next(), _prev(), back(), and front().

Referenced by Inkscape::UI::Handle::move().

◆ handleToward()

Handle * Inkscape::UI::Node::handleToward ( Node to)

Gets the handle that faces the given adjacent node.

Will abort with error if the given node is not adjacent.

Definition at line 1562 of file node.cpp.

References _next(), _prev(), back(), and front().

Referenced by Inkscape::UI::Handle::move().

◆ isDegenerate()

bool Inkscape::UI::Node::isDegenerate ( ) const
inline

Definition at line 162 of file node.h.

References _back, _front, and Inkscape::UI::Handle::isDegenerate().

Referenced by setType().

◆ isEndNode()

bool Inkscape::UI::Node::isEndNode ( ) const

Definition at line 1145 of file node.cpp.

References _next(), and _prev().

Referenced by _updateAutoHandles(), and setType().

◆ move()

void Inkscape::UI::Node::move ( Geom::Point const &  pos)
overridevirtual

Move the control point to new position with side effects.

This is called after each drag. Override this method if only some positions make sense for a control point (like a point that must always be on a path and can't modify it), or when moving a control point changes the positions of other points.

Reimplemented from Inkscape::UI::ControlPoint.

Definition at line 794 of file node.cpp.

References _back, Inkscape::UI::PathManipulator::_bsplineHandlePosition(), Inkscape::UI::ControlPoint::_desktop, _front, _pm(), _unfixed_pos, back(), delta, front(), Inkscape::UI::NO_POWER, Inkscape::UI::ControlPoint::position(), Inkscape::UI::Handle::setPosition(), Inkscape::UI::ControlPoint::setPosition(), and Inkscape::UI::Tools::sp_update_helperpath().

◆ node_type_to_localized_string()

char const * Inkscape::UI::Node::node_type_to_localized_string ( NodeType  type)
static

◆ nodeAwayFrom()

Node * Inkscape::UI::Node::nodeAwayFrom ( Handle h)

Gets the node in the direction opposite to the given handle.

Will abort with error if the handle doesn't belong to this node.

Definition at line 1598 of file node.cpp.

References _next(), _prev(), back(), and front().

Referenced by Inkscape::UI::Handle::dragged(), and Inkscape::UI::Handle::move().

◆ nodeList() [1/2]

NodeList & Inkscape::UI::Node::nodeList ( )
inline

Definition at line 191 of file node.h.

References Inkscape::UI::ListNode::ln_list.

Referenced by _pm(), and _pm().

◆ nodeList() [2/2]

NodeList & Inkscape::UI::Node::nodeList ( ) const
inline

Definition at line 192 of file node.h.

References Inkscape::UI::ListNode::ln_list.

◆ nodeToward()

Node * Inkscape::UI::Node::nodeToward ( Handle h)

Gets the node in the direction of the given handle.

Will abort with error if the handle doesn't belong to this node.

Definition at line 1574 of file node.cpp.

References _next(), _prev(), back(), and front().

Referenced by Inkscape::UI::Handle::move().

◆ parse_nodetype()

◆ pickBestType()

void Inkscape::UI::Node::pickBestType ( )

Pick the best type for this node, based on the position of its handles.

This is what assigns types to nodes created using the pen tool.

Definition at line 1103 of file node.cpp.

References _back, _front, _next(), _prev(), Inkscape::UI::ControlPoint::_setControlType(), _type, Inkscape::UI::Handle::isDegenerate(), Inkscape::UI::NODE_CUSP, Inkscape::UI::NODE_SMOOTH, Inkscape::UI::ControlPoint::position(), and Inkscape::UI::SelectableControlPoint::updateState().

Referenced by setType().

◆ setType()

void Inkscape::UI::Node::setType ( NodeType  type,
bool  update_handles = true 
)

◆ showHandles()

void Inkscape::UI::Node::showHandles ( bool  v)

◆ sink()

void Inkscape::UI::Node::sink ( )

Move the node to the bottom of its canvas group.

Useful for node break, to ensure that the selected nodes are above the unselected ones.

Definition at line 1150 of file node.cpp.

References Inkscape::UI::ControlPoint::_canvas_item_ctrl.

◆ snapCandidatePoint()

Inkscape::SnapCandidatePoint Inkscape::UI::Node::snapCandidatePoint ( )

◆ transform()

void Inkscape::UI::Node::transform ( Geom::Affine const &  m)
overridevirtual

Apply an arbitrary affine transformation to a control point.

This is used by ControlPointSelection, and is important for things like nodes with handles. The default implementation simply moves the point according to the transform.

Reimplemented from Inkscape::UI::ControlPoint.

Definition at line 835 of file node.cpp.

References _back, Inkscape::UI::PathManipulator::_bsplineHandlePosition(), _front, _pm(), _unfixed_pos, back(), front(), Inkscape::UI::NO_POWER, Inkscape::UI::ControlPoint::position(), Inkscape::UI::Handle::setPosition(), and Inkscape::UI::ControlPoint::setPosition().

◆ type()

NodeType Inkscape::UI::Node::type ( ) const
inline

Definition at line 140 of file node.h.

References _type.

Referenced by Inkscape::UI::Handle::move(), node_type_to_localized_string(), and setType().

◆ updateHandles()

void Inkscape::UI::Node::updateHandles ( )

Definition at line 974 of file node.cpp.

References _back, _front, and Inkscape::UI::ControlPoint::_handleControlStyling().

Friends And Related Symbol Documentation

◆ Handle

friend class Handle
friend

Definition at line 252 of file node.h.

◆ NodeIterator< Node >

friend class NodeIterator< Node >
friend

Definition at line 253 of file node.h.

◆ NodeIterator< Node const >

friend class NodeIterator< Node const >
friend

Definition at line 253 of file node.h.

◆ NodeList

friend class NodeList
friend

Definition at line 253 of file node.h.

Member Data Documentation

◆ _back

Handle Inkscape::UI::Node::_back
private

◆ _front

Handle Inkscape::UI::Node::_front
private

Node handle in the backward direction of the path.

Definition at line 243 of file node.h.

Referenced by _getTip(), _is_line_segment(), _updateAutoHandles(), bounds(), dragged(), fixNeighbors(), front(), grabbed(), isDegenerate(), move(), pickBestType(), setType(), showHandles(), transform(), and updateHandles().

◆ _handles_shown

bool Inkscape::UI::Node::_handles_shown
private

Definition at line 246 of file node.h.

Referenced by Inkscape::UI::Handle::setPosition(), and showHandles().

◆ _type

NodeType Inkscape::UI::Node::_type
private

Type of node - cusp, smooth...

Definition at line 245 of file node.h.

Referenced by Inkscape::UI::Handle::_eventHandler(), _getTip(), _snapSourceType(), _snapTargetType(), dragged(), fixNeighbors(), pickBestType(), setType(), and type().

◆ _unfixed_pos

std::optional<Geom::Point> Inkscape::UI::Node::_unfixed_pos
private

Definition at line 250 of file node.h.

Referenced by fixNeighbors(), move(), and transform().


The documentation for this class was generated from the following files: