本文整理汇总了C++中geom::OptRect::dimensions方法的典型用法代码示例。如果您正苦于以下问题:C++ OptRect::dimensions方法的具体用法?C++ OptRect::dimensions怎么用?C++ OptRect::dimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geom::OptRect
的用法示例。
在下文中一共展示了OptRect::dimensions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bbox
static void
sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
{
if (g_object_get_data(G_OBJECT(spw), "update")) {
return;
}
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
using Geom::X;
using Geom::Y;
if ( sel && !sel->isEmpty() ) {
int prefs_bbox = prefs->getInt("/tools/bounding_box", 0);
SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
Geom::OptRect const bbox(sel->bounds(bbox_type));
if ( bbox ) {
UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(G_OBJECT(spw), "tracker"));
Unit const *unit = tracker->getActiveUnit();
g_return_if_fail(unit != NULL);
struct { char const *key; double val; } const keyval[] = {
{ "X", bbox->min()[X] },
{ "Y", bbox->min()[Y] },
{ "width", bbox->dimensions()[X] },
{ "height", bbox->dimensions()[Y] }
};
if (unit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) {
double const val = unit->factor * 100;
for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) {
GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key));
gtk_adjustment_set_value(a, val);
tracker->setFullVal( a, keyval[i].val );
}
} else {
for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) {
GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key));
gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, "px", unit));
}
}
}
}
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
}
示例2:
static Geom::Point
unclump_wh (SPItem *item)
{
Geom::Point wh;
std::map<const gchar *, Geom::Point>::iterator i = wh_cache.find(item->getId());
if ( i != wh_cache.end() ) {
wh = i->second;
} else {
Geom::OptRect r = item->desktopVisualBounds();
if (r) {
wh = r->dimensions();
wh_cache[item->getId()] = wh;
} else {
wh = Geom::Point(0, 0);
}
}
return wh;
}
示例3: switch
void
ObjectCompositeSettings::_subjectChanged() {
if (!_subject) {
return;
}
SPDesktop *desktop = _subject->getDesktop();
if (!desktop) {
return;
}
if (_blocked)
return;
_blocked = true;
SPStyle *query = sp_style_new (sp_desktop_document(desktop));
int result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
switch (result) {
case QUERY_STYLE_NOTHING:
_opacity_vbox.set_sensitive(false);
// gtk_widget_set_sensitive (opa, FALSE);
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently
case QUERY_STYLE_MULTIPLE_SAME:
_opacity_vbox.set_sensitive(true);
_opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
break;
}
//query now for current filter mode and average blurring of selection
const int blend_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLEND);
switch(blend_result) {
case QUERY_STYLE_NOTHING:
_fe_cb.set_sensitive(false);
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_SAME:
_fe_cb.set_blend_mode(query->filter_blend_mode.value);
_fe_cb.set_sensitive(true);
break;
case QUERY_STYLE_MULTIPLE_DIFFERENT:
// TODO: set text
_fe_cb.set_sensitive(false);
break;
}
if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) {
int blur_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLUR);
switch (blur_result) {
case QUERY_STYLE_NOTHING: //no blurring
_fe_cb.set_blur_sensitive(false);
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
case QUERY_STYLE_MULTIPLE_SAME:
Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
if (bbox) {
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
_fe_cb.set_blur_sensitive(true);
//update blur widget value
float radius = query->filter_gaussianBlur_deviation.value;
float percent = radius * 400 / perimeter; // so that for a square, 100% == half side
_fe_cb.set_blur_value(percent);
}
break;
}
}
sp_style_unref(query);
_blocked = false;
}
示例4: if
void
ObjectCompositeSettings::_blendBlurValueChanged()
{
if (!_subject) {
return;
}
SPDesktop *desktop = _subject->getDesktop();
if (!desktop) {
return;
}
SPDocument *document = sp_desktop_document (desktop);
if (_blocked)
return;
_blocked = true;
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
//sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
double radius;
if (bbox) {
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
radius = _fe_cb.get_blur_value() * perimeter / 400;
} else {
radius = 0;
}
const Glib::ustring blendmode = _fe_cb.get_blend_mode();
//apply created filter to every selected item
for (StyleSubject::iterator i = _subject->begin() ; i != _subject->end() ; ++i ) {
if (!SP_IS_ITEM(*i)) {
continue;
}
SPItem * item = SP_ITEM(*i);
SPStyle *style = item->style;
g_assert(style != NULL);
if (blendmode != "normal") {
SPFilter *filter = new_filter_simple_from_item(document, item, blendmode.c_str(), radius);
sp_style_set_property_url(item, "filter", filter, false);
} else {
sp_style_set_property_url(item, "filter", NULL, false);
}
if (radius == 0 && item->style->filter.set
&& filter_is_single_gaussian_blur(SP_FILTER(item->style->getFilter()))) {
remove_filter(item, false);
}
else if (radius != 0) {
SPFilter *filter = modify_filter_gaussian_blur_from_item(document, item, radius);
sp_style_set_property_url(item, "filter", filter, false);
}
//request update
item->requestDisplayUpdate(( SP_OBJECT_MODIFIED_FLAG |
SP_OBJECT_STYLE_MODIFIED_FLAG ));
}
DocumentUndo::maybeDone(document, _blur_tag.c_str(), _verb_code,
_("Change blur"));
// resume interruptibility
//sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
_blocked = false;
}
示例5: set_shape
void SPOffset::set_shape() {
if ( this->originalPath == NULL ) {
// oops : no path?! (the offset object should do harakiri)
return;
}
#ifdef OFFSET_VERBOSE
g_print ("rad=%g\n", offset->rad);
#endif
// au boulot
if ( fabs(this->rad) < 0.01 ) {
// grosso modo: 0
// just put the source this as the offseted one, no one will notice
// it's also useless to compute the offset with a 0 radius
//XML Tree being used directly here while it shouldn't be.
const char *res_d = this->getRepr()->attribute("inkscape:original");
if ( res_d ) {
Geom::PathVector pv = sp_svg_read_pathv(res_d);
SPCurve *c = new SPCurve(pv);
g_assert(c != NULL);
this->setCurveInsync (c, TRUE);
this->setCurveBeforeLPE(c);
c->unref();
}
return;
}
// extra paraniac careful check. the preceding if () should take care of this case
if (fabs (this->rad) < 0.01) {
this->rad = (this->rad < 0) ? -0.01 : 0.01;
}
Path *orig = new Path;
orig->Copy ((Path *)this->originalPath);
if ( use_slow_but_correct_offset_method == false ) {
// version par outline
Shape *theShape = new Shape;
Shape *theRes = new Shape;
Path *originaux[1];
Path *res = new Path;
res->SetBackData (false);
// and now: offset
float o_width;
if (this->rad >= 0)
{
o_width = this->rad;
orig->OutsideOutline (res, o_width, join_round, butt_straight, 20.0);
}
else
{
o_width = -this->rad;
orig->OutsideOutline (res, -o_width, join_round, butt_straight, 20.0);
}
if (o_width >= 1.0)
{
// res->ConvertForOffset (1.0, orig, offset->rad);
res->ConvertWithBackData (1.0);
}
else
{
// res->ConvertForOffset (o_width, orig, offset->rad);
res->ConvertWithBackData (o_width);
}
res->Fill (theShape, 0);
theRes->ConvertToShape (theShape, fill_positive);
originaux[0] = res;
theRes->ConvertToForme (orig, 1, originaux);
Geom::OptRect bbox = this->desktopVisualBounds();
if ( bbox ) {
gdouble size = L2(bbox->dimensions());
gdouble const exp = this->transform.descrim();
if (exp != 0) {
size /= exp;
}
orig->Coalesce (size * 0.001);
//g_print ("coa %g exp %g item %p\n", size * 0.001, exp, item);
}
// if (o_width >= 1.0)
// {
// orig->Coalesce (0.1); // small treshhold, since we only want to get rid of small segments
// the curve should already be computed by the Outline() function
// orig->ConvertEvenLines (1.0);
// orig->Simplify (0.5);
// }
// else
//.........这里部分代码省略.........
开发者ID:NotBrianZach,项目名称:modalComposableProgrammableFuzzySearchingVectorGraphicEditing,代码行数:101,代码来源:sp-offset.cpp