本文整理汇总了C++中SPCurve::append方法的典型用法代码示例。如果您正苦于以下问题:C++ SPCurve::append方法的具体用法?C++ SPCurve::append怎么用?C++ SPCurve::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPCurve
的用法示例。
在下文中一共展示了SPCurve::append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: items
void
sp_selected_path_combine(SPDesktop *desktop)
{
Inkscape::Selection *selection = desktop->getSelection();
SPDocument *doc = desktop->getDocument();
std::vector<SPItem*> items(selection->itemList());
if (items.size() < 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine."));
return;
}
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Combining paths..."));
// set "busy" cursor
desktop->setWaitingCursor();
items = sp_degroup_list (items); // descend into any groups in selection
std::vector<SPItem*> to_paths;
for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i) {
if (!dynamic_cast<SPPath *>(*i) && !dynamic_cast<SPGroup *>(*i)) {
to_paths.push_back(*i);
}
}
std::vector<Inkscape::XML::Node*> converted;
bool did = sp_item_list_to_curves(to_paths, items, converted);
for (std::vector<Inkscape::XML::Node*>::const_iterator i = converted.begin(); i != converted.end(); ++i)
items.push_back((SPItem*)doc->getObjectByRepr(*i));
items = sp_degroup_list (items); // converting to path may have added more groups, descend again
sort(items.begin(),items.end(),less_than_items);
assert(!items.empty()); // cannot be NULL because of list length check at top of function
// remember the position, id, transform and style of the topmost path, they will be assigned to the combined one
gint position = 0;
char const *id = NULL;
char const *transform = NULL;
char const *style = NULL;
char const *path_effect = NULL;
SPCurve* curve = NULL;
SPItem *first = NULL;
Inkscape::XML::Node *parent = NULL;
if (did) {
selection->clear();
}
for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i){
SPItem *item = *i;
SPPath *path = dynamic_cast<SPPath *>(item);
if (!path) {
continue;
}
if (!did) {
selection->clear();
did = true;
}
SPCurve *c = path->get_curve_for_edit();
if (first == NULL) { // this is the topmost path
first = item;
parent = first->getRepr()->parent();
position = first->getRepr()->position();
id = first->getRepr()->attribute("id");
transform = first->getRepr()->attribute("transform");
// FIXME: merge styles of combined objects instead of using the first one's style
style = first->getRepr()->attribute("style");
path_effect = first->getRepr()->attribute("inkscape:path-effect");
//c->transform(item->transform);
curve = c;
} else {
c->transform(item->getRelativeTransform(first));
curve->append(c, false);
c->unref();
// reduce position only if the same parent
if (item->getRepr()->parent() == parent) {
position--;
}
// delete the object for real, so that its clones can take appropriate action
item->deleteObject();
}
}
if (did) {
first->deleteObject(false);
// delete the topmost.
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
// restore id, transform, path effect, and style
repr->setAttribute("id", id);
if (transform) {
//.........这里部分代码省略.........
示例2: path
void
sp_selected_path_combine(SPDesktop *desktop)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
if (g_slist_length((GSList *) selection->itemList()) < 1) {
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine."));
return;
}
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Combining paths..."));
// set "busy" cursor
desktop->setWaitingCursor();
GSList *items = g_slist_copy((GSList *) selection->itemList());
items = sp_degroup_list (items); // descend into any groups in selection
GSList *to_paths = NULL;
for (GSList *i = items; i != NULL; i = i->next) {
SPItem *item = (SPItem *) i->data;
if (!SP_IS_PATH(item) && !SP_IS_GROUP(item))
to_paths = g_slist_prepend(to_paths, item);
}
GSList *converted = NULL;
bool did = sp_item_list_to_curves(to_paths, &items, &converted);
g_slist_free(to_paths);
for (GSList *i = converted; i != NULL; i = i->next)
items = g_slist_prepend(items, doc->getObjectByRepr((Inkscape::XML::Node*)(i->data)));
items = sp_degroup_list (items); // converting to path may have added more groups, descend again
items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position);
items = g_slist_reverse(items);
// remember the position, id, transform and style of the topmost path, they will be assigned to the combined one
gint position = 0;
char const *id = NULL;
char const *transform = NULL;
char const *style = NULL;
char const *path_effect = NULL;
SPCurve* curve = NULL;
SPItem *first = NULL;
Inkscape::XML::Node *parent = NULL;
if (did) {
selection->clear();
}
for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom
SPItem *item = (SPItem *) i->data;
if (!SP_IS_PATH(item)) {
continue;
}
if (!did) {
selection->clear();
did = true;
}
SPCurve *c = SP_PATH(item)->get_curve_for_edit();
if (first == NULL) { // this is the topmost path
first = item;
parent = first->getRepr()->parent();
position = first->getRepr()->position();
id = first->getRepr()->attribute("id");
transform = first->getRepr()->attribute("transform");
// FIXME: merge styles of combined objects instead of using the first one's style
style = first->getRepr()->attribute("style");
path_effect = first->getRepr()->attribute("inkscape:path-effect");
//c->transform(item->transform);
curve = c;
} else {
c->transform(item->getRelativeTransform(first));
curve->append(c, false);
c->unref();
// reduce position only if the same parent
if (item->getRepr()->parent() == parent) {
position--;
}
// delete the object for real, so that its clones can take appropriate action
item->deleteObject();
}
}
g_slist_free(items);
if (did) {
first->deleteObject(false);
// delete the topmost.
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
// restore id, transform, path effect, and style
repr->setAttribute("id", id);
//.........这里部分代码省略.........
示例3: spdc_flush_white
static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
{
SPCurve *c;
if (dc->white_curves) {
g_assert(dc->white_item);
c = SPCurve::concat(dc->white_curves);
g_slist_free(dc->white_curves);
dc->white_curves = NULL;
if (gc) {
c->append(gc, FALSE);
}
} else if (gc) {
c = gc;
c->ref();
} else {
return;
}
// Now we have to go back to item coordinates at last
c->transform( dc->white_item
? (dc->white_item)->dt2i_affine()
: dc->desktop->dt2doc() );
SPDesktop *desktop = dc->desktop;
SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
if ( c && !c->is_empty() ) {
// We actually have something to write
bool has_lpe = false;
Inkscape::XML::Node *repr;
if (dc->white_item) {
repr = dc->white_item->getRepr();
has_lpe = SP_LPE_ITEM(dc->white_item)->hasPathEffectRecursive();
} else {
repr = xml_doc->createElement("svg:path");
// Set style
sp_desktop_apply_style_tool(desktop, repr, tool_name(dc).data(), false);
}
gchar *str = sp_svg_write_path( c->get_pathvector() );
g_assert( str != NULL );
if (has_lpe)
repr->setAttribute("inkscape:original-d", str);
else
repr->setAttribute("d", str);
g_free(str);
if (!dc->white_item) {
// Attach repr
SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
spdc_check_for_and_apply_waiting_LPE(dc, item, c);
if(previous_shape_type != BEND_CLIPBOARD){
dc->selection->set(repr);
}
Inkscape::GC::release(repr);
item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
item->updateRepr();
item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
if(previous_shape_type == BEND_CLIPBOARD){
repr->parent()->removeChild(repr);
}
}
DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL,
_("Draw path"));
// When quickly drawing several subpaths with Shift, the next subpath may be finished and
// flushed before the selection_modified signal is fired by the previous change, which
// results in the tool losing all of the selected path's curve except that last subpath. To
// fix this, we force the selection_modified callback now, to make sure the tool's curve is
// in sync immediately.
spdc_selection_modified(desktop->getSelection(), 0, dc);
}
c->unref();
// Flush pending updates
doc->ensureUpToDate();
}