本文整理汇总了C++中SPObject类的典型用法代码示例。如果您正苦于以下问题:C++ SPObject类的具体用法?C++ SPObject怎么用?C++ SPObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sp_conn_end_href_changed
void
sp_conn_end_href_changed(SPObject */*old_ref*/, SPObject */*ref*/,
SPConnEnd *connEndPtr, SPPath *const path, unsigned const handle_ix)
{
g_return_if_fail(connEndPtr != NULL);
SPConnEnd &connEnd = *connEndPtr;
connEnd._delete_connection.disconnect();
connEnd._transformed_connection.disconnect();
connEnd._group_connection.disconnect();
if (connEnd.href) {
SPObject *refobj = connEnd.ref.getObject();
if (refobj) {
connEnd._delete_connection
= refobj->connectDelete(sigc::bind(sigc::ptr_fun(&sp_conn_end_deleted),
path, handle_ix));
// This allows the connector tool to dive into a group's children
// And connect to their children's centers.
SPObject *parent = refobj->parent;
if (SP_IS_GROUP(parent) && ! SP_IS_LAYER(parent)) {
connEnd._group_connection
= SP_ITEM(parent)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_conn_end_shape_move),
path));
}
connEnd._transformed_connection
= SP_ITEM(refobj)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_conn_end_shape_move),
path));
}
}
}
示例2: sp_root_build
/**
* Fills in the data for an SPObject from its Inkscape::XML::Node object.
* It fills in data such as version, x, y, width, height, etc.
* It then calls the object's parent class object's build function.
*/
static void sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
SPGroup *group = (SPGroup *) object;
SPRoot *root = (SPRoot *) object;
//XML Tree being used directly here while it shouldn't be.
if ( !object->getRepr()->attribute("version") ) {
repr->setAttribute("version", SVG_VERSION);
}
object->readAttr( "version" );
object->readAttr( "inkscape:version" );
/* It is important to parse these here, so objects will have viewport build-time */
object->readAttr( "x" );
object->readAttr( "y" );
object->readAttr( "width" );
object->readAttr( "height" );
object->readAttr( "viewBox" );
object->readAttr( "preserveAspectRatio" );
object->readAttr( "onload" );
if (((SPObjectClass *) parent_class)->build)
(* ((SPObjectClass *) parent_class)->build) (object, document, repr);
// Search for first <defs> node
for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
if (SP_IS_DEFS(o)) {
root->defs = SP_DEFS(o);
break;
}
}
// clear transform, if any was read in - SVG does not allow transform= on <svg>
SP_ITEM(object)->transform = Geom::identity();
}
示例3: sp_clippath_modified
static void
sp_clippath_modified(SPObject *object, guint flags)
{
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
flags &= SP_OBJECT_MODIFIED_CASCADE;
SPObjectGroup *og = SP_OBJECTGROUP(object);
GSList *l = NULL;
for (SPObject *child = sp_object_first_child(SP_OBJECT(og)); child != NULL; child = SP_OBJECT_NEXT(child)) {
g_object_ref(G_OBJECT(child));
l = g_slist_prepend(l, child);
}
l = g_slist_reverse(l);
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->emitModified(flags);
}
g_object_unref(G_OBJECT(child));
}
}
示例4: build
/**
* Virtual build: set gradient attributes from its associated repr.
*/
void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr)
{
// Work-around in case a swatch had been marked for immediate collection:
if ( repr->attribute("osb:paint") && repr->attribute("inkscape:collect") ) {
repr->setAttribute("inkscape:collect", 0);
}
SPPaintServer::build(document, repr);
for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
this->has_stops = TRUE;
break;
}
}
this->readAttr( "gradientUnits" );
this->readAttr( "gradientTransform" );
this->readAttr( "spreadMethod" );
this->readAttr( "xlink:href" );
this->readAttr( "osb:paint" );
// Register ourselves
document->addResource("gradient", this);
}
示例5: sp_gradient_vector_widget_destroy
static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer /*data*/)
#endif
{
SPObject *gradient = SP_OBJECT(g_object_get_data(G_OBJECT(object), "gradient"));
sigc::connection *release_connection = static_cast<sigc::connection *>(g_object_get_data(G_OBJECT(object), "gradient_release_connection"));
sigc::connection *modified_connection = static_cast<sigc::connection *>(g_object_get_data(G_OBJECT(object), "gradient_modified_connection"));
if (gradient) {
g_assert( release_connection != NULL );
g_assert( modified_connection != NULL );
release_connection->disconnect();
modified_connection->disconnect();
sp_signal_disconnect_by_data(gradient, object);
if (gradient->getRepr()) {
sp_repr_remove_listener_by_data(gradient->getRepr(), object);
}
}
SelectedColor *selected_color = static_cast<SelectedColor *>(g_object_get_data(G_OBJECT(object), "cselector"));
if (selected_color) {
delete selected_color;
g_object_set_data(G_OBJECT(object), "cselector", NULL);
}
}
示例6: remove_child
/**
* Callback for remove_child event.
*/
void SPGradient::remove_child(Inkscape::XML::Node *child)
{
this->invalidateVector();
SPPaintServer::remove_child(child);
this->has_stops = FALSE;
for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
this->has_stops = TRUE;
break;
}
}
if ( this->getStopCount() == 0 ) {
gchar const * attr = this->getAttribute("osb:paint");
if ( attr && strcmp(attr, "solid") ) {
this->setAttribute( "osb:paint", "solid", 0 );
}
}
/* Fixme: should we schedule "modified" here? */
this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
示例7: sp_clippath_view_new_prepend
Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int key) {
Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing);
display = sp_clippath_view_new_prepend(display, key, ai);
for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS);
if (ac) {
/* The order is not important in clippath */
ai->appendChild(ac);
}
}
}
if (clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && display->bbox) {
Geom::Affine t = Geom::Scale(display->bbox->dimensions());
t.setTranslation(display->bbox->min());
ai->setChildTransform(t);
}
ai->setStyle(this->style);
return ai;
}
示例8: sp_tref_href_changed
/* For the sigc::connection changes (i.e. when the object being refered to changes) */
static void
sp_tref_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTRef *tref)
{
if (tref)
{
// Save a pointer to the original object being referred to
SPObject *refRoot = tref->getObjectReferredTo();
tref->_delete_connection.disconnect();
if (tref->stringChild) {
tref->detach(tref->stringChild);
tref->stringChild = NULL;
}
// Ensure that we are referring to a legitimate object
if (tref->href && refRoot && sp_tref_reference_allowed(tref, refRoot)) {
// Update the text being referred to (will create a new string child)
sp_tref_update_text(tref);
// Restore the delete connection now that we're done messing with stuff
tref->_delete_connection = refRoot->connectDelete(sigc::bind(sigc::ptr_fun(&sp_tref_delete_self), tref));
}
}
}
示例9: Shape
Shape* SPFlowtext::_buildExclusionShape() const
{
Shape *shape = new Shape();
Shape *shape_temp = new Shape();
for (SPObject *child = children ; child ; child = child->getNext() ) {
// RH: is it right that this shouldn't be recursive?
if ( SP_IS_FLOWREGIONEXCLUDE(child) ) {
SPFlowregionExclude *c_child = SP_FLOWREGIONEXCLUDE(child);
if ( c_child->computed && c_child->computed->hasEdges() ) {
if (shape->hasEdges()) {
shape_temp->Booleen(shape, c_child->computed, bool_op_union);
std::swap(shape, shape_temp);
} else {
shape->Copy(c_child->computed);
}
}
}
}
delete shape_temp;
return shape;
}
示例10: sp_marker_load_from_svg
static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current_doc)
{
static SPDocument *doc = NULL;
static unsigned int edoc = FALSE;
if (!current_doc) {
return NULL;
}
/* Try to load from document */
if (!edoc && !doc) {
gchar *markers = g_build_filename(INKSCAPE_MARKERSDIR, "/markers.svg", NULL);
if (Inkscape::IO::file_test(markers, G_FILE_TEST_IS_REGULAR)) {
doc = SPDocument::createNewDoc(markers, FALSE);
}
g_free(markers);
if (doc) {
doc->ensureUpToDate();
} else {
edoc = TRUE;
}
}
if (!edoc && doc) {
/* Get the marker we want */
SPObject *object = doc->getObjectById(name);
if (object && SP_IS_MARKER(object)) {
SPDefs *defs = current_doc->getDefs();
Inkscape::XML::Document *xml_doc = current_doc->getReprDoc();
Inkscape::XML::Node *mark_repr = object->getRepr()->duplicate(xml_doc);
defs->getRepr()->addChild(mark_repr, NULL);
SPObject *cloned_item = current_doc->getObjectByRepr(mark_repr);
Inkscape::GC::release(mark_repr);
return cloned_item;
}
}
return NULL;
}
示例11: SP_FLOWTEXT
void SPFlowtext::modified(unsigned int flags) {
SPObject *region = NULL;
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
flags &= SP_OBJECT_MODIFIED_CASCADE;
// FIXME: the below stanza is copied over from sp_text_modified, consider factoring it out
if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
SPFlowtext *text = SP_FLOWTEXT(this);
Geom::OptRect pbox = text->geometricBounds();
for (SPItemView* v = text->display; v != NULL; v = v->next) {
Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem);
text->_clearFlow(g);
g->setStyle(this->style);
text->layout.show(g, pbox);
}
}
for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) {
if (SP_IS_FLOWREGION(o)) {
region = o;
break;
}
}
if (region) {
if (flags || (region->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
region->emitModified(flags); // pass down to the region only
}
}
}
示例12: sp_group_perform_patheffect
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();
}
}
}
}
示例13: sp_object_ref
void SPClipPath::modified(unsigned int flags) {
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
for (SPObject *child = this->firstChild(); child; child = child->getNext()) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
l = g_slist_reverse(l);
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->emitModified(flags);
}
sp_object_unref(child);
}
}
示例14: sp_textpath_write
static Inkscape::XML::Node *
sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
SPTextPath *textpath = SP_TEXTPATH(object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
repr = xml_doc->createElement("svg:textPath");
}
textpath->attributes.writeTo(repr);
if (textpath->startOffset._set) {
if (textpath->startOffset.unit == SVGLength::PERCENT) {
Inkscape::SVGOStringStream os;
os << (textpath->startOffset.computed * 100.0) << "%";
SP_OBJECT_REPR(textpath)->setAttribute("startOffset", os.str().c_str());
} else {
/* FIXME: This logic looks rather undesirable if e.g. startOffset is to be
in ems. */
sp_repr_set_svg_double(repr, "startOffset", textpath->startOffset.computed);
}
}
if ( textpath->sourcePath->sourceHref ) repr->setAttribute("xlink:href", textpath->sourcePath->sourceHref);
if ( flags&SP_OBJECT_WRITE_BUILD ) {
GSList *l = NULL;
for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
Inkscape::XML::Node* c_repr=NULL;
if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
c_repr = child->updateRepr(xml_doc, NULL, flags);
} else if ( SP_IS_TEXTPATH(child) ) {
//c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
} else if ( SP_IS_STRING(child) ) {
c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
}
if ( c_repr ) l = g_slist_prepend(l, c_repr);
}
while ( l ) {
repr->addChild((Inkscape::XML::Node *) l->data, NULL);
Inkscape::GC::release((Inkscape::XML::Node *) l->data);
l = g_slist_remove(l, l->data);
}
} else {
for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
child->updateRepr(flags);
} else if ( SP_IS_TEXTPATH(child) ) {
//c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
} else if ( SP_IS_STRING(child) ) {
SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str());
}
}
}
if (((SPObjectClass *) textpath_parent_class)->write)
((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags);
return repr;
}
示例15: release
void SPObject::release() {
SPObject* object = this;
debug("id=%p, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
while (object->children) {
object->detach(object->children);
}
}