本文整理汇总了C++中SPCurve::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SPCurve::unref方法的具体用法?C++ SPCurve::unref怎么用?C++ SPCurve::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPCurve
的用法示例。
在下文中一共展示了SPCurve::unref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
/**
* Sets a value in the path object given by 'key', to 'value'. This is used
* for setting attributes and markers on a path object.
*/
static void
sp_path_set(SPObject *object, unsigned int key, gchar const *value)
{
SPPath *path = (SPPath *) object;
switch (key) {
case SP_ATTR_INKSCAPE_ORIGINAL_D:
if (value) {
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *curve = new SPCurve(pv);
if (curve) {
path->set_original_curve(curve, TRUE, true);
curve->unref();
}
} else {
path->set_original_curve(NULL, TRUE, true);
}
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_D:
if (value) {
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *curve = new SPCurve(pv);
if (curve) {
((SPShape *) path)->setCurve(curve, TRUE);
curve->unref();
}
} else {
((SPShape *) path)->setCurve(NULL, TRUE);
}
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_PROP_MARKER:
case SP_PROP_MARKER_START:
case SP_PROP_MARKER_MID:
case SP_PROP_MARKER_END:
sp_shape_set_marker(object, key, value);
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_CONNECTOR_TYPE:
case SP_ATTR_CONNECTOR_CURVATURE:
case SP_ATTR_CONNECTION_START:
case SP_ATTR_CONNECTION_END:
case SP_ATTR_CONNECTION_START_POINT:
case SP_ATTR_CONNECTION_END_POINT:
path->connEndPair.setAttr(key, value);
break;
default:
if (((SPObjectClass *) parent_class)->set) {
((SPObjectClass *) parent_class)->set(object, key, value);
}
break;
}
}
示例2:
/**
* Computes a point on the offset; used to set a "seed" position for
* the control knot.
*
* \return the topmost point on the offset.
*/
void
sp_offset_top_point (SPOffset const * offset, Geom::Point *px)
{
(*px) = Geom::Point(0, 0);
if (offset == NULL) {
return;
}
if (offset->knotSet)
{
(*px) = offset->knot;
return;
}
SPCurve *curve = SP_SHAPE (offset)->getCurve();
if (curve == NULL)
{
// CPPIFY
//offset->set_shape();
const_cast<SPOffset*>(offset)->set_shape();
curve = SP_SHAPE (offset)->getCurve();
if (curve == NULL)
return;
}
if (curve->is_empty())
{
curve->unref();
return;
}
Path *finalPath = new Path;
finalPath->LoadPathVector(curve->get_pathvector());
Shape *theShape = new Shape;
finalPath->Convert (1.0);
finalPath->Fill (theShape, 0);
if (theShape->hasPoints())
{
theShape->SortPoints ();
*px = theShape->getPoint(0).x;
}
delete theShape;
delete finalPath;
curve->unref();
}
开发者ID:NotBrianZach,项目名称:modalComposableProgrammableFuzzySearchingVectorGraphicEditing,代码行数:59,代码来源:sp-offset.cpp
示例3: if
void
SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item)
{
if (!SP_IS_GROUP(group)) {
return;
}
GSList *item_list = sp_item_group_item_list(SP_GROUP(group));
for ( GSList *iter = item_list; iter; iter = iter->next ) {
SPObject *subitem = static_cast<SPObject *>(iter->data);
if (SP_IS_GROUP(subitem)) {
apply_to_clip_or_mask_group(SP_ITEM(subitem), item);
} else if (SP_IS_SHAPE(subitem)) {
SPCurve * c = NULL;
if (SP_IS_PATH(subitem)) {
c = SP_PATH(subitem)->get_original_curve();
} else {
c = SP_SHAPE(subitem)->getCurve();
}
if (c) {
bool success = false;
if(SP_IS_GROUP(group)){
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)));
success = this->performPathEffect(c);
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse());
} else {
success = this->performPathEffect(c);
}
Inkscape::XML::Node *repr = subitem->getRepr();
if (success) {
gchar *str = sp_svg_write_path(c->get_pathvector());
repr->setAttribute("d", str);
g_free(str);
} else {
// LPE was unsuccesfull. Read the old 'd'-attribute.
if (gchar const * value = repr->attribute("d")) {
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *oldcurve = new SPCurve(pv);
if (oldcurve) {
SP_SHAPE(subitem)->setCurve(oldcurve, TRUE);
oldcurve->unref();
}
}
}
c->unref();
}
}
}
}
示例4: sp_dropper_context_setup
static void sp_dropper_context_setup(SPEventContext *ec)
{
SPDropperContext *dc = SP_DROPPER_CONTEXT(ec);
if (((SPEventContextClass *) parent_class)->setup) {
((SPEventContextClass *) parent_class)->setup(ec);
}
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
SPCurve *c = new SPCurve();
const double C1 = 0.552;
c->moveto(-1,0);
c->curveto(-1, C1, -C1, 1, 0, 1 );
c->curveto(C1, 1, 1, C1, 1, 0 );
c->curveto(1, -C1, C1, -1, 0, -1 );
c->curveto(-C1, -1, -1, -C1, -1, 0 );
c->closepath();
dc->area = sp_canvas_bpath_new(sp_desktop_controls(ec->desktop), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(dc->area), 0x00000000,(SPWindRule)0);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->area), 0x0000007f, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_hide(dc->area);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/dropper/selcue")) {
ec->enableSelectionCue();
}
if (prefs->getBool("/tools/dropper/gradientdrag")) {
ec->enableGrDrag();
}
}
示例5: refresh_source
void SPUsePath::refresh_source()
{
sourceDirty = false;
delete originalPath;
originalPath = NULL;
// le mauvais cas: pas d'attribut d => il faut verifier que c'est une SPShape puis prendre le contour
// [tr: The bad case: no d attribute. Must check that it's a SPShape and then take the outline.]
SPObject *refobj = sourceObject;
if ( refobj == NULL ) return;
SPItem *item = SP_ITEM(refobj);
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item))
{
curve = SP_SHAPE(item)->getCurve();
}
else if (SP_IS_TEXT(item))
{
curve = SP_TEXT(item)->getNormalizedBpath();
}
else
{
return;
}
if (curve == NULL)
return;
originalPath = new Path;
originalPath->LoadPathVector(curve->get_pathvector(), item->transform, true);
curve->unref();
}
示例6: if
static void
sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
{
GSList const *item_list = sp_item_group_item_list(SP_GROUP(group));
for ( GSList const *iter = item_list; iter; iter = iter->next ) {
SPObject *subitem = static_cast<SPObject *>(iter->data);
if (SP_IS_GROUP(subitem)) {
sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write);
} else if (SP_IS_SHAPE(subitem)) {
SPCurve * c = NULL;
if (SP_IS_PATH(subitem)) {
c = SP_PATH(subitem)->get_original_curve();
} else {
c = SP_SHAPE(subitem)->getCurve();
}
// only run LPEs when the shape has a curve defined
if (c) {
sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
SP_SHAPE(subitem)->setCurve(c, TRUE);
if (write) {
Inkscape::XML::Node *repr = subitem->getRepr();
gchar *str = sp_svg_write_path(c->get_pathvector());
repr->setAttribute("d", str);
#ifdef GROUP_VERBOSE
g_message("sp_group_perform_patheffect writes 'd' attribute");
#endif
g_free(str);
}
c->unref();
}
}
}
}
示例7: set
void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value)
{
SPPolyLine *polyline = SP_POLYLINE(object);
switch (key) {
case SP_ATTR_POINTS: {
SPCurve * curve;
const gchar * cptr;
char * eptr;
gboolean hascpt;
if (!value) break;
curve = new SPCurve ();
hascpt = FALSE;
cptr = value;
eptr = NULL;
while (TRUE) {
gdouble x, y;
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
cptr++;
}
if (!*cptr) break;
x = g_ascii_strtod (cptr, &eptr);
if (eptr == cptr) break;
cptr = eptr;
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
cptr++;
}
if (!*cptr) break;
y = g_ascii_strtod (cptr, &eptr);
if (eptr == cptr) break;
cptr = eptr;
if (hascpt) {
curve->lineto(x, y);
} else {
curve->moveto(x, y);
hascpt = TRUE;
}
}
(SP_SHAPE (polyline))->setCurve (curve, TRUE);
curve->unref();
break;
}
default:
if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) {
((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value);
}
break;
}
}
示例8: if
static void
sp_path_update_patheffect(SPLPEItem *lpeitem, bool write)
{
SPShape * const shape = (SPShape *) lpeitem;
Inkscape::XML::Node *repr = shape->getRepr();
#ifdef PATH_VERBOSE
g_message("sp_path_update_patheffect");
#endif
if (shape->_curve_before_lpe && sp_lpe_item_has_path_effect_recursive(lpeitem)) {
SPCurve *curve = shape->_curve_before_lpe->copy();
/* if a path has an lpeitem applied, then reset the curve to the _curve_before_lpe.
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
shape->setCurveInsync(curve, TRUE);
bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve);
if (success && write) {
// could also do shape->getRepr()->updateRepr(); but only the d attribute needs updating.
#ifdef PATH_VERBOSE
g_message("sp_path_update_patheffect writes 'd' attribute");
#endif
if ( shape->_curve != NULL ) {
gchar *str = sp_svg_write_path(shape->_curve->get_pathvector());
repr->setAttribute("d", str);
g_free(str);
} else {
repr->setAttribute("d", NULL);
}
} else if (!success) {
// LPE was unsuccesfull. Read the old 'd'-attribute.
if (gchar const * value = repr->attribute("d")) {
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *oldcurve = new SPCurve(pv);
if (oldcurve) {
shape->setCurve(oldcurve, TRUE);
oldcurve->unref();
}
}
}
shape->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
curve->unref();
}
}
示例9:
void
sp_selected_path_reverse(SPDesktop *desktop)
{
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> items = selection->itemList();
if (items.empty()) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
return;
}
// set "busy" cursor
desktop->setWaitingCursor();
bool did = false;
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));
for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); ++i){
SPPath *path = dynamic_cast<SPPath *>(*i);
if (!path) {
continue;
}
did = true;
SPCurve *rcurve = path->get_curve_reference()->create_reverse();
gchar *str = sp_svg_write_path(rcurve->get_pathvector());
if ( path->hasPathEffectRecursive() ) {
path->getRepr()->setAttribute("inkscape:original-d", str);
} else {
path->getRepr()->setAttribute("d", str);
}
g_free(str);
rcurve->unref();
// reverse nodetypes order (Bug #179866)
gchar *nodetypes = g_strdup(path->getRepr()->attribute("sodipodi:nodetypes"));
if ( nodetypes ) {
path->getRepr()->setAttribute("sodipodi:nodetypes", g_strreverse(nodetypes));
g_free(nodetypes);
}
}
desktop->clearWaitingCursor();
if (did) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_REVERSE,
_("Reverse path"));
} else {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
}
示例10:
void
sp_selected_path_reverse(SPDesktop *desktop)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
GSList *items = (GSList *) selection->itemList();
if (!items) {
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
return;
}
// set "busy" cursor
desktop->setWaitingCursor();
bool did = false;
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));
for (GSList *i = items; i != NULL; i = i->next) {
if (!SP_IS_PATH(i->data)) {
continue;
}
did = true;
SPPath *path = SP_PATH(i->data);
SPCurve *rcurve = path->get_curve_reference()->create_reverse();
gchar *str = sp_svg_write_path(rcurve->get_pathvector());
if ( path->hasPathEffectRecursive() ) {
path->getRepr()->setAttribute("inkscape:original-d", str);
} else {
path->getRepr()->setAttribute("d", str);
}
g_free(str);
rcurve->unref();
// reverse nodetypes order (Bug #179866)
gchar *nodetypes = g_strdup(path->getRepr()->attribute("sodipodi:nodetypes"));
if ( nodetypes ) {
path->getRepr()->setAttribute("sodipodi:nodetypes", g_strreverse(nodetypes));
g_free(nodetypes);
}
}
desktop->clearWaitingCursor();
if (did) {
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE,
_("Reverse path"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
}
示例11: set_shape
void SPLine::set_shape() {
SPCurve *c = new SPCurve();
c->moveto(this->x1.computed, this->y1.computed);
c->lineto(this->x2.computed, this->y2.computed);
this->setCurveInsync(c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update
this->setCurveBeforeLPE(c);
// LPE's cannot be applied to lines. (the result can (generally) not be represented as SPLine)
c->unref();
}
示例12: sp_spray_context_setup
static void sp_spray_context_setup(SPEventContext *ec)
{
SPSprayContext *tc = SP_SPRAY_CONTEXT(ec);
if (((SPEventContextClass *) parent_class)->setup) {
((SPEventContextClass *) parent_class)->setup(ec);
}
{
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
SPCurve *c = new SPCurve();
const double C1 = 0.552;
c->moveto(-1,0);
c->curveto(-1, C1, -C1, 1, 0, 1 );
c->curveto(C1, 1, 1, C1, 1, 0 );
c->curveto(1, -C1, C1, -1, 0, -1 );
c->curveto(-C1, -1, -1, -C1, -1, 0 );
c->closepath();
tc->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(ec->desktop), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(tc->dilate_area), 0x00000000,(SPWindRule)0);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(tc->dilate_area), 0xff9900ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_hide(tc->dilate_area);
}
tc->is_drawing = false;
tc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
sp_event_context_read(ec, "distrib");
sp_event_context_read(ec, "width");
sp_event_context_read(ec, "ratio");
sp_event_context_read(ec, "tilt");
sp_event_context_read(ec, "rotation_variation");
sp_event_context_read(ec, "scale_variation");
sp_event_context_read(ec, "mode");
sp_event_context_read(ec, "population");
sp_event_context_read(ec, "force");
sp_event_context_read(ec, "mean");
sp_event_context_read(ec, "standard_deviation");
sp_event_context_read(ec, "usepressure");
sp_event_context_read(ec, "Scale");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/spray/selcue")) {
ec->enableSelectionCue();
}
if (prefs->getBool("/tools/spray/gradientdrag")) {
ec->enableGrDrag();
}
}
示例13: spdc_attach_selection
static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/)
{
// We reset white and forget white/start/end anchors
spdc_reset_white(dc);
dc->sa = NULL;
dc->ea = NULL;
SPItem *item = dc->selection ? dc->selection->singleItem() : NULL;
if ( item && SP_IS_PATH(item) ) {
// Create new white data
// Item
dc->white_item = item;
// Curve list
// We keep it in desktop coordinates to eliminate calculation errors
SPCurve *norm = SP_PATH(item)->get_curve_for_edit();
norm->transform((dc->white_item)->i2dt_affine());
g_return_if_fail( norm != NULL );
dc->white_curves = g_slist_reverse(norm->split());
norm->unref();
// Anchor list
for (GSList *l = dc->white_curves; l != NULL; l = l->next) {
SPCurve *c;
c = static_cast<SPCurve*>(l->data);
g_return_if_fail( c->get_segment_count() > 0 );
if ( !c->is_closed() ) {
SPDrawAnchor *a;
a = sp_draw_anchor_new(dc, c, TRUE, *(c->first_point()));
if (a)
dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
a = sp_draw_anchor_new(dc, c, FALSE, *(c->last_point()));
if (a)
dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
}
}
// fixme: recalculate active anchor?
}
}
示例14: sp_image_set_curve
static void sp_image_set_curve( SPImage *image )
{
//create a curve at the image's boundary for snapping
if ((image->height.computed < MAGIC_EPSILON_TOO) || (image->width.computed < MAGIC_EPSILON_TOO) || (image->clip_ref->getObject())) {
if (image->curve) {
image->curve = image->curve->unref();
}
} else {
Geom::OptRect rect = image->bbox(Geom::identity(), SPItem::VISUAL_BBOX);
SPCurve *c = SPCurve::new_from_rect(*rect, true);
if (image->curve) {
image->curve = image->curve->unref();
}
if (c) {
image->curve = c->ref();
c->unref();
}
}
}
示例15:
void
PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
curve = SP_SHAPE(linked_obj)->getCurve();
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
}
if (curve == NULL) {
// curve invalid, set default value
_pathvector = sp_svg_read_pathv(defvalue);
} else {
_pathvector = curve->get_pathvector();
curve->unref();
}
must_recalculate_pwd2 = true;
emit_changed();
SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
}