seltrans.cpp revision d190791228fa8662b1de5a4d67265585c6ea663c
/** @file
* @brief Helper object for transforming selected items
*/
/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Carl Hetherington <inkscape@carlh.net>
* Diederik van Lierop <mail@diedenrezi.nl>
*
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 1999-2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <cstring>
#include <string>
#include <gdk/gdkkeysyms.h>
#include "document.h"
#include "sp-namedview.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "knot.h"
#include "snap.h"
#include "selection.h"
#include "select-context.h"
#include "sp-item.h"
#include "sp-item-transform.h"
#include "seltrans-handles.h"
#include "seltrans.h"
#include "selection-chemistry.h"
#include "sp-metrics.h"
#include "verbs.h"
#include "display/sp-ctrlline.h"
#include "preferences.h"
#include "mod360.h"
#include "display/snap-indicator.h"
static void sp_sel_trans_handle_new_event(SPKnot *knot, Geom::Point *position, guint32 state, gpointer data);
static gboolean sp_sel_trans_handle_request(SPKnot *knot, Geom::Point *p, guint state, gboolean *data);
{
case GDK_MOTION_NOTIFY:
break;
case GDK_KEY_PRESS:
/* stamping mode: both mode(show content and outline) operation with knot */
if (!SP_KNOT_IS_GRABBED(knot)) {
return FALSE;
}
return TRUE;
}
break;
default:
break;
}
return FALSE;
}
_grabbed(false),
_show_handles(true),
_bbox(),
{
for (int i = 0; i < 8; i++) {
}
_center_is_set = false; // reread _center from items, or set to bbox midpoint
"anchor", GTK_ANCHOR_CENTER,
"mode", SP_CTRL_MODE_COLOR,
"shape", SP_CTRL_SHAPE_BITMAP,
"size", 13.0,
"filled", TRUE,
"fill_color", 0x00000000,
"stroked", TRUE,
"stroke_color", 0x000000a0,
NULL);
"anchor", GTK_ANCHOR_CENTER,
"mode", SP_CTRL_MODE_XOR,
"shape", SP_CTRL_SHAPE_CROSS,
"size", 7.0,
"filled", TRUE,
"fill_color", 0xffffff7f,
"stroked", TRUE,
"stroke_color", 0xffffffff,
NULL);
for (int i = 0; i < 4; i++) {
sp_canvas_item_hide(_l[i]);
}
);
);
}
{
for (unsigned int i = 0; i < 8; i++) {
if (_shandle[i]) {
}
if (_rhandle[i]) {
}
}
if (_chandle) {
}
if (_norm) {
}
if (_grip) {
}
for (int i = 0; i < 4; i++) {
if (_l[i]) {
}
}
}
}
{
}
{
if (_state == STATE_SCALE) {
} else {
}
_center_is_set = true; // no need to reread center
}
{
_center = p;
_center_is_set = true;
// Write the new center position into all selected items
// only set the value; updating repr and document_done will be done once, on ungrab
}
}
void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool show_handles, bool translating)
{
// While dragging a handle, we will either scale, skew, or rotate and the "translating" parameter will be false
// When dragging the selected item itself however, we will translate the selection and that parameter will be true
_grabbed = true;
_changed = false;
if (_empty) {
return;
}
_items_centers.push_back(it->getCenter()); // for content-dragging, we need to remember original centers
}
_handle_x = x;
_handle_y = y;
// The selector tool should snap the bbox, special snappoints, and path nodes
// (The special points are the handles, center, rotation axis, font baseline, ends of spiral, etc.)
// First, determine the bounding box
_approximate_bbox = selection->bounds(SPItem::APPROXIMATE_BBOX); // Used for correctly scaling the strokewidth
_point = p;
if (_geometric_bbox) {
} else {
_point_geom = p;
}
// Next, get all points to consider for snapping
// have been turned off because (for example) the user only want paths as a snap target, not nodes
// but as a snap source we still need some nodes though!
std::vector<Inkscape::SnapCandidatePoint> snap_points_hull = selection->getSnapPointsConvexHull(&local_snapprefs);
/* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
An average user would rarely ever try to snap such a large number of nodes anyway, because
(s)he could hardly discern which node would be snapping */
} else {
}
// Unfortunately, by now we will have lost the font-baseline snappoints :-(
}
// Find bbox hulling all special points, which excludes stroke width. Here we need to include the
// path nodes, for example because a rectangle which has been converted to a path doesn't have
// any other special points
if ( snap_points_hull.empty() == false ) {
i++;
while (i != snap_points_hull.end()) {
i++;
}
}
// Collect the bounding box's corners and midpoints for each selected item
if (m.snapprefs.getSnapModeBBox()) {
// Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations
// this is easy to do, but when snapping the visual bbox while scaling we will have to compensate for the scaling of the
// stroke width. (see get_scale_transform_with_stroke()). This however is currently only implemented for a single bbox.
// That's why we have both _bbox_points_for_translating and _bbox_points.
if (((_items.size() > 0) && (_items.size() < 50)) || prefs->getBool("/options/snapclosestonly/value", false)) {
// More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl
// (see the comment a few lines above). In that case we will use the bbox of the selection as a whole
getBBoxPoints(sp_item_bbox_desktop(_items[i], _snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp);
}
} else {
}
}
if (_bbox) {
// There are two separate "opposites" (i.e. opposite w.r.t. the handle being dragged):
// - one for snapping the boundingbox, which can be either visual or geometric
// - one for snapping the special points
// The "opposite" in case of a geometric boundingbox always coincides with the "opposite" for the special points
// These distinct "opposites" are needed in the snapmanager to avoid bugs such as #sf1540195 (in which
// a box is caught between two guides)
_opposite_for_specpoints = snap_points_bbox.min() + snap_points_bbox.dimensions() * Geom::Scale(1-x, 1-y);
}
// When snapping the node closest to the mouse pointer is absolutely preferred over the closest snap
// (i.e. when weight == 1), then we will not even try to snap to other points and discard those other
// points immediately.
if (m.snapprefs.getSnapModeNode()) {
} else {
}
if (m.snapprefs.getSnapModeBBox()) {
} else {
}
// Each of the three vectors of snappoints now contains either one snappoint or none at all.
if (_snap_points.size() > 1 || _bbox_points.size() > 1 || _bbox_points_for_translating.size() > 1) {
g_warning("Incorrect assumption encountered while finding the snap source; nothing serious, but please report to Diederik");
}
// Now let's reduce this to a single closest snappoint
Geom::Coord dsp = _snap_points.size() == 1 ? Geom::L2((_snap_points.at(0)).getPoint() - p) : NR_HUGE;
Geom::Coord dbbp = _bbox_points.size() == 1 ? Geom::L2((_bbox_points.at(0)).getPoint() - p) : NR_HUGE;
Geom::Coord dbbpft = _bbox_points_for_translating.size() == 1 ? Geom::L2((_bbox_points_for_translating.at(0)).getPoint() - p) : NR_HUGE;
if (translating) {
} else {
}
} else {
} else {
}
}
g_warning("Checking number of snap sources failed; nothing serious, but please report to Diederik");
}
// Optionally, show the snap source
if (!(_state == STATE_ROTATE && x != 0.5 && y != 0.5)) { // but not when we're dragging a rotation handle, because that won't snap
// Now either _bbox_points or _snap_points has a single element, the other one has zero..... or both have zero elements
g_warning("too many snap sources to display, please fix this");
} else if (m.snapprefs.getSnapEnabledGlobally()) {
}
}
}
}
if ((x != -1) && (y != -1)) {
}
if (_show == SHOW_OUTLINE) {
for (int i = 0; i < 4; i++)
sp_canvas_item_show(_l[i]);
}
}
{
if (_show == SHOW_CONTENT) {
// update the content
}
} else {
if (_bbox) {
/* update the outline */
for (unsigned i = 0 ; i < 4 ; i++) {
}
for (unsigned i = 0 ; i < 4 ; i++) {
}
}
}
_changed = true;
}
{
_grabbed = false;
_show_handles = true;
}
if (_show == SHOW_OUTLINE) {
for (int i = 0; i < 4; i++)
sp_canvas_item_hide(_l[i]);
}
if (_stamp_cache) {
_stamp_cache = NULL;
}
sp_selection_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE)? true : false);
if (_center) {
_center_is_set = true;
}
// If dragging showed content live, sp_selection_apply_affine cannot change the centers
// appropriately - it does not know the original positions of the centers (all objects already have
// the new bboxes). So we need to reset the centers from our saved array.
for (unsigned i = 0; i < _items_centers.size(); i++) {
}
}
}
if (_current_relative_affine.isTranslation()) {
_("Move"));
_("Scale"));
_("Rotate"));
} else {
_("Skew"));
}
} else {
if (_center_is_set) {
// we were dragging center; update reprs and commit undoable action
}
_("Set center"));
}
}
}
/* fixme: This is really bad, as we compare positions for each stamp (Lauris) */
/* fixme: IMHO the best way to keep sort cache would be to implement timestamping at last */
{
if ( fixup && _stamp_cache ) {
// TODO - give a proper fix. Simple temproary work-around for the grab() issue
_stamp_cache = NULL;
}
/* stamping mode */
if (!_empty) {
GSList *l;
if (_stamp_cache) {
l = _stamp_cache;
} else {
/* Build cache */
_stamp_cache = l;
}
while (l) {
// remember the position of the item
// remember parent
// add the new repr to the parent
// move to the saved position
if (_show == SHOW_OUTLINE) {
} else {
}
}
l = l->next;
}
_("Stamp"));
}
if ( fixup && _stamp_cache ) {
// TODO - give a proper fix. Simple temproary work-around for the grab() issue
_stamp_cache = NULL;
}
}
{
if ( !_show_handles || _empty )
{
return;
}
// center handle
_chandle = sp_knot_new(_desktop, _("<b>Center</b> of rotation and skewing: drag to reposition; scaling with Shift also uses this center"));
}
if ( _state == STATE_SCALE ) {
_("<b>Squeeze or stretch</b> selection; with <b>Ctrl</b> to scale uniformly; with <b>Shift</b> to scale around rotation center"),
_("<b>Scale</b> selection; with <b>Ctrl</b> to scale uniformly; with <b>Shift</b> to scale around rotation center"));
} else {
_("<b>Skew</b> selection; with <b>Ctrl</b> to snap angle; with <b>Shift</b> to skew around the opposite side"),
_("<b>Rotate</b> selection; with <b>Ctrl</b> to snap angle; with <b>Shift</b> to rotate around the opposite corner"));
}
if (!_center_is_set) {
_center_is_set = true;
}
} else {
}
}
{
if (_empty) {
return;
}
//Update the bboxes
if (!_bbox) {
_empty = true;
return;
}
}
{
for (int i = 0; i < num; i++) {
sp_knot_hide(knot[i]);
}
}
}
{
g_return_if_fail( !_empty );
for (int i = 0; i < num; i++) {
sp_knot_update_ctrl(knot[i]);
g_signal_connect(G_OBJECT(knot[i]), "event", G_CALLBACK(sp_seltrans_handle_event), (gpointer) &handle[i]);
}
sp_knot_show(knot[i]);
// shouldn't have nullary bbox, but knots
+ ( _bbox->dimensions()
sp_knot_moveto(knot[i], p);
}
}
{
);
}
{
}
static void sp_sel_trans_handle_new_event(SPKnot *knot, Geom::Point *position, guint state, gpointer data)
{
);
}
static gboolean sp_sel_trans_handle_request(SPKnot *knot, Geom::Point *position, guint state, gboolean *data)
{
);
}
{
);
}
{
case GTK_ANCHOR_CENTER:
if (state & GDK_SHIFT_MASK) {
// Unset the center position for all selected items
it->unsetCenter();
_center_is_set = false; // center has changed
}
_("Reset center"));
}
break;
default:
break;
}
}
{
case GTK_ANCHOR_CENTER:
"shape", SP_CTRL_SHAPE_BITMAP,
"size", 13.0,
NULL);
break;
default:
"shape", SP_CTRL_SHAPE_CROSS,
"size", 7.0,
NULL);
break;
}
}
void Inkscape::SelTrans::handleNewEvent(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle)
{
if (!SP_KNOT_IS_GRABBED(knot)) {
return;
}
// in case items have been unhooked from the document, don't
// try to continue processing events for them.
return;
}
}
}
gboolean Inkscape::SelTrans::handleRequest(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle)
{
if (!SP_KNOT_IS_GRABBED(knot)) {
return TRUE;
}
// When holding shift while rotating or skewing, the transformation will be
// relative to the point opposite of the handle; otherwise it will be relative
// to the center as set for the selection
} else if (_center) {
} else {
// FIXME
return TRUE;
}
}
return TRUE;
}
{
if (!_grabbed) {
// reread in case it changed on the fly:
//SPItem::APPROXIMATE_BBOX will be replaced by SPItem::VISUAL_BBOX, as soon as the latter is implemented properly
_center_is_set = false; // center(s) may have changed
}
}
{
if (!_grabbed) {
// reset internal flag
_changed = false;
_center_is_set = false; // center(s) may have changed
}
}
/*
* handlers for handle move-request
*/
/** Returns -1 or 1 according to the sign of x. Returns 1 for 0 and NaN. */
static double sign(double const x)
{
return ( x < 0
? -1
: 1 );
}
{
}
{
}
{
}
{
}
{
}
{
// Calculate the scale factors, which can be either visual or geometric
// depending on which type of bbox is currently being used (see preferences -> selector tool)
// Find the scale factors for the geometric bbox
// We're scaling either the visual or the geometric bbox here (see the comment above)
for ( unsigned int i = 0 ; i < 2 ; i++ ) {
} else if (default_scale[i] != 0) {
}
}
// Update the knot position
// When scaling by an integer, snapping is not needed
} else {
// In all other cases we should try to snap now
// Scale is locked to a 1:1 aspect ratio, so that s[X] must be made to equal s[Y].
//
// The aspect-ratio must be locked before snapping
} else {
}
// Snap along a suitable constraint vector from the origin.
} else {
/* Scale aspect ratio is unlocked */
}
// We didn't snap at all! Don't update the handle position, just calculate the new transformation
// We snapped the bbox (which is either visual or geometric)
// Calculate the new transformation and update the handle position
} else {
// We snapped the special points (e.g. nodes), which are not at the visual bbox
// The handle location however (pt) might however be at the visual bbox, so we
// will have to calculate pt taking the stroke width into account
}
}
/* Status text */
_("<b>Scale</b>: %0.2f%% x %0.2f%%; with <b>Ctrl</b> to lock ratio"),
return TRUE;
}
gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state)
{
case GDK_TOP_SIDE:
case GDK_BOTTOM_SIDE:
break;
case GDK_LEFT_SIDE:
case GDK_RIGHT_SIDE:
break;
default:
return TRUE;
};
// Calculate the scale factors, which can be either visual or geometric
// depending on which type of bbox is currently being used (see preferences -> selector tool)
// Find the scale factors for the geometric bbox
} else if (default_scale[axis] != 0) {
}
// Calculate the new transformation and update the handle position
// When stretching by an integer, snapping is not needed
} else {
// In all other cases we should try to snap now
bb = m.constrainedSnapStretch(_bbox_points, _point, Geom::Coord(default_scale[axis]), _origin_for_bboxpoints, Geom::Dim2(axis), symmetrical);
sn = m.constrainedSnapStretch(_snap_points, _point, Geom::Coord(geom_scale[axis]), _origin_for_specpoints, Geom::Dim2(axis), symmetrical);
if (bb.getSnapped()) {
// We snapped the bbox (which is either visual or geometric)
}
if (sn.getSnapped()) {
}
if (symmetrical) {
// on ctrl, apply symmetrical scaling instead of stretching
// Preserve aspect ratio, but never flip in the dimension not being edited (by using fabs())
}
// We didn't snap at all! Don't update the handle position, just calculate the new transformation
// Calculate the new transformation and update the handle position
} else {
// We snapped the special points (e.g. nodes), which are not at the visual bbox
// The handle location however (pt) might however be at the visual bbox, so we
// will have to calculate pt taking the stroke width into account
}
}
// status text
_("<b>Scale</b>: %0.2f%% x %0.2f%%; with <b>Ctrl</b> to lock ratio"),
return TRUE;
}
gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state)
{
/* When skewing (or rotating):
* 1) the stroke width will not change. This makes life much easier because we don't have to
* account for that (like for scaling or stretching). As a consequence, all points will
* have the same origin for the transformation and for the snapping.
* 2) When holding shift, the transformation will be relative to the point opposite of
* the handle; otherwise it will be relative to the center as set for the selection
*/
case GDK_SB_H_DOUBLE_ARROW:
break;
case GDK_SB_V_DOUBLE_ARROW:
break;
default:
abort();
break;
}
return false;
}
// Calculate the scale factors, which can be either visual or geometric
// depending on which type of bbox is currently being used (see preferences -> selector tool)
// Prevent shrinking of the selected object, while allowing mirroring
} else {
// Allow expanding of the selected object by integer multiples
}
if (state & GDK_CONTROL_MASK) {
// Snap to defined angle increments
if (snaps) {
}
}
} else {
// Snap to objects, grids, guides
// When skewing, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapSkew" for details
Inkscape::SnappedPoint sn = m.constrainedSnapSkew(_snap_points, _point, constraint, s, _origin, Geom::Dim2(dim_b));
if (sn.getSnapped()) {
// We snapped something, so change the skew to reflect it
} else {
}
}
// Update the handle position
// Calculate the relative affine
for (int i = 0; i < 2; i++) {
}
}
// Update the status text
// TRANSLATORS: don't modify the first ";"
// (it will NOT be displayed as ";" - only the second one will be)
_("<b>Skew</b>: %0.2f°; with <b>Ctrl</b> to snap angle"),
degrees);
return TRUE;
}
{
/* When rotating (or skewing):
* 1) the stroke width will not change. This makes life much easier because we don't have to
* account for that (like for scaling or stretching). As a consequence, all points will
* have the same origin for the transformation and for the snapping.
* 2) When holding shift, the transformation will be relative to the point opposite of
* the handle; otherwise it will be relative to the center as set for the selection
*/
// rotate affine in rotate
double radians;
if (state & GDK_CONTROL_MASK) {
// Snap to defined angle increments
if (snaps) {
}
} else {
}
// Calculate the relative affine
// Update the handle position
// Update the status text
// TRANSLATORS: don't modify the first ";"
// (it will NOT be displayed as ";" - only the second one will be)
_("<b>Rotate</b>: %0.2f°; with <b>Ctrl</b> to snap angle"), degrees);
return TRUE;
}
// Move the item's transformation center
{
if (state & GDK_CONTROL_MASK) {
} else {
}
}
// screen pixels to snap center to bbox
#define SNAP_DIST 5
// FIXME: take from prefs
for (int i = 0; i < 2; i++) {
}
}
}
}
}
// status text
_message_context.setF(Inkscape::NORMAL_MESSAGE, _("Move <b>center</b> to %s, %s"), xs->str, ys->str);
return TRUE;
}
/*
* handlers for handle movement
*
*/
void sp_sel_trans_stretch(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &pt, guint state)
{
}
void sp_sel_trans_scale(Inkscape::SelTrans *seltrans, SPSelTransHandle const &, Geom::Point &pt, guint state)
{
}
void sp_sel_trans_skew(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &pt, guint state)
{
}
void sp_sel_trans_rotate(Inkscape::SelTrans *seltrans, SPSelTransHandle const &, Geom::Point &pt, guint state)
{
}
void Inkscape::SelTrans::stretch(SPSelTransHandle const &/*handle*/, Geom::Point &/*pt*/, guint /*state*/)
{
transform(_absolute_affine, Geom::Point(0, 0)); // we have already accounted for origin, so pass 0,0
}
{
transform(_absolute_affine, Geom::Point(0, 0)); // we have already accounted for origin, so pass 0,0
}
void Inkscape::SelTrans::skew(SPSelTransHandle const &/*handle*/, Geom::Point &/*pt*/, guint /*state*/)
{
}
{
}
void sp_sel_trans_center(Inkscape::SelTrans *seltrans, SPSelTransHandle const &, Geom::Point &pt, guint /*state*/)
{
}
{
/* The amount that we've moved by during this drag */
if (alt) {
// Alt pressed means: move only by integer multiples of the grid spacing
if (control) { // ... if also constrained to the orthogonal axes
} else {
}
}
} else if (shift) {
if (control) { // shift & control: constrained movement without snapping
} else {
}
}
} else { //!shift: with snapping
/* We're snapping to things, possibly with a constraint to horizontal or
** vertical movement. Obtain a list of possible translations and then
** pick the smallest.
*/
/* This will be our list of possible translations */
if (control) { // constrained movement with snapping
/* Snap to things, and also constrain to horizontal or vertical movement */
// When doing a constrained translation, all points will move in the same direction, i.e.
// either horizontally or vertically. Therefore we only have to specify the direction of
// the constraint-line once. The constraint lines are parallel, but might not be colinear.
// Therefore we will have to set the point through which the constraint-line runs
// individually for each point to be snapped; this will be handled however by _snapTransformed()
dxy));
dxy));
} else { // !control
// Let's leave this timer code here for a while. I'll probably need it in the near future (Diederik van Lierop)
/* GTimeVal starttime;
GTimeVal endtime;
g_get_current_time(&starttime); */
/* Snap to things with no constraint */
/*g_get_current_time(&endtime);
double elapsed = ((((double)endtime.tv_sec - starttime.tv_sec) * G_USEC_PER_SEC + (endtime.tv_usec - starttime.tv_usec))) / 1000.0;
std::cout << "Time spent snapping: " << elapsed << std::endl; */
}
/* Pick one */
if (i->getSnapped()) {
if (best_snapped_point.isOtherSnapBetter(*i, true)) {
best_snapped_point = *i;
dxy = i->getTransformation();
}
}
}
if (best_snapped_point.getSnapped()) {
} else {
// We didn't snap, so remove any previous snap indicator
if (control) {
// If we didn't snap, then we should still constrain horizontally or vertically
// (When we did snap, then this constraint has already been enforced by
// calling constrainedSnapTranslation() above)
} else {
}
}
}
}
// status text
_message_context.setF(Inkscape::NORMAL_MESSAGE, _("<b>Move</b> by %s, %s; with <b>Ctrl</b> to restrict to horizontal/vertical; with <b>Shift</b> to disable snapping"), xs->str, ys->str);
}
// Given a location of a handle at the visual bounding box, find the corresponding location at the
// geometrical bounding box
{
// When the selector tool is using geometric bboxes, then the handle is already
// located at one of the geometric bbox corners
return visual_handle_pos;
}
if (!_geometric_bbox) {
//_getGeomHandlePos() can only be used after _geometric_bbox has been defined!
return visual_handle_pos;
}
// Using the Geom::Rect constructor below ensures that "min() < max()", which is important
// because this will also hold for _bbox, and which is required for get_scale_transform_with_stroke()
Geom::Rect new_bbox = Geom::Rect(_origin_for_bboxpoints, visual_handle_pos); // new visual bounding box
// Please note that the new_bbox might in fact be just a single line, for example when stretching (in
// which case the handle and origin will be aligned vertically or horizontally)
Geom::Point normalized_handle_pos = (visual_handle_pos - new_bbox.min()) * Geom::Scale(new_bbox.dimensions()).inverse();
// Calculate the absolute affine while taking into account the scaling of the stroke width
new_bbox.min()[Geom::X], new_bbox.min()[Geom::Y], new_bbox.max()[Geom::X], new_bbox.max()[Geom::Y]);
// Calculate the scaled geometrical bbox
Geom::Rect new_geom_bbox = Geom::Rect(_geometric_bbox->min() * abs_affine, _geometric_bbox->max() * abs_affine);
// Find the location of the handle on this new geometrical bbox
return normalized_handle_pos * Geom::Scale(new_geom_bbox.dimensions()) + new_geom_bbox.min(); //new position of the geometric handle
}
Geom::Scale Inkscape::calcScaleFactors(Geom::Point const &initial_point, Geom::Point const &new_point, Geom::Point const &origin, bool const skew)
{
// Work out the new scale factors for the bbox
for ( unsigned int i = 0 ; i < 2 ; i++ ) {
if (skew) {
} else {
}
}
}
return scale;
}
// Only for scaling/stretching
{
Geom::Matrix abs_affine = Geom::Translate(-_origin) * Geom::Matrix(default_scale) * Geom::Translate(_origin);
bool transform_stroke = false;
gdouble strokewidth = 0;
}
_absolute_affine = get_scale_transform_with_stroke (*_approximate_bbox, strokewidth, transform_stroke,
// return the new handle position
}
// Only for scaling/stretching
{
_absolute_affine = Geom::Translate(-_origin_for_specpoints) * _relative_affine * Geom::Translate(_origin_for_specpoints);
if (_geometric_bbox) {
Geom::Rect visual_bbox = get_visual_bbox(_geometric_bbox, _absolute_affine, _strokewidth, transform_stroke);
// return the new handle position
}
// Fall back scenario, in case we don't have a geometric bounding box at hand;
// (Due to some bugs related to bounding boxes having at least one zero dimension; For more details
g_warning("No geometric bounding box has been calculated; this is a bug that needs fixing!");
}
void Inkscape::SelTrans::_keepClosestPointOnly(std::vector<Inkscape::SnapCandidatePoint> &points, const Geom::Point &reference)
{
Inkscape::SnapCandidatePoint closest_point = Inkscape::SnapCandidatePoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, SNAPTARGET_UNDEFINED);
for(std::vector<Inkscape::SnapCandidatePoint>::const_iterator i = points.begin(); i != points.end(); i++) {
closest_point = *i;
closest_dist = dist;
}
}
}
/*
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:encoding=utf-8:textwidth=99 :