Example #1
0
/** \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;
}
Example #2
0
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;
}