path-manipulator.h revision dabddfe3f78a4db2df25fca2ea0c2ac139c0c08d
1276N/A/** @file
1577N/A * Path manipulator - a component that edits a single path on-canvas
1276N/A */
1276N/A/* Authors:
1276N/A * Krzysztof KosiƄski <tweenk.pl@gmail.com>
479N/A *
851N/A * Copyright (C) 2009 Authors
479N/A * Released under GNU GPL, read the file 'COPYING' for more information
1003N/A */
479N/A
479N/A#ifndef SEEN_UI_TOOL_PATH_MANIPULATOR_H
479N/A#define SEEN_UI_TOOL_PATH_MANIPULATOR_H
479N/A
1276N/A#include <string>
479N/A#include <memory>
479N/A#include <2geom/pathvector.h>
479N/A#include <2geom/affine.h>
479N/A#include <boost/shared_ptr.hpp>
479N/A#include <boost/weak_ptr.hpp>
479N/A#include "ui/tool/node.h"
479N/A#include "ui/tool/manipulator.h"
851N/A#include "live_effects/lpe-bspline.h"
1003N/A
1577N/Astruct SPCanvasItem;
851N/Aclass SPCurve;
851N/Aclass SPPath;
851N/A
851N/Anamespace Inkscape {
851N/Anamespace XML { class Node; }
1577N/A
479N/Anamespace UI {
479N/A
479N/Aclass PathManipulator;
479N/Aclass ControlPointSelection;
479N/Aclass PathManipulatorObserver;
479N/Aclass CurveDragPoint;
479N/Aclass PathCanvasGroups;
479N/Aclass MultiPathManipulator;
1003N/Aclass Node;
851N/Aclass Handle;
479N/A
1003N/Astruct PathSharedData {
479N/A NodeSharedData node_data;
479N/A SPCanvasGroup *outline_group;
479N/A SPCanvasGroup *dragpoint_group;
479N/A};
1577N/A
1577N/A/**
1577N/A * Manipulator that edits a single path using nodes with handles.
1577N/A * Currently only cubic bezier and linear segments are supported, but this might change
1577N/A * some time in the future.
479N/A */
851N/Aclass PathManipulator : public PointManipulator {
1577N/Apublic:
479N/A typedef SPPath *ItemType;
1577N/A
479N/A PathManipulator(MultiPathManipulator &mpm, SPPath *path, Geom::Affine const &edit_trans,
851N/A guint32 outline_color, Glib::ustring lpe_key);
1577N/A ~PathManipulator();
479N/A virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *);
479N/A
479N/A bool empty();
479N/A void writeXML();
1276N/A void update(bool alert_LPE = false); // update display, but don't commit
1276N/A void clear(); // remove all nodes from manipulator
1276N/A SPPath *item() { return _path; }
1276N/A
1276N/A void selectSubpaths();
1276N/A void invertSelectionInSubpaths();
1276N/A
1276N/A void insertNodeAtExtremum(ExtremumType extremum);
void insertNodes();
void duplicateNodes();
void weldNodes(NodeList::iterator preserve_pos = NodeList::iterator());
void weldSegments();
void breakNodes();
void deleteNodes(bool keep_shape = true);
void deleteSegments();
void reverseSubpaths(bool selected_only);
void setSegmentType(SegmentType);
void scaleHandle(Node *n, int which, int dir, bool pixel);
void rotateHandle(Node *n, int which, int dir, bool pixel);
void showOutline(bool show);
void showHandles(bool show);
void showPathDirection(bool show);
void setLiveOutline(bool set);
void setLiveObjects(bool set);
void updateHandles();
void setControlsTransform(Geom::Affine const &);
void hideDragPoint();
MultiPathManipulator &mpm() { return _multi_path_manipulator; }
NodeList::iterator subdivideSegment(NodeList::iterator after, double t);
NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected,
bool search_unselected, bool closest);
int BSplineGetSteps();
// this is necessary for Tab-selection in MultiPathManipulator
SubpathList &subpathList() { return _subpaths; }
static bool is_item_type(void *item);
private:
typedef NodeList Subpath;
typedef boost::shared_ptr<NodeList> SubpathPtr;
void _createControlPointsFromGeometry();
bool isBSpline(bool recalculate);
double BSplineHandlePosition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h,double pos);
void BSplineNodeHandlesReposition(Node *n);
void _createGeometryFromControlPoints(bool alert_LPE = false);
unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape);
std::string _createTypeString();
void _updateOutline();
//void _setOutline(Geom::PathVector const &);
void _getGeometry();
void _setGeometry();
Glib::ustring _nodetypesKey();
Inkscape::XML::Node *_getXMLNode();
void _selectionChanged(SelectableControlPoint *p, bool selected);
bool _nodeClicked(Node *, GdkEventButton *);
void _handleGrabbed();
bool _handleClicked(Handle *, GdkEventButton *);
void _handleUngrabbed();
void _externalChange(unsigned type);
void _removeNodesFromSelection();
void _commit(Glib::ustring const &annotation);
void _commit(Glib::ustring const &annotation, gchar const *key);
void _updateDragPoint(Geom::Point const &);
void _updateOutlineOnZoomChange();
double _getStrokeTolerance();
Handle *_chooseHandle(Node *n, int which);
SubpathList _subpaths;
MultiPathManipulator &_multi_path_manipulator;
SPPath *_path; ///< can be an SPPath or an Inkscape::LivePathEffect::Effect !!!
SPCurve *_spcurve; // in item coordinates
SPCanvasItem *_outline;
CurveDragPoint *_dragpoint; // an invisible control point hoverng over curve
PathManipulatorObserver *_observer;
Geom::Affine _d2i_transform; ///< desktop-to-item transform
Geom::Affine _i2d_transform; ///< item-to-desktop transform, inverse of _d2i_transform
Geom::Affine _edit_transform; ///< additional transform to apply to editing controls
unsigned _num_selected; ///< number of selected nodes
bool _show_handles;
bool _show_outline;
bool _show_path_direction;
bool _live_outline;
bool _live_objects;
Glib::ustring _lpe_key;
friend class PathManipulatorObserver;
friend class CurveDragPoint;
friend class Node;
friend class Handle;
};
} // namespace UI
} // namespace Inkscape
#endif
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :