seltrans.h revision 48061050b8a8ee6514eb6847620c7bc6b265b3c4
0N/A#ifndef SEEN_SELTRANS_H
0N/A#define SEEN_SELTRANS_H
0N/A
0N/A/*
0N/A * Helper object for transforming selected items
0N/A *
0N/A * Authors:
0N/A * Lauris Kaplinski <lauris@kaplinski.com>
0N/A * Carl Hetherington <inkscape@carlh.net>
0N/A * Diederik van Lierop <mail@diedenrezi.nl>
0N/A *
0N/A * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
0N/A * Copyright (C) 1999-2002 Lauris Kaplinski
0N/A *
0N/A * Released under GNU GPL, read the file 'COPYING' for more information
0N/A */
0N/A
0N/A#include <stddef.h>
0N/A#include <sigc++/sigc++.h>
0N/A#include <2geom/point.h>
0N/A#include <2geom/affine.h>
0N/A#include <2geom/rect.h>
0N/A#include "knot.h"
0N/A#include "selcue.h"
0N/A#include "message-context.h"
0N/A#include <vector>
0N/A#include "sp-item.h"
0N/A
0N/Astruct SPKnot;
0N/Aclass SPDesktop;
0N/Aclass SPCanvasItem;
0N/Aclass SPSelTransHandle;
0N/A
0N/Anamespace Inkscape
0N/A{
0N/A
0N/AGeom::Scale calcScaleFactors(Geom::Point const &initial_point, Geom::Point const &new_point, Geom::Point const &origin, bool const skew = false);
0N/A
0N/Anamespace XML
0N/A{
0N/A class Node;
0N/A}
0N/A
0N/Aclass SelTrans
0N/A{
0N/Apublic:
0N/A SelTrans(SPDesktop *desktop);
0N/A ~SelTrans();
0N/A
0N/A Inkscape::MessageContext &messageContext() {
0N/A return _message_context;
0N/A }
0N/A
0N/A void increaseState();
0N/A void resetState();
0N/A void setCenter(Geom::Point const &p);
0N/A void grab(Geom::Point const &p, gdouble x, gdouble y, bool show_handles, bool translating);
0N/A void transform(Geom::Affine const &rel_affine, Geom::Point const &norm);
0N/A void ungrab();
0N/A void stamp();
0N/A void moveTo(Geom::Point const &xy, guint state);
0N/A void stretch(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
0N/A void scale(Geom::Point &pt, guint state);
0N/A void skew(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
0N/A void rotate(Geom::Point &pt, guint state);
0N/A gboolean scaleRequest(Geom::Point &pt, guint state);
0N/A gboolean stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
0N/A gboolean skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
0N/A gboolean rotateRequest(Geom::Point &pt, guint state);
0N/A gboolean centerRequest(Geom::Point &pt, guint state);
0N/A
0N/A gboolean handleRequest(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle);
0N/A void handleGrab(SPKnot *knot, guint state, SPSelTransHandle const &handle);
0N/A void handleClick(SPKnot *knot, guint state, SPSelTransHandle const &handle);
0N/A void handleNewEvent(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle);
0N/A
0N/A enum Show
0N/A {
0N/A SHOW_CONTENT,
0N/A SHOW_OUTLINE
0N/A };
0N/A
0N/A void setShow(Show s) {
0N/A _show = s;
0N/A }
0N/A bool isEmpty() {
0N/A return _empty;
0N/A }
0N/A bool isGrabbed() {
0N/A return _grabbed;
0N/A }
0N/A bool centerIsVisible() {
0N/A return ( _chandle && SP_KNOT_IS_VISIBLE (_chandle) );
0N/A }
0N/A
0N/A void getNextClosestPoint(bool reverse);
0N/A
0N/Aprivate:
0N/A void _updateHandles();
0N/A void _updateVolatileState();
0N/A void _selChanged(Inkscape::Selection *selection);
0N/A void _selModified(Inkscape::Selection *selection, guint flags);
0N/A void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num,
0N/A gchar const *even_tip, gchar const *odd_tip);
0N/A Geom::Point _getGeomHandlePos(Geom::Point const &visual_handle_pos);
0N/A Geom::Point _calcAbsAffineDefault(Geom::Scale const default_scale);
0N/A Geom::Point _calcAbsAffineGeom(Geom::Scale const geom_scale);
0N/A void _keepClosestPointOnly(Geom::Point const &p);
0N/A
0N/A enum State {
0N/A STATE_SCALE, //scale or stretch
0N/A STATE_ROTATE //rotate or skew
0N/A };
0N/A
0N/A SPDesktop *_desktop;
0N/A
0N/A std::vector<SPItem *> _items;
0N/A std::vector<SPItem const *> _items_const;
0N/A std::vector<Geom::Affine> _items_affines;
0N/A std::vector<Geom::Point> _items_centers;
0N/A
0N/A std::vector<Inkscape::SnapCandidatePoint> _snap_points;
0N/A std::vector<Inkscape::SnapCandidatePoint> _bbox_points;
0N/A std::vector<Inkscape::SnapCandidatePoint> _all_snap_sources_sorted;
0N/A std::vector<Inkscape::SnapCandidatePoint>::iterator _all_snap_sources_iter;
0N/A Inkscape::SelCue _selcue;
0N/A
0N/A Inkscape::Selection *_selection;
0N/A State _state;
0N/A Show _show;
0N/A
0N/A bool _grabbed;
0N/A bool _show_handles;
0N/A bool _empty;
0N/A bool _changed;
0N/A
0N/A SPItem::BBoxType _snap_bbox_type;
0N/A
0N/A Geom::OptRect _bbox;
0N/A Geom::OptRect _visual_bbox;
0N/A Geom::OptRect _geometric_bbox;
0N/A gdouble _strokewidth;
0N/A
0N/A Geom::Affine _current_relative_affine;
0N/A Geom::Affine _absolute_affine;
0N/A Geom::Affine _relative_affine;
0N/A /* According to Merriam - Webster's online dictionary
0N/A * Affine: a transformation (as a translation, a rotation, or a uniform stretching) that carries straight
0N/A * lines into straight lines and parallel lines into parallel lines but may alter distance between points
0N/A * and angles between lines <affine geometry>
0N/A */
0N/A
0N/A Geom::Point _opposite; ///< opposite point to where a scale is taking place
0N/A Geom::Point _opposite_for_specpoints;
0N/A Geom::Point _opposite_for_bboxpoints;
0N/A Geom::Point _origin_for_specpoints;
0N/A Geom::Point _origin_for_bboxpoints;
0N/A
0N/A gdouble _handle_x;
0N/A gdouble _handle_y;
0N/A
0N/A boost::optional<Geom::Point> _center;
0N/A bool _center_is_set; ///< we've already set _center, no need to reread it from items
0N/A
0N/A SPKnot *_shandle[8];
0N/A SPKnot *_rhandle[8];
0N/A SPKnot *_chandle;
0N/A SPCanvasItem *_norm;
0N/A SPCanvasItem *_grip;
0N/A SPCanvasItem *_l[4];
0N/A guint _sel_changed_id;
0N/A guint _sel_modified_id;
0N/A GSList *_stamp_cache;
0N/A
0N/A Geom::Point _origin; ///< position of origin for transforms
0N/A Geom::Point _point; ///< original position of the knot being used for the current transform
0N/A Geom::Point _point_geom; ///< original position of the knot being used for the current transform
0N/A Inkscape::MessageContext _message_context;
0N/A sigc::connection _sel_changed_connection;
0N/A sigc::connection _sel_modified_connection;
0N/A};
0N/A
0N/A}
0N/A
0N/A#endif // SEEN_SELTRANS_H
0N/A
0N/A
0N/A/*
0N/A Local Variables:
0N/A mode:c++
0N/A c-file-style:"stroustrup"
0N/A c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
0N/A indent-tabs-mode:nil
0N/A fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :