本文整理汇总了C++中SPDesktop类的典型用法代码示例。如果您正苦于以下问题:C++ SPDesktop类的具体用法?C++ SPDesktop怎么用?C++ SPDesktop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPDesktop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dialog
/** \brief Create an execution environment that will allow the effect
to execute independently.
\param effect The effect that we should execute
\param doc The Document to execute on
\param docCache The cache created for that document
\param show_working Show the working dialog
\param show_error Show the error dialog (not working)
Grabs the selection of the current document so that it can get
restored. Will generate a document cache if one isn't provided.
*/
ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Implementation::ImplementationDocumentCache * docCache, bool show_working, bool show_errors) :
_state(ExecutionEnv::INIT),
_visibleDialog(NULL),
_mainloop(NULL),
_doc(doc),
_docCache(docCache),
_effect(effect),
_show_working(show_working),
_show_errors(show_errors)
{
SPDesktop *desktop = (SPDesktop *)_doc;
sp_namedview_document_from_window(desktop);
if (desktop != NULL) {
std::vector<SPItem*> selected = desktop->getSelection()->itemList();
for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){
Glib::ustring selected_id;
selected_id = (*x)->getId();
_selected.insert(_selected.end(), selected_id);
//std::cout << "Selected: " << selected_id << std::endl;
}
}
genDocCache();
return;
}
示例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: gr_gradient_combo_changed
/*
* User selected a gradient from the combobox
*/
static void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data)
{
if (blocked) {
return;
}
SPGradient *gr = NULL;
gint n = ege_select_one_action_get_active(act);
GtkTreeModel *model = ege_select_one_action_get_model(act);
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child(model, &iter, NULL, n)) {
gtk_tree_model_get(model, &iter, 2, &gr, -1);
}
if (gr) {
gr = sp_gradient_ensure_vector_normalized(gr);
SPDesktop *desktop = static_cast<SPDesktop *>(data);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
ToolBase *ev = desktop->getEventContext();
gr_apply_gradient(selection, ev? ev->get_drag() : NULL, gr);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT,
_("Assign gradient to object"));
}
}
示例4: sp_simplify_flatten
static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(obj, "desktop"));
std::vector<SPItem *> selected = desktop->getSelection()->itemList();
for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){
SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it);
if (lpeitem && lpeitem->hasPathEffect()){
PathEffectList lpelist = lpeitem->getEffectList();
std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
for (i = lpelist.begin(); i != lpelist.end(); ++i) {
LivePathEffectObject *lpeobj = (*i)->lpeobject;
if (lpeobj) {
Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
if (dynamic_cast<Inkscape::LivePathEffect::LPESimplify *>(lpe)) {
SPShape * shape = dynamic_cast<SPShape *>(lpeitem);
if(shape){
SPCurve * c = shape->getCurveBeforeLPE();
lpe->doEffect(c);
lpeitem->setCurrentPathEffect(*i);
if (lpelist.size() > 1){
lpeitem->removeCurrentPathEffect(true);
shape->setCurveBeforeLPE(c);
} else {
lpeitem->removeCurrentPathEffect(false);
shape->setCurve(c,0);
}
break;
}
}
}
}
}
}
}
示例5: box3d_angle_value_changed
static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis axis)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
SPDocument *document = desktop->getDocument();
// quit if run by the attr_changed or selection changed listener
if (g_object_get_data( dataKludge, "freeze" )) {
return;
}
// in turn, prevent listener from responding
g_object_set_data(dataKludge, "freeze", GINT_TO_POINTER(TRUE));
std::list<Persp3D *> sel_persps = desktop->getSelection()->perspList();
if (sel_persps.empty()) {
// this can happen when the document is created; we silently ignore it
return;
}
Persp3D *persp = sel_persps.front();
persp->perspective_impl->tmat.set_infinite_direction (axis,
gtk_adjustment_get_value(adj));
persp->updateRepr();
// TODO: use the correct axis here, too
DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
}
示例6: sp_item_create_link
static void
sp_item_create_link(GtkMenuItem *menuitem, SPItem *item)
{
g_assert(SP_IS_ITEM(item));
g_assert(!SP_IS_ANCHOR(item));
SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
g_return_if_fail(desktop != NULL);
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
Inkscape::XML::Node *repr = xml_doc->createElement("svg:a");
SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item));
SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr);
g_return_if_fail(SP_IS_ANCHOR(object));
const char *id = SP_OBJECT_REPR(item)->attribute("id");
Inkscape::XML::Node *child = SP_OBJECT_REPR(item)->duplicate(xml_doc);
SP_OBJECT(item)->deleteObject(false);
repr->addChild(child, NULL);
child->setAttribute("id", id);
Inkscape::GC::release(repr);
Inkscape::GC::release(child);
sp_document_done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE,
_("Create link"));
sp_object_attributes_dialog(object, "SPAnchor");
sp_desktop_selection(desktop)->set(SP_ITEM(object));
}
示例7:
void
ExecutionEnv::cancel (void) {
SPDesktop *desktop = (SPDesktop *)_doc;
desktop->clearWaitingCursor();
_effect->get_imp()->cancelProcessing();
return;
}
示例8: sp_select_context_setup
static void
sp_select_context_setup(SPEventContext *ec)
{
SPSelectContext *select_context = SP_SELECT_CONTEXT(ec);
if (((SPEventContextClass *) parent_class)->setup) {
((SPEventContextClass *) parent_class)->setup(ec);
}
SPDesktop *desktop = ec->desktop;
select_context->_describer = new Inkscape::SelectionDescriber(
desktop->selection,
desktop->messageStack(),
_("Click selection to toggle scale/rotation handles"),
_("No objects selected. Click, Shift+click, or drag around objects to select.")
);
select_context->_seltrans = new Inkscape::SelTrans(desktop);
sp_event_context_read(ec, "show");
sp_event_context_read(ec, "transform");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/select/gradientdrag")) {
ec->enableGrDrag();
}
}
示例9: sp_pencil_tb_tolerance_value_changed
static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl)
{
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" )) {
return;
}
// in turn, prevent listener from responding
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
prefs->setDouble("/tools/freehand/pencil/tolerance",
gtk_adjustment_get_value(adj));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop"));
std::vector<SPItem *> selected = desktop->getSelection()->itemList();
for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){
SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it);
if (lpeitem && lpeitem->hasPathEffect()){
Inkscape::LivePathEffect::Effect* simplify = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY);
if(simplify){
Inkscape::LivePathEffect::LPESimplify *lpe_simplify = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(simplify->getLPEObj()->get_lpe());
if (lpe_simplify) {
double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
tol = tol/(100.0*(102.0-tol));
std::ostringstream ss;
ss << tol;
Inkscape::LivePathEffect::Effect* powerstroke = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE);
bool simplified = false;
if(powerstroke){
Inkscape::LivePathEffect::LPEPowerStroke *lpe_powerstroke = dynamic_cast<Inkscape::LivePathEffect::LPEPowerStroke*>(powerstroke->getLPEObj()->get_lpe());
if(lpe_powerstroke){
lpe_powerstroke->getRepr()->setAttribute("is_visible", "false");
sp_lpe_item_update_patheffect(lpeitem, false, false);
SPShape *sp_shape = dynamic_cast<SPShape *>(lpeitem);
if (sp_shape) {
guint previous_curve_length = sp_shape->getCurve()->get_segment_count();
lpe_simplify->getRepr()->setAttribute("threshold", ss.str());
sp_lpe_item_update_patheffect(lpeitem, false, false);
simplified = true;
guint curve_length = sp_shape->getCurve()->get_segment_count();
std::vector<Geom::Point> ts = lpe_powerstroke->offset_points.data();
double factor = (double)curve_length/ (double)previous_curve_length;
for (size_t i = 0; i < ts.size(); i++) {
ts[i][Geom::X] = ts[i][Geom::X] * factor;
}
lpe_powerstroke->offset_points.param_setValue(ts);
}
lpe_powerstroke->getRepr()->setAttribute("is_visible", "true");
sp_lpe_item_update_patheffect(lpeitem, false, false);
}
}
if(!simplified){
lpe_simplify->getRepr()->setAttribute("threshold", ss.str());
}
}
}
}
}
}
示例10: sp_arctb_startend_value_changed
static void
sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name, gchar const *other_name)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, gtk_adjustment_get_value(adj));
}
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" )) {
return;
}
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL);
bool modmade = false;
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
if (!strcmp(value_name, "start")) {
ge->start = (gtk_adjustment_get_value(adj) * M_PI)/ 180;
} else {
ge->end = (gtk_adjustment_get_value(adj) * M_PI)/ 180;
}
ge->normalize();
(SP_OBJECT(ge))->updateRepr();
(SP_OBJECT(ge))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
modmade = true;
}
}
g_free(namespaced_name);
GtkAdjustment *other = GTK_ADJUSTMENT( g_object_get_data( tbl, other_name ) );
sp_arctb_sensitivize( tbl, gtk_adjustment_get_value(adj), gtk_adjustment_get_value(other) );
if (modmade) {
DocumentUndo::maybeDone(desktop->getDocument(), value_name, SP_VERB_CONTEXT_ARC,
_("Arc: Change start/end"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
示例11: sp_selection_layout_widget_modify_selection
static void
sp_selection_layout_widget_modify_selection(SPWidget *spw, Inkscape::Selection *selection, guint flags, gpointer data)
{
SPDesktop *desktop = static_cast<SPDesktop *>(data);
if ((desktop->getSelection() == selection) // only respond to changes in our desktop
&& (flags & (SP_OBJECT_MODIFIED_FLAG |
SP_OBJECT_PARENT_MODIFIED_FLAG |
SP_OBJECT_CHILD_MODIFIED_FLAG )))
{
sp_selection_layout_widget_update(spw, selection);
}
}
示例12: toggle_pattern
static void toggle_pattern( GtkToggleAction* act, gpointer data )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gboolean active = gtk_toggle_action_get_active(act);
prefs->setInt("/options/transform/pattern", active);
SPDesktop *desktop = static_cast<SPDesktop *>(data);
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> are <b>transformed</b> along with their objects when those are transformed (moved, scaled, rotated, or skewed)."));
} else {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> remain <b>fixed</b> when objects are transformed (moved, scaled, rotated, or skewed)."));
}
}
示例13: toggle_stroke
static void toggle_stroke( GtkToggleAction* act, gpointer data )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gboolean active = gtk_toggle_action_get_active(act);
prefs->setBool("/options/transform/stroke", active);
SPDesktop *desktop = static_cast<SPDesktop *>(data);
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>scaled</b> when objects are scaled."));
} else {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>not scaled</b> when objects are scaled."));
}
}
示例14: toggle_corners
static void toggle_corners( GtkToggleAction* act, gpointer data)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gboolean active = gtk_toggle_action_get_active(act);
prefs->setBool("/options/transform/rectcorners", active);
SPDesktop *desktop = static_cast<SPDesktop *>(data);
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>scaled</b> when rectangles are scaled."));
} else {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>not scaled</b> when rectangles are scaled."));
}
}
示例15: gr_stop_combo_changed
/*
* User selected a stop from the combobox
*/
static void gr_stop_combo_changed(GtkComboBox * /*widget*/, GtkWidget *data)
{
if (blocked) {
return;
}
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(data), "desktop"));
ToolBase *ev = desktop->getEventContext();
SPGradient *gr = gr_get_selected_gradient(data);
select_drag_by_stop(data, gr, ev);
}