本文整理汇总了C++中inkscape::Selection类的典型用法代码示例。如果您正苦于以下问题:C++ Selection类的具体用法?C++ Selection怎么用?C++ Selection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Selection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSelectionChanged
void
LivePathEffectEditor::setDesktop(SPDesktop *desktop)
{
Panel::setDesktop(desktop);
if ( desktop == current_desktop ) {
return;
}
if (current_desktop) {
selection_changed_connection.disconnect();
selection_modified_connection.disconnect();
}
lpe_list_locked = false;
current_desktop = desktop;
if (desktop) {
Inkscape::Selection *selection = sp_desktop_selection(desktop);
selection_changed_connection = selection->connectChanged(
sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) );
selection_modified_connection = selection->connectModified(
sigc::bind (sigc::ptr_fun(&lpeeditor_selection_modified), this ) );
onSelectionChanged(selection);
} else {
onSelectionChanged(NULL);
}
}
示例2:
void
ExecutionEnv::reselect (void) {
if (_doc == NULL) {
return;
}
SPDocument * doc = _doc->doc();
if (doc == NULL) {
return;
}
SPDesktop *desktop = (SPDesktop *)_doc;
sp_namedview_document_from_window(desktop);
if (desktop == NULL) {
return;
}
Inkscape::Selection * selection = desktop->getSelection();
for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); ++i) {
SPObject * obj = doc->getObjectById(i->c_str());
if (obj != NULL) {
selection->add(obj);
}
}
return;
}
示例3: setup
void LpeTool::setup() {
PenTool::setup();
Inkscape::Selection *selection = this->desktop->getSelection();
SPItem *item = selection->singleItem();
this->sel_changed_connection.disconnect();
this->sel_changed_connection =
selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_lpetool_context_selection_changed), (gpointer)this));
this->shape_editor = new ShapeEditor(this->desktop);
lpetool_context_switch_mode(this, Inkscape::LivePathEffect::INVALID_LPE);
lpetool_context_reset_limiting_bbox(this);
lpetool_create_measuring_items(this);
// TODO temp force:
this->enableSelectionCue();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (item) {
this->shape_editor->set_item(item);
}
if (prefs->getBool("/tools/lpetool/selcue")) {
this->enableSelectionCue();
}
}
示例4: mesh_toolbox_watch_ec
static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
static sigc::connection c_selection_changed;
static sigc::connection c_selection_modified;
static sigc::connection c_subselection_changed;
static sigc::connection c_defs_release;
static sigc::connection c_defs_modified;
if (SP_IS_MESH_CONTEXT(ec)) {
// connect to selection modified and changed signals
Inkscape::Selection *selection = desktop->getSelection();
SPDocument *document = desktop->getDocument();
c_selection_changed = selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), holder));
c_selection_modified = selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), holder));
c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), holder));
c_defs_release = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), holder));
c_defs_modified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), holder));
ms_tb_selection_changed(selection, holder);
} else {
if (c_selection_changed)
c_selection_changed.disconnect();
if (c_selection_modified)
c_selection_modified.disconnect();
if (c_subselection_changed)
c_subselection_changed.disconnect();
if (c_defs_release)
c_defs_release.disconnect();
if (c_defs_modified)
c_defs_modified.disconnect();
}
}
示例5: warning
void
FontSubstitution::show(Glib::ustring out, GSList *l)
{
Gtk::MessageDialog warning(_("\nSome fonts are not available and have been substituted."),
false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true);
warning.set_resizable(true);
warning.set_title(_("Font substitution"));
GtkWidget *dlg = GTK_WIDGET(warning.gobj());
sp_transientize(dlg);
Gtk::TextView * textview = new Gtk::TextView();
textview->set_editable(false);
textview->set_wrap_mode(Gtk::WRAP_WORD);
textview->show();
textview->get_buffer()->set_text(_(out.c_str()));
Gtk::ScrolledWindow * scrollwindow = new Gtk::ScrolledWindow();
scrollwindow->add(*textview);
scrollwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scrollwindow->set_shadow_type(Gtk::SHADOW_IN);
scrollwindow->set_size_request(0, 100);
scrollwindow->show();
Gtk::CheckButton *cbSelect = new Gtk::CheckButton();
cbSelect->set_label(_("Select all the affected items"));
cbSelect->set_active(true);
cbSelect->show();
Gtk::CheckButton *cbWarning = new Gtk::CheckButton();
cbWarning->set_label(_("Don't show this warning again"));
cbWarning->show();
#if GTK_CHECK_VERSION(3,0,0)
Gtk::Box * box = warning.get_content_area();
#else
Gtk::Box * box = warning.get_vbox();
#endif
box->set_spacing(2);
box->pack_start(*scrollwindow, true, true, 4);
box->pack_start(*cbSelect, false, false, 0);
box->pack_start(*cbWarning, false, false, 0);
warning.run();
if (cbWarning->get_active()) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt("/options/font/substitutedlg", 0);
}
if (cbSelect->get_active()) {
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
selection->clear();
selection->setList(l);
}
}
示例6: path_data
/**
\brief This actually draws the grid.
\param module The effect that was called (unused)
\param document What should be edited.
*/
void
Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
{
Inkscape::Selection * selection = ((SPDesktop *)document)->selection;
Geom::Rect bounding_area = Geom::Rect(Geom::Point(0,0), Geom::Point(100,100));
if (selection->isEmpty()) {
/* get page size */
SPDocument * doc = document->doc();
bounding_area = Geom::Rect( Geom::Point(0,0),
Geom::Point(doc->getWidth(), doc->getHeight()) );
} else {
Geom::OptRect bounds = selection->visualBounds();
if (bounds) {
bounding_area = *bounds;
}
gdouble doc_height = (document->doc())->getHeight();
Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
bounding_area = temprec;
}
float spacings[2] = { module->get_param_float("xspacing"),
module->get_param_float("yspacing") };
float line_width = module->get_param_float("lineWidth");
float offsets[2] = { module->get_param_float("xoffset"),
module->get_param_float("yoffset") };
Glib::ustring path_data("");
path_data = build_lines(bounding_area,
offsets, spacings);
Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc();
//XML Tree being used directly here while it shouldn't be.
Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->getRepr();
Inkscape::XML::Node * path = xml_doc->createElement("svg:path");
path->setAttribute("d", path_data.c_str());
Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000");
style += ";stroke-width:";
gchar floatstring[64];
std::ostringstream stringstream;
stringstream << line_width;
sprintf(floatstring, "%s", stringstream.str().c_str());
style += floatstring;
style += "pt";
path->setAttribute("style", style.c_str());
current_layer->appendChild(path);
Inkscape::GC::release(path);
return;
}
示例7:
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."));
}
}
示例8:
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."));
}
}
示例9:
void
OriginalPathParam::on_select_original_button_click()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
SPItem *original = ref.getObject();
if (desktop == NULL || original == NULL) {
return;
}
Inkscape::Selection *selection = sp_desktop_selection(desktop);
selection->clear();
selection->set(original);
}
示例10:
/*
* Attempts to perform the construction of the given type (i.e., to apply the corresponding LPE) to
* a single selected item. Returns whether we succeeded.
*/
bool
lpetool_try_construction(LpeTool *lc, Inkscape::LivePathEffect::EffectType const type)
{
Inkscape::Selection *selection = lc->desktop->getSelection();
SPItem *item = selection->singleItem();
// TODO: should we check whether type represents a valid geometric construction?
if (item && SP_IS_LPE_ITEM(item) && Inkscape::LivePathEffect::Effect::acceptsNumClicks(type) == 0) {
Inkscape::LivePathEffect::Effect::createAndApply(type, lc->desktop->getDocument(), item);
return true;
}
return false;
}
示例11: onDown
void LivePathEffectEditor::onDown()
{
Inkscape::Selection *sel = _getSelection();
if ( sel && !sel->isEmpty() ) {
SPItem *item = sel->singleItem();
if ( item && SP_IS_LPE_ITEM(item) ) {
sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item));
sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Move path effect down") );
effect_list_reload(SP_LPE_ITEM(item));
}
}
}
示例12: sp_find_dialog_find
void sp_find_dialog_find(GObject *, GObject *dlg)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
bool hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includehidden")));
bool locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includelocked")));
GSList *l = NULL;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inselection")))) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) {
l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked);
} else {
l = all_selection_items (desktop->selection, l, NULL, hidden, locked);
}
} else {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) {
l = all_items (desktop->currentLayer(), l, hidden, locked);
} else {
l = all_items (SP_DOCUMENT_ROOT (sp_desktop_document (desktop)), l, hidden, locked);
}
}
guint all = g_slist_length (l);
bool exact = true;
GSList *n = NULL;
n = filter_list (l, dlg, exact);
if (n == NULL) {
exact = false;
n = filter_list (l, dlg, exact);
}
if (n != NULL) {
int count = g_slist_length (n);
desktop->messageStack()->flashF(Inkscape::NORMAL_MESSAGE,
// TRANSLATORS: "%s" is replaced with "exact" or "partial" when this string is displayed
ngettext("<b>%d</b> object found (out of <b>%d</b>), %s match.",
"<b>%d</b> objects found (out of <b>%d</b>), %s match.",
count),
count, all, exact? _("exact") : _("partial"));
Inkscape::Selection *selection = sp_desktop_selection (desktop);
selection->clear();
selection->setList(n);
scroll_to_show_item (desktop, SP_ITEM(n->data));
} else {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No objects found"));
}
}
示例13: stop
static void
gradient_selection_changed (Inkscape::Selection *, gpointer data)
{
SPGradientContext *rc = (SPGradientContext *) data;
GrDrag *drag = rc->_grdrag;
Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(rc)->desktop);
guint n_obj = g_slist_length((GSList *) selection->itemList());
if (!drag->isNonEmpty() || selection->isEmpty())
return;
guint n_tot = drag->numDraggers();
guint n_sel = drag->numSelected();
//The use of ngettext in the following code is intentional even if the English singular form would never be used
if (n_sel == 1) {
if (drag->singleSelectedDraggerNumDraggables() == 1) {
gchar * message = g_strconcat(
//TRANSLATORS: %s will be substituted with the point name (see previous messages); This is part of a compound message
_("%s selected"),
//TRANSLATORS: Mind the space in front. This is part of a compound message
ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot),
ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL);
rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,
message,_(gr_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj);
} else {
gchar * message = g_strconcat(
//TRANSLATORS: This is a part of a compound message (out of two more indicating: grandint handle count & object count)
ngettext("One handle merging %d stop (drag with <b>Shift</b> to separate) selected",
"One handle merging %d stops (drag with <b>Shift</b> to separate) selected",drag->singleSelectedDraggerNumDraggables()),
ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot),
ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL);
rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj);
}
} else if (n_sel > 1) {
//TRANSLATORS: The plural refers to number of selected gradient handles. This is part of a compound message (part two indicates selected object count)
gchar * message = g_strconcat(ngettext("<b>%d</b> gradient handle selected out of %d","<b>%d</b> gradient handles selected out of %d",n_sel),
//TRANSLATORS: Mind the space in front. (Refers to gradient handles selected). This is part of a compound message
ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL);
rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message, n_sel, n_tot, n_obj);
} else if (n_sel == 0) {
rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,
//TRANSLATORS: The plural refers to number of selected objects
ngettext("<b>No</b> gradient handles selected out of %d on %d selected object",
"<b>No</b> gradient handles selected out of %d on %d selected objects",n_obj), n_tot, n_obj);
}
}
示例14: sp_rtb_value_changed
static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name,
void (SPRect::*setter)(gdouble))
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
Unit const *unit = tracker->getActiveUnit();
g_return_if_fail(unit != NULL);
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name,
Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"));
}
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" ) || tracker->isUpdating()) {
return;
}
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE));
bool modmade = false;
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
if (SP_IS_RECT(*i)) {
if (gtk_adjustment_get_value(adj) != 0) {
(SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"));
} else {
(*i)->getRepr()->setAttribute(value_name, NULL);
}
modmade = true;
}
}
sp_rtb_sensitivize( tbl );
if (modmade) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_RECT,
_("Change rectangle"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
示例15: sp_spray_dilate
static bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
{
Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop;
if (selection->isEmpty()) {
return false;
}
bool did = false;
double radius = get_dilate_radius(tc);
double path_force = get_path_force(tc);
if (radius == 0 || path_force == 0) {
return false;
}
double path_mean = get_path_mean(tc);
if (radius == 0 || path_mean == 0) {
return false;
}
double path_standard_deviation = get_path_standard_deviation(tc);
if (radius == 0 || path_standard_deviation == 0) {
return false;
}
double move_force = get_move_force(tc);
double move_mean = get_move_mean(tc);
double move_standard_deviation = get_move_standard_deviation(tc);
for (GSList *items = g_slist_copy((GSList *) selection->itemList());
items != NULL;
items = items->next) {
SPItem *item = (SPItem *) items->data;
if (is_transform_modes(tc->mode)) {
if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, move_force, tc->population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib))
did = true;
} else {
if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, path_force, tc->population, tc->scale, tc->scale_variation, reverse, path_mean, path_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib))
did = true;
}
}
return did;
}