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

Group of selected control points. More...

#include <control-point-selection.h>

Inheritance diagram for Inkscape::UI::ControlPointSelection:
Inkscape::UI::Manipulator

Public Types

using set_type = std::unordered_set< SelectableControlPoint * >
 
using Set = set_type
 
using iterator = set_type::iterator
 
using const_iterator = set_type::const_iterator
 
using size_type = set_type::size_type
 
using value_type = SelectableControlPoint *
 
using key_type = SelectableControlPoint *
 

Public Member Functions

 ControlPointSelection (SPDesktop *d, Inkscape::CanvasItemGroup *th_group)
 
 ~ControlPointSelection () override
 
bool empty () const
 
size_type size () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
std::pair< iterator, bool > insert (const value_type &x, bool notify=true, bool to_update=true)
 Add a control point to the selection.
 
template<class InputIterator >
void insert (InputIterator first, InputIterator last)
 
void clear ()
 Remove all points from the selection, making it empty.
 
void erase (iterator pos, bool to_update=true)
 Remove a point from the selection.
 
size_type erase (const key_type &k, bool notify=true)
 
void erase (iterator first, iterator last)
 
iterator find (const key_type &k)
 
set_type const & allPoints () const
 
set_typeallPoints ()
 
void selectAll ()
 Select all points that this selection can contain.
 
void selectArea (Geom::Path const &, bool invert=false)
 Select all points inside the given rectangle (in desktop coordinates).
 
void invertSelection ()
 Unselect all selected points and select all unselected points.
 
void spatialGrow (SelectableControlPoint *origin, int dir)
 
bool event (Inkscape::UI::Tools::ToolBase *tool, CanvasEvent const &event) override
 Handle input event. Returns true if handled.
 
void transform (Geom::Affine const &m)
 Transform all selected control points by the given affine transformation.
 
void align (Geom::Dim2 d, AlignTargetNode target=AlignTargetNode::MID_NODE)
 Align control points on the specified axis.
 
void distribute (Geom::Dim2 d)
 Equdistantly distribute control points by moving them in the specified dimension.
 
Geom::OptRect pointwiseBounds ()
 Get the bounds of the selection.
 
Geom::OptRect bounds ()
 
std::optional< Geom::PointfirstSelectedPoint () const
 The first selected point is the first selection a user makes, but only if they selected exactly one point.
 
bool transformHandlesEnabled ()
 
void showTransformHandles (bool v, bool one_node)
 
void hideTransformHandles ()
 
void restoreTransformHandles ()
 
void toggleTransformHandlesMode ()
 
void getOriginalPoints (std::vector< Inkscape::SnapCandidatePoint > &pts)
 
void getUnselectedPoints (std::vector< Inkscape::SnapCandidatePoint > &pts)
 
void setOriginalPoints ()
 
- Public Member Functions inherited from Inkscape::UI::Manipulator
 Manipulator (SPDesktop *d)
 
virtual ~Manipulator ()=default
 

Public Attributes

sigc::signal< void()> signal_update
 Fires when the display needs to be updated to reflect changes.
 
sigc::signal< void(std::vector< SelectableControlPoint * >, bool)> signal_selection_changed
 
sigc::signal< void(CommitEvent)> signal_commit
 Fires when a change that needs to be committed to XML happens.
 
std::list< SelectableControlPoint * > _points_list
 
- Public Attributes inherited from Inkscape::UI::Manipulator
SPDesktop *const _desktop
 

Private Member Functions

void _pointGrabbed (SelectableControlPoint *)
 
void _pointDragged (Geom::Point &, MotionEvent const &)
 
void _pointUngrabbed ()
 
bool _pointClicked (SelectableControlPoint *, ButtonReleaseEvent const &)
 
void _mouseoverChanged ()
 
void _update ()
 
void _updateTransformHandles (bool preserve_center)
 
void _updateBounds ()
 
bool _keyboardMove (KeyPressEvent const &, Geom::Point const &)
 Moves the selected points along the supplied unit vector according to the modifier state of the supplied event.
 
