control-point-selection.cpp revision bd80360f39d70d4a2622064a4fa0f29dd829d1ed
98N/A * Node selection - implementation 1351N/A * Krzysztof KosiĆski <tweenk.pl@gmail.com> 98N/A * Copyright (C) 2009 Authors 919N/A * Released under GNU GPL, read the file 'COPYING' for more information 919N/A * @class ControlPointSelection 919N/A * @brief Group of selected control points. 98N/A * Some operations can be performed on all selected points regardless of their type, therefore 98N/A * this class is also a Manipulator. It handles the transformations of points using 98N/A * The exposed interface is similar to that of an STL set. Internally, a hash map is used. 98N/A * @todo Correct iterators (that don't expose the connection list) 911N/A/** @var ControlPointSelection::signal_update 1370N/A * Fires when the display needs to be updated to reflect changes. 1370N/A/** @var ControlPointSelection::signal_point_changed 911N/A * Fires when a control point is added to or removed from the selection. 98N/A * The first param contains a pointer to the control point that changed sel. state. 1370N/A * The second says whether the point is currently selected. 1351N/A/** @var ControlPointSelection::signal_commit 1351N/A * Fires when a change that needs to be committed to XML happens. /** Add a control point to the selection. */ /** Remove a point from the selection. */ /** Remove all points from the selection, making it empty. */ /** Select all points that this selection can contain. */ /** Select all points inside the given rectangle (in desktop coordinates). */ /** Unselect all selected points and select all unselected points. */ // use >= to also deselect the origin node when it's the last one selected /** Transform all selected control points by the given affine transformation. */ // TODO preserving the rotation radius needs some rethinking... /** Align control points on the specified axis. */ /** Equdistantly distribute control points by moving them in the specified dimension. */ // this needs to be a multimap, otherwise it will fail when some points have the same coord // first we insert all points into a multimap keyed by the aligned coord to sort them // simultaneously we compute the extent of selection // now we iterate over the multimap and set aligned positions. /** Get the bounds of the selection. * @return Smallest rectangle containing the positions of all selected points, * or nothing if the selection is empty */ // clicking a selected node should toggle the transform handles between rotate and scale mode, /** Moves the selected points along the supplied unit vector according to * the modifier state of the supplied event. */ /** Rotates the selected points in the given direction according to the modifier state * from the supplied event. * @param event Key event to take modifier state from * @param dir Direction of rotation (math convention: 1 = counterclockwise, -1 = clockwise) if (
empty())
return false;
for (
unsigned i = 0; i <
4; ++i) {
// Rotate by "one pixel". We interpret this as rotating by an angle that causes // the topmost point of a circle circumscribed about the selection's bounding box // to move on an arc 1 screen pixel long. // translate to origin, rotate, translate back to original position if (
empty())
return false;
// TODO should the saved rotation center or the current center be used? // Scale by "one pixel". It means shrink/grow 1px for the larger dimension if (
empty())
return false;
// implement generic event handling that should apply for all control point selections here; // for example, keyboard moves and transformations. This way this functionality doesn't need // to be duplicated in many places // Later split out so that it can be reused in object selection // do not handle key events if the selection is empty // NOTE: H is horizontal flip, while Shift+H switches transform handle mode! // any modifiers except shift should cause no action c-file-style:"stroustrup" c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :