本文整理汇总了C++中geom::OptRect类的典型用法代码示例。如果您正苦于以下问题:C++ OptRect类的具体用法?C++ OptRect怎么用?C++ OptRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OptRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sp_canvas_bpath_update
static void sp_canvas_bpath_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
{
SPCanvasBPath *cbp = SP_CANVAS_BPATH(item);
item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
if (reinterpret_cast<SPCanvasItemClass *>(sp_canvas_bpath_parent_class)->update) {
reinterpret_cast<SPCanvasItemClass *>(sp_canvas_bpath_parent_class)->update(item, affine, flags);
}
sp_canvas_item_reset_bounds (item);
if (!cbp->curve) return;
cbp->affine = affine;
Geom::OptRect bbox = bounds_exact_transformed(cbp->curve->get_pathvector(), affine);
if (bbox) {
item->x1 = (int)bbox->min()[Geom::X] - 1;
item->y1 = (int)bbox->min()[Geom::Y] - 1;
item->x2 = (int)bbox->max()[Geom::X] + 1;
item->y2 = (int)bbox->max()[Geom::Y] + 1;
} else {
item->x1 = 0;
item->y1 = 0;
item->x2 = 0;
item->y2 = 0;
}
item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
示例2: bbox
Geom::OptRect SPTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const {
Geom::OptRect bbox;
// find out the ancestor text which holds our layout
SPObject const *parent_text = this;
while ( parent_text && !SP_IS_TEXT(parent_text) ) {
parent_text = parent_text->parent;
}
if (parent_text == NULL) {
return bbox;
}
// get the bbox of our portion of the layout
bbox = SP_TEXT(parent_text)->layout.bounds(transform,
sp_text_get_length_upto(parent_text, this), sp_text_get_length_upto(this, NULL) - 1);
// Add stroke width
// FIXME this code is incorrect
if (bbox && type == SPItem::VISUAL_BBOX && !this->style->stroke.isNone()) {
double scale = transform.descrim();
bbox->expandBy(0.5 * this->style->stroke_width.computed * scale);
}
return bbox;
}
示例3: getConnectionPointPos
Geom::Point SPAvoidRef::getConnectionPointPos()
{
g_assert(item);
// the center is all we are interested in now; we used to care
// about non-center points, but that's moot.
Geom::OptRect bbox = item->documentVisualBounds();
return (bbox) ? bbox->midpoint() : Geom::Point(0, 0);
}
示例4: visualBounds
Geom::OptRect Selection::visualBounds() const
{
std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
Geom::OptRect bbox;
for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) {
bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds());
}
return bbox;
}
开发者ID:NotBrianZach,项目名称:modalComposableProgrammableFuzzySearchingVectorGraphicEditing,代码行数:10,代码来源:selection.cpp
示例5: bbox
Geom::OptRect SPFlowtext::bbox(Geom::Affine const &transform, SPItem::BBoxType type) const {
Geom::OptRect bbox = this->layout.bounds(transform);
// Add stroke width
// FIXME this code is incorrect
if (bbox && type == SPItem::VISUAL_BBOX && !this->style->stroke.isNone()) {
double scale = transform.descrim();
bbox->expandBy(0.5 * this->style->stroke_width.computed * scale);
}
return bbox;
}
示例6: geometricBounds
Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) {
Geom::OptRect bbox;
for (SPObject *i = firstChild(); i; i = i->getNext()) {
if (SP_IS_ITEM(i)) {
Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform);
bbox.unionWith(tmp);
}
}
return bbox;
}
示例7: preferredBounds
// If we have a selection of multiple items, then the center of the first item
// will be returned; this is also the case in SelTrans::centerRequest()
boost::optional<Geom::Point> Selection::center() const {
std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
if (!items.empty()) {
SPItem *first = items.back(); // from the first item in selection
if (first->isCenterSet()) { // only if set explicitly
return first->getCenter();
}
}
Geom::OptRect bbox = preferredBounds();
if (bbox) {
return bbox->midpoint();
} else {
return boost::optional<Geom::Point>();
}
}
开发者ID:NotBrianZach,项目名称:modalComposableProgrammableFuzzySearchingVectorGraphicEditing,代码行数:17,代码来源:selection.cpp
示例8: 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));
}
示例9: Point
/**
Center of bbox of item
*/
static Geom::Point
unclump_center (SPItem *item)
{
std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(item->getId());
if ( i != c_cache.end() ) {
return i->second;
}
Geom::OptRect r = item->desktopVisualBounds();
if (r) {
Geom::Point const c = r->midpoint();
c_cache[item->getId()] = c;
return c;
} else {
// FIXME
return Geom::Point(0, 0);
}
}
示例10:
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;
}
示例11:
SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) {
std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
gdouble max = sml ? 1e18 : 0;
SPItem *ist = NULL;
for ( std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i) {
Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds();
if (!obox || obox.isEmpty()) continue;
Geom::Rect bbox = *obox;
gdouble size = compare == 2 ? bbox.area() :
(compare == 1 ? bbox.width() : bbox.height());
size = sml ? size : size * -1;
if (size < max) {
max = size;
ist = SP_ITEM(*i);
}
}
return ist;
}
开发者ID:NotBrianZach,项目名称:modalComposableProgrammableFuzzySearchingVectorGraphicEditing,代码行数:20,代码来源:selection.cpp
示例12: sp_textpath_to_text
void sp_textpath_to_text(SPObject *tp)
{
SPObject *text = tp->parent;
Geom::OptRect bbox = SP_ITEM(text)->geometricBounds(SP_ITEM(text)->i2doc_affine());
if (!bbox) {
return;
}
Geom::Point xy = bbox->min();
xy *= tp->document->getDocumentScale().inverse(); // Convert to user-units.
// make a list of textpath children
GSList *tp_reprs = NULL;
for (SPObject *o = tp->firstChild() ; o != NULL; o = o->next) {
tp_reprs = g_slist_prepend(tp_reprs, o->getRepr());
}
for ( GSList *i = tp_reprs ; i ; i = i->next ) {
// make a copy of each textpath child
Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(text->getRepr()->document());
// remove the old repr from under textpath
tp->getRepr()->removeChild((Inkscape::XML::Node *) i->data);
// put its copy under text
text->getRepr()->addChild(copy, NULL); // fixme: copy id
}
//remove textpath
tp->deleteObject();
g_slist_free(tp_reprs);
// set x/y on text (to be near where it was when on path)
/* fixme: Yuck, is this really the right test? */
if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) {
sp_repr_set_svg_double(text->getRepr(), "x", xy[Geom::X]);
sp_repr_set_svg_double(text->getRepr(), "y", xy[Geom::Y]);
}
}
示例13: getBBoxPoints
void Inkscape::getBBoxPoints(Geom::OptRect const bbox,
std::vector<SnapCandidatePoint> *points,
bool const /*isTarget*/,
bool const includeCorners,
bool const includeLineMidpoints,
bool const includeObjectMidpoints)
{
if (bbox) {
// collect the corners of the bounding box
for ( unsigned k = 0 ; k < 4 ; k++ ) {
if (includeCorners) {
points->push_back(SnapCandidatePoint(bbox->corner(k), SNAPSOURCE_BBOX_CORNER, -1, SNAPTARGET_BBOX_CORNER, *bbox));
}
// optionally, collect the midpoints of the bounding box's edges too
if (includeLineMidpoints) {
points->push_back(SnapCandidatePoint((bbox->corner(k) + bbox->corner((k+1) % 4))/2, SNAPSOURCE_BBOX_EDGE_MIDPOINT, -1, SNAPTARGET_BBOX_EDGE_MIDPOINT, *bbox));
}
}
if (includeObjectMidpoints) {
points->push_back(SnapCandidatePoint(bbox->midpoint(), SNAPSOURCE_BBOX_MIDPOINT, -1, SNAPTARGET_BBOX_MIDPOINT, *bbox));
}
}
}
示例14: switch
void
sp_gradient_pattern_common_setup(cairo_pattern_t *cp,
SPGradient *gr,
Geom::OptRect const &bbox,
double opacity)
{
// set spread type
switch (gr->getSpread()) {
case SP_GRADIENT_SPREAD_REFLECT:
cairo_pattern_set_extend(cp, CAIRO_EXTEND_REFLECT);
break;
case SP_GRADIENT_SPREAD_REPEAT:
cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT);
break;
case SP_GRADIENT_SPREAD_PAD:
default:
cairo_pattern_set_extend(cp, CAIRO_EXTEND_PAD);
break;
}
// add stops
for (std::vector<SPGradientStop>::iterator i = gr->vector.stops.begin();
i != gr->vector.stops.end(); ++i)
{
// multiply stop opacity by paint opacity
cairo_pattern_add_color_stop_rgba(cp, i->offset,
i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity * opacity);
}
// set pattern matrix
Geom::Affine gs2user = gr->gradientTransform;
if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX && bbox) {
Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top());
gs2user *= bbox2user;
}
ink_cairo_pattern_set_matrix(cp, gs2user.inverse());
}
示例15: transshift
/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */
static void
feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Affine trans, Geom::OptRect area, bool optimize_stroke, double stroke_width)
{
if (!area)
return;
if (path.empty())
return;
// Transform all coordinates to coords within "area"
Geom::Point shift = area->min();
Geom::Rect view = *area;
view.expandBy (stroke_width);
view = view * (Geom::Affine)Geom::Translate(-shift);
// Pass transformation to feed_curve, so that we don't need to create a whole new path.
Geom::Affine transshift(trans * Geom::Translate(-shift));
Geom::Point initial = path.initialPoint() * transshift;
cairo_move_to(ct, initial[0], initial[1] );
for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) {
feed_curve_to_cairo(ct, *cit, transshift, view, optimize_stroke);
}
if (path.closed()) {
if (!optimize_stroke) {
cairo_close_path(ct);
} else {
cairo_line_to(ct, initial[0], initial[1]);
/* We cannot use cairo_close_path(ct) here because some parts of the path may have been
clipped and not drawn (maybe the before last segment was outside view area), which
would result in closing the "subpath" after the last interruption, not the entire path.
However, according to cairo documentation:
The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate
in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead,
there is a line join connecting the final and initial segments of the sub-path.
The correct fix will be possible when cairo introduces methods for moving without
ending/starting subpaths, which we will use for skipping invisible segments; then we
will be able to use cairo_close_path here. This issue also affects ps/eps/pdf export,
see bug 168129
*/
}
}
}