bool _keyboardRotate (KeyPressEvent const &, int)
 Rotates the selected points in the given direction according to the modifier state from the supplied event.
 
bool _keyboardScale (KeyPressEvent const &, int)
 
bool _keyboardFlip (Geom::Dim2)
 
void _keyboardTransform (Geom::Affine const &)
 
void _commitHandlesTransform (CommitEvent ce)
 
double _rotationRadius (Geom::Point const &)
 Computes the distance to the farthest corner of the bounding box.
 

Private Attributes

set_type _points
 
set_type _all_points
 
std::unordered_map< SelectableControlPoint *, Geom::Point_original_positions
 
std::unordered_map< SelectableControlPoint *, Geom::Affine_last_trans
 
std::optional< double > _rot_radius
 
std::optional< double > _mouseover_rot_radius
 
std::optional< Geom::Point_first_point
 
Geom::OptRect _bounds
 
TransformHandleSet_handles
 
SelectableControlPoint_grabbed_point
 
SelectableControlPoint_farthest_point
 
unsigned _dragging: 1
 
unsigned _handles_visible: 1
 
unsigned _one_node_handles: 1
 

Friends

class SelectableControlPoint
 

Detailed Description

Group of selected control points.

Some operations can be performed on all selected points regardless of their type, therefore this class is also a Manipulator. It handles the transformations of points using the keyboard.

The exposed interface is similar to that of an STL set. Internally, a hash map is used.

