本文整理汇总了C++中inkscape::Selection::visualBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::visualBounds方法的具体用法?C++ Selection::visualBounds怎么用?C++ Selection::visualBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inkscape::Selection
的用法示例。
在下文中一共展示了Selection::visualBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path_data
/**
\brief This actually draws the grid.
\param module The effect that was called (unused)
\param document What should be edited.
*/
void
Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
{
Inkscape::Selection * selection = ((SPDesktop *)document)->selection;
Geom::Rect bounding_area = Geom::Rect(Geom::Point(0,0), Geom::Point(100,100));
if (selection->isEmpty()) {
/* get page size */
SPDocument * doc = document->doc();
bounding_area = Geom::Rect( Geom::Point(0,0),
Geom::Point(doc->getWidth(), doc->getHeight()) );
} else {
Geom::OptRect bounds = selection->visualBounds();
if (bounds) {
bounding_area = *bounds;
}
gdouble doc_height = (document->doc())->getHeight();
Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
bounding_area = temprec;
}
float spacings[2] = { module->get_param_float("xspacing"),
module->get_param_float("yspacing") };
float line_width = module->get_param_float("lineWidth");
float offsets[2] = { module->get_param_float("xoffset"),
module->get_param_float("yoffset") };
Glib::ustring path_data("");
path_data = build_lines(bounding_area,
offsets, spacings);
Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc();
//XML Tree being used directly here while it shouldn't be.
Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->getRepr();
Inkscape::XML::Node * path = xml_doc->createElement("svg:path");
path->setAttribute("d", path_data.c_str());
Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000");
style += ";stroke-width:";
gchar floatstring[64];
std::ostringstream stringstream;
stringstream << line_width;
sprintf(floatstring, "%s", stringstream.str().c_str());
style += floatstring;
style += "pt";
path->setAttribute("style", style.c_str());
current_layer->appendChild(path);
Inkscape::GC::release(path);
return;
}
示例2: 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 = sp_desktop_selection(desktop);
SPDocument *document = sp_desktop_document(desktop);
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;
SPUnit const &unit = *tracker->getActiveUnit();
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.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
x0 = sp_units_get_pixels (gtk_adjustment_get_value (a_x), unit);
y0 = sp_units_get_pixels (gtk_adjustment_get_value (a_y), unit);
x1 = x0 + sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit);
xrel = sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit) / bbox_user->dimensions()[Geom::X];
y1 = y0 + sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit);
yrel = sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit) / bbox_user->dimensions()[Geom::Y];
} else {
double const x0_propn = gtk_adjustment_get_value (a_x) * unit.unittobase;
x0 = bbox_user->min()[Geom::X] * x0_propn;
double const y0_propn = gtk_adjustment_get_value (a_y) * unit.unittobase;
y0 = y0_propn * bbox_user->min()[Geom::Y];
xrel = gtk_adjustment_get_value (a_w) * unit.unittobase;
x1 = x0 + xrel * bbox_user->dimensions()[Geom::X];
yrel = gtk_adjustment_get_value (a_h) * unit.unittobase;
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.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
mh = sp_pixels_get_units (mh, unit);
sh = sp_pixels_get_units (sh, unit);
mv = sp_pixels_get_units (mv, unit);
sv = sp_pixels_get_units (sv, 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" :
mv > 5e-4 ? "selector:toolbar:move:vertical" :
//.........这里部分代码省略.........