本文整理汇总了C++中SPDesktop::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ SPDesktop::setPosition方法的具体用法?C++ SPDesktop::setPosition怎么用?C++ SPDesktop::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPDesktop
的用法示例。
在下文中一共展示了SPDesktop::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sp_dt_ruler_event
//.........这里部分代码省略.........
normal = normal_tr_to_bl;
} else {
normal = Geom::Point(1.,0.);
}
}
guide = sp_guideline_new(desktop->guides, NULL, event_dt, normal);
sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor);
#if GTK_CHECK_VERSION(3,0,0)
gdk_device_grab(device,
gtk_widget_get_window(widget),
GDK_OWNERSHIP_NONE,
FALSE,
(GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ),
NULL,
event->button.time);
#else
gdk_pointer_grab(gtk_widget_get_window (widget), FALSE,
(GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ),
NULL, NULL,
event->button.time);
#endif
}
break;
case GDK_MOTION_NOTIFY:
if (clicked) {
Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
Geom::Point event_dt(desktop->w2d(event_w));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
if ( ( abs( (gint) event->motion.x - xp ) < tolerance )
&& ( abs( (gint) event->motion.y - yp ) < tolerance ) ) {
break;
}
dragged = true;
// explicitly show guidelines; if I draw a guide, I want them on
if ((horiz ? wy : wx) >= 0) {
desktop->namedview->setGuides(true);
}
if (!(event->motion.state & GDK_SHIFT_MASK)) {
sp_dt_ruler_snap_new_guide(desktop, guide, event_dt, normal);
}
sp_guideline_set_normal(SP_GUIDELINE(guide), normal);
sp_guideline_set_position(SP_GUIDELINE(guide), event_dt);
desktop->set_coordinate_status(event_dt);
desktop->setPosition(event_dt);
}
break;
case GDK_BUTTON_RELEASE:
if (clicked && event->button.button == 1) {
sp_event_context_discard_delayed_snap_event(desktop->event_context);
#if GTK_CHECK_VERSION(3,0,0)
gdk_device_ungrab(device, event->button.time);
#else
gdk_pointer_ungrab(event->button.time);
#endif
Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
Geom::Point event_dt(desktop->w2d(event_w));
if (!(event->button.state & GDK_SHIFT_MASK)) {
sp_dt_ruler_snap_new_guide(desktop, guide, event_dt, normal);
}
sp_canvas_item_destroy(guide);
guide = NULL;
if ((horiz ? wy : wx) >= 0) {
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide");
sp_repr_set_point(repr, "orientation", normal);
sp_repr_set_point(repr, "position", event_dt);
desktop->namedview->appendChild(repr);
Inkscape::GC::release(repr);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE,
_("Create guide"));
}
desktop->set_coordinate_status(event_dt);
if (!dragged) {
// Ruler click (without drag) toggle the guide visibility on and off
Inkscape::XML::Node *repr = desktop->namedview->getRepr();
sp_namedview_toggle_guides(sp_desktop_document(desktop), repr);
}
clicked = false;
dragged = false;
}
default:
break;
}
return FALSE;
}
示例2: sp_dt_guide_event
//.........这里部分代码省略.........
{
Geom::Point pt = motion_dt - guide->point_on_line;
Geom::Angle angle(pt);
if (event->motion.state & GDK_CONTROL_MASK) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12));
bool const relative_snaps = abs(prefs->getBool("/options/relativeguiderotationsnap/value", false));
if (snaps) {
if (relative_snaps) {
Geom::Angle orig_angle(guide->normal_to_line);
Geom::Angle snap_angle = angle - orig_angle;
double sections = floor(snap_angle.radians0() * snaps / M_PI + .5);
angle = (M_PI / snaps) * sections + orig_angle.radians0();
} else {
double sections = floor(angle.radians0() * snaps / M_PI + .5);
angle = (M_PI / snaps) * sections;
}
}
}
sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), false);
break;
}
case SP_DRAG_MOVE_ORIGIN:
{
sp_guide_moveto(*guide, motion_dt, false);
break;
}
case SP_DRAG_NONE:
g_assert_not_reached();
break;
}
moved = true;
desktop->set_coordinate_status(motion_dt);
desktop->setPosition(motion_dt);
ret = TRUE;
}
break;
case GDK_BUTTON_RELEASE:
if (drag_type != SP_DRAG_NONE && event->button.button == 1) {
sp_event_context_discard_delayed_snap_event(desktop->event_context);
if (moved) {
Geom::Point const event_w(event->button.x,
event->button.y);
Geom::Point event_dt(desktop->w2d(event_w));
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, NULL, NULL, guide);
if (drag_type == SP_DRAG_MOVE_ORIGIN) {
// If we snap in guideConstrainedSnap() below, then motion_dt will
// be forced to be on the guide. If we don't snap however, then
// the origin should still be constrained to the guide. So let's
// do that explicitly first:
Geom::Line line(guide->point_on_line, guide->angle());
Geom::Coord t = line.nearestPoint(event_dt);
event_dt = line.pointAt(t);
if (!(event->button.state & GDK_SHIFT_MASK)) {
m.guideConstrainedSnap(event_dt, *guide);
}
} else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) {
// cannot use shift here to disable snapping, because we already use it for rotating the guide
if (drag_type == SP_DRAG_ROTATE) {
m.guideFreeSnap(event_dt, guide->point_on_line, true, false);
} else {
m.guideFreeSnap(event_dt, guide->normal_to_line, false, true);