本文整理汇总了C++中SPDesktop::getSelection方法的典型用法代码示例。如果您正苦于以下问题:C++ SPDesktop::getSelection方法的具体用法?C++ SPDesktop::getSelection怎么用?C++ SPDesktop::getSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPDesktop
的用法示例。
在下文中一共展示了SPDesktop::getSelection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sp_arctb_open_state_changed
static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0);
}
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" )) {
return;
}
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
bool modmade = false;
if ( ege_select_one_action_get_active(act) != 0 ) {
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
Inkscape::XML::Node *repr = item->getRepr();
repr->setAttribute("sodipodi:open", "true");
item->updateRepr();
modmade = true;
}
}
} else {
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
Inkscape::XML::Node *repr = item->getRepr();
repr->setAttribute("sodipodi:open", NULL);
item->updateRepr();
modmade = true;
}
}
}
if (modmade) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ARC,
_("Arc: Change open/closed"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
示例2:
void
ExecutionEnv::reselect (void) {
if (_doc == NULL) {
return;
}
SPDocument * doc = _doc->doc();
if (doc == NULL) {
return;
}
SPDesktop *desktop = (SPDesktop *)_doc;
sp_namedview_document_from_window(desktop);
if (desktop == NULL) {
return;
}
Inkscape::Selection * selection = desktop->getSelection();
for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); ++i) {
SPObject * obj = doc->getObjectById(i->c_str());
if (obj != NULL) {
selection->add(obj);
}
}
return;
}
示例3: dialog
/** \brief Create an execution environment that will allow the effect
to execute independently.
\param effect The effect that we should execute
\param doc The Document to execute on
\param docCache The cache created for that document
\param show_working Show the working dialog
\param show_error Show the error dialog (not working)
Grabs the selection of the current document so that it can get
restored. Will generate a document cache if one isn't provided.
*/
ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Implementation::ImplementationDocumentCache * docCache, bool show_working, bool show_errors) :
_state(ExecutionEnv::INIT),
_visibleDialog(NULL),
_mainloop(NULL),
_doc(doc),
_docCache(docCache),
_effect(effect),
_show_working(show_working),
_show_errors(show_errors)
{
SPDesktop *desktop = (SPDesktop *)_doc;
sp_namedview_document_from_window(desktop);
if (desktop != NULL) {
std::vector<SPItem*> selected = desktop->getSelection()->itemList();
for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){
Glib::ustring selected_id;
selected_id = (*x)->getId();
_selected.insert(_selected.end(), selected_id);
//std::cout << "Selected: " << selected_id << std::endl;
}
}
genDocCache();
return;
}
示例4: sp_simplify_flatten
static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(obj, "desktop"));
std::vector<SPItem *> selected = desktop->getSelection()->itemList();
for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){
SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it);
if (lpeitem && lpeitem->hasPathEffect()){
PathEffectList lpelist = lpeitem->getEffectList();
std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
for (i = lpelist.begin(); i != lpelist.end(); ++i) {
LivePathEffectObject *lpeobj = (*i)->lpeobject;
if (lpeobj) {
Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
if (dynamic_cast<Inkscape::LivePathEffect::LPESimplify *>(lpe)) {
SPShape * shape = dynamic_cast<SPShape *>(lpeitem);
if(shape){
SPCurve * c = shape->getCurveBeforeLPE();
lpe->doEffect(c);
lpeitem->setCurrentPathEffect(*i);
if (lpelist.size() > 1){
lpeitem->removeCurrentPathEffect(true);
shape->setCurveBeforeLPE(c);
} else {
lpeitem->removeCurrentPathEffect(false);
shape->setCurve(c,0);
}
break;
}
}
}
}
}
}
}
示例5: perspective
static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis axis)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
SPDocument *document = desktop->getDocument();
// quit if run by the attr_changed or selection changed listener
if (g_object_get_data( dataKludge, "freeze" )) {
return;
}
// in turn, prevent listener from responding
g_object_set_data(dataKludge, "freeze", GINT_TO_POINTER(TRUE));
std::list<Persp3D *> sel_persps = desktop->getSelection()->perspList();
if (sel_persps.empty()) {
// this can happen when the document is created; we silently ignore it
return;
}
Persp3D *persp = sel_persps.front();
persp->perspective_impl->tmat.set_infinite_direction (axis,
gtk_adjustment_get_value(adj));
persp->updateRepr();
// TODO: use the correct axis here, too
DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
}
示例6: spdc_create_single_dot
void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) {
g_return_if_fail(!strcmp(tool, "/tools/freehand/pen") || !strcmp(tool, "/tools/freehand/pencil"));
Glib::ustring tool_path = tool;
SPDesktop *desktop = ec->desktop;
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
repr->setAttribute("sodipodi:type", "arc");
SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
Inkscape::GC::release(repr);
// apply the tool's current style
sp_desktop_apply_style_tool(desktop, repr, tool, false);
// find out stroke width (TODO: is there an easier way??)
double stroke_width = 3.0;
gchar const *style_str = repr->attribute("style");
if (style_str) {
SPStyle style(SP_ACTIVE_DOCUMENT);
style.mergeString(style_str);
stroke_width = style.stroke_width.computed;
}
// unset stroke and set fill color to former stroke color
gchar * str;
str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8);
repr->setAttribute("style", str);
g_free(str);
// put the circle where the mouse click occurred and set the diameter to the
// current stroke width, multiplied by the amount specified in the preferences
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Geom::Affine const i2d (item->i2dt_affine ());
Geom::Point pp = pt * i2d.inverse();
double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0);
if (event_state & GDK_MOD1_MASK) {
// TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size
// as specified in prefs. Very simple, but it might be sufficient in practice. If not,
// we need to devise something more sophisticated.
double s = g_random_double_range(-0.5, 0.5);
rad *= (1 + s);
}
if (event_state & GDK_SHIFT_MASK) {
// double the point size
rad *= 2;
}
sp_repr_set_svg_double (repr, "sodipodi:cx", pp[Geom::X]);
sp_repr_set_svg_double (repr, "sodipodi:cy", pp[Geom::Y]);
sp_repr_set_svg_double (repr, "sodipodi:rx", rad * stroke_width);
sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width);
item->updateRepr();
desktop->getSelection()->set(item);
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating single dot"));
DocumentUndo::done(desktop->getDocument(), SP_VERB_NONE, _("Create single dot"));
}
示例7: sp_pencil_tb_tolerance_value_changed
static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl)
{
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" )) {
return;
}
// in turn, prevent listener from responding
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
prefs->setDouble("/tools/freehand/pencil/tolerance",
gtk_adjustment_get_value(adj));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop"));
std::vector<SPItem *> selected = desktop->getSelection()->itemList();
for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){
SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it);
if (lpeitem && lpeitem->hasPathEffect()){
Inkscape::LivePathEffect::Effect* simplify = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY);
if(simplify){
Inkscape::LivePathEffect::LPESimplify *lpe_simplify = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(simplify->getLPEObj()->get_lpe());
if (lpe_simplify) {
double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
tol = tol/(100.0*(102.0-tol));
std::ostringstream ss;
ss << tol;
Inkscape::LivePathEffect::Effect* powerstroke = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE);
bool simplified = false;
if(powerstroke){
Inkscape::LivePathEffect::LPEPowerStroke *lpe_powerstroke = dynamic_cast<Inkscape::LivePathEffect::LPEPowerStroke*>(powerstroke->getLPEObj()->get_lpe());
if(lpe_powerstroke){
lpe_powerstroke->getRepr()->setAttribute("is_visible", "false");
sp_lpe_item_update_patheffect(lpeitem, false, false);
SPShape *sp_shape = dynamic_cast<SPShape *>(lpeitem);
if (sp_shape) {
guint previous_curve_length = sp_shape->getCurve()->get_segment_count();
lpe_simplify->getRepr()->setAttribute("threshold", ss.str());
sp_lpe_item_update_patheffect(lpeitem, false, false);
simplified = true;
guint curve_length = sp_shape->getCurve()->get_segment_count();
std::vector<Geom::Point> ts = lpe_powerstroke->offset_points.data();
double factor = (double)curve_length/ (double)previous_curve_length;
for (size_t i = 0; i < ts.size(); i++) {
ts[i][Geom::X] = ts[i][Geom::X] * factor;
}
lpe_powerstroke->offset_points.param_setValue(ts);
}
lpe_powerstroke->getRepr()->setAttribute("is_visible", "true");
sp_lpe_item_update_patheffect(lpeitem, false, false);
}
}
if(!simplified){
lpe_simplify->getRepr()->setAttribute("threshold", ss.str());
}
}
}
}
}
}
示例8:
static void
sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name, gchar const *other_name)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, gtk_adjustment_get_value(adj));
}
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" )) {
return;
}
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL);
bool modmade = false;
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
if (!strcmp(value_name, "start")) {
ge->start = (gtk_adjustment_get_value(adj) * M_PI)/ 180;
} else {
ge->end = (gtk_adjustment_get_value(adj) * M_PI)/ 180;
}
ge->normalize();
(SP_OBJECT(ge))->updateRepr();
(SP_OBJECT(ge))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
modmade = true;
}
}
g_free(namespaced_name);
GtkAdjustment *other = GTK_ADJUSTMENT( g_object_get_data( tbl, other_name ) );
sp_arctb_sensitivize( tbl, gtk_adjustment_get_value(adj), gtk_adjustment_get_value(other) );
if (modmade) {
DocumentUndo::maybeDone(desktop->getDocument(), value_name, SP_VERB_CONTEXT_ARC,
_("Arc: Change start/end"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
示例9:
static void
sp_selection_layout_widget_modify_selection(SPWidget *spw, Inkscape::Selection *selection, guint flags, gpointer data)
{
SPDesktop *desktop = static_cast<SPDesktop *>(data);
if ((desktop->getSelection() == selection) // only respond to changes in our desktop
&& (flags & (SP_OBJECT_MODIFIED_FLAG |
SP_OBJECT_PARENT_MODIFIED_FLAG |
SP_OBJECT_CHILD_MODIFIED_FLAG )))
{
sp_selection_layout_widget_update(spw, selection);
}
}
示例10: sp_rtb_value_changed
static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name,
void (SPRect::*setter)(gdouble))
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
Unit const *unit = tracker->getActiveUnit();
g_return_if_fail(unit != NULL);
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name,
Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"));
}
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" ) || tracker->isUpdating()) {
return;
}
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE));
bool modmade = false;
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
if (SP_IS_RECT(*i)) {
if (gtk_adjustment_get_value(adj) != 0) {
(SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"));
} else {
(*i)->getRepr()->setAttribute(value_name, NULL);
}
modmade = true;
}
}
sp_rtb_sensitivize( tbl );
if (modmade) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_RECT,
_("Change rectangle"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
示例11: sp_spl_tb_value_changed
static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustring const &value_name)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/spiral/" + value_name,
gtk_adjustment_get_value(adj));
}
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" )) {
return;
}
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL);
bool modmade = false;
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
SPItem *item = *i;
if (SP_IS_SPIRAL(item)) {
Inkscape::XML::Node *repr = item->getRepr();
sp_repr_set_svg_double( repr, namespaced_name,
gtk_adjustment_get_value(adj) );
item->updateRepr();
modmade = true;
}
}
g_free(namespaced_name);
if (modmade) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_SPIRAL,
_("Change spiral"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
示例12: spdc_endpoint_snap_free
void spdc_endpoint_snap_free(ToolBase const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_of_line, guint const /*state*/)
{
SPDesktop *dt = ec->desktop;
SnapManager &m = dt->namedview->snap_manager;
Inkscape::Selection *selection = dt->getSelection();
// selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
// TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
m.setup(dt, true, selection->singleItem());
Inkscape::SnapCandidatePoint scp(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
if (start_of_line) {
scp.addOrigin(*start_of_line);
}
Inkscape::SnappedPoint sp = m.freeSnap(scp);
p = sp.getPoint();
m.unSetup();
}
示例13: ms_tb_selection_changed
/*
* Core function, setup all the widgets whenever something changes on the desktop
*/
static void ms_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointer data)
{
// std::cout << "ms_tb_selection_changed" << std::endl;
if (blocked)
return;
GtkWidget *widget = GTK_WIDGET(data);
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(widget), "desktop"));
if (!desktop) {
return;
}
Inkscape::Selection *selection = desktop->getSelection(); // take from desktop, not from args
if (selection) {
// ToolBase *ev = sp_desktop_event_context(desktop);
// GrDrag *drag = NULL;
// if (ev) {
// drag = ev->get_drag();
// // Hide/show handles?
// }
SPMesh *ms_selected = 0;
SPMeshType ms_type = SP_MESH_TYPE_COONS;
bool ms_selected_multi = false;
bool ms_type_multi = false;
ms_read_selection( selection, ms_selected, ms_selected_multi, ms_type, ms_type_multi );
// std::cout << " type: " << ms_type << std::endl;
EgeSelectOneAction* type = (EgeSelectOneAction *) g_object_get_data(G_OBJECT(widget), "mesh_select_type_action");
gtk_action_set_sensitive( GTK_ACTION(type), (ms_selected && !ms_selected_multi) );
if (ms_selected) {
blocked = TRUE;
ege_select_one_action_set_active( type, ms_type );
blocked = FALSE;
}
}
}
示例14: ms_type_changed
/**
* Sets mesh type: Coons, Bicubic
*/
static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget)
{
// std::cout << "ms_type_changed" << std::endl;
if (blocked) {
return;
}
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(widget), "desktop"));
Inkscape::Selection *selection = desktop->getSelection();
SPMesh *gradient = 0;
ms_get_dt_selected_gradient(selection, gradient);
if (gradient) {
SPMeshType type = (SPMeshType) ege_select_one_action_get_active(act);
// std::cout << " type: " << type << std::endl;
gradient->type = type;
gradient->type_set = true;
gradient->updateRepr();
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
_("Set mesh type"));
}
}
示例15: if
static void
sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
{
if (g_object_get_data(G_OBJECT(spw), "update")) {
return;
}
UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(G_OBJECT(spw), "tracker"));
if ( !tracker || tracker->isUpdating() ) {
/*
* When only units are being changed, don't treat changes
* to adjuster values as object changes.
*/
return;
}
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
Inkscape::Selection *selection = desktop->getSelection();
SPDocument *document = desktop->getDocument();
document->ensureUpToDate ();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Geom::OptRect bbox_vis = selection->visualBounds();
Geom::OptRect bbox_geom = selection->geometricBounds();
int prefs_bbox = prefs->getInt("/tools/bounding_box");
SPItem::BBoxType bbox_type = (prefs_bbox == 0)?
SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
Geom::OptRect bbox_user = selection->bounds(bbox_type);
if ( !bbox_user ) {
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
return;
}
gdouble x0 = 0;
gdouble y0 = 0;
gdouble x1 = 0;
gdouble y1 = 0;
gdouble xrel = 0;
gdouble yrel = 0;
Unit const *unit = tracker->getActiveUnit();
g_return_if_fail(unit != NULL);
GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "X" ) );
GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "Y" ) );
GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "width" ) );
GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) );
if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
x0 = Quantity::convert(gtk_adjustment_get_value(a_x), unit, "px");
y0 = Quantity::convert(gtk_adjustment_get_value(a_y), unit, "px");
x1 = x0 + Quantity::convert(gtk_adjustment_get_value(a_w), unit, "px");
xrel = Quantity::convert(gtk_adjustment_get_value(a_w), unit, "px") / bbox_user->dimensions()[Geom::X];
y1 = y0 + Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px");;
yrel = Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px") / bbox_user->dimensions()[Geom::Y];
} else {
double const x0_propn = gtk_adjustment_get_value (a_x) / 100 / unit->factor;
x0 = bbox_user->min()[Geom::X] * x0_propn;
double const y0_propn = gtk_adjustment_get_value (a_y) / 100 / unit->factor;
y0 = y0_propn * bbox_user->min()[Geom::Y];
xrel = gtk_adjustment_get_value (a_w) / (100 / unit->factor);
x1 = x0 + xrel * bbox_user->dimensions()[Geom::X];
yrel = gtk_adjustment_get_value (a_h) / (100 / unit->factor);
y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y];
}
// Keep proportions if lock is on
GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(G_OBJECT(spw), "lock") );
if ( gtk_toggle_action_get_active(lock) ) {
if (adj == a_h) {
x1 = x0 + yrel * bbox_user->dimensions()[Geom::X];
} else if (adj == a_w) {
y1 = y0 + xrel * bbox_user->dimensions()[Geom::Y];
}
}
// scales and moves, in px
double mh = fabs(x0 - bbox_user->min()[Geom::X]);
double sh = fabs(x1 - bbox_user->max()[Geom::X]);
double mv = fabs(y0 - bbox_user->min()[Geom::Y]);
double sv = fabs(y1 - bbox_user->max()[Geom::Y]);
// unless the unit is %, convert the scales and moves to the unit
if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
mh = Quantity::convert(mh, "px", unit);
sh = Quantity::convert(sh, "px", unit);
mv = Quantity::convert(mv, "px", unit);
sv = Quantity::convert(sv, "px", unit);
}
// do the action only if one of the scales/moves is greater than half the last significant
// digit in the spinbox (currently spinboxes have 3 fractional digits, so that makes 0.0005). If
// the value was changed by the user, the difference will be at least that much; otherwise it's
// just rounding difference between the spinbox value and actual value, so no action is
// performed
char const * const actionkey = ( mh > 5e-4 ? "selector:toolbar:move:horizontal" :
sh > 5e-4 ? "selector:toolbar:scale:horizontal" :
//.........这里部分代码省略.........