本文整理汇总了C++中inkscape::Selection::setReprList方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::setReprList方法的具体用法?C++ Selection::setReprList怎么用?C++ Selection::setReprList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inkscape::Selection
的用法示例。
在下文中一共展示了Selection::setReprList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sp_selected_to_lpeitems
/** Converts the selected items to LPEItems if they are not already so; e.g. SPRects) */
void sp_selected_to_lpeitems(SPDesktop *desktop)
{
Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
return;
}
std::vector<SPItem*> selected(selection->itemList());
std::vector<Inkscape::XML::Node*> to_select;
selection->clear();
std::vector<SPItem*> items(selected);
sp_item_list_to_curves(items, selected, to_select, true);
selection->setReprList(to_select);
selection->addList(selected);
}
示例2:
/* This function is an entry point from GUI */
void
sp_selected_path_to_curves(SPDesktop *desktop, bool interactive)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (selection->isEmpty()) {
if (interactive)
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to path."));
return;
}
bool did = false;
if (interactive) {
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Converting objects to paths..."));
// set "busy" cursor
desktop->setWaitingCursor();
}
GSList *selected = g_slist_copy((GSList *) selection->itemList());
GSList *to_select = NULL;
selection->clear();
GSList *items = g_slist_copy(selected);
did = sp_item_list_to_curves(items, &selected, &to_select);
g_slist_free (items);
selection->setReprList(to_select);
selection->addList(selected);
g_slist_free (to_select);
g_slist_free (selected);
if (interactive) {
desktop->clearWaitingCursor();
if (did) {
sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE,
_("Object to path"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No objects</b> to convert to path in the selection."));
return;
}
}
}
示例3: sp_selected_to_lpeitems
/** Converts the selected items to LPEItems if they are not already so; e.g. SPRects) */
void sp_selected_to_lpeitems(SPDesktop *desktop)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (selection->isEmpty()) {
return;
}
bool did = false;
GSList *selected = g_slist_copy((GSList *) selection->itemList());
GSList *to_select = NULL;
selection->clear();
GSList *items = g_slist_copy(selected);
did = sp_item_list_to_curves(items, &selected, &to_select, true);
g_slist_free (items);
selection->setReprList(to_select);
selection->addList(selected);
g_slist_free (to_select);
g_slist_free (selected);
}
示例4: SPCurve
void
sp_selected_path_break_apart(SPDesktop *desktop)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (selection->isEmpty()) {
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to break apart."));
return;
}
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Breaking apart paths..."));
// set "busy" cursor
desktop->setWaitingCursor();
bool did = false;
for (GSList *items = g_slist_copy((GSList *) selection->itemList());
items != NULL;
items = items->next) {
SPItem *item = (SPItem *) items->data;
if (!SP_IS_PATH(item)) {
continue;
}
SPPath *path = SP_PATH(item);
SPCurve *curve = path->get_curve_for_edit();
if (curve == NULL) {
continue;
}
did = true;
Inkscape::XML::Node *parent = item->getRepr()->parent();
gint pos = item->getRepr()->position();
char const *id = item->getRepr()->attribute("id");
// XML Tree being used directly here while it shouldn't be...
gchar *style = g_strdup(item->getRepr()->attribute("style"));
// XML Tree being used directly here while it shouldn't be...
gchar *path_effect = g_strdup(item->getRepr()->attribute("inkscape:path-effect"));
Geom::PathVector apv = curve->get_pathvector() * path->transform;
curve->unref();
// it's going to resurrect as one of the pieces, so we delete without advertisement
item->deleteObject(false);
curve = new SPCurve(apv);
g_assert(curve != NULL);
GSList *list = curve->split();
curve->unref();
GSList *reprs = NULL;
for (GSList *l = list; l != NULL; l = l->next) {
curve = (SPCurve *) l->data;
Inkscape::XML::Node *repr = parent->document()->createElement("svg:path");
repr->setAttribute("style", style);
repr->setAttribute("inkscape:path-effect", path_effect);
gchar *str = sp_svg_write_path(curve->get_pathvector());
if (path_effect)
repr->setAttribute("inkscape:original-d", str);
else
repr->setAttribute("d", str);
g_free(str);
// add the new repr to the parent
parent->appendChild(repr);
// move to the saved position
repr->setPosition(pos > 0 ? pos : 0);
// if it's the first one, restore id
if (l == list)
repr->setAttribute("id", id);
reprs = g_slist_prepend (reprs, repr);
Inkscape::GC::release(repr);
}
selection->setReprList(reprs);
g_slist_free(reprs);
g_slist_free(list);
g_free(style);
g_free(path_effect);
}
desktop->clearWaitingCursor();
if (did) {
//.........这里部分代码省略.........
示例5: itemlist
void
sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
{
Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to break apart."));
return;
}
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Breaking apart paths..."));
// set "busy" cursor
desktop->setWaitingCursor();
bool did = false;
std::vector<SPItem*> itemlist(selection->itemList());
for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){
SPItem *item = *i;
SPPath *path = dynamic_cast<SPPath *>(item);
if (!path) {
continue;
}
SPCurve *curve = path->get_curve_for_edit();
if (curve == NULL) {
continue;
}
did = true;
Inkscape::XML::Node *parent = item->getRepr()->parent();
gint pos = item->getRepr()->position();
char const *id = item->getRepr()->attribute("id");
// XML Tree being used directly here while it shouldn't be...
gchar *style = g_strdup(item->getRepr()->attribute("style"));
// XML Tree being used directly here while it shouldn't be...
gchar *path_effect = g_strdup(item->getRepr()->attribute("inkscape:path-effect"));
Geom::Affine transform = path->transform;
// it's going to resurrect as one of the pieces, so we delete without advertisement
item->deleteObject(false);
GSList *list = curve->split();
curve->unref();
std::vector<Inkscape::XML::Node*> reprs;
for (GSList *l = list; l != NULL; l = l->next) {
curve = (SPCurve *) l->data;
Inkscape::XML::Node *repr = parent->document()->createElement("svg:path");
repr->setAttribute("style", style);
repr->setAttribute("inkscape:path-effect", path_effect);
gchar *str = sp_svg_write_path(curve->get_pathvector());
if (path_effect)
repr->setAttribute("inkscape:original-d", str);
else
repr->setAttribute("d", str);
g_free(str);
repr->setAttribute("transform", sp_svg_transform_write(transform));
// add the new repr to the parent
parent->appendChild(repr);
// move to the saved position
repr->setPosition(pos > 0 ? pos : 0);
// if it's the first one, restore id
if (l == list)
repr->setAttribute("id", id);
reprs.push_back(repr);
Inkscape::GC::release(repr);
}
selection->setReprList(reprs);
g_slist_free(list);
g_free(style);
g_free(path_effect);
}
desktop->clearWaitingCursor();
if (did) {
if ( !skip_undo ) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART,
_("Break apart"));
}
} else {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
}