Todo:
Correct iterators (that don't expose the connection list)

Definition at line 42 of file control-point-selection.h.

Member Typedef Documentation

◆ const_iterator

using Inkscape::UI::ControlPointSelection::const_iterator = set_type::const_iterator

Definition at line 53 of file control-point-selection.h.

◆ iterator

Definition at line 52 of file control-point-selection.h.

◆ key_type

◆ Set

◆ set_type

◆ size_type

Definition at line 54 of file control-point-selection.h.

◆ value_type

Constructor & Destructor Documentation

◆ ControlPointSelection()

◆ ~ControlPointSelection()

Inkscape::UI::ControlPointSelection::~ControlPointSelection ( )
override

Definition at line 72 of file control-point-selection.cpp.

References _handles, and clear().

Member Function Documentation

◆ _commitHandlesTransform()

void Inkscape::UI::ControlPointSelection::_commitHandlesTransform ( CommitEvent  ce)
private

◆ _keyboardFlip()

◆ _keyboardMove()

bool Inkscape::UI::ControlPointSelection::_keyboardMove ( KeyPressEvent const &  event,
Geom::Point const &  dir 
)
private

◆ _keyboardRotate()

bool Inkscape::UI::ControlPointSelection::_keyboardRotate ( KeyPressEvent const &  event,
int  dir 
)
private

Rotates the selected points in the given direction according to the modifier state from the supplied event.

Parameters
eventKey event to take modifier state from
dirDirection of rotation (math convention: 1 = counterclockwise, -1 = clockwise)

Definition at line 582 of file control-point-selection.cpp.

References Inkscape::UI::Manipulator::_desktop, _handles, _mouseover_rot_radius, _rot_radius, _rotationRadius(), Inkscape::UI::COMMIT_KEYBOARD_ROTATE, SPDesktop::current_zoom(), empty(), event(), Inkscape::Preferences::get(), Inkscape::Preferences::getIntLimited(), Inkscape::mod_alt(), Inkscape::UI::ControlPoint::mouseovered_point, Inkscape::UI::ControlPoint::position(), rc, Inkscape::UI::TransformHandleSet::rotationCenter(), signal_commit, and transform().

Referenced by event().

◆ _keyboardScale()

◆ _keyboardTransform()

void Inkscape::UI::ControlPointSelection::_keyboardTransform ( Geom::Affine const &  )
private

◆ _mouseoverChanged()

void Inkscape::UI::ControlPointSelection::_mouseoverChanged ( )
private

Definition at line 479 of file control-point-selection.cpp.

References _mouseover_rot_radius.

Referenced by ControlPointSelection().

◆ _pointClicked()

bool Inkscape::UI::ControlPointSelection::_pointClicked ( SelectableControlPoint p,
ButtonReleaseEvent const &  event 
)
private

◆ _pointDragged()

◆ _pointGrabbed()

◆ _pointUngrabbed()

◆ _rotationRadius()

double Inkscape::UI::ControlPointSelection::_rotationRadius ( Geom::Point const &  rc)
private

Computes the distance to the farthest corner of the bounding box.

Used to determine what it means to "rotate by one pixel".

Definition at line 564 of file control-point-selection.cpp.

References bounds(), Geom::GenericRect< C >::corner(), Geom::distance(), empty(), len, and rc.

Referenced by _keyboardRotate().

◆ _update()

◆ _updateBounds()

void Inkscape::UI::ControlPointSelection::_updateBounds ( )
private

◆ _updateTransformHandles()

◆ align()

◆ allPoints() [1/2]

set_type & Inkscape::UI::ControlPointSelection::allPoints ( )
inline

Definition at line 92 of file control-point-selection.h.

References _all_points.

◆ allPoints() [2/2]

◆ begin() [1/2]

iterator Inkscape::UI::ControlPointSelection::begin ( )
inline

◆ begin() [2/2]

const_iterator Inkscape::UI::ControlPointSelection::begin ( ) const
inline

Definition at line 64 of file control-point-selection.h.

References _points.

◆ bounds()

Geom::OptRect Inkscape::UI::ControlPointSelection::bounds ( )

◆ clear()

◆ distribute()

void Inkscape::UI::ControlPointSelection::distribute ( Geom::Dim2  d)

Equdistantly distribute control points by moving them in the specified dimension.

Definition at line 292 of file control-point-selection.cpp.

References _points, empty(), num, size(), Inkscape::UI::start, and Geom::GenericOptInterval< C >::unionWith().

Referenced by Inkscape::UI::MultiPathManipulator::distributeNodes().

◆ empty()

bool Inkscape::UI::ControlPointSelection::empty ( ) const
inline

Definition at line 59 of file control-point-selection.h.

References _points.

Referenced by Inkscape::UI::PathManipulator::_deleteSegments(), _keyboardFlip(), _keyboardRotate(), _keyboardScale(), _rotationRadius(), _update(), align(), Inkscape::UI::MultiPathManipulator::alignNodes(), Inkscape::UI::MultiPathManipulator::breakNodes(), clear(), Inkscape::UI::Toolbar::NodeToolbar::coord_changed(), Inkscape::UI::MultiPathManipulator::copySelectedPath(), Inkscape::UI::MultiPathManipulator::deleteNodes(), Inkscape::UI::PathManipulator::deleteNodes(), Inkscape::UI::MultiPathManipulator::deleteSegments(), distribute(), Inkscape::UI::MultiPathManipulator::distributeNodes(), Inkscape::UI::MultiPathManipulator::duplicateNodes(), Inkscape::UI::PathManipulator::duplicateNodes(), event(), Inkscape::UI::PathManipulator::extremeNode(), Inkscape::UI::MultiPathManipulator::insertNodes(), Inkscape::UI::MultiPathManipulator::insertNodesAtExtrema(), Inkscape::UI::MultiPathManipulator::joinNodes(), Inkscape::UI::MultiPathManipulator::joinSegments(), Inkscape::UI::MultiPathManipulator::move(), Inkscape::UI::MultiPathManipulator::reverseSubpaths(), Inkscape::UI::Tools::NodeTool::root_handler(), Inkscape::UI::MultiPathManipulator::scale(), Inkscape::UI::Tools::NodeTool::select_point(), Inkscape::SelectionHelper::selectNone(), Inkscape::UI::MultiPathManipulator::selectSubpaths(), Inkscape::UI::MultiPathManipulator::setNodeType(), Inkscape::UI::MultiPathManipulator::setSegmentType(), and Inkscape::UI::PathManipulator::setSegmentType().

◆ end() [1/2]

iterator Inkscape::UI::ControlPointSelection::end ( )
inline

Definition at line 65 of file control-point-selection.h.

References _points.

Referenced by clear(), and Inkscape::UI::SelectableControlPoint::selected().

◆ end() [2/2]

const_iterator Inkscape::UI::ControlPointSelection::end ( ) const
inline

Definition at line 66 of file control-point-selection.h.

References _points.

◆ erase() [1/3]

ControlPointSelection::size_type Inkscape::UI::ControlPointSelection::erase ( const key_type k,
bool  notify = true 
)

Definition at line 112 of file control-point-selection.cpp.

References _points, erase(), and signal_selection_changed.

◆ erase() [2/3]

void Inkscape::UI::ControlPointSelection::erase ( iterator  first,
iterator  last 
)

Definition at line 123 of file control-point-selection.cpp.

References _update(), erase(), and signal_selection_changed.

◆ erase() [3/3]

◆ event()

◆ find()

iterator Inkscape::UI::ControlPointSelection::find ( const key_type k)
inline

Definition at line 86 of file control-point-selection.h.

References _points.

Referenced by Inkscape::UI::SelectableControlPoint::selected().

◆ firstSelectedPoint()

std::optional< Geom::Point > Inkscape::UI::ControlPointSelection::firstSelectedPoint ( ) const

The first selected point is the first selection a user makes, but only if they selected exactly one point.

Selecting multiples at once does nothing.

Definition at line 339 of file control-point-selection.cpp.

References _first_point.

◆ getOriginalPoints()

void Inkscape::UI::ControlPointSelection::getOriginalPoints ( std::vector< Inkscape::SnapCandidatePoint > &  pts)

◆ getUnselectedPoints()

void Inkscape::UI::ControlPointSelection::getUnselectedPoints ( std::vector< Inkscape::SnapCandidatePoint > &  pts)

Definition at line 767 of file control-point-selection.cpp.

References allPoints(), and node.

◆ hideTransformHandles()

void Inkscape::UI::ControlPointSelection::hideTransformHandles ( )

◆ insert() [1/2]

◆ insert() [2/2]

template<class InputIterator >
void Inkscape::UI::ControlPointSelection::insert ( InputIterator  first,
InputIterator  last 
)
inline

Definition at line 71 of file control-point-selection.h.

References _update(), insert(), and signal_selection_changed.

◆ invertSelection()

void Inkscape::UI::ControlPointSelection::invertSelection ( )

Unselect all selected points and select all unselected points.

Definition at line 183 of file control-point-selection.cpp.

References _all_points, _update(), erase(), insert(), and signal_selection_changed.

Referenced by Inkscape::SelectionHelper::invertAllInAll(), and Inkscape::UI::Tools::NodeTool::select_area().

◆ pointwiseBounds()

Geom::OptRect Inkscape::UI::ControlPointSelection::pointwiseBounds ( )

Get the bounds of the selection.

Returns
Smallest rectangle containing the positions of all selected points, or nothing if the selection is empty

Definition at line 325 of file control-point-selection.cpp.

References _bounds.

Referenced by Inkscape::UI::Toolbar::NodeToolbar::coord_changed().

◆ restoreTransformHandles()

void Inkscape::UI::ControlPointSelection::restoreTransformHandles ( )

◆ selectAll()

void Inkscape::UI::ControlPointSelection::selectAll ( )

◆ selectArea()

void Inkscape::UI::ControlPointSelection::selectArea ( Geom::Path const &  path,
bool  invert = false 
)

Select all points inside the given rectangle (in desktop coordinates).

Definition at line 164 of file control-point-selection.cpp.

References _all_points, _update(), erase(), insert(), invert(), signal_selection_changed, and Geom::Path::winding().

Referenced by Inkscape::UI::Tools::NodeTool::select_area().

◆ setOriginalPoints()

void Inkscape::UI::ControlPointSelection::setOriginalPoints ( )

◆ showTransformHandles()

void Inkscape::UI::ControlPointSelection::showTransformHandles ( bool  v,
bool  one_node 
)

◆ size()

◆ spatialGrow()

void Inkscape::UI::ControlPointSelection::spatialGrow ( SelectableControlPoint origin,
int  dir 
)

◆ toggleTransformHandlesMode()

◆ transform()

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

◆ transformHandlesEnabled()

bool Inkscape::UI::ControlPointSelection::transformHandlesEnabled ( )
inline

Definition at line 109 of file control-point-selection.h.

References _handles_visible.

Referenced by Inkscape::UI::Node::_getTip().

Friends And Related Symbol Documentation

◆ SelectableControlPoint

friend class SelectableControlPoint
friend

Definition at line 165 of file control-point-selection.h.

Member Data Documentation

◆ _all_points

set_type Inkscape::UI::ControlPointSelection::_all_points
private

◆ _bounds

Geom::OptRect Inkscape::UI::ControlPointSelection::_bounds
private

Definition at line 158 of file control-point-selection.h.

Referenced by _update(), _updateBounds(), bounds(), and pointwiseBounds().

◆ _dragging

unsigned Inkscape::UI::ControlPointSelection::_dragging
private

◆ _farthest_point

SelectableControlPoint * Inkscape::UI::ControlPointSelection::_farthest_point
private

Definition at line 160 of file control-point-selection.h.

Referenced by _pointDragged(), _pointGrabbed(), and _pointUngrabbed().

◆ _first_point

std::optional<Geom::Point> Inkscape::UI::ControlPointSelection::_first_point
private

Definition at line 157 of file control-point-selection.h.

Referenced by _update(), and firstSelectedPoint().

◆ _grabbed_point

SelectableControlPoint* Inkscape::UI::ControlPointSelection::_grabbed_point
private

Definition at line 160 of file control-point-selection.h.

Referenced by _pointDragged(), _pointGrabbed(), and _pointUngrabbed().

◆ _handles

◆ _handles_visible

unsigned Inkscape::UI::ControlPointSelection::_handles_visible
private

◆ _last_trans

std::unordered_map<SelectableControlPoint *, Geom::Affine> Inkscape::UI::ControlPointSelection::_last_trans
private

Definition at line 154 of file control-point-selection.h.

Referenced by _pointDragged(), _pointGrabbed(), and _pointUngrabbed().

◆ _mouseover_rot_radius

std::optional<double> Inkscape::UI::ControlPointSelection::_mouseover_rot_radius
private

Definition at line 156 of file control-point-selection.h.

Referenced by _keyboardRotate(), _mouseoverChanged(), and transform().

◆ _one_node_handles

unsigned Inkscape::UI::ControlPointSelection::_one_node_handles
private

Definition at line 163 of file control-point-selection.h.

Referenced by _updateTransformHandles(), and showTransformHandles().

◆ _original_positions

std::unordered_map<SelectableControlPoint *, Geom::Point> Inkscape::UI::ControlPointSelection::_original_positions
private

◆ _points

◆ _points_list

std::list<SelectableControlPoint *> Inkscape::UI::ControlPointSelection::_points_list

Definition at line 127 of file control-point-selection.h.

Referenced by align(), clear(), erase(), and insert().

◆ _rot_radius

std::optional<double> Inkscape::UI::ControlPointSelection::_rot_radius
private

Definition at line 155 of file control-point-selection.h.

Referenced by _keyboardRotate(), _updateBounds(), and transform().

◆ signal_commit

Inkscape::UI::ControlPointSelection::signal_commit

◆ signal_selection_changed

◆ signal_update

Inkscape::UI::ControlPointSelection::signal_update

Fires when the display needs to be updated to reflect changes.

Definition at line 117 of file control-point-selection.h.

Referenced by Inkscape::UI::MultiPathManipulator::_commit(), _pointDragged(), ControlPointSelection(), Inkscape::UI::PathManipulator::PathManipulator(), and transform().


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