From 69ae98cb453849c6d32a1c7ea8bc057fb13deea3 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Jun 2014 11:32:51 -0400 Subject: 1. make it compile (bzr r13341.5.1) --- src/box3d.cpp | 2 +- src/desktop.cpp | 2 +- src/document-undo.cpp | 4 +- src/document.cpp | 4 +- src/extension/effect.cpp | 6 +- src/extension/error-file.cpp | 2 +- src/extension/extension.cpp | 2 +- src/extension/implementation/script.cpp | 2 +- src/extension/init.cpp | 2 +- src/extension/internal/cdr-input.cpp | 2 +- src/extension/internal/filter/filter-file.cpp | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 2 +- src/extension/internal/vsd-input.cpp | 2 +- src/extension/system.cpp | 2 +- src/file.cpp | 4 +- src/inkscape-private.h | 42 +- src/inkscape.cpp | 550 +++++++++++++------------- src/inkscape.h | 260 ++++++++---- src/inkview.cpp | 4 +- src/interface.cpp | 10 +- src/io/resource.cpp | 2 +- src/live_effects/lpe-perspective_path.cpp | 2 +- src/main-cmdlineact.cpp | 2 +- src/main.cpp | 14 +- src/persp3d.cpp | 2 +- src/preferences.cpp | 6 +- src/selection-chemistry.cpp | 2 +- src/selection.cpp | 4 +- src/shortcuts.cpp | 4 +- src/tools-switch.cpp | 2 +- src/ui/dialog/export.cpp | 2 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 2 +- src/ui/dialog/inkscape-preferences.cpp | 2 +- src/ui/dialog/swatches.cpp | 2 +- src/ui/dialog/symbols.cpp | 6 +- src/ui/dialog/template-load-tab.cpp | 2 +- src/ui/view/view.cpp | 6 +- src/vanishing-point.cpp | 2 +- src/verbs.cpp | 18 +- src/widgets/box3d-toolbar.cpp | 2 +- src/widgets/desktop-widget.cpp | 8 +- src/widgets/icon.cpp | 2 +- 42 files changed, 542 insertions(+), 458 deletions(-) (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index 13a8d0e3e..080ff2e21 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -403,7 +403,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta snap_pts[3] = diag2.closest_to (pt); } - gdouble const zoom = inkscape_active_desktop()->current_zoom(); + gdouble const zoom = INKSCAPE->active_desktop()->current_zoom(); // determine the distances to all potential snapping points double snap_dists[MAX_POINT_COUNT]; diff --git a/src/desktop.cpp b/src/desktop.cpp index f14a314b9..e90b2caec 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1431,7 +1431,7 @@ void SPDesktop::emitToolSubselectionChanged(gpointer data) { _tool_subselection_changed.emit(data); - inkscape_subselection_changed (this); + INKSCAPE->subselection_changed (this); } void SPDesktop::updateNow() diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 39c8a04a0..da40dcd4d 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -271,7 +271,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) doc->priv->seeking = false; if (ret) - inkscape_external_change(); + INKSCAPE->external_change(); return ret; } @@ -316,7 +316,7 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) doc->priv->seeking = false; if (ret) - inkscape_external_change(); + INKSCAPE->external_change(); return ret; } diff --git a/src/document.cpp b/src/document.cpp index f79a00178..80e9bfe4f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -218,7 +218,7 @@ SPDocument::~SPDocument() { } if (keepalive) { - inkscape_unref(); + inkscape_unref(INKSCAPE); keepalive = FALSE; } @@ -448,7 +448,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, rdf_set_defaults( document ); if (keepalive) { - inkscape_ref(); + inkscape_ref(INKSCAPE); } // Check if the document already has a perspective (e.g., when opening an existing diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 3c8ee5844..2ebf8964d 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -89,11 +89,11 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * } // children of "inkscape-extension" } // if we have an XML file - if (INKSCAPE != NULL && inkscape_use_gui()) { + if (INKSCAPE != NULL && INKSCAPE->use_gui()) { if (_effects_list == NULL) - _effects_list = find_menu(inkscape_get_menus(INKSCAPE), EFFECTS_LIST); + _effects_list = find_menu(INKSCAPE->get_menus(), EFFECTS_LIST); if (_filters_list == NULL) - _filters_list = find_menu(inkscape_get_menus(INKSCAPE), FILTERS_LIST); + _filters_list = find_menu(INKSCAPE->get_menus(), FILTERS_LIST); } if ((_effects_list != NULL || _filters_list != NULL)) { diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp index f60af870f..2970bf8d9 100644 --- a/src/extension/error-file.cpp +++ b/src/extension/error-file.cpp @@ -50,7 +50,7 @@ ErrorFileNotice::ErrorFileNotice (void) : { /* This is some filler text, needs to change before relase */ Glib::ustring dialog_text(_("One or more extensions failed to load\n\nThe failed extensions have been skipped. Inkscape will continue to run normally but those extensions will be unavailable. For details to troubleshoot this problem, please refer to the error log located at: ")); - gchar * ext_error_file = profile_path(EXTENSION_ERROR_LOG_FILENAME); + gchar * ext_error_file = INKSCAPE->profile_path(EXTENSION_ERROR_LOG_FILENAME); dialog_text += ext_error_file; g_free(ext_error_file); set_message(dialog_text, true); diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 06e35ff3e..b62cfd8af 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -662,7 +662,7 @@ Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc, void Extension::error_file_open (void) { - gchar * ext_error_file = profile_path(EXTENSION_ERROR_LOG_FILENAME); + gchar * ext_error_file = INKSCAPE->profile_path(EXTENSION_ERROR_LOG_FILENAME); gchar * filename = g_filename_from_utf8( ext_error_file, -1, NULL, NULL, NULL ); error_file.open(filename); if (!error_file.is_open()) { diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index f0fd3711b..bacb126ef 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -1031,7 +1031,7 @@ int Script::execute (const std::list &in_command, Glib::ustring stderr_data = fileerr.string(); if (stderr_data.length() != 0 && - inkscape_use_gui() + INKSCAPE->use_gui() ) { checkStderr(stderr_data, Gtk::MESSAGE_INFO, _("Inkscape has received additional data from the script executed. " diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 912d58a13..57d7f9e33 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -243,7 +243,7 @@ init() /* Load search path for extensions */ if (Inkscape::Extension::Extension::search_path.size() == 0) { - Inkscape::Extension::Extension::search_path.push_back(profile_path("extensions")); + Inkscape::Extension::Extension::search_path.push_back(INKSCAPE->profile_path("extensions")); Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR)); diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index 0111ed626..6048c232c 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -237,7 +237,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // If only one page is present, import that one without bothering user if (tmpSVGOutput.size() > 1) { CdrImportDialog *dlg = 0; - if (inkscape_use_gui()) { + if (INKSCAPE->use_gui()) { dlg = new CdrImportDialog(tmpSVGOutput); if (!dlg->showDialog()) { delete dlg; diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index 48e64f089..04d3f27e1 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -29,7 +29,7 @@ namespace Filter { void Filter::filters_all_files(void) { - gchar *filtersProfilePath = profile_path("filters"); + gchar *filtersProfilePath = INKSCAPE->profile_path("filters"); filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled")); filters_load_dir(filtersProfilePath, _("Personal")); diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 63581bd8a..fbb8b0793 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -696,7 +696,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { } PdfImportDialog *dlg = NULL; - if (inkscape_use_gui()) { + if (INKSCAPE->use_gui()) { dlg = new PdfImportDialog(pdf_doc, uri); if (!dlg->showDialog()) { _cancelled = true; diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 6fc79237b..6b435746b 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -236,7 +236,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // If only one page is present, import that one without bothering user if (tmpSVGOutput.size() > 1) { VsdImportDialog *dlg = 0; - if (inkscape_use_gui()) { + if (INKSCAPE->use_gui()) { dlg = new VsdImportDialog(tmpSVGOutput); if (!dlg->showDialog()) { delete dlg; diff --git a/src/extension/system.cpp b/src/extension/system.cpp index c244d9c16..e81ec0e42 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -121,7 +121,7 @@ SPDocument *open(Extension *key, gchar const *filename) } if (last_chance_svg) { - if ( inkscape_use_gui() ) { + if ( INKSCAPE->use_gui() ) { sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG.")); } else { g_warning("%s", _("Format autodetect failed. The file is being opened as SVG.")); diff --git a/src/file.cpp b/src/file.cpp index 51e629c7d..2c0ba5365 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -175,7 +175,7 @@ SPDesktop *sp_file_new(const std::string &templ) Glib::ustring sp_file_default_template_uri() { std::list sources; - sources.push_back( profile_path("templates") ); // first try user's local dir + sources.push_back( INKSCAPE->profile_path("templates") ); // first try user's local dir sources.push_back( g_strdup(INKSCAPE_TEMPLATESDIR) ); // then the system templates dir std::list baseNames; gchar const* localized = _("default.svg"); @@ -314,7 +314,7 @@ bool sp_file_open(const Glib::ustring &uri, sp_file_add_recent( doc->getURI() ); } - if ( inkscape_use_gui() ) { + if ( INKSCAPE->use_gui() ) { // Perform a fixup pass for hrefs. if ( Inkscape::ResourceManager::getManager().fixupBrokenLinks(doc) ) { Glib::ustring msg = _("Broken links have been changed to point to existing files."); diff --git a/src/inkscape-private.h b/src/inkscape-private.h index d28ed223e..a55d92829 100644 --- a/src/inkscape-private.h +++ b/src/inkscape-private.h @@ -14,42 +14,42 @@ */ #include -#define SP_TYPE_INKSCAPE (inkscape_get_type ()) -#define SP_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_INKSCAPE, Inkscape)) -#define SP_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_INKSCAPE, InkscapeClass)) -#define SP_IS_INKSCAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_INKSCAPE)) -#define SP_IS_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_INKSCAPE)) +//#define SP_TYPE_INKSCAPE (inkscape_get_type ()) +#define SP_INKSCAPE(obj) (dynamic_cast(obj)) //(G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_INKSCAPE, Inkscape)) +//#define SP_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_INKSCAPE, InkscapeClass)) +#define SP_IS_INKSCAPE(obj) (dynamic_cast (obj) != NULL) +//#define SP_IS_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_INKSCAPE)) #include "inkscape.h" struct SPColor; namespace Inkscape { class Selection; } -GType inkscape_get_type (void); +//GType inkscape_get_type (void); -void inkscape_ref (void); -void inkscape_unref (void); +//void inkscape_ref (void); +//void inkscape_unref (void); -guint inkscape_mapalt(); -void inkscape_mapalt(guint); +//guint inkscape_mapalt(); +//void inkscape_mapalt(guint); -guint inkscape_trackalt(); -void inkscape_trackalt(guint); +//guint inkscape_trackalt(); +//void inkscape_trackalt(guint); /* * These are meant solely for desktop, document etc. implementations */ -void inkscape_selection_modified (Inkscape::Selection *selection, guint flags); -void inkscape_selection_changed (Inkscape::Selection * selection); -void inkscape_selection_set (Inkscape::Selection * selection); -void inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext); -void inkscape_add_desktop (SPDesktop * desktop); -void inkscape_remove_desktop (SPDesktop * desktop); -void inkscape_activate_desktop (SPDesktop * desktop); -void inkscape_reactivate_desktop (SPDesktop * desktop); +//void inkscape_selection_modified (Inkscape::Selection *selection, guint flags); +//void inkscape_selection_changed (Inkscape::Selection * selection); +//void inkscape_selection_set (Inkscape::Selection * selection); +//void inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext); +//void inkscape_add_desktop (SPDesktop * desktop); +//void inkscape_remove_desktop (SPDesktop * desktop); +//void inkscape_activate_desktop (SPDesktop * desktop); +//void inkscape_reactivate_desktop (SPDesktop * desktop); -void inkscape_set_color (SPColor *color, float opacity); +//void inkscape_set_color (SPColor *color, float opacity); #endif // SEEN_INKSCAPE_PRIVATE_H diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 4b4c8c678..23c2b001a 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -76,6 +76,7 @@ static Inkscape::Application *inkscape = NULL; /* Backbones of configuration xml data */ #include "menus-skeleton.h" +#if 0 enum { MODIFY_SELECTION, // global: one of selections modified CHANGE_SELECTION, // global: one of selections changed @@ -91,25 +92,27 @@ enum { // may not be reflected by a selection change and thus needs a separate signal LAST_SIGNAL }; +#endif -#define DESKTOP_IS_ACTIVE(d) (inkscape->desktops && ((d) == inkscape->desktops->data)) +#define DESKTOP_IS_ACTIVE(d) (!inkscape->desktops->empty() && ((d) == inkscape->desktops->front())) /*################################ # FORWARD DECLARATIONS ################################*/ -namespace Inkscape { -struct ApplicationClass; -} +//namespace Inkscape { +//struct ApplicationClass; +//} -static void inkscape_class_init (Inkscape::ApplicationClass *klass); -static void inkscape_init (SPObject *object); -static void inkscape_dispose (GObject *object); +//static void inkscape_class_init (Inkscape::ApplicationClass *klass); +//static void inkscape_init (SPObject *object); +//static void inkscape_dispose (GObject *object); -static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); -static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); +//static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); +//static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); +#if 0 class AppSelectionModel { Inkscape::LayerModel _layer_model; Inkscape::Selection *_selection; @@ -125,21 +128,9 @@ public: Inkscape::Selection *getSelection() const { return _selection; } }; +#endif -struct Inkscape::Application { - GObject object; - Inkscape::XML::Document *menus; - std::map document_set; - std::map selection_models; - GSList *desktops; - gchar *argv0; - gboolean dialogs_toggle; - gboolean use_gui; // may want to consider a virtual function - // for overriding things like the warning dlg's - guint mapalt; - guint trackalt; -}; - +#if 0 struct Inkscape::ApplicationClass { GObjectClass object_class; @@ -158,9 +149,9 @@ struct Inkscape::ApplicationClass { void (* dialogs_unhide) (Inkscape::Application *inkscape); void (* external_change) (Inkscape::Application *inkscape); }; +#endif -static GObjectClass * parent_class; -static guint inkscape_signals[LAST_SIGNAL] = {0}; +// static guint inkscape_signals[LAST_SIGNAL] = {0}; static void (* segv_handler) (int) = SIG_DFL; static void (* abrt_handler) (int) = SIG_DFL; @@ -176,34 +167,12 @@ static void (* bus_handler) (int) = SIG_DFL; #define MENUS_FILE "menus.xml" -/** - * Retrieves the GType for the Inkscape Application object. - */ -GType -inkscape_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (Inkscape::ApplicationClass), - NULL, NULL, - (GClassInitFunc) inkscape_class_init, - NULL, NULL, - sizeof (Inkscape::Application), - 4, - (GInstanceInitFunc) inkscape_init, - NULL - }; - type = g_type_register_static (G_TYPE_OBJECT, "Inkscape_Application", &info, (GTypeFlags)0); - } - return type; -} - - /** * Initializes the inkscape class, registering all of its signal handlers * and virtual functions */ + +#if 0 static void inkscape_class_init (Inkscape::ApplicationClass * klass) { @@ -303,21 +272,47 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) klass->activate_desktop = inkscape_activate_desktop_private; klass->deactivate_desktop = inkscape_deactivate_desktop_private; } +#endif #ifdef WIN32 typedef int uid_t; #define getuid() 0 #endif +Inkscape::Application * inkscape_ref(Inkscape::Application * in) +{ + g_return_val_if_fail(in != NULL, NULL); + g_return_val_if_fail(dynamic_cast(in) != NULL, NULL); + + in->refCount++; + return in; +} + +Inkscape::Application * inkscape_unref(Inkscape::Application * in) +{ + g_return_val_if_fail(in != NULL, NULL); + g_return_val_if_fail(dynamic_cast(in) != NULL, NULL); + + in->refCount--; + + if (in->refCount <= 0) { + delete in; + } + + return NULL; +} + +namespace Inkscape { + /** * static gint inkscape_autosave(gpointer); * * Callback passed to g_timeout_add_seconds() * Responsible for autosaving all open documents */ -static gint inkscape_autosave(gpointer) +int Application::autosave() { - if (inkscape->document_set.empty()) { // nothing to autosave + if (document_set.empty()) { // nothing to autosave return TRUE; } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -336,7 +331,7 @@ static gint inkscape_autosave(gpointer) } GDir *autosave_dir_ptr = g_dir_open(autosave_dir.c_str(), 0, NULL); - if( !autosave_dir_ptr ){ + if (!autosave_dir_ptr) { // Try to create the autosave directory if it doesn't exist if (g_mkdir(autosave_dir.c_str(), 0755)) { // the creation failed @@ -367,8 +362,8 @@ static gint inkscape_autosave(gpointer) gint docnum = 0; SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Autosaving documents...")); - for (std::map::iterator iter = inkscape->document_set.begin(); - iter != inkscape->document_set.end(); + for (std::map::iterator iter = document_set.begin(); + iter != document_set.end(); ++iter) { SPDocument *doc = iter->first; @@ -469,7 +464,16 @@ static gint inkscape_autosave(gpointer) return TRUE; } -void inkscape_autosave_init() +} // namespace Inkscape + +int inkscape_autosave(gpointer) { + g_assert(inkscape != NULL); + return inkscape->autosave(); +} + +namespace Inkscape { + +void Application::autosave_init() { static guint32 autosave_timeout_id = 0; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -493,105 +497,61 @@ void inkscape_autosave_init() } -static void -inkscape_init (SPObject * object) +Application::Application() { if (!inkscape) { - inkscape = (Inkscape::Application *) object; + inkscape = this; } else { - g_assert_not_reached (); + g_assert_not_reached(); } - new (&inkscape->document_set) std::map(); - new (&inkscape->selection_models) std::map(); - - inkscape->menus = NULL; - inkscape->desktops = NULL; - inkscape->dialogs_toggle = TRUE; - inkscape->mapalt = GDK_MOD1_MASK; - inkscape->trackalt = FALSE; + this->menus = NULL; + //this->desktops = NULL; + this->_dialogs_toggle = TRUE; + this->_mapalt = GDK_MOD1_MASK; + this->_trackalt = FALSE; } -static void -inkscape_dispose (GObject *object) +Application::~Application() { - Inkscape::Application *inkscape = (Inkscape::Application *) object; - - g_assert (!inkscape->desktops); + g_assert (!desktops); Inkscape::Preferences::unload(); - if (inkscape->menus) { + if (menus) { /* fixme: This is not the best place */ - Inkscape::GC::release(inkscape->menus); - inkscape->menus = NULL; + Inkscape::GC::release(menus); + menus = NULL; } - inkscape->selection_models.~map(); - inkscape->document_set.~map(); - - G_OBJECT_CLASS (parent_class)->dispose (object); - gtk_main_quit (); } - -void -inkscape_ref (void) -{ - if (inkscape) - g_object_ref (G_OBJECT (inkscape)); -} - - -void -inkscape_unref (void) -{ - if (inkscape) - g_object_unref (G_OBJECT (inkscape)); -} - -/* returns the mask of the keyboard modifier to map to Alt, zero if no mapping */ -/* Needs to be a guint because gdktypes.h does not define a 'no-modifier' value */ -guint -inkscape_mapalt() { - return inkscape->mapalt; -} - /* Sets the keyboard modifer to map to Alt. Zero switches off mapping, as does '1', which is the default */ -void inkscape_mapalt(guint maskvalue) +void Application::mapalt(guint maskvalue) { - if(maskvalue<2 || maskvalue> 5 ){ /* MOD5 is the highest defined in gdktypes.h */ - inkscape->mapalt=0; - }else{ - inkscape->mapalt=(GDK_MOD1_MASK << (maskvalue-1)); + if ( maskvalue < 2 || maskvalue > 5 ) { // MOD5 is the highest defined in gdktypes.h + _mapalt = 0; + } else { + _mapalt = (GDK_MOD1_MASK << (maskvalue-1)); } } -guint -inkscape_trackalt() { - return inkscape->trackalt; -} - -void inkscape_trackalt(guint trackvalue) -{ - inkscape->trackalt = trackvalue; -} - - +} // namespace Inkscape +#if 0 static void -inkscape_activate_desktop_private (Inkscape::Application */*inkscape*/, SPDesktop *desktop) +inkscape_activate_desktop_private (Inkscape::Application *, SPDesktop *desktop) { desktop->set_active (true); } static void -inkscape_deactivate_desktop_private (Inkscape::Application */*inkscape*/, SPDesktop *desktop) +inkscape_deactivate_desktop_private (Inkscape::Application *, SPDesktop *desktop) { desktop->set_active (false); } - +#endif /* fixme: This is EVIL, and belongs to main after all */ @@ -791,7 +751,10 @@ inkscape_crash_handler (int /*signum*/) } *(b + pos) = '\0'; - if ( inkscape_get_instance() && inkscape_use_gui() ) { + // checking whether we have an Inkscape instance after that instance caused an exception is like + // checking if your mother existed after sitting on you and nearly hospitalizing you + + if ( inkscape_get_instance() && inkscape->use_gui() ) { GtkWidget *msgbox = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", b); gtk_dialog_run (GTK_DIALOG (msgbox)); gtk_widget_destroy (msgbox); @@ -835,7 +798,7 @@ private: void inkscape_application_init (const gchar *argv0, gboolean use_gui) { - inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); + inkscape = new Inkscape::Application(); /* fixme: load application defaults */ segv_handler = signal (SIGSEGV, inkscape_crash_handler); @@ -846,7 +809,7 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui) bus_handler = signal (SIGBUS, inkscape_crash_handler); #endif - inkscape->use_gui = use_gui; + inkscape->use_gui(use_gui); inkscape->argv0 = g_strdup(argv0); /* Load the preferences and menus */ @@ -862,7 +825,7 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui) } if (use_gui) { - inkscape_load_menus(inkscape); + inkscape->load_menus(); Inkscape::DeviceManager::getManager().loadConfig(); } Inkscape::ResourceManager::getManager(); @@ -891,16 +854,16 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui) /* Check for global remapping of Alt key */ if (use_gui) { - inkscape_mapalt(guint(prefs->getInt("/options/mapalt/value", 0))); - inkscape_trackalt(guint(prefs->getInt("/options/trackalt/value", 0))); + inkscape->mapalt(guint(prefs->getInt("/options/mapalt/value", 0))); + inkscape->trackalt(guint(prefs->getInt("/options/trackalt/value", 0))); } /* Initialize the extensions */ Inkscape::Extension::init(); - inkscape_autosave_init(); + inkscape->autosave_init(); - return; + //return; } /** @@ -912,25 +875,23 @@ inkscape_get_instance() return inkscape; } -gboolean inkscape_use_gui() -{ - return inkscape_get_instance()->use_gui; -} +namespace Inkscape { + +//gboolean inkscape_use_gui() +//{ +// return inkscape_get_instance()->use_gui; +//} /** * Menus management * */ -bool inkscape_load_menus( Inkscape::Application * inkscape ) +bool Application::load_menus() { gchar *fn = profile_path(MENUS_FILE); gchar *menus_xml = 0; gsize len = 0; - if ( inkscape != inkscape_get_instance() ) { - g_warning("BAD BAD BAD THINGS"); - } - if ( g_file_get_contents(fn, &menus_xml, &len, NULL) ) { // load the menus_xml file inkscape->menus = sp_repr_read_mem(menus_xml, len, NULL); @@ -941,8 +902,8 @@ bool inkscape_load_menus( Inkscape::Application * inkscape ) g_free(fn); fn = 0; - if ( !inkscape->menus ) { - inkscape->menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); + if ( !menus ) { + menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); } return (inkscape->menus != 0); @@ -950,137 +911,162 @@ bool inkscape_load_menus( Inkscape::Application * inkscape ) void -inkscape_selection_modified (Inkscape::Selection *selection, guint flags) +Application::selection_modified (Inkscape::Selection *selection, guint flags) { g_return_if_fail (selection != NULL); if (DESKTOP_IS_ACTIVE (selection->desktop())) { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[MODIFY_SELECTION], 0, selection, flags); + signal_selection_modified.emit(this, selection, flags); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[MODIFY_SELECTION], 0, selection, flags); } } void -inkscape_selection_changed (Inkscape::Selection * selection) +Application::selection_changed (Inkscape::Selection * selection) { g_return_if_fail (selection != NULL); - + if (DESKTOP_IS_ACTIVE (selection->desktop())) { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); + signal_selection_changed.emit(this, selection); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); } } void -inkscape_subselection_changed (SPDesktop *desktop) +Application::subselection_changed (SPDesktop *desktop) { g_return_if_fail (desktop != NULL); if (DESKTOP_IS_ACTIVE (desktop)) { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SUBSELECTION], 0, desktop); + signal_subselection_changed.emit(this, desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SUBSELECTION], 0, desktop); } } void -inkscape_selection_set (Inkscape::Selection * selection) +Application::selection_set (Inkscape::Selection * selection) { g_return_if_fail (selection != NULL); if (DESKTOP_IS_ACTIVE (selection->desktop())) { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, selection); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); + signal_selection_set.emit(this, selection); + signal_selection_changed.emit(this, selection); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, selection); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); } } void -inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext) +Application::eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext) { g_return_if_fail (eventcontext != NULL); g_return_if_fail (SP_IS_EVENT_CONTEXT (eventcontext)); if (DESKTOP_IS_ACTIVE (eventcontext->desktop)) { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, eventcontext); + signal_eventcontext_set.emit(this, eventcontext); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, eventcontext); } } void -inkscape_add_desktop (SPDesktop * desktop) +Application::add_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); - g_return_if_fail (inkscape != NULL); + //g_return_if_fail (inkscape != NULL); - g_assert (!g_slist_find (inkscape->desktops, desktop)); + g_assert (std::find(desktops->begin(), desktops->end(), desktop) == desktops->end()); - inkscape->desktops = g_slist_prepend (inkscape->desktops, desktop); + desktops->push_front(desktop); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext()); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop)); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop)); + signal_activate_desktop.emit(this, desktop); + signal_eventcontext_set.emit(this, desktop->getEventContext()); + signal_selection_set.emit(this, sp_desktop_selection(desktop)); + signal_selection_changed.emit(this, sp_desktop_selection(desktop)); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext()); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop)); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop)); } void -inkscape_remove_desktop (SPDesktop * desktop) +Application::remove_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); g_return_if_fail (inkscape != NULL); - g_assert (g_slist_find (inkscape->desktops, desktop)); + g_assert (std::find (desktops->begin(), desktops->end(), desktop) != desktops->end() ); if (DESKTOP_IS_ACTIVE (desktop)) { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, desktop); - if (inkscape->desktops->next != NULL) { - SPDesktop * new_desktop = static_cast(inkscape->desktops->next->data); - inkscape->desktops = g_slist_remove (inkscape->desktops, new_desktop); - inkscape->desktops = g_slist_prepend (inkscape->desktops, new_desktop); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, new_desktop); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, new_desktop->getEventContext()); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (new_desktop)); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (new_desktop)); + signal_deactivate_desktop.emit(this, desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, desktop); + if (desktops->size() > 1) { + SPDesktop * new_desktop = *(++desktops->begin()); + desktops->remove(new_desktop); + desktops->push_front(new_desktop); + + signal_activate_desktop.emit(this, new_desktop); + signal_eventcontext_set.emit(this, new_desktop->getEventContext()); + signal_selection_set.emit(this, sp_desktop_selection(new_desktop)); + signal_selection_changed.emit(this, sp_desktop_selection(new_desktop)); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, new_desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, new_desktop->getEventContext()); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (new_desktop)); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (new_desktop)); } else { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, NULL); + signal_eventcontext_set.emit(this, NULL); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, NULL); if (sp_desktop_selection(desktop)) sp_desktop_selection(desktop)->clear(); } } - inkscape->desktops = g_slist_remove (inkscape->desktops, desktop); + desktops->remove(desktop); // if this was the last desktop, shut down the program - if (inkscape->desktops == NULL) { - inkscape_exit (inkscape); + if (desktops->empty()) { + this->exit(); } } void -inkscape_activate_desktop (SPDesktop * desktop) +Application::activate_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); - g_return_if_fail (inkscape != NULL); if (DESKTOP_IS_ACTIVE (desktop)) { return; } - g_assert (g_slist_find (inkscape->desktops, desktop)); + SPDesktop* oldDesktop = 0; + std::list::iterator i; + + g_assert ((i = std::find (desktops->begin(), desktops->end(), desktop)) != desktops->end()); - SPDesktop *current = static_cast(inkscape->desktops->data); + oldDesktop = *i; + SPDesktop *current = desktops->front(); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, current); + signal_deactivate_desktop.emit(this, current); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, current); - inkscape->desktops = g_slist_remove (inkscape->desktops, desktop); - inkscape->desktops = g_slist_prepend (inkscape->desktops, desktop); + desktops->remove (desktop); + desktops->push_front (desktop); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext()); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop)); - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop)); + signal_activate_desktop.emit(this, desktop); + signal_eventcontext_set.emit(this, desktop->getEventContext()); + signal_selection_set(this, sp_desktop_selection(desktop)); + signal_selection_changed(this, sp_desktop_selection(desktop)); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext()); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop)); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop)); } @@ -1088,65 +1074,63 @@ inkscape_activate_desktop (SPDesktop * desktop) * Resends ACTIVATE_DESKTOP for current desktop; needed when a new desktop has got its window that dialogs will transientize to */ void -inkscape_reactivate_desktop (SPDesktop * desktop) +Application::reactivate_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); - g_return_if_fail (inkscape != NULL); - if (DESKTOP_IS_ACTIVE (desktop)) - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); + if (DESKTOP_IS_ACTIVE (desktop)) { + signal_activate_desktop.emit(this, desktop); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); + } } SPDesktop * -inkscape_find_desktop_by_dkey (unsigned int dkey) +Application::find_desktop_by_dkey (unsigned int dkey) { - for (GSList *r = inkscape->desktops; r; r = r->next) { - if ((static_cast(r->data))->dkey == dkey){ - return (static_cast(r->data)); + for (std::list::iterator r = desktops->begin(); r != desktops->end(); r++) { + if ((*r)->dkey == dkey){ + return *r; } } return NULL; } - - -static unsigned int -inkscape_maximum_dkey() +unsigned int +Application::maximum_dkey() { unsigned int dkey = 0; - for (GSList *r = inkscape->desktops; r; r = r->next) { - if ((static_cast(r->data))->dkey > dkey){ - dkey = (static_cast(r->data))->dkey; + for (std::list::iterator r = desktops->begin(); r != desktops->end(); r++) { + if ((*r)->dkey > dkey){ + dkey = (*r)->dkey; } } - return dkey; } -static SPDesktop * -inkscape_next_desktop () +SPDesktop * +Application::next_desktop () { SPDesktop *d = NULL; - unsigned int dkey_current = (static_cast(inkscape->desktops->data))->dkey; + unsigned int dkey_current = (desktops->front())->dkey; - if (dkey_current < inkscape_maximum_dkey()) { + if (dkey_current < maximum_dkey()) { // find next existing - for (unsigned int i = dkey_current + 1; i <= inkscape_maximum_dkey(); i++) { - d = inkscape_find_desktop_by_dkey (i); + for (unsigned int i = dkey_current + 1; i <= maximum_dkey(); i++) { + d = find_desktop_by_dkey (i); if (d) { break; } } } else { // find first existing - for (unsigned int i = 0; i <= inkscape_maximum_dkey(); i++) { - d = inkscape_find_desktop_by_dkey (i); + for (unsigned int i = 0; i <= maximum_dkey(); i++) { + d = find_desktop_by_dkey (i); if (d) { break; } @@ -1154,22 +1138,21 @@ inkscape_next_desktop () } g_assert (d); - return d; } -static SPDesktop * -inkscape_prev_desktop () +SPDesktop * +Application::prev_desktop () { SPDesktop *d = NULL; - unsigned int dkey_current = (static_cast(inkscape->desktops->data))->dkey; + unsigned int dkey_current = (desktops->front())->dkey; if (dkey_current > 0) { // find prev existing for (signed int i = dkey_current - 1; i >= 0; i--) { - d = inkscape_find_desktop_by_dkey (i); + d = find_desktop_by_dkey (i); if (d) { break; } @@ -1177,81 +1160,78 @@ inkscape_prev_desktop () } if (!d) { // find last existing - d = inkscape_find_desktop_by_dkey (inkscape_maximum_dkey()); + d = find_desktop_by_dkey (maximum_dkey()); } g_assert (d); - return d; } void -inkscape_switch_desktops_next () +Application::switch_desktops_next () { - inkscape_next_desktop()->presentWindow(); + next_desktop()->presentWindow(); } - - void -inkscape_switch_desktops_prev () +Application::switch_desktops_prev() { - inkscape_prev_desktop()->presentWindow(); + prev_desktop()->presentWindow(); } - - void -inkscape_dialogs_hide () +Application::dialogs_hide() { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0); - inkscape->dialogs_toggle = FALSE; + signal_dialogs_hide.emit(this); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0); + _dialogs_toggle = FALSE; } void -inkscape_dialogs_unhide () +Application::dialogs_unhide() { - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0); - inkscape->dialogs_toggle = TRUE; + signal_dialogs_unhide.emit(this); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0); + _dialogs_toggle = TRUE; } void -inkscape_dialogs_toggle () +Application::dialogs_toggle() { - if (inkscape->dialogs_toggle) { - inkscape_dialogs_hide (); + if (_dialogs_toggle) { + dialogs_hide(); } else { - inkscape_dialogs_unhide (); + dialogs_unhide(); } } void -inkscape_external_change () +Application::external_change() { - g_return_if_fail (inkscape != NULL); - - g_signal_emit (G_OBJECT (inkscape), inkscape_signals[EXTERNAL_CHANGE], 0); + //g_return_if_fail (inkscape != NULL); + signal_external_change.emit(this); + //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[EXTERNAL_CHANGE], 0); } /** * fixme: These need probably signals too */ void -inkscape_add_document (SPDocument *document) +Application::add_document (SPDocument *document) { g_return_if_fail (document != NULL); // try to insert the pair into the list - if (!(inkscape->document_set.insert(std::make_pair(document, 1)).second)) { + if (!(document_set.insert(std::make_pair(document, 1)).second)) { //insert failed, this key (document) is already in the list - for (std::map::iterator iter = inkscape->document_set.begin(); - iter != inkscape->document_set.end(); + for (std::map::iterator iter = document_set.begin(); + iter != document_set.end(); ++iter) { if (iter->first == document) { // found this document in list, increase its count @@ -1261,10 +1241,10 @@ inkscape_add_document (SPDocument *document) } else { // insert succeeded, this document is new. Do we need to create a // selection model for it, i.e. are we running without a desktop? - if (!inkscape->use_gui) { + if (!_use_gui) { // Create layer model and selection model so we can run some verbs without a GUI - g_assert(inkscape->selection_models.find(document) == inkscape->selection_models.end()); - inkscape->selection_models[document] = new AppSelectionModel(document); + g_assert(selection_models.find(document) == selection_models.end()); + selection_models[document] = new AppSelectionModel(document); } } } @@ -1272,24 +1252,24 @@ inkscape_add_document (SPDocument *document) // returns true if this was last reference to this document, so you can delete it bool -inkscape_remove_document (SPDocument *document) +Application::remove_document (SPDocument *document) { g_return_val_if_fail (document != NULL, false); - for (std::map::iterator iter = inkscape->document_set.begin(); - iter != inkscape->document_set.end(); + for (std::map::iterator iter = document_set.begin(); + iter != document_set.end(); ++iter) { if (iter->first == document) { // found this document in list, decrease its count iter->second --; if (iter->second < 1) { // this was the last one, remove the pair from list - inkscape->document_set.erase (iter); + document_set.erase (iter); // also remove the selection model - std::map::iterator sel_iter = inkscape->selection_models.find(document); - if (sel_iter != inkscape->selection_models.end()) { - inkscape->selection_models.erase(sel_iter); + std::map::iterator sel_iter = selection_models.find(document); + if (sel_iter != selection_models.end()) { + selection_models.erase(sel_iter); } return true; @@ -1303,37 +1283,38 @@ inkscape_remove_document (SPDocument *document) } SPDesktop * -inkscape_active_desktop (void) +Application::active_desktop() { - if (inkscape->desktops == NULL) { + if (desktops == NULL) { return NULL; } - return static_cast(inkscape->desktops->data); + return desktops->front(); } SPDocument * -inkscape_active_document (void) +Application::active_document() { if (SP_ACTIVE_DESKTOP) { return sp_desktop_document (SP_ACTIVE_DESKTOP); - } else if (!inkscape->document_set.empty()) { + } else if (!document_set.empty()) { // If called from the command line there will be no desktop // So 'fall back' to take the first listed document in the Inkscape instance - return inkscape->document_set.begin()->first; + return document_set.begin()->first; } return NULL; } -bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop) { +bool +Application::sole_desktop_for_document(SPDesktop const &desktop) { SPDocument const* document = desktop.doc(); if (!document) { return false; } - for ( GSList *iter = inkscape->desktops ; iter ; iter = iter->next ) { - SPDesktop *other_desktop=static_cast(iter->data); - SPDocument *other_document=other_desktop->doc(); + for ( std::list::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++ ) { + SPDesktop *other_desktop = *iter; + SPDocument *other_document = other_desktop->doc(); if ( other_document == document && other_desktop != &desktop ) { return false; } @@ -1342,7 +1323,7 @@ bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop) { } Inkscape::UI::Tools::ToolBase * -inkscape_active_event_context (void) +Application::active_event_context (void) { if (SP_ACTIVE_DESKTOP) { return SP_ACTIVE_DESKTOP->getEventContext(); @@ -1352,26 +1333,26 @@ inkscape_active_event_context (void) } Inkscape::ActionContext -inkscape_active_action_context() +Application::active_action_context() { if (SP_ACTIVE_DESKTOP) { return Inkscape::ActionContext(SP_ACTIVE_DESKTOP); } - SPDocument *doc = inkscape_active_document(); + SPDocument *doc = active_document(); if (!doc) { return Inkscape::ActionContext(); } - return inkscape_action_context_for_document(doc); + return action_context_for_document(doc); } Inkscape::ActionContext -inkscape_action_context_for_document(SPDocument *doc) +Application::action_context_for_document(SPDocument *doc) { // If there are desktops, check them first to see if the document is bound to one of them - for (GSList *iter = inkscape->desktops ; iter ; iter = iter->next) { - SPDesktop *desktop=static_cast(iter->data); + for (std::list::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++) { + SPDesktop *desktop = *iter; if (desktop->doc() == doc) { return Inkscape::ActionContext(desktop); } @@ -1391,10 +1372,10 @@ inkscape_action_context_for_document(SPDocument *doc) #####################*/ void -inkscape_refresh_display (Inkscape::Application *inkscape) +Application::refresh_display () { - for (GSList *l = inkscape->desktops; l != NULL; l = l->next) { - (static_cast(l->data))->requestRedraw(); + for (std::list::iterator l = desktops->begin(); l != desktops->end(); l++) { + (*l)->requestRedraw(); } } @@ -1404,19 +1385,20 @@ inkscape_refresh_display (Inkscape::Application *inkscape) * saves the preferences if appropriate, and quits. */ void -inkscape_exit (Inkscape::Application */*inkscape*/) +Application::exit () { g_assert (INKSCAPE); //emit shutdown signal so that dialogs could remember layout - g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0); + signal_shut_down.emit(this); + //g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0); Inkscape::Preferences::unload(); gtk_main_quit (); } char * -homedir_path(const char *filename) +Application::homedir_path(const char *filename) { static const gchar *homedir = NULL; if (!homedir) { @@ -1434,7 +1416,7 @@ homedir_path(const char *filename) * file should be located. */ gchar * -profile_path(const char *filename) +Application::profile_path(const char *filename) { static const gchar *prefdir = NULL; @@ -1546,21 +1528,23 @@ profile_path(const char *filename) } Inkscape::XML::Node * -inkscape_get_menus (Inkscape::Application * inkscape) +Application::get_menus() { - Inkscape::XML::Node *repr = inkscape->menus->root(); + Inkscape::XML::Node *repr = menus->root(); g_assert (!(strcmp (repr->name(), "inkscape"))); return repr->firstChild(); } void -inkscape_get_all_desktops(std::list< SPDesktop* >& listbuf) +Application::get_all_desktops(std::list< SPDesktop* >& listbuf) { - for(GSList* l = inkscape->desktops; l != NULL; l = l->next) { - listbuf.push_back(static_cast< SPDesktop* >(l->data)); + for (std::list::iterator it = desktops->begin(); it != desktops->end(); it++) { + listbuf.push_back(*it); } } +} // namespace Inkscape + /* Local Variables: mode:c++ diff --git a/src/inkscape.h b/src/inkscape.h index 823e7524f..f37da7472 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -6,115 +6,215 @@ * * Authors: * Lauris Kaplinski + * Liam P. White * - * Copyright (C) 1999-2003 Authors + * Copyright (C) 1999-2014 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include +#include "selection.h" +#include "color.h" +#include "layer-model.h" #include +#include class SPDesktop; class SPDocument; namespace Inkscape { + +struct Application; namespace UI { namespace Tools { class ToolBase; -} -} -} +} // namespace Tools +} // namespace UI -namespace Inkscape { - class ActionContext; - struct Application; - namespace XML { - class Node; - struct Document; - } -} +class ActionContext; -#define INKSCAPE inkscape_get_instance() +namespace XML { +class Node; +struct Document; +} // namespace XML -void inkscape_autosave_init(); +} // namespace Inkscape -void inkscape_application_init (const gchar *argv0, gboolean use_gui); +Inkscape::Application * inkscape_ref (Inkscape::Application * in); +Inkscape::Application * inkscape_unref(Inkscape::Application * in); -bool inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton, unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml, const gchar *e_notsp, const gchar *warn); +#define INKSCAPE inkscape_get_instance() +#define SP_ACTIVE_EVENTCONTEXT (INKSCAPE->active_event_context()) +#define SP_ACTIVE_DOCUMENT (INKSCAPE->active_document()) +#define SP_ACTIVE_DESKTOP (INKSCAPE->active_desktop()) +// \TODO hack +#define inkscape_active_desktop() SP_ACTIVE_DESKTOP + +class AppSelectionModel { + Inkscape::LayerModel _layer_model; + Inkscape::Selection *_selection; + +public: + AppSelectionModel(SPDocument *doc) { + _layer_model.setDocument(doc); + // TODO: is this really how we should manage the lifetime of the selection? + // I just copied this from the initialization of the Selection in SPDesktop. + // When and how is it actually released? + _selection = Inkscape::GC::release(new Inkscape::Selection(&_layer_model, NULL)); + } + + Inkscape::Selection *getSelection() const { return _selection; } +}; -/* Menus */ -bool inkscape_load_menus (Inkscape::Application * inkscape); -bool inkscape_save_menus (Inkscape::Application * inkscape); -Inkscape::XML::Node *inkscape_get_menus (Inkscape::Application * inkscape); +namespace Inkscape { -Inkscape::Application *inkscape_get_instance(); -gboolean inkscape_use_gui(); +struct Application { +private: + unsigned refCount; + gboolean _dialogs_toggle; + guint _mapalt; + guint _trackalt; + gboolean _use_gui; // may want to consider a virtual function + // for overriding things like the warning dlg's + +public: + Application(); + ~Application(); + + Inkscape::XML::Document *menus; + std::map document_set; + std::map selection_models; + std::list * desktops; + gchar *argv0; + + // returns the mask of the keyboard modifier to map to Alt, zero if no mapping + // Needs to be a guint because gdktypes.h does not define a 'no-modifier' value + guint mapalt() const { return _mapalt; } + + // Sets the keyboard modifer to map to Alt. Zero switches off mapping, as does '1', which is the default + void mapalt(guint maskvalue); + + guint trackalt() const { return _trackalt; } + void trackalt(guint trackvalue) { _trackalt = trackvalue; } + + gboolean use_gui() const { return _use_gui; } + void use_gui(gboolean guival) { _use_gui = guival; } + + // signals + + // one of selections changed + sigc::signal signal_selection_changed; + // one of subselections (text selection, gradient handle, etc) changed + sigc::signal signal_subselection_changed; + // one of selections modified + sigc::signal signal_selection_modified; + // one of selections set + sigc::signal signal_selection_set; + // tool switched + sigc::signal signal_eventcontext_set; + // some desktop got focus + sigc::signal signal_activate_desktop; + // some desktop lost focus + sigc::signal signal_deactivate_desktop; + + // probably orphaned signals + sigc::signal signal_destroy_document; + sigc::signal signal_color_set; + + // inkscape is quitting + sigc::signal signal_shut_down; + // user pressed F12 + sigc::signal signal_dialogs_hide; + // user pressed F12 + sigc::signal signal_dialogs_unhide; + // a document was changed by some external means (undo or XML editor); this + // may not be reflected by a selection change and thus needs a separate signal + sigc::signal signal_external_change; + + // useful functions + void autosave_init(); + void application_init (const gchar *argv0, gboolean use_gui); + void load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton, + unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml, + const gchar *e_notsp, const gchar *warn); + + bool load_menus(); + bool save_menus(); + Inkscape::XML::Node * get_menus(); + + //static Inkscape::Application* get_instance(); + + Inkscape::UI::Tools::ToolBase * active_event_context(); + SPDocument * active_document(); + SPDesktop * active_desktop(); + + // Use this function to get selection model etc for a document + Inkscape::ActionContext action_context_for_document(SPDocument *doc); + Inkscape::ActionContext active_action_context(); + + bool sole_desktop_for_document(SPDesktop const &desktop); + + // Inkscape desktop stuff + void add_desktop(SPDesktop * desktop); + void remove_desktop(SPDesktop* desktop); + void activate_desktop (SPDesktop * desktop); + void switch_desktops_next (); + void switch_desktops_prev (); + void get_all_desktops (std::list< SPDesktop* >& listbuf); + void reactivate_desktop (SPDesktop * desktop); + SPDesktop * find_desktop_by_dkey (unsigned int dkey); + unsigned int maximum_dkey(); + SPDesktop * next_desktop (); + SPDesktop * prev_desktop (); + + void dialogs_hide (); + void dialogs_unhide (); + void dialogs_toggle (); + + void external_change (); + void selection_modified (Inkscape::Selection *selection, guint flags); + void selection_changed (Inkscape::Selection * selection); + void subselection_changed (SPDesktop *desktop); + void selection_set (Inkscape::Selection * selection); + + void eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext); + + // Moved document add/remove functions into public inkscape.h as they are used + // (rightly or wrongly) by console-mode functions + void add_document (SPDocument *document); + bool remove_document (SPDocument *document); + + gchar *homedir_path(const char *filename); + gchar *profile_path(const char *filename); + + // fixme: This has to be rethought + void refresh_display (); + + // fixme: This also + void exit (); + + int autosave(); + + friend Application * ::inkscape_ref (Application * in); + friend Application * ::inkscape_unref(Application * in); +}; + +} // namespace Inkscape bool inkscapeIsCrashing(); -SPDesktop * inkscape_find_desktop_by_dkey (unsigned int dkey); - -#define SP_ACTIVE_EVENTCONTEXT inkscape_active_event_context () -Inkscape::UI::Tools::ToolBase * inkscape_active_event_context (void); - -#define SP_ACTIVE_DOCUMENT inkscape_active_document () -SPDocument * inkscape_active_document (void); - -#define SP_ACTIVE_DESKTOP inkscape_active_desktop () -SPDesktop * inkscape_active_desktop (void); - -// Use this function to get selection model etc for a document, if possible! -// The "active" alternative below has all the horrible static cling of a singleton. -Inkscape::ActionContext -inkscape_action_context_for_document(SPDocument *doc); - -// More horrible static cling... sorry about this. Should really replace all of -// the static stuff with a single instance of some kind of engine class holding -// all the document / non-GUI stuff, and an optional GUI class that behaves a -// bit like SPDesktop does currently. Then it will be easier to write good code -// that doesn't just expect a GUI all the time (like lots of the app currently -// does). -// Also, while the "active" document / desktop concepts are convenient, they -// appear to have been abused somewhat, further increasing static cling. -Inkscape::ActionContext inkscape_active_action_context(); - -bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop); +// gets the current instance and calls autosave() +int inkscape_autosave(gpointer unused); -gchar *homedir_path(const char *filename); -gchar *profile_path(const char *filename); +// hmm, I wonder what this does /s +Inkscape::Application* inkscape_get_instance(); -/* Inkscape desktop stuff */ -void inkscape_activate_desktop (SPDesktop * desktop); -void inkscape_switch_desktops_next (); -void inkscape_switch_desktops_prev (); -void inkscape_get_all_desktops (std::list< SPDesktop* >& listbuf); - -void inkscape_dialogs_hide (); -void inkscape_dialogs_unhide (); -void inkscape_dialogs_toggle (); - -void inkscape_external_change (); -void inkscape_subselection_changed (SPDesktop *desktop); - -/* Moved document add/remove functions into public inkscape.h as they are used - (rightly or wrongly) by console-mode functions */ -void inkscape_add_document (SPDocument *document); -bool inkscape_remove_document (SPDocument *document); - -/* - * fixme: This has to be rethought - */ - -void inkscape_refresh_display (Inkscape::Application *inkscape); - -/* - * fixme: This also - */ - -void inkscape_exit (Inkscape::Application *inkscape); +// only temporary until I can properly clean this up +void inkscape_application_init (const gchar *argv0, gboolean use_gui); #endif diff --git a/src/inkview.cpp b/src/inkview.cpp index 82bd08e34..df2661968 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -60,7 +60,7 @@ #include "io/inkjar.h" #endif -#include "inkscape-private.h" +#include "inkscape.h" Inkscape::Application *inkscape; @@ -232,7 +232,7 @@ main (int argc, const char **argv) ss.view = NULL; ss.fullscreen = false; - inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); + inkscape = new Inkscape::Application;//(Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); // starting at where the commandline options stopped parsing because // we want all the files to be in the list diff --git a/src/interface.cpp b/src/interface.cpp index 1cbeb44a3..987c4987e 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -270,7 +270,7 @@ sp_create_window(SPViewWidget *vw, gboolean editable) // needed because the first ACTIVATE_DESKTOP was sent when there was no window yet if ( SP_IS_DESKTOP_WIDGET(vw) ) { - inkscape_reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop); + INKSCAPE->reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop); } } @@ -318,7 +318,7 @@ sp_ui_close_view(GtkWidget */*widget*/) // If closing the last document, open a new document so Inkscape doesn't quit. std::list desktops; - inkscape_get_all_desktops(desktops); + INKSCAPE->get_all_desktops(desktops); if (desktops.size() == 1) { Glib::ustring templateUri = sp_file_default_template_uri(); SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true ); @@ -921,7 +921,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I GtkWidget *sp_ui_main_menubar(Inkscape::UI::View::View *view) { GtkWidget *mbar = gtk_menu_bar_new(); - sp_ui_build_dyn_menus(inkscape_get_menus(INKSCAPE), mbar, view); + sp_ui_build_dyn_menus(INKSCAPE->get_menus(), mbar, view); return mbar; } @@ -2106,13 +2106,13 @@ void ContextMenu::ImageEdit(void) void ContextMenu::ImageTraceBitmap(void) { - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); _desktop->_dlg_mgr->showDialog("Trace"); } void ContextMenu::ImageTracePixelArt(void) { - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); _desktop->_dlg_mgr->showDialog("PixelArt"); } diff --git a/src/io/resource.cpp b/src/io/resource.cpp index ac1c5f06b..94bd7fca1 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -73,7 +73,7 @@ Util::ptr_shared get_path(Domain domain, Type type, char const *filename) case TEMPLATES: name = "templates"; break; default: return get_path(SYSTEM, type, filename); } - path = profile_path(name); + path = INKSCAPE->profile_path(name); } break; } diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index c255f8665..a7748c5a8 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -60,7 +60,7 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : concatenate_before_pwd2 = true; // don't split the path into its subpaths _provides_knotholder_entities = true; - Persp3D *persp = persp3d_document_first_persp(inkscape_active_document()); + Persp3D *persp = persp3d_document_first_persp(SP_ACTIVE_DOCUMENT); Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; pmat.copy_tmat(tmat); } diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index 6af616e34..9da7f6a79 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -82,7 +82,7 @@ CmdLineAction::doList (ActionContext const & context) { bool CmdLineAction::idle (void) { std::list desktops; - inkscape_get_all_desktops(desktops); + INKSCAPE->get_all_desktops(desktops); // We're going to assume one desktop per document, because no one // should have had time to make more at this point. diff --git a/src/main.cpp b/src/main.cpp index 517ba0506..597cda27d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -933,9 +933,9 @@ guint get_group0_keyval(GdkEventKey const* event); static void snooper(GdkEvent *event, gpointer /*data*/) { - if (inkscape_mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */ + if (INKSCAPE->mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */ { - GdkModifierType mapping=(GdkModifierType)inkscape_mapalt(); + GdkModifierType mapping=(GdkModifierType)INKSCAPE->mapalt(); switch (event->type) { case GDK_MOTION_NOTIFY: if(event->motion.state & mapping) { @@ -957,7 +957,7 @@ snooper(GdkEvent *event, gpointer /*data*/) { } } - if (inkscape_trackalt()) { + if (INKSCAPE->trackalt()) { // MacOS X with X11 has some problem with the default // xmodmapping. A ~/.xmodmap solution does not work reliably due // to the way we package our executable in a .app that can launch @@ -1042,7 +1042,7 @@ sp_main_gui(int argc, char const **argv) } // Add our icon directory to the search path for icon theme lookups. - gchar *usericondir = profile_path("icons"); + gchar *usericondir = INKSCAPE->profile_path("icons"); gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), usericondir); gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), INKSCAPE_PIXMAPDIR); g_free(usericondir); @@ -1125,14 +1125,14 @@ static int sp_process_file_list(GSList *fl) retVal++; } else { - inkscape_add_document(doc); + INKSCAPE->add_document(doc); if (sp_vacuum_defs) { doc->vacuumDocument(); } // Execute command-line actions (selections and verbs) using our local models - bool has_performed_actions = Inkscape::CmdLineAction::doList(inkscape_active_action_context()); + bool has_performed_actions = Inkscape::CmdLineAction::doList(INKSCAPE->active_action_context()); #ifdef WITH_DBUS // If we've been asked to listen for D-Bus messages, enter a main loop here @@ -1221,7 +1221,7 @@ static int sp_process_file_list(GSList *fl) do_query_dimension (doc, false, sp_query_x? Geom::X : Geom::Y, sp_query_id); } - inkscape_remove_document(doc); + INKSCAPE->remove_document(doc); delete doc; } diff --git a/src/persp3d.cpp b/src/persp3d.cpp index b10e5f23b..1088f098d 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -140,7 +140,7 @@ void Persp3D::set(unsigned key, gchar const *value) { } // FIXME: Is this the right place for resetting the draggers? - Inkscape::UI::Tools::ToolBase *ec = inkscape_active_event_context(); + Inkscape::UI::Tools::ToolBase *ec = INKSCAPE->active_event_context(); if (SP_IS_BOX3D_CONTEXT(ec)) { Inkscape::UI::Tools::Box3dTool *bc = SP_BOX3D_CONTEXT(ec); bc->_vpdrag->updateDraggers(); diff --git a/src/preferences.cpp b/src/preferences.cpp index d0c3783b5..ede60c686 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -91,11 +91,11 @@ Preferences::Preferences() : _hasError(false) { // profile_path essentailly returns the argument prefixed by the profile directory. - gchar *path = profile_path(NULL); + gchar *path = INKSCAPE->profile_path(NULL); _prefs_dir = path; g_free(path); - path = profile_path(_prefs_basename.c_str()); + path = INKSCAPE->profile_path(_prefs_basename.c_str()); _prefs_filename = path; g_free(path); @@ -155,7 +155,7 @@ void Preferences::_load() // create some subdirectories for user stuff char const *user_dirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL}; for (int i=0; user_dirs[i]; ++i) { - char *dir = profile_path(user_dirs[i]); + char *dir = INKSCAPE->profile_path(user_dirs[i]); g_mkdir(dir, 0755); g_free(dir); } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index a350dd7a7..ebd5f4510 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3512,7 +3512,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) directory = g_path_get_dirname( document->getURI() ); } if (directory == NULL) { - directory = homedir_path(NULL); + directory = INKSCAPE->homedir_path(NULL); } gchar *filepath = g_build_filename(directory, basename, NULL); g_free(directory); diff --git a/src/selection.cpp b/src/selection.cpp index 17b7253f2..b1fa4b32d 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -89,7 +89,7 @@ Selection::_emit_modified(Selection *selection) } void Selection::_emitModified(guint flags) { - inkscape_selection_modified(this, flags); + INKSCAPE->selection_modified(this, flags); _modified_signal.emit(this, flags); } @@ -104,7 +104,7 @@ void Selection::_emitChanged(bool persist_selection_context/* = false */) { _releaseContext(_selection_context); } - inkscape_selection_changed(this); + INKSCAPE->selection_changed(this); _changed_signal.emit(this); } diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index 1e43c98c6..016a48d8f 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -211,7 +211,7 @@ Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename) void sp_shortcut_get_file_names(std::vector *names, std::vector *paths) { std::list sources; - sources.push_back( profile_path("keys") ); + sources.push_back( INKSCAPE->profile_path("keys") ); sources.push_back( g_strdup(INKSCAPE_KEYSDIR) ); // loop through possible keyboard shortcut file locations. @@ -229,7 +229,7 @@ void sp_shortcut_get_file_names(std::vector *names, std::vectorprofile_path("keys")) && !strcmp(lower, "default.xml")) { // Dont add the users custom keys file continue; diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index fe9d32f43..8d9baff48 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -153,7 +153,7 @@ tools_switch(SPDesktop *dt, int num) /* fixme: This is really ugly hack. We should bind and unbind class methods */ /* First 4 tools use guides, first is undefined but we don't care */ dt->activate_guides(num < 5); - inkscape_eventcontext_set(dt->getEventContext()); + INKSCAPE->eventcontext_set(dt->getEventContext()); } void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p) diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 913713e5c..3aad1a8a8 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -588,7 +588,7 @@ Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ust } if (directory.empty()) { - directory = homedir_path(NULL); + directory = INKSCAPE->homedir_path(NULL); } Glib::ustring filename = Glib::build_filename(directory, id+".png"); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 8ba3ad684..c4281babc 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1044,7 +1044,7 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl } // allow easy access to the user's own templates folder - gchar *templates = profile_path("templates"); + gchar *templates = INKSCAPE->profile_path("templates"); if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) && Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) { add_shortcut_folder(templates); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index f1a29e971..f1535175a 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1908,7 +1908,7 @@ void InkscapePreferences::initPageSystem() _page_system.add_group_header( _("System info")); - _sys_user_config.set_text((char const *)profile_path("")); + _sys_user_config.set_text((char const *)INKSCAPE->profile_path("")); _sys_user_config.set_editable(false); _page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 4f0cb211a..6dbb1d5e9 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -527,7 +527,7 @@ static void loadEmUp() beenHere = true; std::list sources; - sources.push_back( profile_path("palettes") ); + sources.push_back( INKSCAPE->profile_path("palettes") ); sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) ); sources.push_back( g_strdup(CREATE_PALETTESDIR) ); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index c58df864c..9e5e94498 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -572,9 +572,9 @@ void SymbolsDialog::get_symbols() { Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { directories.push_back( INKSCAPE_SYMBOLSDIR ); } - if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { - directories.push_back( profile_path("symbols") ); + if( Inkscape::IO::file_test( INKSCAPE->profile_path("symbols"), G_FILE_TEST_EXISTS ) && + Inkscape::IO::file_test( INKSCAPE->profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { + directories.push_back( INKSCAPE->profile_path("symbols") ); } std::list::iterator it; diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index d75f81456..1bd9510dc 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -194,7 +194,7 @@ void TemplateLoadTab::_refreshTemplatesList() void TemplateLoadTab::_loadTemplates() { // user's local dir - _getTemplatesFromDir(profile_path("templates") + _loading_path); + _getTemplatesFromDir(INKSCAPE->profile_path("templates") + _loading_path); // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index 72548e213..cfedb6921 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -85,7 +85,7 @@ void View::_close() { if (_doc) { _document_uri_set_connection.disconnect(); _document_resized_connection.disconnect(); - if (inkscape_remove_document(_doc)) { + if (INKSCAPE->remove_document(_doc)) { // this was the last view of this document, so delete it delete _doc; } @@ -111,13 +111,13 @@ void View::setDocument(SPDocument *doc) { if (_doc) { _document_uri_set_connection.disconnect(); _document_resized_connection.disconnect(); - if (inkscape_remove_document(_doc)) { + if (INKSCAPE->remove_document(_doc)) { // this was the last view of this document, so delete it delete _doc; } } - inkscape_add_document(doc); + INKSCAPE->add_document(doc); _doc = doc; _document_uri_set_connection = diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index bb6a2c4d7..66e699b41 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -633,7 +633,7 @@ VPDrag::updateBoxHandles () return; } - Inkscape::UI::Tools::ToolBase *ec = inkscape_active_event_context(); + Inkscape::UI::Tools::ToolBase *ec = INKSCAPE->active_event_context(); g_assert (ec != NULL); if (ec->shape_editor != NULL) { ec->shape_editor->update_knotholder(); diff --git a/src/verbs.cpp b/src/verbs.cpp index 0c329cab8..420b243d0 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -873,10 +873,10 @@ void FileVerb::perform(SPAction *action, void *data) // sp_file_export_to_ocal(*parent); // break; case SP_VERB_FILE_NEXT_DESKTOP: - inkscape_switch_desktops_next(); + INKSCAPE->switch_desktops_next(); break; case SP_VERB_FILE_PREV_DESKTOP: - inkscape_switch_desktops_prev(); + INKSCAPE->switch_desktops_prev(); break; case SP_VERB_FILE_CLOSE_VIEW: sp_ui_close_view(NULL); @@ -1170,11 +1170,11 @@ void SelectionVerb::perform(SPAction *action, void *data) SelectionHelper::reverse(dt); break; case SP_VERB_SELECTION_TRACE: - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); dt->_dlg_mgr->showDialog("Trace"); break; case SP_VERB_SELECTION_PIXEL_ART: - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); dt->_dlg_mgr->showDialog("PixelArt"); break; case SP_VERB_SELECTION_CREATE_BITMAP: @@ -1188,7 +1188,7 @@ void SelectionVerb::perform(SPAction *action, void *data) sp_selected_path_break_apart(dt); break; case SP_VERB_SELECTION_ARRANGE: - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); dt->_dlg_mgr->showDialog("TileDialog"); //FIXME: denis: What's this string (to be changed) break; default: @@ -1929,7 +1929,7 @@ void ZoomVerb::perform(SPAction *action, void *data) dt->toggleColorProfAdjust(); break; case SP_VERB_VIEW_ICON_PREVIEW: - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); dt->_dlg_mgr->showDialog("IconPreviewPanel"); break; @@ -1948,7 +1948,7 @@ void DialogVerb::perform(SPAction *action, void *data) { if (reinterpret_cast(data) != SP_VERB_DIALOG_TOGGLE) { // unhide all when opening a new dialog - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); } g_return_if_fail(ensure_desktop_valid(action)); @@ -2011,7 +2011,7 @@ void DialogVerb::perform(SPAction *action, void *data) dt->_dlg_mgr->showDialog("UndoHistory"); break; case SP_VERB_DIALOG_TOGGLE: - inkscape_dialogs_toggle(); + INKSCAPE->dialogs_toggle(); break; case SP_VERB_DIALOG_CLONETILER: //clonetiler_dialog(); @@ -2083,7 +2083,7 @@ void HelpVerb::perform(SPAction *action, void *data) */ case SP_VERB_HELP_MEMORY: - inkscape_dialogs_unhide(); + INKSCAPE->dialogs_unhide(); dt->_dlg_mgr->showDialog("Memory"); break; default: diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp index 6d6b86c4d..ecc7890b9 100644 --- a/src/widgets/box3d-toolbar.cpp +++ b/src/widgets/box3d-toolbar.cpp @@ -194,7 +194,7 @@ static void box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObj sp_repr_synthesize_events(persp_repr, &box3d_persp_tb_repr_events, tbl); } - inkscape_active_document()->setCurrentPersp3D(persp3d_get_from_repr(persp_repr)); + SP_ACTIVE_DOCUMENT->setCurrentPersp3D(persp3d_get_from_repr(persp_repr)); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setString("/tools/shapes/3dbox/persp", persp_repr->attribute("id")); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 2c28dfbfa..de5db279f 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -795,7 +795,7 @@ static void sp_desktop_widget_dispose(GObject *object) dtw->layer_selector->setDesktop(NULL); dtw->layer_selector->unreference(); - inkscape_remove_desktop (dtw->desktop); // clears selection too + INKSCAPE->remove_desktop (dtw->desktop); // clears selection too dtw->modified_connection.disconnect(); dtw->desktop->destroy(); Inkscape::GC::release (dtw->desktop); @@ -1091,7 +1091,7 @@ SPDesktopWidget::shutdown() { g_assert(desktop != NULL); - if (inkscape_is_sole_desktop_for_document(*desktop)) { + if (INKSCAPE->sole_desktop_for_document(*desktop)) { SPDocument *doc = desktop->doc(); if (doc->isModifiedSinceSave()) { GtkWidget *dialog; @@ -1672,7 +1672,7 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview) dtw->desktop = new SPDesktop(); dtw->stub = new SPDesktopWidget::WidgetStub (dtw); dtw->desktop->init (namedview, dtw->canvas, dtw->stub); - inkscape_add_desktop (dtw->desktop); + INKSCAPE->add_desktop (dtw->desktop); // Add the shape geometry to libavoid for autorouting connectors. // This needs desktop set for its spacing preferences. @@ -1818,7 +1818,7 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*) } } - inkscape_activate_desktop (desktop); + INKSCAPE->activate_desktop (desktop); return false; } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index a96f47124..0814d56d6 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1257,7 +1257,7 @@ std::list &IconImpl::icons_svg_paths() static bool initialized = false; if (!initialized) { // Fall back from user prefs dir into system locations. - gchar *userdir = profile_path("icons"); + gchar *userdir = INKSCAPE->profile_path("icons"); sources.push_back(g_build_filename(userdir,"icons.svg", NULL)); sources.push_back(g_build_filename(INKSCAPE_PIXMAPDIR, "icons.svg", NULL)); g_free(userdir); -- cgit v1.2.3 From 60f288cc584bf34c65698341427cf377b88c7138 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Jun 2014 16:21:44 -0400 Subject: 2. connect signals (bzr r13341.5.2) --- src/document-private.h | 2 ++ src/document-undo.cpp | 3 +-- src/document-undo.h | 2 +- src/document.cpp | 35 +++++++++++++++++++---------- src/inkscape.cpp | 10 +++++++-- src/ui/dialog/align-and-distribute.cpp | 14 +++++++----- src/ui/dialog/clonetiler.cpp | 40 +++++++++++++++++++--------------- src/ui/dialog/clonetiler.h | 5 +++-- src/ui/dialog/desktop-tracker.cpp | 21 ++++++++++-------- src/ui/dialog/desktop-tracker.h | 4 ++-- src/ui/dialog/dialog.cpp | 31 +++++++++++++++----------- src/ui/dialog/grid-arrange-tab.cpp | 3 ++- src/ui/dialog/panel-dialog.h | 6 +++-- src/ui/dialog/transformation.cpp | 13 +++++------ src/ui/widget/dock.cpp | 7 ++++-- src/widgets/sp-widget.cpp | 33 ++++++++++++++++++++-------- src/widgets/sp-widget.h | 3 +++ 17 files changed, 145 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/document-private.h b/src/document-private.h index 4560aa28f..ae189c2c0 100644 --- a/src/document-private.h +++ b/src/document-private.h @@ -74,6 +74,8 @@ struct SPDocumentPrivate { Inkscape::ConsoleOutputUndoObserver console_output_undo_observer; bool seeking; + sigc::connection selChangeConnection; + sigc::connection desktopActivatedConnection; }; #endif // SEEN_SP_DOCUMENT_PRIVATE_H diff --git a/src/document-undo.cpp b/src/document-undo.cpp index da40dcd4d..a40b2fb81 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -112,9 +112,8 @@ void Inkscape::DocumentUndo::done(SPDocument *doc, const unsigned int event_type maybeDone(doc, NULL, event_type, event_description); } -void Inkscape::DocumentUndo::resetKey( Inkscape::Application * /*inkscape*/, SPDesktop * /*desktop*/, GObject *base ) +void Inkscape::DocumentUndo::resetKey( SPDocument *doc ) { - SPDocument *doc = reinterpret_cast(base); doc->actionkey.clear(); } diff --git a/src/document-undo.h b/src/document-undo.h index 38e575a34..8333e715a 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -42,7 +42,7 @@ public: static void maybeDone(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring const &event_description); - static void resetKey(Inkscape::Application *inkscape, SPDesktop *desktop, GObject *base); + static void resetKey(SPDocument *doc); static void cancel(SPDocument *document); diff --git a/src/document.cpp b/src/document.cpp index 80e9bfe4f..ee1a48eb6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -154,6 +154,17 @@ SPDocument::~SPDocument() { router = NULL; } + if (oldSignalsConnected) { + priv->selChangeConnection.disconnect(); + priv->desktopActivatedConnection.disconnect(); + //g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE), + //reinterpret_cast(DocumentUndo::resetKey), + //static_cast(this)); + } else { + _selection_changed_connection.disconnect(); + _desktop_activated_connection.disconnect(); + } + if (priv) { if (priv->partial) { sp_repr_free_log(priv->partial); @@ -208,15 +219,6 @@ SPDocument::~SPDocument() { rerouting_handler_id = 0; } - if (oldSignalsConnected) { - g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE), - reinterpret_cast(DocumentUndo::resetKey), - static_cast(this)); - } else { - _selection_changed_connection.disconnect(); - _desktop_activated_connection.disconnect(); - } - if (keepalive) { inkscape_unref(INKSCAPE); keepalive = FALSE; @@ -463,10 +465,21 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, DocumentUndo::setUndoSensitive(document, true); // reset undo key when selection changes, so that same-key actions on different objects are not coalesced - g_signal_connect(G_OBJECT(INKSCAPE), "change_selection", + document->priv->selChangeConnection = INKSCAPE->signal_selection_changed.connect( + sigc::hide( // hide unused first and second args + sigc::hide(sigc::bind( + sigc::ptr_fun(&DocumentUndo::resetKey), document) + ))); + document->priv->desktopActivatedConnection = INKSCAPE->signal_activate_desktop.connect( + sigc::hide( // hide unused first and second args + sigc::hide(sigc::bind( + sigc::ptr_fun(&DocumentUndo::resetKey), document) + ))); + + /*g_signal_connect(G_OBJECT(INKSCAPE), "change_selection", G_CALLBACK(DocumentUndo::resetKey), document); g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", - G_CALLBACK(DocumentUndo::resetKey), document); + G_CALLBACK(DocumentUndo::resetKey), document);*/ document->oldSignalsConnected = true; return document; diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 23c2b001a..4e8b06ef4 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -506,7 +506,7 @@ Application::Application() } this->menus = NULL; - //this->desktops = NULL; + this->desktops = NULL; this->_dialogs_toggle = TRUE; this->_mapalt = GDK_MOD1_MASK; this->_trackalt = FALSE; @@ -976,6 +976,10 @@ void Application::add_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); + if (desktops == NULL) { + desktops = new std::list; + g_message("Creating new desktop list."); + } //g_return_if_fail (inkscape != NULL); g_assert (std::find(desktops->begin(), desktops->end(), desktop) == desktops->end()); @@ -1030,7 +1034,9 @@ Application::remove_desktop (SPDesktop * desktop) // if this was the last desktop, shut down the program if (desktops->empty()) { + g_message("Shutting down."); this->exit(); + delete desktops; } } @@ -1285,7 +1291,7 @@ Application::remove_document (SPDocument *document) SPDesktop * Application::active_desktop() { - if (desktops == NULL) { + if (!desktops || desktops->empty()) { return NULL; } diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index e02ccd3f1..527f4d59c 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -829,14 +829,14 @@ private : -static void on_tool_changed(Inkscape::Application */*inkscape*/, Inkscape::UI::Tools::ToolBase */*context*/, AlignAndDistribute *daad) +static void on_tool_changed(AlignAndDistribute *daad) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop && desktop->getEventContext()) daad->setMode(tools_active(desktop) == TOOLS_NODES); } -static void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad) +static void on_selection_changed(AlignAndDistribute *daad) { daad->randomize_bbox = Geom::OptRect(); } @@ -1044,10 +1044,12 @@ AlignAndDistribute::AlignAndDistribute() contents->pack_start(_nodesFrame, true, true); //Connect to the global tool change signal - g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this); + INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)))); + //g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this); // Connect to the global selection change, to invalidate cached randomize_bbox - g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); + INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)))); + //g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); randomize_bbox = Geom::OptRect(); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &AlignAndDistribute::setDesktop) ); @@ -1055,7 +1057,7 @@ AlignAndDistribute::AlignAndDistribute() show_all_children(); - on_tool_changed (NULL, NULL, this); // set current mode + on_tool_changed (this); // set current mode } AlignAndDistribute::~AlignAndDistribute() @@ -1075,7 +1077,7 @@ void AlignAndDistribute::setTargetDesktop(SPDesktop *desktop) { if (_desktop != desktop) { _desktop = desktop; - on_tool_changed (NULL, NULL, this); + on_tool_changed (this); } } diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index fb131d8da..b0298afa6 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -75,15 +75,12 @@ static gdouble trace_zoom; static SPDocument *trace_doc = NULL; -CloneTiler::CloneTiler (void) : +CloneTiler::CloneTiler () : UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER), dlg(NULL), desktop(NULL), deskTrack(), - table_row_labels(NULL), - selectChangedConn(), - subselChangedConn(), - selectModifiedConn() + table_row_labels(NULL) { Gtk::Box *contents = _getContents(); contents->set_spacing(0); @@ -1272,12 +1269,14 @@ CloneTiler::CloneTiler (void) : // connect to global selection changed signal (so we can change desktops) and // external_change (so we're not fooled by undo) - g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg); - g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg); - g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE)); + selectChangedConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg))); + externChangedConn = INKSCAPE->signal_external_change.connect (sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg))); + //g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg); + //g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg); + g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this); // update now - clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); + clonetiler_change_selection (sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); } { @@ -1349,7 +1348,7 @@ void CloneTiler::on_picker_color_changed(guint rgba) is_updating = false; } -void CloneTiler::clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg) +void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg) { GtkWidget *buttons = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles")); GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); @@ -1378,16 +1377,21 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Application * /*inkscape* } } -void CloneTiler::clonetiler_external_change(Inkscape::Application * /*inkscape*/, GtkWidget *dlg) +void CloneTiler::clonetiler_external_change(GtkWidget *dlg) { - clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); + clonetiler_change_selection (sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); } -void CloneTiler::clonetiler_disconnect_gsignal(GObject *widget, gpointer source) +void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source) { - if (source && G_IS_OBJECT(source)) { - sp_signal_disconnect_by_data (source, widget); - } + //if (source && G_IS_OBJECT(source)) { + //sp_signal_disconnect_by_data (source, widget); + //} + g_return_if_fail(source != NULL); + + CloneTiler* dlg = reinterpret_cast(source); + dlg->selectChangedConn.disconnect(); + dlg->externChangedConn.disconnect(); } Geom::Affine CloneTiler::clonetiler_get_transform( @@ -2164,7 +2168,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d } g_slist_free (to_delete); - clonetiler_change_selection (NULL, selection, dlg); + clonetiler_change_selection (selection, dlg); if (do_undo) { DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, @@ -2630,7 +2634,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) clonetiler_trace_finish (); } - clonetiler_change_selection (NULL, selection, dlg); + clonetiler_change_selection (selection, dlg); desktop->clearWaitingCursor(); diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index e2a0240ee..879fed8c2 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -58,8 +58,8 @@ protected: static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); static void clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg); static void clonetiler_unclump(GtkWidget */*widget*/, void *); - static void clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg); - static void clonetiler_external_change(Inkscape::Application * /*inkscape*/, GtkWidget *dlg); + static void clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg); + static void clonetiler_external_change(GtkWidget *dlg); static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source); static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg); static guint clonetiler_number_of_clones(SPObject *obj); @@ -130,6 +130,7 @@ private: sigc::connection desktopChangeConn; sigc::connection selectChangedConn; + sigc::connection externChangedConn; sigc::connection subselChangedConn; sigc::connection selectModifiedConn; sigc::connection color_changed_connection; diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 8a359dd2d..3a8f5176e 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -22,7 +22,6 @@ DesktopTracker::DesktopTracker() : desktop(0), widget(0), hierID(0), - inkID(0), trackActive(false), desktopChangedSig() { @@ -41,7 +40,12 @@ void DesktopTracker::connect(GtkWidget *widget) // Use C/gobject callbacks to avoid gtkmm rewrap-during-destruct issues: hierID = g_signal_connect( G_OBJECT(widget), "hierarchy-changed", G_CALLBACK(hierarchyChangeCB), this ); - inkID = g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(activateDesktopCB), this ); + inkID = INKSCAPE->signal_activate_desktop.connect( + sigc::hide<0>( + sigc::bind( + sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this) + )); + //inkID = g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(activateDesktopCB), this ); GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET); if (wdgt && !base) { @@ -60,11 +64,10 @@ void DesktopTracker::disconnect() } hierID = 0; } - if (inkID) { - if (INKSCAPE) { - g_signal_handler_disconnect(G_OBJECT(INKSCAPE), inkID); - } - inkID = 0; + if (inkID.connected()) { + inkID.disconnect(); + //g_signal_handler_disconnect(G_OBJECT(INKSCAPE), inkID); + //inkID = 0; } } @@ -94,12 +97,12 @@ sigc::connection DesktopTracker::connectDesktopChanged( const sigc::slottrackActive) { self->setDesktop(desktop); } - return FALSE; + //return FALSE; } bool DesktopTracker::hierarchyChangeCB(GtkWidget * /*widget*/, GtkWidget* /*prev*/, DesktopTracker *self) diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h index 7da55cf2f..a58666c0d 100644 --- a/src/ui/dialog/desktop-tracker.h +++ b/src/ui/dialog/desktop-tracker.h @@ -37,7 +37,7 @@ public: sigc::connection connectDesktopChanged( const sigc::slot & slot ); private: - static gboolean activateDesktopCB(Inkscape::Application *inkscape, SPDesktop *desktop, DesktopTracker *self ); + static void activateDesktopCB(SPDesktop *desktop, DesktopTracker *self ); static bool hierarchyChangeCB(GtkWidget *widget, GtkWidget* prev, DesktopTracker *self); void handleHierarchyChange(); @@ -47,7 +47,7 @@ private: SPDesktop *desktop; GtkWidget *widget; gulong hierID; - gulong inkID; + sigc::connection inkID; bool trackActive; sigc::signal desktopChangedSig; }; diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 645294bb5..e98befc89 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -41,27 +41,28 @@ namespace Inkscape { namespace UI { namespace Dialog { -void sp_retransientize(Inkscape::Application */*inkscape*/, SPDesktop *desktop, gpointer dlgPtr) +gboolean sp_retransientize_again(gpointer dlgPtr) { Dialog *dlg = static_cast(dlgPtr); - dlg->onDesktopActivated (desktop); + dlg->retransientize_suppress = false; + return FALSE; // so that it is only called once } -gboolean sp_retransientize_again(gpointer dlgPtr) +#if 0 +void sp_retransientize(SPDesktop *desktop, Dialog * dlgPtr) { Dialog *dlg = static_cast(dlgPtr); - dlg->retransientize_suppress = false; - return FALSE; // so that it is only called once + dlg->onDesktopActivated (desktop); } -void sp_dialog_shutdown(GObject * /*object*/, gpointer dlgPtr) +void sp_dialog_shutdown(GObject * /*object*/, Dialog * dlgPtr) { Dialog *dlg = static_cast(dlgPtr); dlg->onShutdown(); } -static void hideCallback(GObject * /*object*/, gpointer dlgPtr) +static void hideCallback(GObject * /*object*/, Dialog * dlgPtr) { g_return_if_fail( dlgPtr != NULL ); @@ -69,14 +70,14 @@ static void hideCallback(GObject * /*object*/, gpointer dlgPtr) dlg->onHideF12(); } -static void unhideCallback(GObject * /*object*/, gpointer dlgPtr) +static void unhideCallback(GObject * /*object*/, Dialog* dlgPtr) { g_return_if_fail( dlgPtr != NULL ); Dialog *dlg = static_cast(dlgPtr); dlg->onShowF12(); } - +#endif //===================================================================== @@ -103,10 +104,14 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat _behavior = behavior_factory(*this); _desktop = SP_ACTIVE_DESKTOP; - g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this); - g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this); - g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this); - g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_dialog_shutdown), (void *)this); + INKSCAPE->signal_activate_desktop.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onDesktopActivated))); + INKSCAPE->signal_dialogs_hide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onHideF12))); + INKSCAPE->signal_dialogs_unhide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShowF12))); + INKSCAPE->signal_shut_down.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShutdown))); + //g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this); + //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this); + //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this); + //g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_dialog_shutdown), (void *)this); Glib::wrap(gobj())->signal_event().connect(sigc::mem_fun(*this, &Dialog::_onEvent)); Glib::wrap(gobj())->signal_key_press_event().connect(sigc::mem_fun(*this, &Dialog::_onKeyPress)); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 72217c729..117420b47 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -605,7 +605,8 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) { // Selection Change signal - g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); + INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection)))); + //g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); } Gtk::Box *contents = this; diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index 1fefd811e..1589c7058 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -247,8 +247,10 @@ PanelDialog *PanelDialog new PanelDialog(panel, panel.getPrefsPath(), panel.getVerb(), panel.getApplyLabel()); - g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(_handle_activate_desktop), instance); - g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(handle_deactivate_desktop), instance); + INKSCAPE->signal_activate_desktop.connect (sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopActivated)); + INKSCAPE->signal_deactivate_desktop.connect(sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopDeactivated)); + //g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(_handle_activate_desktop), instance); + //g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(handle_deactivate_desktop), instance); return instance; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index a7f0b068e..9df328566 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -47,16 +47,13 @@ namespace Inkscape { namespace UI { namespace Dialog { -static void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, Transformation *daad) +static void on_selection_changed(Inkscape::Selection *selection, Transformation *daad) { int page = daad->getCurrentPage(); daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection); } -static void on_selection_modified( Inkscape::Application */*inkscape*/, - Inkscape::Selection *selection, - guint /*flags*/, - Transformation *daad ) +static void on_selection_modified(Inkscape::Selection *selection, Transformation *daad) { int page = daad->getCurrentPage(); daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection); @@ -159,8 +156,10 @@ Transformation::Transformation() } // Connect to the global selection changed & modified signals - g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); - g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this); + INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); + INKSCAPE->signal_selection_modified.connect(sigc::hide<0>(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this)))); + //g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); + //g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) ); _deskTrack.connect(GTK_WIDGET(gobj())); diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 52e9ea605..4b22bba67 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -119,8 +119,11 @@ Dock::Dock(Gtk::Orientation orientation) gdl_dock_bar_set_style(_gdl_dock_bar, gdl_dock_bar_style); - g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this); - g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this); + + //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this); + //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this); + INKSCAPE->signal_dialogs_hide.connect(sigc::hide(sigc::mem_fun(*this, &Dock::hide))); + INKSCAPE->signal_dialogs_unhide.connect(sigc::hide(sigc::mem_fun(*this, &Dock::show))); g_signal_connect(_paned->gobj(), "button-press-event", G_CALLBACK(_on_paned_button_event), (void *)this); g_signal_connect(_paned->gobj(), "button-release-event", G_CALLBACK(_on_paned_button_event), (void *)this); diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 0e2295e36..98d528d4a 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -15,6 +15,7 @@ #include "macros.h" #include "document.h" +#include "inkscape.h" #include "sp-widget.h" #include "helper/sp-marshal.h" @@ -185,9 +186,14 @@ void SPWidgetImpl::dispose(GObject *object) // the checks are necessary because when destroy is caused by the program shutting down, // the inkscape object may already be (partly?) invalid --bb - if (G_IS_OBJECT(spw->inkscape) && G_OBJECT_GET_CLASS(spw->inkscape)) { - sp_signal_disconnect_by_data(spw->inkscape, spw); + if (dynamic_cast(spw->inkscape)) { + spw->selModified.disconnect(); + spw->selChanged.disconnect(); + spw->selSet.disconnect(); } + //if (G_IS_OBJECT(spw->inkscape) && G_OBJECT_GET_CLASS(spw->inkscape)) { + //sp_signal_disconnect_by_data(spw->inkscape, spw); + //} spw->inkscape = NULL; } @@ -205,9 +211,12 @@ void SPWidgetImpl::show(GtkWidget *widget) if (spw->inkscape) { // Connect signals - g_signal_connect(spw->inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw); - g_signal_connect(spw->inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw); - g_signal_connect(spw->inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw); + spw->selModified = spw->inkscape->signal_selection_modified.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)); + spw->selChanged = spw->inkscape->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)); + spw->selSet = spw->inkscape->signal_selection_set.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw)); + //g_signal_connect(spw->inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw); + //g_signal_connect(spw->inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw); + //g_signal_connect(spw->inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw); } if (reinterpret_cast(parentClass)->show) { @@ -221,7 +230,10 @@ void SPWidgetImpl::hide(GtkWidget *widget) if (spw->inkscape) { // Disconnect signals - sp_signal_disconnect_by_data(spw->inkscape, spw); + spw->selModified.disconnect(); + spw->selChanged.disconnect(); + spw->selSet.disconnect(); + //sp_signal_disconnect_by_data(spw->inkscape, spw); } if (reinterpret_cast(parentClass)->hide) { @@ -299,9 +311,12 @@ GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, Inkscape::Application *i spw->inkscape = inkscape; if (gtk_widget_get_visible(GTK_WIDGET(spw))) { - g_signal_connect(inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw); - g_signal_connect(inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw); - g_signal_connect(inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw); + spw->selModified = spw->inkscape->signal_selection_modified.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)); + spw->selChanged = spw->inkscape->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)); + spw->selSet = spw->inkscape->signal_selection_set.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw)); + //g_signal_connect(inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw); + //g_signal_connect(inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw); + //g_signal_connect(inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw); } g_signal_emit(spw, signals[CONSTRUCT], 0); diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h index 3a23a92c5..469ab2d92 100644 --- a/src/widgets/sp-widget.h +++ b/src/widgets/sp-widget.h @@ -43,6 +43,9 @@ struct SPWidget { GtkBin bin; Inkscape::Application *inkscape; + sigc::connection selModified; + sigc::connection selChanged; + sigc::connection selSet; private: Inkscape::SPWidgetImpl *_impl; }; -- cgit v1.2.3 From cdc7587062b42c39a23451e5c9ec7da06dd6fdb3 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Jun 2014 21:45:01 -0400 Subject: 3. remove dead code, refactor existing code. Connect overlooked signals. (bzr r13341.5.3) --- src/CMakeLists.txt | 1 - src/Makefile_insert | 2 +- src/desktop.cpp | 1 - src/dialogs/dialog-events.cpp | 4 +- src/dialogs/dialog-events.h | 2 +- src/document.cpp | 10 +- src/extension/effect.cpp | 2 +- src/inkscape-private.h | 67 --- src/inkscape.cpp | 604 +++++++++------------------- src/inkscape.h | 36 +- src/inkview.cpp | 2 +- src/interface.cpp | 2 +- src/main.cpp | 2 +- src/selection-chemistry.cpp | 2 +- src/selection.cpp | 2 +- src/test-helpers.h | 2 +- src/tools-switch.cpp | 2 +- src/ui/dialog/align-and-distribute.cpp | 10 +- src/ui/dialog/align-and-distribute.h | 3 +- src/ui/dialog/clonetiler.cpp | 6 +- src/ui/dialog/desktop-tracker.cpp | 3 - src/ui/dialog/dialog.cpp | 35 -- src/ui/dialog/export.cpp | 2 +- src/ui/dialog/grid-arrange-tab.cpp | 12 - src/ui/dialog/panel-dialog.h | 6 +- src/ui/dialog/transformation.cpp | 9 +- src/ui/dialog/transformation.h | 3 + src/ui/view/view.cpp | 2 +- src/ui/widget/dock.cpp | 4 +- src/ui/widget/object-composite-settings.cpp | 21 - src/verbs.cpp | 2 +- src/widgets/desktop-widget.cpp | 2 +- src/widgets/gradient-vector.cpp | 15 +- src/widgets/sp-widget.cpp | 3 - 34 files changed, 252 insertions(+), 629 deletions(-) delete mode 100644 src/inkscape-private.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d40aad802..47b181522 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -344,7 +344,6 @@ set(inkscape_SRC # ige-mac-menu.h ink-action.h ink-comboboxentry-action.h - inkscape-private.h inkscape-version.h inkscape.h interface.h diff --git a/src/Makefile_insert b/src/Makefile_insert index 6d0d6b08c..9ac08a822 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -72,7 +72,7 @@ ink_common_sources += \ ink-action.h \ ink-comboboxentry-action.cpp \ ink-comboboxentry-action.h \ - inkscape.cpp inkscape.h inkscape-private.h \ + inkscape.cpp inkscape.h \ interface.cpp interface.h \ isinf.h \ isnormal.h \ diff --git a/src/desktop.cpp b/src/desktop.cpp index e90b2caec..935567462 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -56,7 +56,6 @@ #include "event-log.h" #include "helper/action-context.h" #include "interface.h" -#include "inkscape-private.h" #include "layer-fns.h" #include "layer-manager.h" #include "layer-model.h" diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp index a12e3eafc..01213f1c7 100644 --- a/src/dialogs/dialog-events.cpp +++ b/src/dialogs/dialog-events.cpp @@ -6,7 +6,7 @@ * bulia byak * Johan Engelen * - * Copyright (C) 2003-2007 Authors + * Copyright (C) 2003-2014 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -25,7 +25,7 @@ #include "macros.h" #include #include "desktop.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "preferences.h" #include "ui/tools/tool-base.h" diff --git a/src/dialogs/dialog-events.h b/src/dialogs/dialog-events.h index 623058282..5320685b2 100644 --- a/src/dialogs/dialog-events.h +++ b/src/dialogs/dialog-events.h @@ -4,7 +4,7 @@ /* Authors: * bulia byak * - * Copyright (C) 2003 authors + * Copyright (C) 2003-2014 authors * * Released under GNU GPL, read the file 'COPYING' for more information */ diff --git a/src/document.cpp b/src/document.cpp index ee1a48eb6..26e59e610 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -50,7 +50,7 @@ #include "document-private.h" #include "document-undo.h" #include "id-clash.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "inkscape-version.h" #include "libavoid/router.h" #include "persp3d.h" @@ -157,9 +157,6 @@ SPDocument::~SPDocument() { if (oldSignalsConnected) { priv->selChangeConnection.disconnect(); priv->desktopActivatedConnection.disconnect(); - //g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE), - //reinterpret_cast(DocumentUndo::resetKey), - //static_cast(this)); } else { _selection_changed_connection.disconnect(); _desktop_activated_connection.disconnect(); @@ -475,11 +472,6 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) ))); - - /*g_signal_connect(G_OBJECT(INKSCAPE), "change_selection", - G_CALLBACK(DocumentUndo::resetKey), document); - g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", - G_CALLBACK(DocumentUndo::resetKey), document);*/ document->oldSignalsConnected = true; return document; diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 2ebf8964d..c68845d8a 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -9,7 +9,7 @@ */ #include "prefdialog.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "helper/action.h" #include "ui/view/view.h" #include "desktop-handles.h" diff --git a/src/inkscape-private.h b/src/inkscape-private.h deleted file mode 100644 index a55d92829..000000000 --- a/src/inkscape-private.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef SEEN_INKSCAPE_PRIVATE_H -#define SEEN_INKSCAPE_PRIVATE_H - -/* - * Some forward declarations - * - * Authors: - * Lauris Kaplinski - * - * Copyright (C) 1999-2002 Lauris Kaplinski - * Copyright (C) 2001-2002 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -#include - -//#define SP_TYPE_INKSCAPE (inkscape_get_type ()) -#define SP_INKSCAPE(obj) (dynamic_cast(obj)) //(G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_INKSCAPE, Inkscape)) -//#define SP_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_INKSCAPE, InkscapeClass)) -#define SP_IS_INKSCAPE(obj) (dynamic_cast (obj) != NULL) -//#define SP_IS_INKSCAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_INKSCAPE)) - -#include "inkscape.h" - -struct SPColor; -namespace Inkscape { class Selection; } - -//GType inkscape_get_type (void); - -//void inkscape_ref (void); -//void inkscape_unref (void); - -//guint inkscape_mapalt(); -//void inkscape_mapalt(guint); - -//guint inkscape_trackalt(); -//void inkscape_trackalt(guint); - -/* - * These are meant solely for desktop, document etc. implementations - */ - -//void inkscape_selection_modified (Inkscape::Selection *selection, guint flags); -//void inkscape_selection_changed (Inkscape::Selection * selection); -//void inkscape_selection_set (Inkscape::Selection * selection); -//void inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext); -//void inkscape_add_desktop (SPDesktop * desktop); -//void inkscape_remove_desktop (SPDesktop * desktop); -//void inkscape_activate_desktop (SPDesktop * desktop); -//void inkscape_reactivate_desktop (SPDesktop * desktop); - -//void inkscape_set_color (SPColor *color, float opacity); - -#endif // SEEN_INKSCAPE_PRIVATE_H - - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 4e8b06ef4..2181b2814 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -1,12 +1,13 @@ /** * @file - * Legacy interface to main application. + * Interface to main application. */ /* Authors: * Lauris Kaplinski * bulia byak + * Liam P. White * - * Copyright (C) 1999-2005 authors + * Copyright (C) 1999-2014 authors * g++ port Copyright (C) 2003 Nathan Hurst * * Released under GNU GPL, read the file 'COPYING' for more information @@ -50,109 +51,35 @@ #include #include #include + #include "desktop.h" #include "desktop-handles.h" #include "device-manager.h" #include "document.h" -#include "ui/tools/tool-base.h" #include "extension/db.h" #include "extension/init.h" #include "extension/output.h" #include "extension/system.h" -#include "inkscape-private.h" +#include "helper/action-context.h" +#include "helper/sp-marshal.h" +#include "inkscape.h" #include "io/sys.h" #include "layer-model.h" #include "message-stack.h" #include "preferences.h" #include "resource-manager.h" #include "selection.h" +#include "ui/tools/tool-base.h" #include "ui/dialog/debug.h" #include "xml/repr.h" -#include "helper/action-context.h" -#include "helper/sp-marshal.h" static Inkscape::Application *inkscape = NULL; /* Backbones of configuration xml data */ #include "menus-skeleton.h" -#if 0 -enum { - MODIFY_SELECTION, // global: one of selections modified - CHANGE_SELECTION, // global: one of selections changed - CHANGE_SUBSELECTION, // global: one of subselections (text selection, gradient handle, etc) changed - SET_SELECTION, // global: one of selections set - SET_EVENTCONTEXT, // tool switched - ACTIVATE_DESKTOP, // some desktop got focus - DEACTIVATE_DESKTOP, // some desktop lost focus - SHUTDOWN_SIGNAL, // inkscape is quitting - DIALOGS_HIDE, // user pressed F12 - DIALOGS_UNHIDE, // user pressed F12 - EXTERNAL_CHANGE, // a document was changed by some external means (undo or XML editor); this - // may not be reflected by a selection change and thus needs a separate signal - LAST_SIGNAL -}; -#endif - #define DESKTOP_IS_ACTIVE(d) (!inkscape->desktops->empty() && ((d) == inkscape->desktops->front())) - -/*################################ -# FORWARD DECLARATIONS -################################*/ - -//namespace Inkscape { -//struct ApplicationClass; -//} - -//static void inkscape_class_init (Inkscape::ApplicationClass *klass); -//static void inkscape_init (SPObject *object); -//static void inkscape_dispose (GObject *object); - -//static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); -//static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); - -#if 0 -class AppSelectionModel { - Inkscape::LayerModel _layer_model; - Inkscape::Selection *_selection; - -public: - AppSelectionModel(SPDocument *doc) { - _layer_model.setDocument(doc); - // TODO: is this really how we should manage the lifetime of the selection? - // I just copied this from the initialization of the Selection in SPDesktop. - // When and how is it actually released? - _selection = Inkscape::GC::release(new Inkscape::Selection(&_layer_model, NULL)); - } - - Inkscape::Selection *getSelection() const { return _selection; } -}; -#endif - -#if 0 -struct Inkscape::ApplicationClass { - GObjectClass object_class; - - /* Signals */ - void (* change_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection); - void (* change_subselection) (Inkscape::Application * inkscape, SPDesktop *desktop); - void (* modify_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection, guint flags); - void (* set_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection); - void (* set_eventcontext) (Inkscape::Application * inkscape, Inkscape::UI::Tools::ToolBase * eventcontext); - void (* activate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop); - void (* deactivate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop); - void (* destroy_document) (Inkscape::Application *inkscape, SPDocument *doc); - void (* color_set) (Inkscape::Application *inkscape, SPColor *color, double opacity); - void (* shut_down) (Inkscape::Application *inkscape); - void (* dialogs_hide) (Inkscape::Application *inkscape); - void (* dialogs_unhide) (Inkscape::Application *inkscape); - void (* external_change) (Inkscape::Application *inkscape); -}; -#endif - -// static guint inkscape_signals[LAST_SIGNAL] = {0}; - static void (* segv_handler) (int) = SIG_DFL; static void (* abrt_handler) (int) = SIG_DFL; static void (* fpe_handler) (int) = SIG_DFL; @@ -166,123 +93,39 @@ static void (* bus_handler) (int) = SIG_DFL; #define INKSCAPE_LEGACY_PROFILE_DIR ".inkscape" #define MENUS_FILE "menus.xml" - -/** - * Initializes the inkscape class, registering all of its signal handlers - * and virtual functions - */ - -#if 0 -static void -inkscape_class_init (Inkscape::ApplicationClass * klass) -{ - GObjectClass * object_class; - - object_class = (GObjectClass *) klass; - - parent_class = (GObjectClass *)g_type_class_peek_parent (klass); - - inkscape_signals[MODIFY_SELECTION] = g_signal_new ("modify_selection", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, modify_selection), - NULL, NULL, - sp_marshal_VOID__POINTER_UINT, - G_TYPE_NONE, 2, - G_TYPE_POINTER, G_TYPE_UINT); - inkscape_signals[CHANGE_SELECTION] = g_signal_new ("change_selection", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, change_selection), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - inkscape_signals[CHANGE_SUBSELECTION] = g_signal_new ("change_subselection", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, change_subselection), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - inkscape_signals[SET_SELECTION] = g_signal_new ("set_selection", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, set_selection), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - inkscape_signals[SET_EVENTCONTEXT] = g_signal_new ("set_eventcontext", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, set_eventcontext), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - inkscape_signals[ACTIVATE_DESKTOP] = g_signal_new ("activate_desktop", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, activate_desktop), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - inkscape_signals[DEACTIVATE_DESKTOP] = g_signal_new ("deactivate_desktop", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, deactivate_desktop), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - inkscape_signals[SHUTDOWN_SIGNAL] = g_signal_new ("shut_down", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, shut_down), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - inkscape_signals[DIALOGS_HIDE] = g_signal_new ("dialogs_hide", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, dialogs_hide), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - inkscape_signals[DIALOGS_UNHIDE] = g_signal_new ("dialogs_unhide", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, dialogs_unhide), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - inkscape_signals[EXTERNAL_CHANGE] = g_signal_new ("external_change", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (Inkscape::ApplicationClass, external_change), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - object_class->dispose = inkscape_dispose; - - klass->activate_desktop = inkscape_activate_desktop_private; - klass->deactivate_desktop = inkscape_deactivate_desktop_private; -} -#endif +#define SP_INDENT 8 #ifdef WIN32 typedef int uid_t; #define getuid() 0 #endif +class InkErrorHandler : public Inkscape::ErrorReporter { +public: + InkErrorHandler(bool useGui) : Inkscape::ErrorReporter(), + _useGui(useGui) + {} + virtual ~InkErrorHandler() {} + + virtual void handleError( Glib::ustring const& primary, Glib::ustring const& secondary ) const + { + if (_useGui) { + Gtk::MessageDialog err(primary, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); + err.set_secondary_text(secondary); + err.run(); + } else { + g_message("%s", primary.data()); + g_message("%s", secondary.data()); + } + } + +private: + bool _useGui; +}; + Inkscape::Application * inkscape_ref(Inkscape::Application * in) { g_return_val_if_fail(in != NULL, NULL); - g_return_val_if_fail(dynamic_cast(in) != NULL, NULL); in->refCount++; return in; @@ -291,7 +134,6 @@ Inkscape::Application * inkscape_ref(Inkscape::Application * in) Inkscape::Application * inkscape_unref(Inkscape::Application * in) { g_return_val_if_fail(in != NULL, NULL); - g_return_val_if_fail(dynamic_cast(in) != NULL, NULL); in->refCount--; @@ -302,6 +144,40 @@ Inkscape::Application * inkscape_unref(Inkscape::Application * in) return NULL; } +int inkscape_autosave(gpointer) { + g_assert(inkscape != NULL); + return inkscape->autosave(); +} + +/** + * Returns the current Inkscape::Application global object + */ +Inkscape::Application * +inkscape_get_instance() +{ + return inkscape; +} + +/* fixme: This is EVIL, and belongs to main after all */ + +static bool crashIsHappening = false; + +bool inkscapeIsCrashing() +{ + return crashIsHappening; +} + + +void +inkscape_application_init (const gchar *argv0, gboolean use_gui) +{ + if (!inkscape) { + inkscape = new Inkscape::Application(argv0, use_gui); + } else { + g_assert_not_reached(); + } +} + namespace Inkscape { /** @@ -371,7 +247,6 @@ int Application::autosave() ++docnum; Inkscape::XML::Node *repr = doc->getReprRoot(); - // g_debug("Document %d: \"%s\" %s", docnum, doc ? doc->getName() : "(null)", doc ? (doc->isModifiedSinceSave() ? "(dirty)" : "(clean)") : "(null)"); if (doc->isModifiedSinceSave()) { gchar *oldest_autosave = 0; @@ -402,8 +277,6 @@ int Application::autosave() } } - // g_debug("%d previous autosaves exists. Max = %d", count, autosave_max); - // Have we reached the limit for number of autosaves? if ( count >= autosave_max ){ // Remove the oldest file @@ -425,8 +298,6 @@ int Application::autosave() g_free(baseName); baseName = 0; - // g_debug("Filename: %s", full_path); - // Try to save the file FILE *file = Inkscape::IO::fopen_utf8name(full_path, "w"); gchar *errortext = 0; @@ -464,15 +335,6 @@ int Application::autosave() return TRUE; } -} // namespace Inkscape - -int inkscape_autosave(gpointer) { - g_assert(inkscape != NULL); - return inkscape->autosave(); -} - -namespace Inkscape { - void Application::autosave_init() { static guint32 autosave_timeout_id = 0; @@ -484,46 +346,114 @@ void Application::autosave_init() autosave_timeout_id = 0; } - // g_debug("options.autosave.enable = %d", prefs->getBool("/options/autosave/enable", true)); // Is autosave enabled? if (!prefs->getBool("/options/autosave/enable", true)){ autosave_timeout_id = 0; } else { // Turn on autosave guint32 timeout = prefs->getInt("/options/autosave/interval", 10) * 60; - // g_debug("options.autosave.interval = %d", prefs->getInt("/options/autosave/interval", 10)); autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL); } } +void Application::argv0(char const* argv) +{ + _argv0 = g_strdup(argv); +} + -Application::Application() +Application::Application(const char* argv, bool use_gui) : + refCount(1), + _dialogs_toggle(TRUE), + _mapalt(GDK_MOD1_MASK), + _trackalt(FALSE), + _use_gui(use_gui), + menus(NULL), + desktops(NULL) { - if (!inkscape) { - inkscape = this; - } else { - g_assert_not_reached(); + /* fixme: load application defaults */ + + segv_handler = signal (SIGSEGV, Application::crash_handler); + abrt_handler = signal (SIGABRT, Application::crash_handler); + fpe_handler = signal (SIGFPE, Application::crash_handler); + ill_handler = signal (SIGILL, Application::crash_handler); +#ifndef WIN32 + bus_handler = signal (SIGBUS, Application::crash_handler); +#endif + + _argv0 = g_strdup(argv); + + /* Load the preferences and menus */ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + InkErrorHandler* handler = new InkErrorHandler(use_gui); + prefs->setErrorHandler(handler); + { + Glib::ustring msg; + Glib::ustring secondary; + if (prefs->getLastError( msg, secondary )) { + handler->handleError(msg, secondary); + } } - this->menus = NULL; - this->desktops = NULL; - this->_dialogs_toggle = TRUE; - this->_mapalt = GDK_MOD1_MASK; - this->_trackalt = FALSE; + if (use_gui) { + load_menus(); + Inkscape::DeviceManager::getManager().loadConfig(); + } + Inkscape::ResourceManager::getManager(); + + /* set language for user interface according setting in preferences */ + Glib::ustring ui_language = prefs->getString("/ui/language"); + if(!ui_language.empty()) + { + setenv("LANGUAGE", ui_language, 1); + } + + /* DebugDialog redirection. On Linux, default to OFF, on Win32, default to ON. + * Use only if use_gui is enabled + */ +#ifdef WIN32 +#define DEFAULT_LOG_REDIRECT true +#else +#define DEFAULT_LOG_REDIRECT false +#endif + + if (use_gui == TRUE && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT)) + { + Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages(); + } + + /* Check for global remapping of Alt key */ + if (use_gui) + { + mapalt(guint(prefs->getInt("/options/mapalt/value", 0))); + trackalt(guint(prefs->getInt("/options/trackalt/value", 0))); + } + + /* Initialize the extensions */ + Inkscape::Extension::init(); + + autosave_init(); } Application::~Application() { - g_assert (!desktops); + if (desktops) { + g_error("FATAL: desktops still in list on application destruction!"); + } Inkscape::Preferences::unload(); if (menus) { - /* fixme: This is not the best place */ Inkscape::GC::release(menus); menus = NULL; } + if (_argv0) { + g_free(_argv0); + _argv0 = NULL; + } + + refCount = 0; gtk_main_quit (); } @@ -537,36 +467,8 @@ void Application::mapalt(guint maskvalue) } } -} // namespace Inkscape -#if 0 -static void -inkscape_activate_desktop_private (Inkscape::Application *, SPDesktop *desktop) -{ - desktop->set_active (true); -} - - -static void -inkscape_deactivate_desktop_private (Inkscape::Application *, SPDesktop *desktop) -{ - desktop->set_active (false); -} -#endif - -/* fixme: This is EVIL, and belongs to main after all */ - -#define SP_INDENT 8 - - -static bool crashIsHappening = false; - -bool inkscapeIsCrashing() -{ - return crashIsHappening; -} - -static void -inkscape_crash_handler (int /*signum*/) +void +Application::crash_handler (int /*signum*/) { using Inkscape::Debug::SimpleEvent; using Inkscape::Debug::EventTracker; @@ -606,7 +508,7 @@ inkscape_crash_handler (int /*signum*/) gint count = 0; gchar *curdir = g_get_current_dir(); // This one needs to be freed explicitly - gchar *inkscapedir = g_path_get_dirname(INKSCAPE->argv0); // Needs to be freed + gchar *inkscapedir = g_path_get_dirname(INKSCAPE->_argv0); // Needs to be freed GSList *savednames = NULL; GSList *failednames = NULL; for (std::map::iterator iter = inkscape->document_set.begin(); @@ -771,117 +673,6 @@ inkscape_crash_handler (int /*signum*/) /* on exit, allow restored signal handler to take over and crash us */ } - -class InkErrorHandler : public Inkscape::ErrorReporter { -public: - InkErrorHandler(bool useGui) : Inkscape::ErrorReporter(), - _useGui(useGui) - {} - virtual ~InkErrorHandler() {} - - virtual void handleError( Glib::ustring const& primary, Glib::ustring const& secondary ) const - { - if (_useGui) { - Gtk::MessageDialog err(primary, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); - err.set_secondary_text(secondary); - err.run(); - } else { - g_message("%s", primary.data()); - g_message("%s", secondary.data()); - } - } - -private: - bool _useGui; -}; - -void -inkscape_application_init (const gchar *argv0, gboolean use_gui) -{ - inkscape = new Inkscape::Application(); - /* fixme: load application defaults */ - - segv_handler = signal (SIGSEGV, inkscape_crash_handler); - abrt_handler = signal (SIGABRT, inkscape_crash_handler); - fpe_handler = signal (SIGFPE, inkscape_crash_handler); - ill_handler = signal (SIGILL, inkscape_crash_handler); -#ifndef WIN32 - bus_handler = signal (SIGBUS, inkscape_crash_handler); -#endif - - inkscape->use_gui(use_gui); - inkscape->argv0 = g_strdup(argv0); - - /* Load the preferences and menus */ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - InkErrorHandler* handler = new InkErrorHandler(use_gui); - prefs->setErrorHandler(handler); - { - Glib::ustring msg; - Glib::ustring secondary; - if (prefs->getLastError( msg, secondary )) { - handler->handleError(msg, secondary); - } - } - - if (use_gui) { - inkscape->load_menus(); - Inkscape::DeviceManager::getManager().loadConfig(); - } - Inkscape::ResourceManager::getManager(); - - /* set language for user interface according setting in preferences */ - Glib::ustring ui_language = prefs->getString("/ui/language"); - if(!ui_language.empty()) - { - setenv("LANGUAGE", ui_language, 1); - } - - /* DebugDialog redirection. On Linux, default to OFF, on Win32, default to ON. - * Use only if use_gui is enabled - */ -#ifdef WIN32 -#define DEFAULT_LOG_REDIRECT true -#else -#define DEFAULT_LOG_REDIRECT false -#endif - - if (use_gui == TRUE && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT)) - { - Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages(); - } - - /* Check for global remapping of Alt key */ - if (use_gui) - { - inkscape->mapalt(guint(prefs->getInt("/options/mapalt/value", 0))); - inkscape->trackalt(guint(prefs->getInt("/options/trackalt/value", 0))); - } - - /* Initialize the extensions */ - Inkscape::Extension::init(); - - inkscape->autosave_init(); - - //return; -} - -/** - * Returns the current Inkscape::Application global object - */ -Inkscape::Application * -inkscape_get_instance() -{ - return inkscape; -} - -namespace Inkscape { - -//gboolean inkscape_use_gui() -//{ -// return inkscape_get_instance()->use_gui; -//} - /** * Menus management * @@ -894,7 +685,7 @@ bool Application::load_menus() if ( g_file_get_contents(fn, &menus_xml, &len, NULL) ) { // load the menus_xml file - inkscape->menus = sp_repr_read_mem(menus_xml, len, NULL); + menus = sp_repr_read_mem(menus_xml, len, NULL); g_free(menus_xml); menus_xml = 0; @@ -906,7 +697,7 @@ bool Application::load_menus() menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); } - return (inkscape->menus != 0); + return (menus != 0); } @@ -917,7 +708,6 @@ Application::selection_modified (Inkscape::Selection *selection, guint flags) if (DESKTOP_IS_ACTIVE (selection->desktop())) { signal_selection_modified.emit(this, selection, flags); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[MODIFY_SELECTION], 0, selection, flags); } } @@ -929,7 +719,6 @@ Application::selection_changed (Inkscape::Selection * selection) if (DESKTOP_IS_ACTIVE (selection->desktop())) { signal_selection_changed.emit(this, selection); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); } } @@ -940,7 +729,6 @@ Application::subselection_changed (SPDesktop *desktop) if (DESKTOP_IS_ACTIVE (desktop)) { signal_subselection_changed.emit(this, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SUBSELECTION], 0, desktop); } } @@ -953,8 +741,6 @@ Application::selection_set (Inkscape::Selection * selection) if (DESKTOP_IS_ACTIVE (selection->desktop())) { signal_selection_set.emit(this, selection); signal_selection_changed.emit(this, selection); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, selection); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, selection); } } @@ -967,7 +753,6 @@ Application::eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext) if (DESKTOP_IS_ACTIVE (eventcontext->desktop)) { signal_eventcontext_set.emit(this, eventcontext); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, eventcontext); } } @@ -977,23 +762,20 @@ Application::add_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); if (desktops == NULL) { - desktops = new std::list; + desktops = new std::vector; g_message("Creating new desktop list."); } - //g_return_if_fail (inkscape != NULL); - g_assert (std::find(desktops->begin(), desktops->end(), desktop) == desktops->end()); + if (std::find(desktops->begin(), desktops->end(), desktop) != desktops->end()) { + g_error("Attempted to add desktop already in list."); + } - desktops->push_front(desktop); + desktops->insert(desktops->begin(), desktop); signal_activate_desktop.emit(this, desktop); signal_eventcontext_set.emit(this, desktop->getEventContext()); signal_selection_set.emit(this, sp_desktop_selection(desktop)); signal_selection_changed.emit(this, sp_desktop_selection(desktop)); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext()); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop)); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop)); } @@ -1004,39 +786,36 @@ Application::remove_desktop (SPDesktop * desktop) g_return_if_fail (desktop != NULL); g_return_if_fail (inkscape != NULL); - g_assert (std::find (desktops->begin(), desktops->end(), desktop) != desktops->end() ); + if (std::find (desktops->begin(), desktops->end(), desktop) == desktops->end() ) { + g_error("Attempted to remove desktop not in list."); + } if (DESKTOP_IS_ACTIVE (desktop)) { signal_deactivate_desktop.emit(this, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, desktop); if (desktops->size() > 1) { SPDesktop * new_desktop = *(++desktops->begin()); - desktops->remove(new_desktop); - desktops->push_front(new_desktop); + desktops->erase(std::find(desktops->begin(), desktops->end(), new_desktop)); + desktops->insert(desktops->begin(), new_desktop); signal_activate_desktop.emit(this, new_desktop); signal_eventcontext_set.emit(this, new_desktop->getEventContext()); signal_selection_set.emit(this, sp_desktop_selection(new_desktop)); signal_selection_changed.emit(this, sp_desktop_selection(new_desktop)); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, new_desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, new_desktop->getEventContext()); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (new_desktop)); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (new_desktop)); } else { signal_eventcontext_set.emit(this, NULL); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, NULL); if (sp_desktop_selection(desktop)) sp_desktop_selection(desktop)->clear(); } } - desktops->remove(desktop); + desktops->erase(std::find(desktops->begin(), desktops->end(), desktop)); // if this was the last desktop, shut down the program if (desktops->empty()) { g_message("Shutting down."); this->exit(); delete desktops; + desktops = NULL; } } @@ -1051,28 +830,23 @@ Application::activate_desktop (SPDesktop * desktop) return; } - SPDesktop* oldDesktop = 0; - std::list::iterator i; + std::vector::iterator i; - g_assert ((i = std::find (desktops->begin(), desktops->end(), desktop)) != desktops->end()); + if ((i = std::find (desktops->begin(), desktops->end(), desktop)) == desktops->end()) { + g_error("Tried to activate desktop not added to list."); + } - oldDesktop = *i; SPDesktop *current = desktops->front(); signal_deactivate_desktop.emit(this, current); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DEACTIVATE_DESKTOP], 0, current); - desktops->remove (desktop); - desktops->push_front (desktop); + desktops->erase (i); + desktops->insert (desktops->begin(), desktop); signal_activate_desktop.emit(this, desktop); signal_eventcontext_set.emit(this, desktop->getEventContext()); signal_selection_set(this, sp_desktop_selection(desktop)); signal_selection_changed(this, sp_desktop_selection(desktop)); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext()); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop)); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop)); } @@ -1086,7 +860,6 @@ Application::reactivate_desktop (SPDesktop * desktop) if (DESKTOP_IS_ACTIVE (desktop)) { signal_activate_desktop.emit(this, desktop); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop); } } @@ -1095,7 +868,7 @@ Application::reactivate_desktop (SPDesktop * desktop) SPDesktop * Application::find_desktop_by_dkey (unsigned int dkey) { - for (std::list::iterator r = desktops->begin(); r != desktops->end(); r++) { + for (std::vector::iterator r = desktops->begin(), e = desktops->end(); r != e; ++r) { if ((*r)->dkey == dkey){ return *r; } @@ -1109,7 +882,7 @@ Application::maximum_dkey() { unsigned int dkey = 0; - for (std::list::iterator r = desktops->begin(); r != desktops->end(); r++) { + for (std::vector::iterator r = desktops->begin(), e = desktops->end(); r != e; ++r) { if ((*r)->dkey > dkey){ dkey = (*r)->dkey; } @@ -1127,7 +900,7 @@ Application::next_desktop () if (dkey_current < maximum_dkey()) { // find next existing - for (unsigned int i = dkey_current + 1; i <= maximum_dkey(); i++) { + for (unsigned int i = dkey_current + 1; i <= maximum_dkey(); ++i) { d = find_desktop_by_dkey (i); if (d) { break; @@ -1135,7 +908,7 @@ Application::next_desktop () } } else { // find first existing - for (unsigned int i = 0; i <= maximum_dkey(); i++) { + for (unsigned int i = 0; i <= maximum_dkey(); ++i) { d = find_desktop_by_dkey (i); if (d) { break; @@ -1157,7 +930,7 @@ Application::prev_desktop () if (dkey_current > 0) { // find prev existing - for (signed int i = dkey_current - 1; i >= 0; i--) { + for (signed int i = dkey_current - 1; i >= 0; --i) { d = find_desktop_by_dkey (i); if (d) { break; @@ -1191,7 +964,6 @@ void Application::dialogs_hide() { signal_dialogs_hide.emit(this); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0); _dialogs_toggle = FALSE; } @@ -1201,7 +973,6 @@ void Application::dialogs_unhide() { signal_dialogs_unhide.emit(this); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0); _dialogs_toggle = TRUE; } @@ -1220,9 +991,7 @@ Application::dialogs_toggle() void Application::external_change() { - //g_return_if_fail (inkscape != NULL); signal_external_change.emit(this); - //g_signal_emit (G_OBJECT (inkscape), inkscape_signals[EXTERNAL_CHANGE], 0); } /** @@ -1318,7 +1087,7 @@ Application::sole_desktop_for_document(SPDesktop const &desktop) { if (!document) { return false; } - for ( std::list::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++ ) { + for ( std::vector::iterator iter = desktops->begin(), e = desktops->end() ; iter != e; ++iter ) { SPDesktop *other_desktop = *iter; SPDocument *other_document = other_desktop->doc(); if ( other_document == document && other_desktop != &desktop ) { @@ -1357,7 +1126,7 @@ Inkscape::ActionContext Application::action_context_for_document(SPDocument *doc) { // If there are desktops, check them first to see if the document is bound to one of them - for (std::list::iterator iter = desktops->begin() ; iter != desktops->end() ; iter++) { + for (std::vector::iterator iter = desktops->begin(), e = desktops->end() ; iter != e ; ++iter) { SPDesktop *desktop = *iter; if (desktop->doc() == doc) { return Inkscape::ActionContext(desktop); @@ -1365,8 +1134,8 @@ Application::action_context_for_document(SPDocument *doc) } // Document is not associated with any desktops - maybe we're in command-line mode - std::map::iterator sel_iter = inkscape->selection_models.find(doc); - if (sel_iter == inkscape->selection_models.end()) { + std::map::iterator sel_iter = selection_models.find(doc); + if (sel_iter == selection_models.end()) { return Inkscape::ActionContext(); } return Inkscape::ActionContext(sel_iter->second->getSelection()); @@ -1380,7 +1149,7 @@ Application::action_context_for_document(SPDocument *doc) void Application::refresh_display () { - for (std::list::iterator l = desktops->begin(); l != desktops->end(); l++) { + for (std::vector::iterator l = desktops->begin(), e = desktops->end(); l != e; ++l) { (*l)->requestRedraw(); } } @@ -1393,11 +1162,8 @@ Application::refresh_display () void Application::exit () { - g_assert (INKSCAPE); - //emit shutdown signal so that dialogs could remember layout signal_shut_down.emit(this); - //g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0); Inkscape::Preferences::unload(); gtk_main_quit (); @@ -1411,7 +1177,9 @@ Application::homedir_path(const char *filename) homedir = g_get_home_dir(); } if (!homedir) { - homedir = g_path_get_dirname(INKSCAPE->argv0); + if (inkscape) { + homedir = g_path_get_dirname(inkscape->_argv0); + } } return g_build_filename(homedir, filename, NULL); } @@ -1544,9 +1312,7 @@ Application::get_menus() void Application::get_all_desktops(std::list< SPDesktop* >& listbuf) { - for (std::list::iterator it = desktops->begin(); it != desktops->end(); it++) { - listbuf.push_back(*it); - } + listbuf.insert(listbuf.end(), desktops->begin(), desktops->end()); } } // namespace Inkscape diff --git a/src/inkscape.h b/src/inkscape.h index f37da7472..4b969bddb 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -14,19 +14,20 @@ */ #include -#include -#include "selection.h" -#include "color.h" -#include "layer-model.h" +#include #include +#include #include +#include "layer-model.h" +#include "selection.h" class SPDesktop; class SPDocument; +struct SPColor; namespace Inkscape { -struct Application; +class Application; namespace UI { namespace Tools { @@ -48,6 +49,8 @@ Inkscape::Application * inkscape_ref (Inkscape::Application * in); Inkscape::Application * inkscape_unref(Inkscape::Application * in); #define INKSCAPE inkscape_get_instance() +#define SP_INKSCAPE(obj) (dynamic_cast(obj)) +#define SP_IS_INKSCAPE(obj) (dynamic_cast (obj) != NULL) #define SP_ACTIVE_EVENTCONTEXT (INKSCAPE->active_event_context()) #define SP_ACTIVE_DOCUMENT (INKSCAPE->active_document()) #define SP_ACTIVE_DESKTOP (INKSCAPE->active_desktop()) @@ -72,24 +75,24 @@ public: namespace Inkscape { -struct Application { +class Application { private: unsigned refCount; gboolean _dialogs_toggle; guint _mapalt; guint _trackalt; - gboolean _use_gui; // may want to consider a virtual function - // for overriding things like the warning dlg's + char * _argv0; + bool _use_gui; // may want to consider a virtual function + // for overriding things like the warning dlg's public: - Application(); + Application(const char* argv0, bool use_gui); ~Application(); Inkscape::XML::Document *menus; std::map document_set; std::map selection_models; - std::list * desktops; - gchar *argv0; + std::vector * desktops; // returns the mask of the keyboard modifier to map to Alt, zero if no mapping // Needs to be a guint because gdktypes.h does not define a 'no-modifier' value @@ -101,9 +104,12 @@ public: guint trackalt() const { return _trackalt; } void trackalt(guint trackvalue) { _trackalt = trackvalue; } - gboolean use_gui() const { return _use_gui; } + bool use_gui() const { return _use_gui; } void use_gui(gboolean guival) { _use_gui = guival; } + char const* argv0() const { return _argv0; } + void argv0(char const *); + // signals // one of selections changed @@ -188,8 +194,8 @@ public: void add_document (SPDocument *document); bool remove_document (SPDocument *document); - gchar *homedir_path(const char *filename); - gchar *profile_path(const char *filename); + static char *homedir_path(const char *filename); + static char *profile_path(const char *filename); // fixme: This has to be rethought void refresh_display (); @@ -197,6 +203,8 @@ public: // fixme: This also void exit (); + static void crash_handler(int signum); + int autosave(); friend Application * ::inkscape_ref (Application * in); diff --git a/src/inkview.cpp b/src/inkview.cpp index df2661968..f1be398f7 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -232,7 +232,7 @@ main (int argc, const char **argv) ss.view = NULL; ss.fullscreen = false; - inkscape = new Inkscape::Application;//(Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL); + inkscape = new Inkscape::Application(argv[0], true); // starting at where the commandline options stopped parsing because // we want all the files to be in the list diff --git a/src/interface.cpp b/src/interface.cpp index 987c4987e..7fd2b6275 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -29,7 +29,7 @@ #include #include -#include "inkscape-private.h" +#include "inkscape.h" #include "extension/db.h" #include "extension/effect.h" #include "extension/input.h" diff --git a/src/main.cpp b/src/main.cpp index 597cda27d..77be9a275 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,7 +74,7 @@ #include "svg/svg-color.h" #include "svg/stringstream.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "inkscape-version.h" #include "sp-namedview.h" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index ebd5f4510..ec5bc659c 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -99,7 +99,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "display/curve.h" #include "display/canvas-bpath.h" #include "display/cairo-utils.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "path-chemistry.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/multi-path-manipulator.h" diff --git a/src/selection.cpp b/src/selection.cpp index b1fa4b32d..48f6e2414 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -20,7 +20,7 @@ # include #endif #include "macros.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "document.h" #include "layer-model.h" #include "selection.h" diff --git a/src/test-helpers.h b/src/test-helpers.h index 001356e65..d2507128c 100644 --- a/src/test-helpers.h +++ b/src/test-helpers.h @@ -5,7 +5,7 @@ #include #include "document.h" -#include "inkscape-private.h" +#include "inkscape.h" // Dummy functions to keep linker happy diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index 8d9baff48..357fe440c 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -18,7 +18,7 @@ #include #include -#include "inkscape-private.h" +#include "inkscape.h" #include "desktop.h" #include "desktop-handles.h" #include diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 527f4d59c..35a9a8376 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1044,12 +1044,10 @@ AlignAndDistribute::AlignAndDistribute() contents->pack_start(_nodesFrame, true, true); //Connect to the global tool change signal - INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)))); - //g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this); + _toolChangeConn = INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)))); // Connect to the global selection change, to invalidate cached randomize_bbox - INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)))); - //g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); + _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)))); randomize_bbox = Geom::OptRect(); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &AlignAndDistribute::setDesktop) ); @@ -1062,13 +1060,13 @@ AlignAndDistribute::AlignAndDistribute() AlignAndDistribute::~AlignAndDistribute() { - sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this); - for (std::list::iterator it = _actionList.begin(); it != _actionList.end(); ++it) { delete *it; } + _toolChangeConn.disconnect(); + _selChangeConn.disconnect(); _desktopChangeConn.disconnect(); _deskTrack.disconnect(); } diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index dfd84535b..eecc30ff8 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -127,7 +127,8 @@ protected: SPDesktop *_desktop; DesktopTracker _deskTrack; sigc::connection _desktopChangeConn; - + sigc::connection _toolChangeConn; + sigc::connection _selChangeConn; private: AlignAndDistribute(AlignAndDistribute const &d); AlignAndDistribute& operator=(AlignAndDistribute const &d); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b0298afa6..4d5d50de0 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1271,8 +1271,7 @@ CloneTiler::CloneTiler () : // external_change (so we're not fooled by undo) selectChangedConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg))); externChangedConn = INKSCAPE->signal_external_change.connect (sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg))); - //g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg); - //g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg); + g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this); // update now @@ -1384,9 +1383,6 @@ void CloneTiler::clonetiler_external_change(GtkWidget *dlg) void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source) { - //if (source && G_IS_OBJECT(source)) { - //sp_signal_disconnect_by_data (source, widget); - //} g_return_if_fail(source != NULL); CloneTiler* dlg = reinterpret_cast(source); diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 3a8f5176e..06f0216a7 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -45,7 +45,6 @@ void DesktopTracker::connect(GtkWidget *widget) sigc::bind( sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this) )); - //inkID = g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(activateDesktopCB), this ); GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET); if (wdgt && !base) { @@ -66,8 +65,6 @@ void DesktopTracker::disconnect() } if (inkID.connected()) { inkID.disconnect(); - //g_signal_handler_disconnect(G_OBJECT(INKSCAPE), inkID); - //inkID = 0; } } diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index e98befc89..d0da70a60 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -48,37 +48,6 @@ gboolean sp_retransientize_again(gpointer dlgPtr) return FALSE; // so that it is only called once } -#if 0 -void sp_retransientize(SPDesktop *desktop, Dialog * dlgPtr) -{ - Dialog *dlg = static_cast(dlgPtr); - dlg->onDesktopActivated (desktop); -} - -void sp_dialog_shutdown(GObject * /*object*/, Dialog * dlgPtr) -{ - Dialog *dlg = static_cast(dlgPtr); - dlg->onShutdown(); -} - - -static void hideCallback(GObject * /*object*/, Dialog * dlgPtr) -{ - g_return_if_fail( dlgPtr != NULL ); - - Dialog *dlg = static_cast(dlgPtr); - dlg->onHideF12(); -} - -static void unhideCallback(GObject * /*object*/, Dialog* dlgPtr) -{ - g_return_if_fail( dlgPtr != NULL ); - - Dialog *dlg = static_cast(dlgPtr); - dlg->onShowF12(); -} -#endif - //===================================================================== Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path, int verb_num, @@ -108,10 +77,6 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat INKSCAPE->signal_dialogs_hide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onHideF12))); INKSCAPE->signal_dialogs_unhide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShowF12))); INKSCAPE->signal_shut_down.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShutdown))); - //g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this); - //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this); - //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this); - //g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_dialog_shutdown), (void *)this); Glib::wrap(gobj())->signal_event().connect(sigc::mem_fun(*this, &Dialog::_onEvent)); Glib::wrap(gobj())->signal_key_press_event().connect(sigc::mem_fun(*this, &Dialog::_onKeyPress)); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 3aad1a8a8..579b6aec7 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -51,7 +51,7 @@ #include "ui/widget/unit-menu.h" #include "util/units.h" #include "helper/window.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "document.h" #include "document-undo.h" #include "desktop-handles.h" diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 117420b47..028c94ec1 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -567,17 +567,6 @@ void GridArrangeTab::updateSelection() } - -/*########################## -## Experimental -##########################*/ - -static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg) -{ - dlg->updateSelection(); -} - - //######################################################################### //## C O N S T R U C T O R / D E S T R U C T O R //######################################################################### @@ -606,7 +595,6 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) { // Selection Change signal INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection)))); - //g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); } Gtk::Box *contents = this; diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index 1589c7058..470d0d1b3 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -49,7 +49,7 @@ public: virtual UI::Widget::Panel &getPanel() { return _panel; } protected: - static void handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { + /*static void handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { g_return_if_fail(data != NULL); static_cast(data)->_propagateDesktopDeactivated(application, desktop); } @@ -57,7 +57,7 @@ protected: static void _handle_activate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { g_return_if_fail(data != NULL); static_cast(data)->_propagateDesktopActivated(application, desktop); - } + }*/ inline virtual void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document); inline virtual void _propagateDesktopActivated(Inkscape::Application *, SPDesktop *); @@ -249,8 +249,6 @@ PanelDialog *PanelDialog INKSCAPE->signal_activate_desktop.connect (sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopActivated)); INKSCAPE->signal_deactivate_desktop.connect(sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopDeactivated)); - //g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(_handle_activate_desktop), instance); - //g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(handle_deactivate_desktop), instance); return instance; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 9df328566..8bc9ad275 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -156,10 +156,8 @@ Transformation::Transformation() } // Connect to the global selection changed & modified signals - INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); - INKSCAPE->signal_selection_modified.connect(sigc::hide<0>(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this)))); - //g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); - //g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this); + _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); + _selModifyConn = INKSCAPE->signal_selection_modified.connect(sigc::hide<0>(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this)))); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) ); _deskTrack.connect(GTK_WIDGET(gobj())); @@ -169,7 +167,8 @@ Transformation::Transformation() Transformation::~Transformation() { - sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this); + _selModifyConn.disconnect(); + _selChangeConn.disconnect(); _desktopChangeConn.disconnect(); _deskTrack.disconnect(); } diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h index 1d24a0c94..89aa95d90 100644 --- a/src/ui/dialog/transformation.h +++ b/src/ui/dialog/transformation.h @@ -232,6 +232,9 @@ private: Gtk::Button *applyButton; Gtk::Button *resetButton; Gtk::Button *cancelButton; + + sigc::connection _selChangeConn; + sigc::connection _selModifyConn; }; diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index cfedb6921..2b5ff169d 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -20,7 +20,7 @@ #include "message-stack.h" #include "message-context.h" #include "verbs.h" -#include "inkscape-private.h" +#include "inkscape.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 4b22bba67..3448283b9 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -119,9 +119,7 @@ Dock::Dock(Gtk::Orientation orientation) gdl_dock_bar_set_style(_gdl_dock_bar, gdl_dock_bar_style); - - //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this); - //g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this); + INKSCAPE->signal_dialogs_hide.connect(sigc::hide(sigc::mem_fun(*this, &Dock::hide))); INKSCAPE->signal_dialogs_unhide.connect(sigc::hide(sigc::mem_fun(*this, &Dock::show))); diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 537db0fdd..a377bf118 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -39,26 +39,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/*void ObjectCompositeSettings::_on_desktop_activate( - Inkscape::Application *application, - SPDesktop *desktop, - ObjectCompositeSettings *w -) { - if (w->_subject) { - w->_subject->setDesktop(desktop); - } -} - -void ObjectCompositeSettings::_on_desktop_deactivate( - Inkscape::Application *application, - SPDesktop *desktop, - ObjectCompositeSettings *w -) { - if (w->_subject) { - w->_subject->setDesktop(NULL); - } -}*/ - ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char const *history_prefix, int flags) : _verb_code(verb_code), _blur_tag(Glib::ustring(history_prefix) + ":blur"), @@ -102,7 +82,6 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co ObjectCompositeSettings::~ObjectCompositeSettings() { setSubject(NULL); - g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _desktop_activated); } void ObjectCompositeSettings::setSubject(StyleSubject *subject) { diff --git a/src/verbs.cpp b/src/verbs.cpp index 420b243d0..4626621a9 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -52,7 +52,7 @@ #include "helper/action.h" #include "helper/action-context.h" #include "help.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "interface.h" #include "layer-fns.h" #include "layer-manager.h" diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index de5db279f..8822416a7 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -45,7 +45,7 @@ #include "helper/action-context.h" #include "util/units.h" #include "ui/widget/unit-tracker.h" -#include "inkscape-private.h" +#include "inkscape.h" #include "interface.h" #include "macros.h" #include "preferences.h" diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 17ac887c4..9fb439a28 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1032,13 +1032,20 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) sp_transientize(dlg); wd.win = dlg; wd.stop = 0; - g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_transientize_callback), &wd); + + INKSCAPE->signal_activate_desktop.connect(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd)); + g_signal_connect(G_OBJECT(dlg), "event", G_CALLBACK(sp_dialog_event_handler), dlg); g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg); g_signal_connect(G_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); - g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); - g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(sp_dialog_hide), dlg ); - g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(sp_dialog_unhide), dlg ); + + INKSCAPE->signal_shut_down.connect( + sigc::hide<0>( + sigc::hide_return( + sigc::bind(sigc::ptr_fun(&sp_gradient_vector_dialog_delete), (GtkWidget *) NULL, (GdkEvent *) NULL, (GtkWidget *) NULL) + ))); + INKSCAPE->signal_dialogs_hide.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(>k_widget_hide), dlg))); + INKSCAPE->signal_dialogs_unhide.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(>k_widget_show), dlg))); gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 98d528d4a..322b444b9 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -314,9 +314,6 @@ GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, Inkscape::Application *i spw->selModified = spw->inkscape->signal_selection_modified.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)); spw->selChanged = spw->inkscape->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)); spw->selSet = spw->inkscape->signal_selection_set.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw)); - //g_signal_connect(inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw); - //g_signal_connect(inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw); - //g_signal_connect(inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw); } g_signal_emit(spw, signals[CONSTRUCT], 0); -- cgit v1.2.3 From 6d9d6664fc97fd26a4f5818ba8514d9aece0f854 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Wed, 25 Jun 2014 22:42:29 -0400 Subject: Fix filters/extensions menus not populating (bzr r13341.5.4) --- src/inkscape.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 2181b2814..f9a314f7e 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -172,7 +172,7 @@ void inkscape_application_init (const gchar *argv0, gboolean use_gui) { if (!inkscape) { - inkscape = new Inkscape::Application(argv0, use_gui); + new Inkscape::Application(argv0, use_gui); } else { g_assert_not_reached(); } @@ -361,6 +361,11 @@ void Application::argv0(char const* argv) _argv0 = g_strdup(argv); } +/* \brief Constructor for the application. + * Creates a new Inkscape::Application. + * + * \pre inkscape == NULL + */ Application::Application(const char* argv, bool use_gui) : refCount(1), @@ -383,6 +388,10 @@ Application::Application(const char* argv, bool use_gui) : _argv0 = g_strdup(argv); + // \TODO: this belongs to inkscape_application_init but if it isn't here + // then the Filters and Extensions menus don't work. + inkscape = this; + /* Load the preferences and menus */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); InkErrorHandler* handler = new InkErrorHandler(use_gui); -- cgit v1.2.3 From 6dfb9b4eade77ac55d11f05669c2192352b9b8fa Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 26 Jun 2014 13:49:17 -0400 Subject: 4. further refactor Application class; create proper singleton, encapsulate members, simplify signals (bzr r13341.5.6) --- src/document.cpp | 6 +- src/inkscape.cpp | 255 ++++++++++++++++----------------- src/inkscape.h | 107 +++++++------- src/inkview.cpp | 3 +- src/main.cpp | 4 +- src/ui/dialog/align-and-distribute.cpp | 4 +- src/ui/dialog/clonetiler.cpp | 4 +- src/ui/dialog/desktop-tracker.cpp | 5 +- src/ui/dialog/dialog.cpp | 8 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 2 +- src/ui/dialog/grid-arrange-tab.cpp | 2 +- src/ui/dialog/panel-dialog.h | 19 ++- src/ui/dialog/transformation.cpp | 4 +- src/ui/widget/dock.cpp | 4 +- src/ui/widget/imageicon.cpp | 3 +- src/widgets/gradient-vector.cpp | 9 +- src/widgets/icon.cpp | 4 +- src/widgets/sp-widget.cpp | 40 ++++-- 18 files changed, 244 insertions(+), 239 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 26e59e610..000888772 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -463,15 +463,13 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, // reset undo key when selection changes, so that same-key actions on different objects are not coalesced document->priv->selChangeConnection = INKSCAPE->signal_selection_changed.connect( - sigc::hide( // hide unused first and second args sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) - ))); + )); document->priv->desktopActivatedConnection = INKSCAPE->signal_activate_desktop.connect( - sigc::hide( // hide unused first and second args sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) - ))); + )); document->oldSignalsConnected = true; return document; diff --git a/src/inkscape.cpp b/src/inkscape.cpp index f9a314f7e..60f950636 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -8,7 +8,8 @@ * Liam P. White * * Copyright (C) 1999-2014 authors - * g++ port Copyright (C) 2003 Nathan Hurst + * c++ port Copyright (C) 2003 Nathan Hurst + * c++ification copyright (C) 2014 Liam P. White * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -73,12 +74,14 @@ #include "ui/dialog/debug.h" #include "xml/repr.h" -static Inkscape::Application *inkscape = NULL; - /* Backbones of configuration xml data */ #include "menus-skeleton.h" -#define DESKTOP_IS_ACTIVE(d) (!inkscape->desktops->empty() && ((d) == inkscape->desktops->front())) +// Inkscape::Application static members +Inkscape::Application * Inkscape::Application::_S_inst = NULL; +bool Inkscape::Application::_crashIsHappening = false; + +#define DESKTOP_IS_ACTIVE(d) (!INKSCAPE->_desktops->empty() && ((d) == INKSCAPE->_desktops->front())) static void (* segv_handler) (int) = SIG_DFL; static void (* abrt_handler) (int) = SIG_DFL; @@ -144,51 +147,42 @@ Inkscape::Application * inkscape_unref(Inkscape::Application * in) return NULL; } +// Callback passed to g_timeout_add_seconds() +// gets the current instance and calls autosave() int inkscape_autosave(gpointer) { - g_assert(inkscape != NULL); - return inkscape->autosave(); -} - -/** - * Returns the current Inkscape::Application global object - */ -Inkscape::Application * -inkscape_get_instance() -{ - return inkscape; -} - -/* fixme: This is EVIL, and belongs to main after all */ - -static bool crashIsHappening = false; - -bool inkscapeIsCrashing() -{ - return crashIsHappening; + g_assert(INKSCAPE != NULL); + return INKSCAPE->autosave(); } +namespace Inkscape { void -inkscape_application_init (const gchar *argv0, gboolean use_gui) +Application::init (const char *argv0, bool use_gui) { - if (!inkscape) { - new Inkscape::Application(argv0, use_gui); + if (!Application::instance()) { + new Application(argv0, use_gui); } else { g_assert_not_reached(); } } -namespace Inkscape { +/** + * Returns the current Inkscape::Application global object + */ +Application * +Application::instance() +{ + return Application::_S_inst; +} /** * static gint inkscape_autosave(gpointer); * - * Callback passed to g_timeout_add_seconds() * Responsible for autosaving all open documents */ int Application::autosave() { - if (document_set.empty()) { // nothing to autosave + if (_document_set.empty()) { // nothing to autosave return TRUE; } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -238,8 +232,8 @@ int Application::autosave() gint docnum = 0; SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Autosaving documents...")); - for (std::map::iterator iter = document_set.begin(); - iter != document_set.end(); + for (std::map::iterator iter = _document_set.begin(); + iter != _document_set.end(); ++iter) { SPDocument *doc = iter->first; @@ -364,17 +358,17 @@ void Application::argv0(char const* argv) /* \brief Constructor for the application. * Creates a new Inkscape::Application. * - * \pre inkscape == NULL + * \pre Application::_S_inst == NULL */ Application::Application(const char* argv, bool use_gui) : + _menus(NULL), + _desktops(NULL), refCount(1), _dialogs_toggle(TRUE), _mapalt(GDK_MOD1_MASK), _trackalt(FALSE), - _use_gui(use_gui), - menus(NULL), - desktops(NULL) + _use_gui(use_gui) { /* fixme: load application defaults */ @@ -388,9 +382,9 @@ Application::Application(const char* argv, bool use_gui) : _argv0 = g_strdup(argv); - // \TODO: this belongs to inkscape_application_init but if it isn't here + // \TODO: this belongs to Application::init but if it isn't here // then the Filters and Extensions menus don't work. - inkscape = this; + _S_inst = this; /* Load the preferences and menus */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -446,15 +440,15 @@ Application::Application(const char* argv, bool use_gui) : Application::~Application() { - if (desktops) { + if (_desktops) { g_error("FATAL: desktops still in list on application destruction!"); } Inkscape::Preferences::unload(); - if (menus) { - Inkscape::GC::release(menus); - menus = NULL; + if (_menus) { + Inkscape::GC::release(_menus); + _menus = NULL; } if (_argv0) { @@ -466,7 +460,10 @@ Application::~Application() gtk_main_quit (); } -/* Sets the keyboard modifer to map to Alt. Zero switches off mapping, as does '1', which is the default */ +/** Sets the keyboard modifer to map to Alt. + * + * Zero switches off mapping, as does '1', which is the default. + */ void Application::mapalt(guint maskvalue) { if ( maskvalue < 2 || maskvalue > 5 ) { // MOD5 is the highest defined in gdktypes.h @@ -483,7 +480,7 @@ Application::crash_handler (int /*signum*/) using Inkscape::Debug::EventTracker; using Inkscape::Debug::Logger; - static gint recursion = FALSE; + static bool recursion = false; /* * reset all signal handlers: any further crashes should just be allowed @@ -501,9 +498,9 @@ Application::crash_handler (int /*signum*/) if (recursion) { abort (); } - recursion = TRUE; + recursion = true; - crashIsHappening = true; + _crashIsHappening = true; EventTracker > tracker("crash"); tracker.set >("emergency-save"); @@ -520,8 +517,8 @@ Application::crash_handler (int /*signum*/) gchar *inkscapedir = g_path_get_dirname(INKSCAPE->_argv0); // Needs to be freed GSList *savednames = NULL; GSList *failednames = NULL; - for (std::map::iterator iter = inkscape->document_set.begin(); - iter != inkscape->document_set.end(); + for (std::map::iterator iter = INKSCAPE->_document_set.begin(), e = INKSCAPE->_document_set.end(); + iter != e; ++iter) { SPDocument *doc = iter->first; Inkscape::XML::Node *repr; @@ -662,10 +659,7 @@ Application::crash_handler (int /*signum*/) } *(b + pos) = '\0'; - // checking whether we have an Inkscape instance after that instance caused an exception is like - // checking if your mother existed after sitting on you and nearly hospitalizing you - - if ( inkscape_get_instance() && inkscape->use_gui() ) { + if ( instance() && instance()->use_gui() ) { GtkWidget *msgbox = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", b); gtk_dialog_run (GTK_DIALOG (msgbox)); gtk_widget_destroy (msgbox); @@ -694,7 +688,7 @@ bool Application::load_menus() if ( g_file_get_contents(fn, &menus_xml, &len, NULL) ) { // load the menus_xml file - menus = sp_repr_read_mem(menus_xml, len, NULL); + _menus = sp_repr_read_mem(menus_xml, len, NULL); g_free(menus_xml); menus_xml = 0; @@ -702,11 +696,11 @@ bool Application::load_menus() g_free(fn); fn = 0; - if ( !menus ) { - menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); + if ( !_menus ) { + _menus = sp_repr_read_mem(menus_skeleton, MENUS_SKELETON_SIZE, NULL); } - return (menus != 0); + return (_menus != 0); } @@ -716,7 +710,7 @@ Application::selection_modified (Inkscape::Selection *selection, guint flags) g_return_if_fail (selection != NULL); if (DESKTOP_IS_ACTIVE (selection->desktop())) { - signal_selection_modified.emit(this, selection, flags); + signal_selection_modified.emit(selection, flags); } } @@ -727,7 +721,7 @@ Application::selection_changed (Inkscape::Selection * selection) g_return_if_fail (selection != NULL); if (DESKTOP_IS_ACTIVE (selection->desktop())) { - signal_selection_changed.emit(this, selection); + signal_selection_changed.emit(selection); } } @@ -737,7 +731,7 @@ Application::subselection_changed (SPDesktop *desktop) g_return_if_fail (desktop != NULL); if (DESKTOP_IS_ACTIVE (desktop)) { - signal_subselection_changed.emit(this, desktop); + signal_subselection_changed.emit(desktop); } } @@ -748,8 +742,8 @@ Application::selection_set (Inkscape::Selection * selection) g_return_if_fail (selection != NULL); if (DESKTOP_IS_ACTIVE (selection->desktop())) { - signal_selection_set.emit(this, selection); - signal_selection_changed.emit(this, selection); + signal_selection_set.emit(selection); + signal_selection_changed.emit(selection); } } @@ -761,7 +755,7 @@ Application::eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext) g_return_if_fail (SP_IS_EVENT_CONTEXT (eventcontext)); if (DESKTOP_IS_ACTIVE (eventcontext->desktop)) { - signal_eventcontext_set.emit(this, eventcontext); + signal_eventcontext_set.emit(eventcontext); } } @@ -770,21 +764,20 @@ void Application::add_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); - if (desktops == NULL) { - desktops = new std::vector; - g_message("Creating new desktop list."); + if (_desktops == NULL) { + _desktops = new std::vector; } - if (std::find(desktops->begin(), desktops->end(), desktop) != desktops->end()) { + if (std::find(_desktops->begin(), _desktops->end(), desktop) != _desktops->end()) { g_error("Attempted to add desktop already in list."); } - desktops->insert(desktops->begin(), desktop); + _desktops->insert(_desktops->begin(), desktop); - signal_activate_desktop.emit(this, desktop); - signal_eventcontext_set.emit(this, desktop->getEventContext()); - signal_selection_set.emit(this, sp_desktop_selection(desktop)); - signal_selection_changed.emit(this, sp_desktop_selection(desktop)); + signal_activate_desktop.emit(desktop); + signal_eventcontext_set.emit(desktop->getEventContext()); + signal_selection_set.emit(sp_desktop_selection(desktop)); + signal_selection_changed.emit(sp_desktop_selection(desktop)); } @@ -793,38 +786,36 @@ void Application::remove_desktop (SPDesktop * desktop) { g_return_if_fail (desktop != NULL); - g_return_if_fail (inkscape != NULL); - if (std::find (desktops->begin(), desktops->end(), desktop) == desktops->end() ) { + if (std::find (_desktops->begin(), _desktops->end(), desktop) == _desktops->end() ) { g_error("Attempted to remove desktop not in list."); } if (DESKTOP_IS_ACTIVE (desktop)) { - signal_deactivate_desktop.emit(this, desktop); - if (desktops->size() > 1) { - SPDesktop * new_desktop = *(++desktops->begin()); - desktops->erase(std::find(desktops->begin(), desktops->end(), new_desktop)); - desktops->insert(desktops->begin(), new_desktop); + signal_deactivate_desktop.emit(desktop); + if (_desktops->size() > 1) { + SPDesktop * new_desktop = *(++_desktops->begin()); + _desktops->erase(std::find(_desktops->begin(), _desktops->end(), new_desktop)); + _desktops->insert(_desktops->begin(), new_desktop); - signal_activate_desktop.emit(this, new_desktop); - signal_eventcontext_set.emit(this, new_desktop->getEventContext()); - signal_selection_set.emit(this, sp_desktop_selection(new_desktop)); - signal_selection_changed.emit(this, sp_desktop_selection(new_desktop)); + signal_activate_desktop.emit(new_desktop); + signal_eventcontext_set.emit(new_desktop->getEventContext()); + signal_selection_set.emit(sp_desktop_selection(new_desktop)); + signal_selection_changed.emit(sp_desktop_selection(new_desktop)); } else { - signal_eventcontext_set.emit(this, NULL); + signal_eventcontext_set.emit(NULL); if (sp_desktop_selection(desktop)) sp_desktop_selection(desktop)->clear(); } } - desktops->erase(std::find(desktops->begin(), desktops->end(), desktop)); + _desktops->erase(std::find(_desktops->begin(), _desktops->end(), desktop)); // if this was the last desktop, shut down the program - if (desktops->empty()) { - g_message("Shutting down."); + if (_desktops->empty()) { this->exit(); - delete desktops; - desktops = NULL; + delete _desktops; + _desktops = NULL; } } @@ -841,21 +832,21 @@ Application::activate_desktop (SPDesktop * desktop) std::vector::iterator i; - if ((i = std::find (desktops->begin(), desktops->end(), desktop)) == desktops->end()) { + if ((i = std::find (_desktops->begin(), _desktops->end(), desktop)) == _desktops->end()) { g_error("Tried to activate desktop not added to list."); } - SPDesktop *current = desktops->front(); + SPDesktop *current = _desktops->front(); - signal_deactivate_desktop.emit(this, current); + signal_deactivate_desktop.emit(current); - desktops->erase (i); - desktops->insert (desktops->begin(), desktop); + _desktops->erase (i); + _desktops->insert (_desktops->begin(), desktop); - signal_activate_desktop.emit(this, desktop); - signal_eventcontext_set.emit(this, desktop->getEventContext()); - signal_selection_set(this, sp_desktop_selection(desktop)); - signal_selection_changed(this, sp_desktop_selection(desktop)); + signal_activate_desktop.emit(desktop); + signal_eventcontext_set.emit(desktop->getEventContext()); + signal_selection_set(sp_desktop_selection(desktop)); + signal_selection_changed(sp_desktop_selection(desktop)); } @@ -868,7 +859,7 @@ Application::reactivate_desktop (SPDesktop * desktop) g_return_if_fail (desktop != NULL); if (DESKTOP_IS_ACTIVE (desktop)) { - signal_activate_desktop.emit(this, desktop); + signal_activate_desktop.emit(desktop); } } @@ -877,7 +868,7 @@ Application::reactivate_desktop (SPDesktop * desktop) SPDesktop * Application::find_desktop_by_dkey (unsigned int dkey) { - for (std::vector::iterator r = desktops->begin(), e = desktops->end(); r != e; ++r) { + for (std::vector::iterator r = _desktops->begin(), e = _desktops->end(); r != e; ++r) { if ((*r)->dkey == dkey){ return *r; } @@ -891,7 +882,7 @@ Application::maximum_dkey() { unsigned int dkey = 0; - for (std::vector::iterator r = desktops->begin(), e = desktops->end(); r != e; ++r) { + for (std::vector::iterator r = _desktops->begin(), e = _desktops->end(); r != e; ++r) { if ((*r)->dkey > dkey){ dkey = (*r)->dkey; } @@ -905,7 +896,7 @@ SPDesktop * Application::next_desktop () { SPDesktop *d = NULL; - unsigned int dkey_current = (desktops->front())->dkey; + unsigned int dkey_current = (_desktops->front())->dkey; if (dkey_current < maximum_dkey()) { // find next existing @@ -935,7 +926,7 @@ SPDesktop * Application::prev_desktop () { SPDesktop *d = NULL; - unsigned int dkey_current = (desktops->front())->dkey; + unsigned int dkey_current = (_desktops->front())->dkey; if (dkey_current > 0) { // find prev existing @@ -972,8 +963,8 @@ Application::switch_desktops_prev() void Application::dialogs_hide() { - signal_dialogs_hide.emit(this); - _dialogs_toggle = FALSE; + signal_dialogs_hide.emit(); + _dialogs_toggle = false; } @@ -981,8 +972,8 @@ Application::dialogs_hide() void Application::dialogs_unhide() { - signal_dialogs_unhide.emit(this); - _dialogs_toggle = TRUE; + signal_dialogs_unhide.emit(); + _dialogs_toggle = true; } @@ -1000,7 +991,7 @@ Application::dialogs_toggle() void Application::external_change() { - signal_external_change.emit(this); + signal_external_change.emit(); } /** @@ -1012,10 +1003,10 @@ Application::add_document (SPDocument *document) g_return_if_fail (document != NULL); // try to insert the pair into the list - if (!(document_set.insert(std::make_pair(document, 1)).second)) { + if (!(_document_set.insert(std::make_pair(document, 1)).second)) { //insert failed, this key (document) is already in the list - for (std::map::iterator iter = document_set.begin(); - iter != document_set.end(); + for (std::map::iterator iter = _document_set.begin(); + iter != _document_set.end(); ++iter) { if (iter->first == document) { // found this document in list, increase its count @@ -1027,8 +1018,8 @@ Application::add_document (SPDocument *document) // selection model for it, i.e. are we running without a desktop? if (!_use_gui) { // Create layer model and selection model so we can run some verbs without a GUI - g_assert(selection_models.find(document) == selection_models.end()); - selection_models[document] = new AppSelectionModel(document); + g_assert(_selection_models.find(document) == _selection_models.end()); + _selection_models[document] = new AppSelectionModel(document); } } } @@ -1040,20 +1031,20 @@ Application::remove_document (SPDocument *document) { g_return_val_if_fail (document != NULL, false); - for (std::map::iterator iter = document_set.begin(); - iter != document_set.end(); + for (std::map::iterator iter = _document_set.begin(); + iter != _document_set.end(); ++iter) { if (iter->first == document) { // found this document in list, decrease its count iter->second --; if (iter->second < 1) { // this was the last one, remove the pair from list - document_set.erase (iter); + _document_set.erase (iter); // also remove the selection model - std::map::iterator sel_iter = selection_models.find(document); - if (sel_iter != selection_models.end()) { - selection_models.erase(sel_iter); + std::map::iterator sel_iter = _selection_models.find(document); + if (sel_iter != _selection_models.end()) { + _selection_models.erase(sel_iter); } return true; @@ -1069,11 +1060,11 @@ Application::remove_document (SPDocument *document) SPDesktop * Application::active_desktop() { - if (!desktops || desktops->empty()) { + if (!_desktops || _desktops->empty()) { return NULL; } - return desktops->front(); + return _desktops->front(); } SPDocument * @@ -1081,10 +1072,10 @@ Application::active_document() { if (SP_ACTIVE_DESKTOP) { return sp_desktop_document (SP_ACTIVE_DESKTOP); - } else if (!document_set.empty()) { + } else if (!_document_set.empty()) { // If called from the command line there will be no desktop // So 'fall back' to take the first listed document in the Inkscape instance - return document_set.begin()->first; + return _document_set.begin()->first; } return NULL; @@ -1096,7 +1087,7 @@ Application::sole_desktop_for_document(SPDesktop const &desktop) { if (!document) { return false; } - for ( std::vector::iterator iter = desktops->begin(), e = desktops->end() ; iter != e; ++iter ) { + for ( std::vector::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e; ++iter ) { SPDesktop *other_desktop = *iter; SPDocument *other_document = other_desktop->doc(); if ( other_document == document && other_desktop != &desktop ) { @@ -1135,7 +1126,7 @@ Inkscape::ActionContext Application::action_context_for_document(SPDocument *doc) { // If there are desktops, check them first to see if the document is bound to one of them - for (std::vector::iterator iter = desktops->begin(), e = desktops->end() ; iter != e ; ++iter) { + for (std::vector::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e ; ++iter) { SPDesktop *desktop = *iter; if (desktop->doc() == doc) { return Inkscape::ActionContext(desktop); @@ -1143,8 +1134,8 @@ Application::action_context_for_document(SPDocument *doc) } // Document is not associated with any desktops - maybe we're in command-line mode - std::map::iterator sel_iter = selection_models.find(doc); - if (sel_iter == selection_models.end()) { + std::map::iterator sel_iter = _selection_models.find(doc); + if (sel_iter == _selection_models.end()) { return Inkscape::ActionContext(); } return Inkscape::ActionContext(sel_iter->second->getSelection()); @@ -1158,7 +1149,7 @@ Application::action_context_for_document(SPDocument *doc) void Application::refresh_display () { - for (std::vector::iterator l = desktops->begin(), e = desktops->end(); l != e; ++l) { + for (std::vector::iterator l = _desktops->begin(), e = _desktops->end(); l != e; ++l) { (*l)->requestRedraw(); } } @@ -1172,7 +1163,7 @@ void Application::exit () { //emit shutdown signal so that dialogs could remember layout - signal_shut_down.emit(this); + signal_shut_down.emit(); Inkscape::Preferences::unload(); gtk_main_quit (); @@ -1186,8 +1177,8 @@ Application::homedir_path(const char *filename) homedir = g_get_home_dir(); } if (!homedir) { - if (inkscape) { - homedir = g_path_get_dirname(inkscape->_argv0); + if (Application::instance()) { + homedir = g_path_get_dirname(Application::instance()->_argv0); } } return g_build_filename(homedir, filename, NULL); @@ -1313,7 +1304,7 @@ Application::profile_path(const char *filename) Inkscape::XML::Node * Application::get_menus() { - Inkscape::XML::Node *repr = menus->root(); + Inkscape::XML::Node *repr = _menus->root(); g_assert (!(strcmp (repr->name(), "inkscape"))); return repr->firstChild(); } @@ -1321,7 +1312,7 @@ Application::get_menus() void Application::get_all_desktops(std::list< SPDesktop* >& listbuf) { - listbuf.insert(listbuf.end(), desktops->begin(), desktops->end()); + listbuf.insert(listbuf.end(), _desktops->begin(), _desktops->end()); } } // namespace Inkscape diff --git a/src/inkscape.h b/src/inkscape.h index 4b969bddb..821970748 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -48,7 +48,7 @@ struct Document; Inkscape::Application * inkscape_ref (Inkscape::Application * in); Inkscape::Application * inkscape_unref(Inkscape::Application * in); -#define INKSCAPE inkscape_get_instance() +#define INKSCAPE (Inkscape::Application::instance()) #define SP_INKSCAPE(obj) (dynamic_cast(obj)) #define SP_IS_INKSCAPE(obj) (dynamic_cast (obj) != NULL) #define SP_ACTIVE_EVENTCONTEXT (INKSCAPE->active_event_context()) @@ -76,23 +76,15 @@ public: namespace Inkscape { class Application { -private: - unsigned refCount; - gboolean _dialogs_toggle; - guint _mapalt; - guint _trackalt; - char * _argv0; - bool _use_gui; // may want to consider a virtual function - // for overriding things like the warning dlg's +protected: + static Inkscape::Application * _S_inst; -public: Application(const char* argv0, bool use_gui); ~Application(); - Inkscape::XML::Document *menus; - std::map document_set; - std::map selection_models; - std::vector * desktops; +public: + static Application* instance(); + static void init(const char* argv0, bool use_gui); // returns the mask of the keyboard modifier to map to Alt, zero if no mapping // Needs to be a guint because gdktypes.h does not define a 'no-modifier' value @@ -110,36 +102,8 @@ public: char const* argv0() const { return _argv0; } void argv0(char const *); - // signals - - // one of selections changed - sigc::signal signal_selection_changed; - // one of subselections (text selection, gradient handle, etc) changed - sigc::signal signal_subselection_changed; - // one of selections modified - sigc::signal signal_selection_modified; - // one of selections set - sigc::signal signal_selection_set; - // tool switched - sigc::signal signal_eventcontext_set; - // some desktop got focus - sigc::signal signal_activate_desktop; - // some desktop lost focus - sigc::signal signal_deactivate_desktop; - - // probably orphaned signals - sigc::signal signal_destroy_document; - sigc::signal signal_color_set; - - // inkscape is quitting - sigc::signal signal_shut_down; - // user pressed F12 - sigc::signal signal_dialogs_hide; - // user pressed F12 - sigc::signal signal_dialogs_unhide; - // a document was changed by some external means (undo or XML editor); this - // may not be reflected by a selection change and thus needs a separate signal - sigc::signal signal_external_change; + // no setter for this -- only we can control this variable + static bool isCrashing() { return _crashIsHappening; } // useful functions void autosave_init(); @@ -207,22 +171,57 @@ public: int autosave(); + // nobody should be accessing our reference count, so it's made private. friend Application * ::inkscape_ref (Application * in); friend Application * ::inkscape_unref(Application * in); -}; -} // namespace Inkscape - -bool inkscapeIsCrashing(); + // signals + + // one of selections changed + sigc::signal signal_selection_changed; + // one of subselections (text selection, gradient handle, etc) changed + sigc::signal signal_subselection_changed; + // one of selections modified + sigc::signal signal_selection_modified; + // one of selections set + sigc::signal signal_selection_set; + // tool switched + sigc::signal signal_eventcontext_set; + // some desktop got focus + sigc::signal signal_activate_desktop; + // some desktop lost focus + sigc::signal signal_deactivate_desktop; + + // these are orphaned signals (nothing emits them and nothing connects to them) + sigc::signal signal_destroy_document; + sigc::signal signal_color_set; + + // inkscape is quitting + sigc::signal signal_shut_down; + // user pressed F12 + sigc::signal signal_dialogs_hide; + // user pressed F12 + sigc::signal signal_dialogs_unhide; + // a document was changed by some external means (undo or XML editor); this + // may not be reflected by a selection change and thus needs a separate signal + sigc::signal signal_external_change; -// gets the current instance and calls autosave() -int inkscape_autosave(gpointer unused); +private: + Inkscape::XML::Document * _menus; + std::map _document_set; + std::map _selection_models; + std::vector * _desktops; -// hmm, I wonder what this does /s -Inkscape::Application* inkscape_get_instance(); + unsigned refCount; + bool _dialogs_toggle; + guint _mapalt; + guint _trackalt; + char * _argv0; + static bool _crashIsHappening; + bool _use_gui; +}; -// only temporary until I can properly clean this up -void inkscape_application_init (const gchar *argv0, gboolean use_gui); +} // namespace Inkscape #endif diff --git a/src/inkview.cpp b/src/inkview.cpp index f1be398f7..1ec8393ba 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -232,7 +232,8 @@ main (int argc, const char **argv) ss.view = NULL; ss.fullscreen = false; - inkscape = new Inkscape::Application(argv[0], true); + Inkscape::Application::init(argv[0], true); + inkscape = Inkscape::Application::instance(); // starting at where the commandline options stopped parsing because // we want all the files to be in the list diff --git a/src/main.cpp b/src/main.cpp index 77be9a275..8d978c5ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1059,7 +1059,7 @@ sp_main_gui(int argc, char const **argv) gboolean create_new = TRUE; /// \todo FIXME BROKEN - non-UTF-8 sneaks in here. - inkscape_application_init(argv[0], true); + Inkscape::Application::init(argv[0], true); while (fl) { if (sp_file_open((gchar *)fl->data,NULL)) { @@ -1335,7 +1335,7 @@ int sp_main_console(int argc, char const **argv) exit(0); } - inkscape_application_init(argv[0], false); + Inkscape::Application::init(argv[0], false); if (sp_shell) { int retVal = sp_main_shell(argv[0]); // Run as interactive shell diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 35a9a8376..4fd2f0f9c 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1044,10 +1044,10 @@ AlignAndDistribute::AlignAndDistribute() contents->pack_start(_nodesFrame, true, true); //Connect to the global tool change signal - _toolChangeConn = INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)))); + _toolChangeConn = INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this))); // Connect to the global selection change, to invalidate cached randomize_bbox - _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)))); + _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); randomize_bbox = Geom::OptRect(); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &AlignAndDistribute::setDesktop) ); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 4d5d50de0..84ef0b5b0 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1269,8 +1269,8 @@ CloneTiler::CloneTiler () : // connect to global selection changed signal (so we can change desktops) and // external_change (so we're not fooled by undo) - selectChangedConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg))); - externChangedConn = INKSCAPE->signal_external_change.connect (sigc::hide<0>(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg))); + selectChangedConn = INKSCAPE->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg)); + externChangedConn = INKSCAPE->signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg)); g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this); diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 06f0216a7..5eb9ea054 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -41,10 +41,9 @@ void DesktopTracker::connect(GtkWidget *widget) // Use C/gobject callbacks to avoid gtkmm rewrap-during-destruct issues: hierID = g_signal_connect( G_OBJECT(widget), "hierarchy-changed", G_CALLBACK(hierarchyChangeCB), this ); inkID = INKSCAPE->signal_activate_desktop.connect( - sigc::hide<0>( sigc::bind( - sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this) - )); + sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this) + ); GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET); if (wdgt && !base) { diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index d0da70a60..72ca117f7 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -73,10 +73,10 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat _behavior = behavior_factory(*this); _desktop = SP_ACTIVE_DESKTOP; - INKSCAPE->signal_activate_desktop.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onDesktopActivated))); - INKSCAPE->signal_dialogs_hide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onHideF12))); - INKSCAPE->signal_dialogs_unhide.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShowF12))); - INKSCAPE->signal_shut_down.connect(sigc::hide<0>(sigc::mem_fun(*this, &Dialog::onShutdown))); + INKSCAPE->signal_activate_desktop.connect(sigc::mem_fun(*this, &Dialog::onDesktopActivated)); + INKSCAPE->signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dialog::onHideF12)); + INKSCAPE->signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dialog::onShowF12)); + INKSCAPE->signal_shut_down.connect(sigc::mem_fun(*this, &Dialog::onShutdown)); Glib::wrap(gobj())->signal_event().connect(sigc::mem_fun(*this, &Dialog::_onEvent)); Glib::wrap(gobj())->signal_key_press_event().connect(sigc::mem_fun(*this, &Dialog::_onKeyPress)); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index c4281babc..38e359b28 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -539,7 +539,7 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) SVGPreview::SVGPreview() { if (!INKSCAPE) - inkscape_application_init("", false); + Inkscape::Application::init("", false); document = NULL; viewerGtk = NULL; set_size_request(150, 150); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 028c94ec1..f7c035ebe 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -594,7 +594,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) { // Selection Change signal - INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection)))); + INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection))); } Gtk::Box *contents = this; diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index 470d0d1b3..b3beb73c6 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -49,15 +49,6 @@ public: virtual UI::Widget::Panel &getPanel() { return _panel; } protected: - /*static void handle_deactivate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { - g_return_if_fail(data != NULL); - static_cast(data)->_propagateDesktopDeactivated(application, desktop); - } - - static void _handle_activate_desktop(Inkscape::Application *application, SPDesktop *desktop, void *data) { - g_return_if_fail(data != NULL); - static_cast(data)->_propagateDesktopActivated(application, desktop); - }*/ inline virtual void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document); inline virtual void _propagateDesktopActivated(Inkscape::Application *, SPDesktop *); @@ -247,8 +238,14 @@ PanelDialog *PanelDialog new PanelDialog(panel, panel.getPrefsPath(), panel.getVerb(), panel.getApplyLabel()); - INKSCAPE->signal_activate_desktop.connect (sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopActivated)); - INKSCAPE->signal_deactivate_desktop.connect(sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopDeactivated)); + INKSCAPE->signal_activate_desktop.connect( + sigc::bind<0>( + sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopActivated), INKSCAPE + )); + INKSCAPE->signal_deactivate_desktop.connect( + sigc::bind<0>( + sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopDeactivated), INKSCAPE + )); return instance; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 8bc9ad275..c36da373f 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -156,8 +156,8 @@ Transformation::Transformation() } // Connect to the global selection changed & modified signals - _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); - _selModifyConn = INKSCAPE->signal_selection_modified.connect(sigc::hide<0>(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this)))); + _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)); + _selModifyConn = INKSCAPE->signal_selection_modified.connect(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this))); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) ); _deskTrack.connect(GTK_WIDGET(gobj())); diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 3448283b9..f23e4bcca 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -120,8 +120,8 @@ Dock::Dock(Gtk::Orientation orientation) gdl_dock_bar_set_style(_gdl_dock_bar, gdl_dock_bar_style); - INKSCAPE->signal_dialogs_hide.connect(sigc::hide(sigc::mem_fun(*this, &Dock::hide))); - INKSCAPE->signal_dialogs_unhide.connect(sigc::hide(sigc::mem_fun(*this, &Dock::show))); + INKSCAPE->signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dock::hide)); + INKSCAPE->signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dock::show)); g_signal_connect(_paned->gobj(), "button-press-event", G_CALLBACK(_on_paned_button_event), (void *)this); g_signal_connect(_paned->gobj(), "button-release-event", G_CALLBACK(_on_paned_button_event), (void *)this); diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 22abd04ba..0ccff0c9e 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -88,8 +88,9 @@ ImageIcon::~ImageIcon() */ void ImageIcon::init() { + // \FIXME Why? if (!INKSCAPE) - inkscape_application_init("",false); + Inkscape::Application::init("", false); document = NULL; viewerGtkmm = NULL; //set_size_request(150,150); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 9fb439a28..9c27da1f8 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1033,19 +1033,18 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) wd.win = dlg; wd.stop = 0; - INKSCAPE->signal_activate_desktop.connect(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd)); + INKSCAPE->signal_activate_desktop.connect(sigc::bind<0>(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd), INKSCAPE)); g_signal_connect(G_OBJECT(dlg), "event", G_CALLBACK(sp_dialog_event_handler), dlg); g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg); g_signal_connect(G_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); INKSCAPE->signal_shut_down.connect( - sigc::hide<0>( sigc::hide_return( sigc::bind(sigc::ptr_fun(&sp_gradient_vector_dialog_delete), (GtkWidget *) NULL, (GdkEvent *) NULL, (GtkWidget *) NULL) - ))); - INKSCAPE->signal_dialogs_hide.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(>k_widget_hide), dlg))); - INKSCAPE->signal_dialogs_unhide.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(>k_widget_show), dlg))); + )); + INKSCAPE->signal_dialogs_hide.connect(sigc::bind(sigc::ptr_fun(>k_widget_hide), dlg)); + INKSCAPE->signal_dialogs_unhide.connect(sigc::bind(sigc::ptr_fun(>k_widget_show), dlg)); gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 0814d56d6..214990b6b 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1568,7 +1568,7 @@ void IconImpl::addPreRender( GtkIconSize lsize, gchar const *name ) } gboolean IconImpl::prerenderTask(gpointer /*data*/) { - if ( inkscapeIsCrashing() ) { + if ( Inkscape::Application::isCrashing() ) { // stop } else if (!pendingRenders.empty()) { bool workDone = false; @@ -1580,7 +1580,7 @@ gboolean IconImpl::prerenderTask(gpointer /*data*/) { } while (!pendingRenders.empty() && !workDone); } - if (!inkscapeIsCrashing() && !pendingRenders.empty()) { + if (!Inkscape::Application::isCrashing() && !pendingRenders.empty()) { return TRUE; } else { callbackHooked = false; diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 322b444b9..08344d9b2 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -211,12 +211,21 @@ void SPWidgetImpl::show(GtkWidget *widget) if (spw->inkscape) { // Connect signals - spw->selModified = spw->inkscape->signal_selection_modified.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)); - spw->selChanged = spw->inkscape->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)); - spw->selSet = spw->inkscape->signal_selection_set.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw)); - //g_signal_connect(spw->inkscape, "modify_selection", G_CALLBACK(SPWidgetImpl::modifySelectionCB), spw); - //g_signal_connect(spw->inkscape, "change_selection", G_CALLBACK(SPWidgetImpl::changeSelectionCB), spw); - //g_signal_connect(spw->inkscape, "set_selection", G_CALLBACK(SPWidgetImpl::setSelectionCB), spw); + spw->selModified = spw->inkscape->signal_selection_modified.connect( + sigc::bind<0>( + sigc::bind( + sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw), spw->inkscape + )); + spw->selChanged = spw->inkscape->signal_selection_changed.connect( + sigc::bind<0>( + sigc::bind( + sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw), spw->inkscape + )); + spw->selSet = spw->inkscape->signal_selection_set.connect( + sigc::bind<0>( + sigc::bind( + sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw), spw->inkscape + )); } if (reinterpret_cast(parentClass)->show) { @@ -233,7 +242,6 @@ void SPWidgetImpl::hide(GtkWidget *widget) spw->selModified.disconnect(); spw->selChanged.disconnect(); spw->selSet.disconnect(); - //sp_signal_disconnect_by_data(spw->inkscape, spw); } if (reinterpret_cast(parentClass)->hide) { @@ -311,9 +319,21 @@ GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, Inkscape::Application *i spw->inkscape = inkscape; if (gtk_widget_get_visible(GTK_WIDGET(spw))) { - spw->selModified = spw->inkscape->signal_selection_modified.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw)); - spw->selChanged = spw->inkscape->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw)); - spw->selSet = spw->inkscape->signal_selection_set.connect(sigc::bind(sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw)); + spw->selModified = spw->inkscape->signal_selection_modified.connect( + sigc::bind<0>( + sigc::bind( + sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw), spw->inkscape + )); + spw->selChanged = spw->inkscape->signal_selection_changed.connect( + sigc::bind<0>( + sigc::bind( + sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw), spw->inkscape + )); + spw->selSet = spw->inkscape->signal_selection_set.connect( + sigc::bind<0>( + sigc::bind( + sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw), spw->inkscape + )); } g_signal_emit(spw, signals[CONSTRUCT], 0); -- cgit v1.2.3 From 1ed5e67c01975040a78765a1cf97b942d736c14b Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 26 Jun 2014 15:40:39 -0400 Subject: Convert accidental member accesses into static function accesses (bzr r13341.5.7) --- src/extension/error-file.cpp | 3 ++- src/extension/extension.cpp | 2 +- src/extension/init.cpp | 2 +- src/extension/internal/filter/filter-file.cpp | 2 +- src/file.cpp | 2 +- src/io/resource.cpp | 2 +- src/main.cpp | 2 +- src/preferences.cpp | 8 +++++--- src/shortcuts.cpp | 4 ++-- src/ui/dialog/filedialogimpl-gtkmm.cpp | 2 +- src/ui/dialog/inkscape-preferences.cpp | 2 +- src/ui/dialog/swatches.cpp | 2 +- src/ui/dialog/symbols.cpp | 8 +++++--- src/ui/dialog/template-load-tab.cpp | 2 +- src/widgets/icon.cpp | 2 +- 15 files changed, 25 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp index 2970bf8d9..db354c0ce 100644 --- a/src/extension/error-file.cpp +++ b/src/extension/error-file.cpp @@ -48,9 +48,10 @@ ErrorFileNotice::ErrorFileNotice (void) : ) { + // \FIXME change this /* This is some filler text, needs to change before relase */ Glib::ustring dialog_text(_("One or more extensions failed to load\n\nThe failed extensions have been skipped. Inkscape will continue to run normally but those extensions will be unavailable. For details to troubleshoot this problem, please refer to the error log located at: ")); - gchar * ext_error_file = INKSCAPE->profile_path(EXTENSION_ERROR_LOG_FILENAME); + gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME); dialog_text += ext_error_file; g_free(ext_error_file); set_message(dialog_text, true); diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index b62cfd8af..a5f0e6467 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -662,7 +662,7 @@ Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc, void Extension::error_file_open (void) { - gchar * ext_error_file = INKSCAPE->profile_path(EXTENSION_ERROR_LOG_FILENAME); + gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME); gchar * filename = g_filename_from_utf8( ext_error_file, -1, NULL, NULL, NULL ); error_file.open(filename); if (!error_file.is_open()) { diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 57d7f9e33..c16a5a899 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -243,7 +243,7 @@ init() /* Load search path for extensions */ if (Inkscape::Extension::Extension::search_path.size() == 0) { - Inkscape::Extension::Extension::search_path.push_back(INKSCAPE->profile_path("extensions")); + Inkscape::Extension::Extension::search_path.push_back(Inkscape::Application::profile_path("extensions")); Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR)); diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index 04d3f27e1..b1993057d 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -29,7 +29,7 @@ namespace Filter { void Filter::filters_all_files(void) { - gchar *filtersProfilePath = INKSCAPE->profile_path("filters"); + gchar *filtersProfilePath = Inkscape::Application::profile_path("filters"); filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled")); filters_load_dir(filtersProfilePath, _("Personal")); diff --git a/src/file.cpp b/src/file.cpp index 2c0ba5365..99bfcc77f 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -175,7 +175,7 @@ SPDesktop *sp_file_new(const std::string &templ) Glib::ustring sp_file_default_template_uri() { std::list sources; - sources.push_back( INKSCAPE->profile_path("templates") ); // first try user's local dir + sources.push_back( Inkscape::Application::profile_path("templates") ); // first try user's local dir sources.push_back( g_strdup(INKSCAPE_TEMPLATESDIR) ); // then the system templates dir std::list baseNames; gchar const* localized = _("default.svg"); diff --git a/src/io/resource.cpp b/src/io/resource.cpp index 94bd7fca1..501eab03b 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -73,7 +73,7 @@ Util::ptr_shared get_path(Domain domain, Type type, char const *filename) case TEMPLATES: name = "templates"; break; default: return get_path(SYSTEM, type, filename); } - path = INKSCAPE->profile_path(name); + path = Inkscape::Application::profile_path(name); } break; } diff --git a/src/main.cpp b/src/main.cpp index 8d978c5ab..499285a7b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1042,7 +1042,7 @@ sp_main_gui(int argc, char const **argv) } // Add our icon directory to the search path for icon theme lookups. - gchar *usericondir = INKSCAPE->profile_path("icons"); + gchar *usericondir = Inkscape::Application::profile_path("icons"); gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), usericondir); gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), INKSCAPE_PIXMAPDIR); g_free(usericondir); diff --git a/src/preferences.cpp b/src/preferences.cpp index ede60c686..e5a5fe7f0 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -91,11 +91,13 @@ Preferences::Preferences() : _hasError(false) { // profile_path essentailly returns the argument prefixed by the profile directory. - gchar *path = INKSCAPE->profile_path(NULL); + // \TODO this is kinda hackish, but the alternative (strrchr) is worse + + gchar *path = Inkscape::Application::profile_path(NULL); _prefs_dir = path; g_free(path); - path = INKSCAPE->profile_path(_prefs_basename.c_str()); + path = Inkscape::Application::profile_path(_prefs_basename.c_str()); _prefs_filename = path; g_free(path); @@ -155,7 +157,7 @@ void Preferences::_load() // create some subdirectories for user stuff char const *user_dirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL}; for (int i=0; user_dirs[i]; ++i) { - char *dir = INKSCAPE->profile_path(user_dirs[i]); + char *dir = Inkscape::Application::profile_path(user_dirs[i]); g_mkdir(dir, 0755); g_free(dir); } diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index 016a48d8f..e72c16de0 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -211,7 +211,7 @@ Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename) void sp_shortcut_get_file_names(std::vector *names, std::vector *paths) { std::list sources; - sources.push_back( INKSCAPE->profile_path("keys") ); + sources.push_back( Inkscape::Application::profile_path("keys") ); sources.push_back( g_strdup(INKSCAPE_KEYSDIR) ); // loop through possible keyboard shortcut file locations. @@ -229,7 +229,7 @@ void sp_shortcut_get_file_names(std::vector *names, std::vectorprofile_path("keys")) && + if (!strcmp(dirname, Inkscape::Application::profile_path("keys")) && !strcmp(lower, "default.xml")) { // Dont add the users custom keys file continue; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 38e359b28..50a883612 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1044,7 +1044,7 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl } // allow easy access to the user's own templates folder - gchar *templates = INKSCAPE->profile_path("templates"); + gchar *templates = Inkscape::Application::profile_path("templates"); if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) && Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) { add_shortcut_folder(templates); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index f1535175a..5e698355c 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1908,7 +1908,7 @@ void InkscapePreferences::initPageSystem() _page_system.add_group_header( _("System info")); - _sys_user_config.set_text((char const *)INKSCAPE->profile_path("")); + _sys_user_config.set_text((char const *)Inkscape::Application::profile_path("")); _sys_user_config.set_editable(false); _page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 6dbb1d5e9..16c7bc3e6 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -527,7 +527,7 @@ static void loadEmUp() beenHere = true; std::list sources; - sources.push_back( INKSCAPE->profile_path("palettes") ); + sources.push_back( Inkscape::Application::profile_path("palettes") ); sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) ); sources.push_back( g_strdup(CREATE_PALETTESDIR) ); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 9e5e94498..0a35ee760 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -568,13 +568,15 @@ void SymbolsDialog::get_symbols() { std::list directories; +// \TODO optimize this + if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) && Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { directories.push_back( INKSCAPE_SYMBOLSDIR ); } - if( Inkscape::IO::file_test( INKSCAPE->profile_path("symbols"), G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( INKSCAPE->profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { - directories.push_back( INKSCAPE->profile_path("symbols") ); + if( Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_EXISTS ) && + Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { + directories.push_back( Inkscape::Application::profile_path("symbols") ); } std::list::iterator it; diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 1bd9510dc..ff94aad5d 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -194,7 +194,7 @@ void TemplateLoadTab::_refreshTemplatesList() void TemplateLoadTab::_loadTemplates() { // user's local dir - _getTemplatesFromDir(INKSCAPE->profile_path("templates") + _loading_path); + _getTemplatesFromDir(Inkscape::Application::profile_path("templates") + _loading_path); // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 214990b6b..e0b834961 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1257,7 +1257,7 @@ std::list &IconImpl::icons_svg_paths() static bool initialized = false; if (!initialized) { // Fall back from user prefs dir into system locations. - gchar *userdir = INKSCAPE->profile_path("icons"); + gchar *userdir = Inkscape::Application::profile_path("icons"); sources.push_back(g_build_filename(userdir,"icons.svg", NULL)); sources.push_back(g_build_filename(INKSCAPE_PIXMAPDIR, "icons.svg", NULL)); g_free(userdir); -- cgit v1.2.3 From a65c95ff4739e2803e28d64b2a3b3774dd1f45aa Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 26 Jun 2014 21:40:01 -0400 Subject: Move constructor/destructor into private section, remove protected section. Rename init(). Add to-do list. (bzr r13341.5.8) --- src/inkscape.cpp | 17 +++++++++++++++-- src/inkscape.h | 13 ++++++------- src/inkview.cpp | 2 +- src/main.cpp | 4 ++-- src/ui/dialog/filedialogimpl-gtkmm.cpp | 2 +- src/ui/widget/imageicon.cpp | 2 +- 6 files changed, 26 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 60f950636..89501c646 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -9,7 +9,7 @@ * * Copyright (C) 1999-2014 authors * c++ port Copyright (C) 2003 Nathan Hurst - * c++ification copyright (C) 2014 Liam P. White + * c++ification Copyright (C) 2014 Liam P. White * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -103,6 +103,19 @@ typedef int uid_t; #define getuid() 0 #endif +/** C++ification TODO list + * - _S_inst should NOT need to be assigned inside the constructor, but if it isn't the Filters+Extensions menus break. + * - Application::_deskops has to be a pointer because of a signal bug somewhere else. Basically, it will attempt to access a deleted object in sp_ui_close_all(), + * but if it's a pointer we can stop and return NULL in Application::active_desktop() + * - These functions are calling Application::create for no good reason I can determine: + * + * Inkscape::UI::Dialog::SVGPreview::SVGPreview() + * src/ui/dialog/filedialogimpl-gtkmm.cpp:542:9 + * void Inkscape::UI::Widget::ImageIcon::init() + * src/ui/widget/imageicon.cpp:93:9 + */ + + class InkErrorHandler : public Inkscape::ErrorReporter { public: InkErrorHandler(bool useGui) : Inkscape::ErrorReporter(), @@ -157,7 +170,7 @@ int inkscape_autosave(gpointer) { namespace Inkscape { void -Application::init (const char *argv0, bool use_gui) +Application::create(const char *argv0, bool use_gui) { if (!Application::instance()) { new Application(argv0, use_gui); diff --git a/src/inkscape.h b/src/inkscape.h index 821970748..966b6ee87 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -76,15 +76,9 @@ public: namespace Inkscape { class Application { -protected: - static Inkscape::Application * _S_inst; - - Application(const char* argv0, bool use_gui); - ~Application(); - public: static Application* instance(); - static void init(const char* argv0, bool use_gui); + static void create(const char* argv0, bool use_gui); // returns the mask of the keyboard modifier to map to Alt, zero if no mapping // Needs to be a guint because gdktypes.h does not define a 'no-modifier' value @@ -207,6 +201,11 @@ public: sigc::signal signal_external_change; private: + static Inkscape::Application * _S_inst; + + Application(const char* argv0, bool use_gui); + ~Application(); + Inkscape::XML::Document * _menus; std::map _document_set; std::map _selection_models; diff --git a/src/inkview.cpp b/src/inkview.cpp index 1ec8393ba..721b4784f 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -232,7 +232,7 @@ main (int argc, const char **argv) ss.view = NULL; ss.fullscreen = false; - Inkscape::Application::init(argv[0], true); + Inkscape::Application::create(argv[0], true); inkscape = Inkscape::Application::instance(); // starting at where the commandline options stopped parsing because diff --git a/src/main.cpp b/src/main.cpp index 499285a7b..2e36e3d50 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1059,7 +1059,7 @@ sp_main_gui(int argc, char const **argv) gboolean create_new = TRUE; /// \todo FIXME BROKEN - non-UTF-8 sneaks in here. - Inkscape::Application::init(argv[0], true); + Inkscape::Application::create(argv[0], true); while (fl) { if (sp_file_open((gchar *)fl->data,NULL)) { @@ -1335,7 +1335,7 @@ int sp_main_console(int argc, char const **argv) exit(0); } - Inkscape::Application::init(argv[0], false); + Inkscape::Application::create(argv[0], false); if (sp_shell) { int retVal = sp_main_shell(argv[0]); // Run as interactive shell diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 50a883612..014c85bd7 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -539,7 +539,7 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) SVGPreview::SVGPreview() { if (!INKSCAPE) - Inkscape::Application::init("", false); + Inkscape::Application::create("", false); document = NULL; viewerGtk = NULL; set_size_request(150, 150); diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 0ccff0c9e..8c1e44434 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -90,7 +90,7 @@ void ImageIcon::init() { // \FIXME Why? if (!INKSCAPE) - Inkscape::Application::init("", false); + Inkscape::Application::create("", false); document = NULL; viewerGtkmm = NULL; //set_size_request(150,150); -- cgit v1.2.3 From 45f373f3319b598d8e0222fb48e9d3a4760b2044 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Fri, 27 Jun 2014 15:23:06 -0400 Subject: 5. Refactoring of Application class: make copy/assignment operators private, disallow pointers to Application (bzr r13341.5.9) --- src/box3d.cpp | 2 +- src/conn-avoid-ref.cpp | 4 +- src/desktop.cpp | 58 ++++++-------- src/desktop.h | 2 - src/dialogs/dialog-events.cpp | 5 +- src/dialogs/dialog-events.h | 12 +-- src/document-undo.cpp | 4 +- src/document-undo.h | 2 - src/document.cpp | 4 +- src/document.h | 1 - src/extension/effect.cpp | 8 +- src/extension/implementation/script.cpp | 2 +- src/extension/internal/cdr-input.cpp | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 2 +- src/extension/internal/vsd-input.cpp | 2 +- src/extension/system.cpp | 2 +- src/file.cpp | 2 +- src/graphlayout.cpp | 2 +- src/helper/stock-items.cpp | 4 +- src/inkscape.cpp | 76 ++++++++++++------ src/inkscape.h | 27 +++---- src/inkview.cpp | 6 +- src/interface.cpp | 10 +-- src/line-geometry.cpp | 4 +- src/live_effects/effect.cpp | 2 +- src/live_effects/lpe-bspline.cpp | 4 +- src/live_effects/lpe-envelope-perspective.cpp | 2 +- src/live_effects/lpe-lattice2.cpp | 2 +- src/live_effects/parameter/text.cpp | 2 +- src/main-cmdlineact.cpp | 2 +- src/main.cpp | 12 +-- src/persp3d.cpp | 8 +- src/selection-chemistry.cpp | 2 +- src/selection.cpp | 4 +- src/sp-item.cpp | 6 +- src/tools-switch.cpp | 2 +- src/ui/dialog/align-and-distribute.cpp | 4 +- src/ui/dialog/clonetiler.cpp | 4 +- src/ui/dialog/desktop-tracker.cpp | 2 +- src/ui/dialog/desktop-tracker.h | 2 - src/ui/dialog/dialog.cpp | 8 +- src/ui/dialog/dialog.h | 2 - src/ui/dialog/document-metadata.cpp | 4 +- src/ui/dialog/document-metadata.h | 5 +- src/ui/dialog/document-properties.cpp | 4 +- src/ui/dialog/document-properties.h | 4 +- src/ui/dialog/export.cpp | 2 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 3 +- src/ui/dialog/fill-and-stroke.h | 3 +- src/ui/dialog/grid-arrange-tab.cpp | 2 +- src/ui/dialog/panel-dialog.h | 30 ++++--- src/ui/dialog/symbols.cpp | 2 +- src/ui/dialog/transformation.cpp | 4 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/view/view.cpp | 6 +- src/ui/widget/dock.cpp | 4 +- src/ui/widget/imageicon.cpp | 2 +- src/ui/widget/object-composite-settings.h | 5 +- src/ui/widget/panel.cpp | 6 +- src/ui/widget/panel.h | 9 +-- src/vanishing-point.cpp | 22 +++--- src/verbs.cpp | 18 ++--- src/widgets/box3d-toolbar.cpp | 2 +- src/widgets/desktop-widget.cpp | 8 +- src/widgets/gradient-vector.cpp | 11 +-- src/widgets/select-toolbar.cpp | 2 +- src/widgets/sp-widget.cpp | 110 +++++++++++--------------- src/widgets/sp-widget.h | 7 +- src/widgets/stroke-marker-selector.cpp | 2 +- 69 files changed, 286 insertions(+), 306 deletions(-) (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index 080ff2e21..a47dce1b3 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -403,7 +403,7 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta snap_pts[3] = diag2.closest_to (pt); } - gdouble const zoom = INKSCAPE->active_desktop()->current_zoom(); + gdouble const zoom = INKSCAPE.active_desktop()->current_zoom(); // determine the distances to all potential snapping points double snap_dists[MAX_POINT_COUNT]; diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index cb72f65dc..cbc8faf7c 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -87,7 +87,7 @@ void SPAvoidRef::setAvoid(char const *value) void SPAvoidRef::handleSettingChange(void) { - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); if (desktop == NULL) { return; } @@ -277,7 +277,7 @@ static std::vector approxItemWithPoints(SPItem const *item, const G } static Avoid::Polygon avoid_item_poly(SPItem const *item) { - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); g_assert(desktop != NULL); double spacing = desktop->namedview->connector_spacing; diff --git a/src/desktop.cpp b/src/desktop.cpp index 935567462..542f1618b 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -93,28 +93,28 @@ static void _reconstruction_finish(SPDesktop * desktop); static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop); SPDesktop::SPDesktop() : - _dlg_mgr( 0 ), - namedview( 0 ), - canvas( 0 ), - layers( 0 ), - selection( 0 ), - event_context( 0 ), - layer_manager( 0 ), - event_log( 0 ), - temporary_item_list( 0 ), - snapindicator( 0 ), - acetate( 0 ), - main( 0 ), - gridgroup( 0 ), - guides( 0 ), - drawing( 0 ), - sketch( 0 ), - controls( 0 ), - tempgroup ( 0 ), - table( 0 ), - page( 0 ), - page_border( 0 ), - current( 0 ), + _dlg_mgr( NULL ), + namedview( NULL ), + canvas( NULL ), + layers( NULL ), + selection( NULL ), + event_context( NULL ), + layer_manager( NULL ), + event_log( NULL ), + temporary_item_list( NULL ), + snapindicator( NULL ), + acetate( NULL ), + main( NULL ), + gridgroup( NULL ), + guides( NULL ), + drawing( NULL ), + sketch( NULL ), + controls( NULL ), + tempgroup ( NULL ), + table( NULL ), + page( NULL ), + page_border( NULL ), + current( NULL ), _focusMode(false), dkey( 0 ), number( 0 ), @@ -123,16 +123,15 @@ SPDesktop::SPDesktop() : waiting_cursor( false ), showing_dialogs ( false ), guides_active( false ), - gr_item( 0 ), + gr_item( NULL ), gr_point_type( POINT_LG_BEGIN ), gr_point_i( 0 ), gr_fill_or_stroke( Inkscape::FOR_FILL ), _reconstruction_old_layer_id(), // an id attribute is not allowed to be the empty string _display_mode(Inkscape::RENDERMODE_NORMAL), _display_color_mode(Inkscape::COLORMODE_NORMAL), - _widget( 0 ), - _inkscape( 0 ), - _guides_message_context( 0 ), + _widget( NULL ), + _guides_message_context( NULL ), _active( false ), _w2d(), _d2w(), @@ -298,7 +297,6 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid // ? // sp_active_desktop_set (desktop); - _inkscape = INKSCAPE; _activate_connection = _activate_signal.connect( sigc::bind( @@ -384,10 +382,6 @@ void SPDesktop::destroy() layer_manager = NULL; } - if (_inkscape) { - _inkscape = NULL; - } - if (drawing) { doc()->getRoot()->invoke_hide(dkey); g_object_unref(drawing); @@ -1430,7 +1424,7 @@ void SPDesktop::emitToolSubselectionChanged(gpointer data) { _tool_subselection_changed.emit(data); - INKSCAPE->subselection_changed (this); + INKSCAPE.subselection_changed (this); } void SPDesktop::updateNow() diff --git a/src/desktop.h b/src/desktop.h index ec240dd40..2c0275b51 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -73,7 +73,6 @@ struct _GdkEventWindowState; typedef struct _GdkEventWindowState GdkEventWindowState; namespace Inkscape { - struct Application; class LayerModel; class MessageContext; class Selection; @@ -423,7 +422,6 @@ public: private: Inkscape::UI::View::EditWidgetInterface *_widget; - Inkscape::Application *_inkscape; Inkscape::MessageContext *_guides_message_context; bool _active; Geom::Affine _w2d; diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp index 01213f1c7..c1d096197 100644 --- a/src/dialogs/dialog-events.cpp +++ b/src/dialogs/dialog-events.cpp @@ -183,12 +183,11 @@ void sp_transientize(GtkWidget *dialog) void on_transientize (SPDesktop *desktop, win_data *wd ) { - sp_transientize_callback (0, desktop, wd); + sp_transientize_callback (desktop, wd); } void -sp_transientize_callback ( Inkscape::Application * /*inkscape*/, - SPDesktop *desktop, win_data *wd ) +sp_transientize_callback ( SPDesktop *desktop, win_data *wd ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint transient_policy = prefs->getIntLimited( "/options/transientpolicy/value", 1, 0, 2); diff --git a/src/dialogs/dialog-events.h b/src/dialogs/dialog-events.h index 5320685b2..b4a5d7c35 100644 --- a/src/dialogs/dialog-events.h +++ b/src/dialogs/dialog-events.h @@ -28,10 +28,6 @@ class Entry; } class SPDesktop; - -namespace Inkscape { -struct Application; -} // namespace Inkscape typedef struct { GtkWidget *win; @@ -55,14 +51,14 @@ void sp_transientize ( GtkWidget *win ); void on_transientize ( SPDesktop *desktop, win_data *wd ); -void sp_transientize_callback ( Inkscape::Application *inkscape, - SPDesktop *desktop, +void sp_transientize_callback ( SPDesktop *desktop, win_data *wd ); void on_dialog_hide (GtkWidget *w); void on_dialog_unhide (GtkWidget *w); -gboolean sp_dialog_hide (GObject *object, gpointer data); -gboolean sp_dialog_unhide (GObject *object, gpointer data); + +//gboolean sp_dialog_hide (GObject *object, gpointer data); +//gboolean sp_dialog_unhide (GObject *object, gpointer data); #endif diff --git a/src/document-undo.cpp b/src/document-undo.cpp index a40b2fb81..0bce4420a 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -270,7 +270,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) doc->priv->seeking = false; if (ret) - INKSCAPE->external_change(); + INKSCAPE.external_change(); return ret; } @@ -315,7 +315,7 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) doc->priv->seeking = false; if (ret) - INKSCAPE->external_change(); + INKSCAPE.external_change(); return ret; } diff --git a/src/document-undo.h b/src/document-undo.h index 8333e715a..2236626c8 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -12,8 +12,6 @@ class SPDocument; namespace Inkscape { -struct Application; - class DocumentUndo { public: diff --git a/src/document.cpp b/src/document.cpp index 000888772..c38cfa4ae 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -462,11 +462,11 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, DocumentUndo::setUndoSensitive(document, true); // reset undo key when selection changes, so that same-key actions on different objects are not coalesced - document->priv->selChangeConnection = INKSCAPE->signal_selection_changed.connect( + document->priv->selChangeConnection = INKSCAPE.signal_selection_changed.connect( sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) )); - document->priv->desktopActivatedConnection = INKSCAPE->signal_activate_desktop.connect( + document->priv->desktopActivatedConnection = INKSCAPE.signal_activate_desktop.connect( sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) )); diff --git a/src/document.h b/src/document.h index ee903449d..7574e1bda 100644 --- a/src/document.h +++ b/src/document.h @@ -38,7 +38,6 @@ class SPGroup; class SPRoot; namespace Inkscape { - struct Application; class Selection; class UndoStackObserver; class EventLog; diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index c68845d8a..c8f3b2ff9 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -89,11 +89,13 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * } // children of "inkscape-extension" } // if we have an XML file - if (INKSCAPE != NULL && INKSCAPE->use_gui()) { + // \TODO this gets called from the Inkscape::Application constructor, where it initializes the menus. + // But in the constructor, our object isn't quite there yet! + if (Inkscape::Application::exists() && INKSCAPE.use_gui()) { if (_effects_list == NULL) - _effects_list = find_menu(INKSCAPE->get_menus(), EFFECTS_LIST); + _effects_list = find_menu(INKSCAPE.get_menus(), EFFECTS_LIST); if (_filters_list == NULL) - _filters_list = find_menu(INKSCAPE->get_menus(), FILTERS_LIST); + _filters_list = find_menu(INKSCAPE.get_menus(), FILTERS_LIST); } if ((_effects_list != NULL || _filters_list != NULL)) { diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index bacb126ef..976cf42fc 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -1031,7 +1031,7 @@ int Script::execute (const std::list &in_command, Glib::ustring stderr_data = fileerr.string(); if (stderr_data.length() != 0 && - INKSCAPE->use_gui() + INKSCAPE.use_gui() ) { checkStderr(stderr_data, Gtk::MESSAGE_INFO, _("Inkscape has received additional data from the script executed. " diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index 6048c232c..ffbfcc5e5 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -237,7 +237,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // If only one page is present, import that one without bothering user if (tmpSVGOutput.size() > 1) { CdrImportDialog *dlg = 0; - if (INKSCAPE->use_gui()) { + if (INKSCAPE.use_gui()) { dlg = new CdrImportDialog(tmpSVGOutput); if (!dlg->showDialog()) { delete dlg; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index fbb8b0793..bcaa8712f 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -696,7 +696,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { } PdfImportDialog *dlg = NULL; - if (INKSCAPE->use_gui()) { + if (INKSCAPE.use_gui()) { dlg = new PdfImportDialog(pdf_doc, uri); if (!dlg->showDialog()) { _cancelled = true; diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 6b435746b..ab51bbd73 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -236,7 +236,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // If only one page is present, import that one without bothering user if (tmpSVGOutput.size() > 1) { VsdImportDialog *dlg = 0; - if (INKSCAPE->use_gui()) { + if (INKSCAPE.use_gui()) { dlg = new VsdImportDialog(tmpSVGOutput); if (!dlg->showDialog()) { delete dlg; diff --git a/src/extension/system.cpp b/src/extension/system.cpp index e81ec0e42..651964912 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -121,7 +121,7 @@ SPDocument *open(Extension *key, gchar const *filename) } if (last_chance_svg) { - if ( INKSCAPE->use_gui() ) { + if ( INKSCAPE.use_gui() ) { sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG.")); } else { g_warning("%s", _("Format autodetect failed. The file is being opened as SVG.")); diff --git a/src/file.cpp b/src/file.cpp index 99bfcc77f..be2c8ff2c 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -314,7 +314,7 @@ bool sp_file_open(const Glib::ustring &uri, sp_file_add_recent( doc->getURI() ); } - if ( INKSCAPE->use_gui() ) { + if ( INKSCAPE.use_gui() ) { // Perform a fixup pass for hrefs. if ( Inkscape::ResourceManager::getManager().fixupBrokenLinks(doc) ) { Glib::ustring msg = _("Broken links have been changed to point to existing files."); diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 18159cb41..43b424f46 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -117,7 +117,7 @@ void graphlayout(GSList const *const items) { // add the connector spacing to the size of node bounding boxes // so that connectors can always be routed between shapes - SPDesktop* desktop = inkscape_active_desktop(); + SPDesktop* desktop = INKSCAPE.active_desktop(); double spacing = 0; if(desktop) spacing = desktop->namedview->connector_spacing+0.1; diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index a12fa377a..58a8a7dfc 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -195,7 +195,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) gchar * base = g_strndup(e, a); - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); SPDocument *doc = sp_desktop_document(desktop); SPDefs *defs = doc->getDefs(); if (!defs) { @@ -265,7 +265,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) else { - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); SPDocument *doc = sp_desktop_document(desktop); SPObject *object = doc->getObjectById(urn); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 89501c646..cca6918e2 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -81,7 +81,7 @@ Inkscape::Application * Inkscape::Application::_S_inst = NULL; bool Inkscape::Application::_crashIsHappening = false; -#define DESKTOP_IS_ACTIVE(d) (!INKSCAPE->_desktops->empty() && ((d) == INKSCAPE->_desktops->front())) +#define DESKTOP_IS_ACTIVE(d) (!INKSCAPE._desktops->empty() && ((d) == INKSCAPE._desktops->front())) static void (* segv_handler) (int) = SIG_DFL; static void (* abrt_handler) (int) = SIG_DFL; @@ -139,53 +139,77 @@ private: bool _useGui; }; -Inkscape::Application * inkscape_ref(Inkscape::Application * in) +void inkscape_ref(Inkscape::Application & in) { - g_return_val_if_fail(in != NULL, NULL); - - in->refCount++; - return in; + in.refCount++; } -Inkscape::Application * inkscape_unref(Inkscape::Application * in) +void inkscape_unref(Inkscape::Application & in) { - g_return_val_if_fail(in != NULL, NULL); - - in->refCount--; + in.refCount--; - if (in->refCount <= 0) { - delete in; + if (&in == Inkscape::Application::_S_inst) { + if (in.refCount <= 0) { + delete Inkscape::Application::_S_inst; + } + } else { + g_error("Attempt to unref an Application (=%p) not the current instance (=%p) (maybe it's already been destroyed?)", + &in, Inkscape::Application::_S_inst); } - - return NULL; } // Callback passed to g_timeout_add_seconds() // gets the current instance and calls autosave() int inkscape_autosave(gpointer) { - g_assert(INKSCAPE != NULL); - return INKSCAPE->autosave(); + g_assert(Inkscape::Application::exists()); + return INKSCAPE.autosave(); } namespace Inkscape { +/** + * Defined only for debugging purposes. If we are certain the bugs are gone we can remove this + * and the references in inkscape_ref and inkscape_unref. + */ +Application* +Application::operator &() const +{ + return const_cast(this); +} +/** + * Creates a new Inkscape::Application global object. + */ void Application::create(const char *argv0, bool use_gui) { - if (!Application::instance()) { + if (!Application::exists()) { new Application(argv0, use_gui); } else { g_assert_not_reached(); } } + +/** + * Checks whether the current Inkscape::Application global object exists. + */ +bool +Application::exists() +{ + return Application::_S_inst != NULL; +} + /** - * Returns the current Inkscape::Application global object + * Returns the current Inkscape::Application global object. + * \pre Application::_S_inst != NULL */ -Application * +Application& Application::instance() { - return Application::_S_inst; + if (!exists()) { + g_error("Inkscape::Application does not yet exist."); + } + return *Application::_S_inst; } /** @@ -469,6 +493,8 @@ Application::~Application() _argv0 = NULL; } + _S_inst = NULL; // this will probably break things + refCount = 0; gtk_main_quit (); } @@ -527,10 +553,10 @@ Application::crash_handler (int /*signum*/) gint count = 0; gchar *curdir = g_get_current_dir(); // This one needs to be freed explicitly - gchar *inkscapedir = g_path_get_dirname(INKSCAPE->_argv0); // Needs to be freed + gchar *inkscapedir = g_path_get_dirname(INKSCAPE._argv0); // Needs to be freed GSList *savednames = NULL; GSList *failednames = NULL; - for (std::map::iterator iter = INKSCAPE->_document_set.begin(), e = INKSCAPE->_document_set.end(); + for (std::map::iterator iter = INKSCAPE._document_set.begin(), e = INKSCAPE._document_set.end(); iter != e; ++iter) { SPDocument *doc = iter->first; @@ -672,7 +698,7 @@ Application::crash_handler (int /*signum*/) } *(b + pos) = '\0'; - if ( instance() && instance()->use_gui() ) { + if ( exists() && instance().use_gui() ) { GtkWidget *msgbox = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", b); gtk_dialog_run (GTK_DIALOG (msgbox)); gtk_widget_destroy (msgbox); @@ -1190,8 +1216,8 @@ Application::homedir_path(const char *filename) homedir = g_get_home_dir(); } if (!homedir) { - if (Application::instance()) { - homedir = g_path_get_dirname(Application::instance()->_argv0); + if (Application::exists()) { + homedir = g_path_get_dirname(Application::instance()._argv0); } } return g_build_filename(homedir, filename, NULL); diff --git a/src/inkscape.h b/src/inkscape.h index 966b6ee87..fe424377c 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -45,17 +45,13 @@ struct Document; } // namespace Inkscape -Inkscape::Application * inkscape_ref (Inkscape::Application * in); -Inkscape::Application * inkscape_unref(Inkscape::Application * in); +void inkscape_ref (Inkscape::Application & in); +void inkscape_unref(Inkscape::Application & in); #define INKSCAPE (Inkscape::Application::instance()) -#define SP_INKSCAPE(obj) (dynamic_cast(obj)) -#define SP_IS_INKSCAPE(obj) (dynamic_cast (obj) != NULL) -#define SP_ACTIVE_EVENTCONTEXT (INKSCAPE->active_event_context()) -#define SP_ACTIVE_DOCUMENT (INKSCAPE->active_document()) -#define SP_ACTIVE_DESKTOP (INKSCAPE->active_desktop()) -// \TODO hack -#define inkscape_active_desktop() SP_ACTIVE_DESKTOP +#define SP_ACTIVE_EVENTCONTEXT (INKSCAPE.active_event_context()) +#define SP_ACTIVE_DOCUMENT (INKSCAPE.active_document()) +#define SP_ACTIVE_DESKTOP (INKSCAPE.active_desktop()) class AppSelectionModel { Inkscape::LayerModel _layer_model; @@ -77,7 +73,8 @@ namespace Inkscape { class Application { public: - static Application* instance(); + static Application& instance(); + static bool exists(); static void create(const char* argv0, bool use_gui); // returns the mask of the keyboard modifier to map to Alt, zero if no mapping @@ -110,8 +107,6 @@ public: bool save_menus(); Inkscape::XML::Node * get_menus(); - //static Inkscape::Application* get_instance(); - Inkscape::UI::Tools::ToolBase * active_event_context(); SPDocument * active_document(); SPDesktop * active_desktop(); @@ -166,8 +161,8 @@ public: int autosave(); // nobody should be accessing our reference count, so it's made private. - friend Application * ::inkscape_ref (Application * in); - friend Application * ::inkscape_unref(Application * in); + friend void ::inkscape_ref (Application & in); + friend void ::inkscape_unref(Application & in); // signals @@ -206,6 +201,10 @@ private: Application(const char* argv0, bool use_gui); ~Application(); + Application(Application const&); // no copy + Application& operator=(Application const&); // no assign + Application* operator&() const; // no pointer access + Inkscape::XML::Document * _menus; std::map _document_set; std::map _selection_models; diff --git a/src/inkview.cpp b/src/inkview.cpp index 721b4784f..a44d755eb 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -62,8 +62,6 @@ #include "inkscape.h" -Inkscape::Application *inkscape; - #include #ifndef HAVE_BIND_TEXTDOMAIN_CODESET @@ -233,7 +231,7 @@ main (int argc, const char **argv) ss.fullscreen = false; Inkscape::Application::create(argv[0], true); - inkscape = Inkscape::Application::instance(); + //Inkscape::Application &inkscape = Inkscape::Application::instance(); // starting at where the commandline options stopped parsing because // we want all the files to be in the list @@ -571,7 +569,7 @@ static void usage() exit(1); } -#ifdef XXX +#if 0 /* TODO !!! make this temporary stub unnecessary */ Inkscape::Application *inkscape_get_instance() { return NULL; } void inkscape_ref (void) {} diff --git a/src/interface.cpp b/src/interface.cpp index 7fd2b6275..85cdbaf84 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -270,7 +270,7 @@ sp_create_window(SPViewWidget *vw, gboolean editable) // needed because the first ACTIVATE_DESKTOP was sent when there was no window yet if ( SP_IS_DESKTOP_WIDGET(vw) ) { - INKSCAPE->reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop); + INKSCAPE.reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop); } } @@ -318,7 +318,7 @@ sp_ui_close_view(GtkWidget */*widget*/) // If closing the last document, open a new document so Inkscape doesn't quit. std::list desktops; - INKSCAPE->get_all_desktops(desktops); + INKSCAPE.get_all_desktops(desktops); if (desktops.size() == 1) { Glib::ustring templateUri = sp_file_default_template_uri(); SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true ); @@ -921,7 +921,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I GtkWidget *sp_ui_main_menubar(Inkscape::UI::View::View *view) { GtkWidget *mbar = gtk_menu_bar_new(); - sp_ui_build_dyn_menus(INKSCAPE->get_menus(), mbar, view); + sp_ui_build_dyn_menus(INKSCAPE.get_menus(), mbar, view); return mbar; } @@ -2106,13 +2106,13 @@ void ContextMenu::ImageEdit(void) void ContextMenu::ImageTraceBitmap(void) { - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); _desktop->_dlg_mgr->showDialog("Trace"); } void ContextMenu::ImageTracePixelArt(void) { - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); _desktop->_dlg_mgr->showDialog("PixelArt"); } diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index 566af8840..fe279ae19 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -201,7 +201,7 @@ boost::optional Line::intersection_with_viewbox (SPDesktop *desktop void create_canvas_point(Geom::Point const &pos, double size, guint32 rgba) { - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); SPCanvasItem * canvas_pt = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRL, "size", size, "filled", 1, @@ -214,7 +214,7 @@ void create_canvas_point(Geom::Point const &pos, double size, guint32 rgba) void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba) { - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); SPCtrlLine *line = ControlManager::getManager().createControlLine(sp_desktop_controls(desktop), p1, p2); line->setRgba32(rgba); sp_canvas_item_show(line); diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index d0a168a14..e622ca420 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -356,7 +356,7 @@ void Effect::doAcceptPathPreparations(SPLPEItem *lpeitem) { // switch to pen context - SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? + SPDesktop *desktop = INKSCAPE.active_desktop(); // TODO: Is there a better method to find the item's desktop? if (!tools_isactive(desktop, TOOLS_FREEHAND_PEN)) { tools_switch(desktop, TOOLS_FREEHAND_PEN); } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index b19b697c0..247496167 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -392,7 +392,7 @@ void LPEBSpline::toMakeCusp(Gtk::Widget *widgWeight) { void LPEBSpline::toWeight() { changeWeight(weight); } void LPEBSpline::changeWeight(double weightValue) { - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); Inkscape::Selection *selection = sp_desktop_selection(desktop); GSList *items = (GSList *)selection->itemList(); SPItem *item = (SPItem *)g_slist_nth(items, 0)->data; @@ -432,7 +432,7 @@ bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint) { void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { using Geom::X; using Geom::Y; - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); if (INK_IS_NODE_TOOL(desktop->event_context)) { Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); Inkscape::UI::ControlPointSelection::Set &selection = diff --git a/src/live_effects/lpe-envelope-perspective.cpp b/src/live_effects/lpe-envelope-perspective.cpp index bfd6e56d7..a16ed7ab5 100644 --- a/src/live_effects/lpe-envelope-perspective.cpp +++ b/src/live_effects/lpe-envelope-perspective.cpp @@ -352,7 +352,7 @@ LPEEnvelopePerspective::resetGrid() Down_Left_Point.param_set_and_write_default(); //todo:this hack is only to reposition the knots on reser grid button //Better update path effect in LPEITEM - SPDesktop * desktop = inkscape_active_desktop(); + SPDesktop * desktop = INKSCAPE.active_desktop(); tools_switch(desktop, TOOLS_SELECT); tools_switch(desktop, TOOLS_NODES); } diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index db609c9e1..13759f126 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -391,7 +391,7 @@ LPELattice2::resetGrid() grid_point32x33x34x35.param_set_and_write_default(); //todo:this hack is only to reposition the knots on reser grid button //Better update path effect in LPEITEM - SPDesktop * desktop = inkscape_active_desktop(); + SPDesktop * desktop = INKSCAPE.active_desktop(); tools_switch(desktop, TOOLS_SELECT); tools_switch(desktop, TOOLS_NODES); } diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index fcb2fc9fc..88fc27abd 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -32,7 +32,7 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, value(default_value), defvalue(default_value) { - SPDesktop *desktop = inkscape_active_desktop(); // FIXME: we shouldn't use this! + SPDesktop *desktop = INKSCAPE.active_desktop(); // FIXME: we shouldn't use this! canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), ""); sp_canvastext_set_text (canvas_text, default_value.c_str()); sp_canvastext_set_coords (canvas_text, 0, 0); diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index 9da7f6a79..216953f4f 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -82,7 +82,7 @@ CmdLineAction::doList (ActionContext const & context) { bool CmdLineAction::idle (void) { std::list desktops; - INKSCAPE->get_all_desktops(desktops); + INKSCAPE.get_all_desktops(desktops); // We're going to assume one desktop per document, because no one // should have had time to make more at this point. diff --git a/src/main.cpp b/src/main.cpp index 2e36e3d50..e57231d17 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -933,9 +933,9 @@ guint get_group0_keyval(GdkEventKey const* event); static void snooper(GdkEvent *event, gpointer /*data*/) { - if (INKSCAPE->mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */ + if (INKSCAPE.mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */ { - GdkModifierType mapping=(GdkModifierType)INKSCAPE->mapalt(); + GdkModifierType mapping=(GdkModifierType)INKSCAPE.mapalt(); switch (event->type) { case GDK_MOTION_NOTIFY: if(event->motion.state & mapping) { @@ -957,7 +957,7 @@ snooper(GdkEvent *event, gpointer /*data*/) { } } - if (INKSCAPE->trackalt()) { + if (INKSCAPE.trackalt()) { // MacOS X with X11 has some problem with the default // xmodmapping. A ~/.xmodmap solution does not work reliably due // to the way we package our executable in a .app that can launch @@ -1125,14 +1125,14 @@ static int sp_process_file_list(GSList *fl) retVal++; } else { - INKSCAPE->add_document(doc); + INKSCAPE.add_document(doc); if (sp_vacuum_defs) { doc->vacuumDocument(); } // Execute command-line actions (selections and verbs) using our local models - bool has_performed_actions = Inkscape::CmdLineAction::doList(INKSCAPE->active_action_context()); + bool has_performed_actions = Inkscape::CmdLineAction::doList(INKSCAPE.active_action_context()); #ifdef WITH_DBUS // If we've been asked to listen for D-Bus messages, enter a main loop here @@ -1221,7 +1221,7 @@ static int sp_process_file_list(GSList *fl) do_query_dimension (doc, false, sp_query_x? Geom::X : Geom::Y, sp_query_id); } - INKSCAPE->remove_document(doc); + INKSCAPE.remove_document(doc); delete doc; } diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 1088f098d..7abfd0782 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -140,7 +140,7 @@ void Persp3D::set(unsigned key, gchar const *value) { } // FIXME: Is this the right place for resetting the draggers? - Inkscape::UI::Tools::ToolBase *ec = INKSCAPE->active_event_context(); + Inkscape::UI::Tools::ToolBase *ec = INKSCAPE.active_event_context(); if (SP_IS_BOX3D_CONTEXT(ec)) { Inkscape::UI::Tools::Box3dTool *bc = SP_BOX3D_CONTEXT(ec); bc->_vpdrag->updateDraggers(); @@ -289,7 +289,7 @@ persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo) { persp3d_update_box_reprs (persp); persp->updateRepr(SP_OBJECT_WRITE_EXT); if (set_undo) { - DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, + DocumentUndo::done(sp_desktop_document(INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Toggle vanishing point")); } } @@ -300,7 +300,7 @@ persp3d_toggle_VPs (std::list p, Proj::Axis axis) { for (std::list::iterator i = p.begin(); i != p.end(); ++i) { persp3d_toggle_VP((*i), axis, false); } - DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, + DocumentUndo::done(sp_desktop_document(INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Toggle multiple vanishing points")); } @@ -527,7 +527,7 @@ persp3d_print_all_selected() { g_print ("\n======================================\n"); g_print ("Selected perspectives and their boxes:\n"); - std::list sel_persps = sp_desktop_selection(inkscape_active_desktop())->perspList(); + std::list sel_persps = sp_desktop_selection(INKSCAPE.active_desktop())->perspList(); for (std::list::iterator j = sel_persps.begin(); j != sel_persps.end(); ++j) { Persp3D *persp = SP_PERSP3D(*j); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index ec5bc659c..1ee75e381 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3512,7 +3512,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) directory = g_path_get_dirname( document->getURI() ); } if (directory == NULL) { - directory = INKSCAPE->homedir_path(NULL); + directory = INKSCAPE.homedir_path(NULL); } gchar *filepath = g_build_filename(directory, basename, NULL); g_free(directory); diff --git a/src/selection.cpp b/src/selection.cpp index 48f6e2414..81139d044 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -89,7 +89,7 @@ Selection::_emit_modified(Selection *selection) } void Selection::_emitModified(guint flags) { - INKSCAPE->selection_modified(this, flags); + INKSCAPE.selection_modified(this, flags); _modified_signal.emit(this, flags); } @@ -104,7 +104,7 @@ void Selection::_emitChanged(bool persist_selection_context/* = false */) { _releaseContext(_selection_context); } - INKSCAPE->selection_changed(this); + INKSCAPE.selection_changed(this); _changed_signal.emit(this); } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index b10aae1c6..0f068a914 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -899,7 +899,7 @@ void SPItem::getSnappoints(std::vector &p, Inkscap clips_and_masks.push_back(clip_ref->getObject()); clips_and_masks.push_back(mask_ref->getObject()); - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); for (std::list::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); ++o) { if (*o) { // obj is a group object, the children are the actual clippers @@ -1495,7 +1495,7 @@ Geom::Affine SPItem::i2doc_affine() const Geom::Affine SPItem::i2dt_affine() const { Geom::Affine ret; - SPDesktop const *desktop = inkscape_active_desktop(); + SPDesktop const *desktop = INKSCAPE.active_desktop(); if ( desktop ) { ret = i2doc_affine() * desktop->doc2dt(); } else { @@ -1513,7 +1513,7 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) if (parent) { dt2p = static_cast(parent)->i2dt_affine().inverse(); } else { - SPDesktop *dt = inkscape_active_desktop(); + SPDesktop *dt = INKSCAPE.active_desktop(); dt2p = dt->dt2doc(); } diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index 357fe440c..a3e117dfa 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -153,7 +153,7 @@ tools_switch(SPDesktop *dt, int num) /* fixme: This is really ugly hack. We should bind and unbind class methods */ /* First 4 tools use guides, first is undefined but we don't care */ dt->activate_guides(num < 5); - INKSCAPE->eventcontext_set(dt->getEventContext()); + INKSCAPE.eventcontext_set(dt->getEventContext()); } void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p) diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 4fd2f0f9c..dbb7c1244 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1044,10 +1044,10 @@ AlignAndDistribute::AlignAndDistribute() contents->pack_start(_nodesFrame, true, true); //Connect to the global tool change signal - _toolChangeConn = INKSCAPE->signal_eventcontext_set.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this))); + _toolChangeConn = INKSCAPE.signal_eventcontext_set.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this))); // Connect to the global selection change, to invalidate cached randomize_bbox - _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); + _selChangeConn = INKSCAPE.signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this))); randomize_bbox = Geom::OptRect(); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &AlignAndDistribute::setDesktop) ); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 84ef0b5b0..a435c5583 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1269,8 +1269,8 @@ CloneTiler::CloneTiler () : // connect to global selection changed signal (so we can change desktops) and // external_change (so we're not fooled by undo) - selectChangedConn = INKSCAPE->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg)); - externChangedConn = INKSCAPE->signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg)); + selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg)); + externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg)); g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this); diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 5eb9ea054..0659de67b 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -40,7 +40,7 @@ void DesktopTracker::connect(GtkWidget *widget) // Use C/gobject callbacks to avoid gtkmm rewrap-during-destruct issues: hierID = g_signal_connect( G_OBJECT(widget), "hierarchy-changed", G_CALLBACK(hierarchyChangeCB), this ); - inkID = INKSCAPE->signal_activate_desktop.connect( + inkID = INKSCAPE.signal_activate_desktop.connect( sigc::bind( sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this) ); diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h index a58666c0d..28f9243c8 100644 --- a/src/ui/dialog/desktop-tracker.h +++ b/src/ui/dialog/desktop-tracker.h @@ -15,8 +15,6 @@ class SPDesktop; namespace Inkscape { -struct Application; - namespace UI { namespace Dialog { diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 72ca117f7..70f9c6a70 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -73,10 +73,10 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat _behavior = behavior_factory(*this); _desktop = SP_ACTIVE_DESKTOP; - INKSCAPE->signal_activate_desktop.connect(sigc::mem_fun(*this, &Dialog::onDesktopActivated)); - INKSCAPE->signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dialog::onHideF12)); - INKSCAPE->signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dialog::onShowF12)); - INKSCAPE->signal_shut_down.connect(sigc::mem_fun(*this, &Dialog::onShutdown)); + INKSCAPE.signal_activate_desktop.connect(sigc::mem_fun(*this, &Dialog::onDesktopActivated)); + INKSCAPE.signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dialog::onHideF12)); + INKSCAPE.signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dialog::onShowF12)); + INKSCAPE.signal_shut_down.connect(sigc::mem_fun(*this, &Dialog::onShutdown)); Glib::wrap(gobj())->signal_event().connect(sigc::mem_fun(*this, &Dialog::_onEvent)); Glib::wrap(gobj())->signal_key_press_event().connect(sigc::mem_fun(*this, &Dialog::_onKeyPress)); diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h index ec5d203bc..90501550b 100644 --- a/src/ui/dialog/dialog.h +++ b/src/ui/dialog/dialog.h @@ -21,7 +21,6 @@ class SPDesktop; namespace Inkscape { class Selection; -struct Application; } namespace Inkscape { @@ -30,7 +29,6 @@ namespace Dialog { enum BehaviorType { FLOATING, DOCK }; -void sp_retransientize(Inkscape::Application *inkscape, SPDesktop *desktop, gpointer dlgPtr); gboolean sp_retransientize_again(gpointer dlgPtr); void sp_dialog_shutdown(GObject *object, gpointer dlgPtr); diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 09c505860..820d5a8bb 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -223,7 +223,7 @@ DocumentMetadata::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *) } void -DocumentMetadata::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop) +DocumentMetadata::_handleActivateDesktop(SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); @@ -231,7 +231,7 @@ DocumentMetadata::_handleActivateDesktop(Inkscape::Application *, SPDesktop *des } void -DocumentMetadata::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop) +DocumentMetadata::_handleDeactivateDesktop(SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->removeListenerByData(this); diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h index 3b7ed1ec8..cde5d92fd 100644 --- a/src/ui/dialog/document-metadata.h +++ b/src/ui/dialog/document-metadata.h @@ -28,6 +28,7 @@ # include #endif +#include "inkscape.h" #include "ui/widget/licensor.h" #include "ui/widget/registry.h" @@ -56,8 +57,8 @@ protected: void init(); void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); - void _handleActivateDesktop(Inkscape::Application *application, SPDesktop *desktop); - void _handleDeactivateDesktop(Inkscape::Application *application, SPDesktop *desktop); + void _handleActivateDesktop(SPDesktop *desktop); + void _handleDeactivateDesktop(SPDesktop *desktop); Gtk::Notebook _notebook; diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 2674efc1e..ce3b1314c 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1592,7 +1592,7 @@ void DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument update(); } -void DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop) +void DocumentProperties::_handleActivateDesktop(SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); @@ -1601,7 +1601,7 @@ void DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDeskt update(); } -void DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop) +void DocumentProperties::_handleDeactivateDesktop(SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->removeListenerByData(this); diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 495f3177d..b1f90b4b7 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -94,8 +94,8 @@ protected: void save_default_metadata(); void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); - void _handleActivateDesktop(Inkscape::Application *application, SPDesktop *desktop); - void _handleDeactivateDesktop(Inkscape::Application *application, SPDesktop *desktop); + void _handleActivateDesktop(SPDesktop *desktop); + void _handleDeactivateDesktop(SPDesktop *desktop); Inkscape::XML::SignalObserver _emb_profiles_observer, _scripts_observer; Gtk::Notebook _notebook; diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 579b6aec7..7ce9fe2ec 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -588,7 +588,7 @@ Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ust } if (directory.empty()) { - directory = INKSCAPE->homedir_path(NULL); + directory = INKSCAPE.homedir_path(NULL); } Glib::ustring filename = Glib::build_filename(directory, id+".png"); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 014c85bd7..2abe78e49 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -538,7 +538,8 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) SVGPreview::SVGPreview() { - if (!INKSCAPE) + // \FIXME Why?!!?? + if (!Inkscape::Application::exists()) Inkscape::Application::create("", false); document = NULL; viewerGtk = NULL; diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index 340cb860f..f2a6bf39d 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -41,8 +41,7 @@ public: virtual void setDesktop(SPDesktop *desktop); - void selectionChanged(Inkscape::Application *inkscape, - Inkscape::Selection *selection); + //void selectionChanged(Inkscape::Selection *selection); void showPageFill(); void showPageStrokePaint(); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index f7c035ebe..2ff647a74 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -594,7 +594,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) { // Selection Change signal - INKSCAPE->signal_selection_changed.connect(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection))); + INKSCAPE.signal_selection_changed.connect(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection))); } Gtk::Box *contents = this; diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h index b3beb73c6..39110f47a 100644 --- a/src/ui/dialog/panel-dialog.h +++ b/src/ui/dialog/panel-dialog.h @@ -51,8 +51,8 @@ public: protected: inline virtual void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document); - inline virtual void _propagateDesktopActivated(Inkscape::Application *, SPDesktop *); - inline virtual void _propagateDesktopDeactivated(Inkscape::Application *, SPDesktop *); + inline virtual void _propagateDesktopActivated(SPDesktop *); + inline virtual void _propagateDesktopDeactivated(SPDesktop *); UI::Widget::Panel &_panel; sigc::connection _document_replaced_connection; @@ -125,17 +125,17 @@ void PanelDialogBase::_propagateDocumentReplaced(SPDesktop *desktop, SPDocument _panel.signalDocumentReplaced().emit(desktop, document); } -void PanelDialogBase::_propagateDesktopActivated(Inkscape::Application *application, SPDesktop *desktop) +void PanelDialogBase::_propagateDesktopActivated(SPDesktop *desktop) { _document_replaced_connection = desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialogBase::_propagateDocumentReplaced)); - _panel.signalActivateDesktop().emit(application, desktop); + _panel.signalActivateDesktop().emit(desktop); } -void PanelDialogBase::_propagateDesktopDeactivated(Inkscape::Application *application, SPDesktop *desktop) +void PanelDialogBase::_propagateDesktopDeactivated(SPDesktop *desktop) { _document_replaced_connection.disconnect(); - _panel.signalDeactiveDesktop().emit(application, desktop); + _panel.signalDeactiveDesktop().emit(desktop); } @@ -153,7 +153,7 @@ PanelDialog::PanelDialog(Widget::Panel &panel, char const *prefs_path, int co SPDesktop *desktop = SP_ACTIVE_DESKTOP; - _propagateDesktopActivated(INKSCAPE, desktop); + _propagateDesktopActivated(desktop); _document_replaced_connection = desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced)); @@ -202,7 +202,7 @@ PanelDialog::PanelDialog(UI::Widget::Panel &panel, c SPDesktop *desktop = SP_ACTIVE_DESKTOP; - _propagateDesktopActivated(INKSCAPE, desktop); + _propagateDesktopActivated(desktop); _document_replaced_connection = desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced)); @@ -238,14 +238,12 @@ PanelDialog *PanelDialog new PanelDialog(panel, panel.getPrefsPath(), panel.getVerb(), panel.getApplyLabel()); - INKSCAPE->signal_activate_desktop.connect( - sigc::bind<0>( - sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopActivated), INKSCAPE - )); - INKSCAPE->signal_deactivate_desktop.connect( - sigc::bind<0>( - sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopDeactivated), INKSCAPE - )); + INKSCAPE.signal_activate_desktop.connect( + sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopActivated) + ); + INKSCAPE.signal_deactivate_desktop.connect( + sigc::mem_fun(*instance, &PanelDialog::_propagateDesktopDeactivated) + ); return instance; } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 0a35ee760..76532eb7e 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -275,7 +275,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; /**********************************************************/ - currentDesktop = inkscape_active_desktop(); + currentDesktop = INKSCAPE.active_desktop(); currentDocument = sp_desktop_document(currentDesktop); previewDocument = symbols_preview_doc(); /* Template to render symbols in */ diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index c36da373f..43f0e8683 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -156,8 +156,8 @@ Transformation::Transformation() } // Connect to the global selection changed & modified signals - _selChangeConn = INKSCAPE->signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)); - _selModifyConn = INKSCAPE->signal_selection_modified.connect(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this))); + _selChangeConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)); + _selModifyConn = INKSCAPE.signal_selection_modified.connect(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this))); _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) ); _deskTrack.connect(GTK_WIDGET(gobj())); diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index d1355e807..19759b733 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1304,7 +1304,7 @@ bool cc_item_is_connector(SPItem *item) void cc_selection_set_avoid(bool const set_avoid) { - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); if (desktop == NULL) { return; } diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index 2b5ff169d..47e2a1e0d 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -85,7 +85,7 @@ void View::_close() { if (_doc) { _document_uri_set_connection.disconnect(); _document_resized_connection.disconnect(); - if (INKSCAPE->remove_document(_doc)) { + if (INKSCAPE.remove_document(_doc)) { // this was the last view of this document, so delete it delete _doc; } @@ -111,13 +111,13 @@ void View::setDocument(SPDocument *doc) { if (_doc) { _document_uri_set_connection.disconnect(); _document_resized_connection.disconnect(); - if (INKSCAPE->remove_document(_doc)) { + if (INKSCAPE.remove_document(_doc)) { // this was the last view of this document, so delete it delete _doc; } } - INKSCAPE->add_document(doc); + INKSCAPE.add_document(doc); _doc = doc; _document_uri_set_connection = diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index f23e4bcca..c5e14d4f0 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -120,8 +120,8 @@ Dock::Dock(Gtk::Orientation orientation) gdl_dock_bar_set_style(_gdl_dock_bar, gdl_dock_bar_style); - INKSCAPE->signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dock::hide)); - INKSCAPE->signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dock::show)); + INKSCAPE.signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dock::hide)); + INKSCAPE.signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dock::show)); g_signal_connect(_paned->gobj(), "button-press-event", G_CALLBACK(_on_paned_button_event), (void *)this); g_signal_connect(_paned->gobj(), "button-release-event", G_CALLBACK(_on_paned_button_event), (void *)this); diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 8c1e44434..df261b69a 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -89,7 +89,7 @@ ImageIcon::~ImageIcon() void ImageIcon::init() { // \FIXME Why? - if (!INKSCAPE) + if (!Inkscape::Application::exists()) Inkscape::Application::create("", false); document = NULL; viewerGtkmm = NULL; diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index 19a6cb2a5..26d83fdc3 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -32,7 +32,6 @@ class SPDesktop; namespace Inkscape { -struct Application; namespace UI { namespace Widget { @@ -66,8 +65,8 @@ private: gulong _desktop_activated; sigc::connection _subject_changed; - static void _on_desktop_activate(Inkscape::Application *application, SPDesktop *desktop, ObjectCompositeSettings *w); - static void _on_desktop_deactivate(Inkscape::Application *application, SPDesktop *desktop, ObjectCompositeSettings *w); + static void _on_desktop_activate(SPDesktop *desktop, ObjectCompositeSettings *w); + static void _on_desktop_deactivate(SPDesktop *desktop, ObjectCompositeSettings *w); void _subjectChanged(); void _blendBlurValueChanged(); void _opacityValueChanged(); diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index b37137228..c96eac838 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -293,7 +293,7 @@ void Panel::_init() signalResponse().connect(sigc::mem_fun(*this, &Panel::_handleResponse)); - signalActivateDesktop().connect(sigc::hide<0>(sigc::mem_fun(*this, &Panel::setDesktop))); + signalActivateDesktop().connect(sigc::mem_fun(*this, &Panel::setDesktop)); show_all_children(); @@ -643,13 +643,13 @@ Panel::signalDocumentReplaced() return _signal_document_replaced; } -sigc::signal & +sigc::signal & Panel::signalActivateDesktop() { return _signal_activate_desktop; } -sigc::signal & +sigc::signal & Panel::signalDeactiveDesktop() { return _signal_deactive_desktop; diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 0c3d822b8..b9466e07a 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -47,7 +47,6 @@ namespace Gtk { namespace Inkscape { -struct Application; class Selection; namespace UI { @@ -116,8 +115,8 @@ public: void setResponseSensitive(int response_id, bool setting); virtual sigc::signal &signalDocumentReplaced(); - virtual sigc::signal &signalActivateDesktop(); - virtual sigc::signal &signalDeactiveDesktop(); + virtual sigc::signal &signalActivateDesktop(); + virtual sigc::signal &signalDeactiveDesktop(); protected: /** @@ -147,8 +146,8 @@ protected: sigc::signal _signal_response; sigc::signal _signal_present; sigc::signal _signal_document_replaced; - sigc::signal _signal_activate_desktop; - sigc::signal _signal_deactive_desktop; + sigc::signal _signal_activate_desktop; + sigc::signal _signal_deactive_desktop; private: void _init(); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 66e699b41..41f8dfe7d 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -93,7 +93,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g Geom::Point p = ppointer; // FIXME: take from prefs - double snap_dist = SNAP_DIST / inkscape_active_desktop()->current_zoom(); + double snap_dist = SNAP_DIST / INKSCAPE.active_desktop()->current_zoom(); /* * We use dragging_started to indicate if we have already checked for the need to split Draggers up. @@ -109,7 +109,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g for (std::set::iterator vp = sel_vps.begin(); vp != sel_vps.end(); ++vp) { // for each VP that has selected boxes: Persp3D *old_persp = (*vp)->get_perspective(); - sel_boxes = (*vp)->selectedBoxes(sp_desktop_selection(inkscape_active_desktop())); + sel_boxes = (*vp)->selectedBoxes(sp_desktop_selection(INKSCAPE.active_desktop())); // we create a new perspective ... Persp3D *new_persp = persp3d_create_xml_element (dragger->parent->document, old_persp->perspective_impl); @@ -128,7 +128,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g } // FIXME: Do we need to create a new dragger as well? dragger->updateZOrders (); - DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, + DocumentUndo::done(sp_desktop_document (INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Split vanishing points")); return; } @@ -173,7 +173,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g // deleted according to changes in the svg representation, not based on any user input // as is currently the case. - DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, + DocumentUndo::done(sp_desktop_document (INKSCAPE.active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Merge vanishing points")); return; @@ -181,7 +181,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g } // We didn't snap to another dragger, so we'll try a regular snap - SPDesktop *desktop = inkscape_active_desktop(); + SPDesktop *desktop = INKSCAPE.active_desktop(); SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); @@ -277,7 +277,7 @@ VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp) if (vp.is_finite()) { // create the knot - this->knot = new SPKnot(inkscape_active_desktop(), NULL); + this->knot = new SPKnot(INKSCAPE.active_desktop(), NULL); this->knot->setMode(SP_KNOT_MODE_XOR); this->knot->setFill(VP_KNOT_COLOR_NORMAL, VP_KNOT_COLOR_NORMAL, VP_KNOT_COLOR_NORMAL); this->knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff); @@ -394,7 +394,7 @@ VPDragger::VPsOfSelectedBoxes() { std::set sel_vps; VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. - Inkscape::Selection *sel = sp_desktop_selection(inkscape_active_desktop()); + Inkscape::Selection *sel = sp_desktop_selection(INKSCAPE.active_desktop()); for (GSList const* i = sel->itemList(); i != NULL; i = i->next) { if (!SP_IS_BOX3D(i->data)) continue; @@ -487,7 +487,7 @@ VPDragger::printVPs() { VPDrag::VPDrag (SPDocument *document) { this->document = document; - this->selection = sp_desktop_selection(inkscape_active_desktop()); + this->selection = sp_desktop_selection(INKSCAPE.active_desktop()); this->draggers = NULL; this->lines = NULL; @@ -633,7 +633,7 @@ VPDrag::updateBoxHandles () return; } - Inkscape::UI::Tools::ToolBase *ec = INKSCAPE->active_event_context(); + Inkscape::UI::Tools::ToolBase *ec = INKSCAPE.active_event_context(); g_assert (ec != NULL); if (ec->shape_editor != NULL) { ec->shape_editor->update_knotholder(); @@ -706,7 +706,7 @@ void VPDrag::drawLinesForFace(const SPBox3D *box, Proj::Axis axis) //, guint cor // draw perspective lines for infinite VPs boost::optional pt1, pt2, pt3, pt4; Persp3D *persp = box3d_get_perspective(box); - SPDesktop *desktop = inkscape_active_desktop (); // FIXME: Store the desktop in VPDrag + SPDesktop *desktop = INKSCAPE.active_desktop (); // FIXME: Store the desktop in VPDrag Box3D::PerspectiveLine pl (corner1, axis, persp); pt1 = pl.intersection_with_viewbox(desktop); @@ -780,7 +780,7 @@ VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1) void VPDrag::addLine(Geom::Point const &p1, Geom::Point const &p2, Inkscape::CtrlLineType type) { - SPCtrlLine *line = ControlManager::getManager().createControlLine(sp_desktop_controls(inkscape_active_desktop()), p1, p2, type); + SPCtrlLine *line = ControlManager::getManager().createControlLine(sp_desktop_controls(INKSCAPE.active_desktop()), p1, p2, type); sp_canvas_item_show(line); this->lines = g_slist_append(this->lines, line); } diff --git a/src/verbs.cpp b/src/verbs.cpp index 4626621a9..cfda87bb6 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -873,10 +873,10 @@ void FileVerb::perform(SPAction *action, void *data) // sp_file_export_to_ocal(*parent); // break; case SP_VERB_FILE_NEXT_DESKTOP: - INKSCAPE->switch_desktops_next(); + INKSCAPE.switch_desktops_next(); break; case SP_VERB_FILE_PREV_DESKTOP: - INKSCAPE->switch_desktops_prev(); + INKSCAPE.switch_desktops_prev(); break; case SP_VERB_FILE_CLOSE_VIEW: sp_ui_close_view(NULL); @@ -1170,11 +1170,11 @@ void SelectionVerb::perform(SPAction *action, void *data) SelectionHelper::reverse(dt); break; case SP_VERB_SELECTION_TRACE: - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); dt->_dlg_mgr->showDialog("Trace"); break; case SP_VERB_SELECTION_PIXEL_ART: - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); dt->_dlg_mgr->showDialog("PixelArt"); break; case SP_VERB_SELECTION_CREATE_BITMAP: @@ -1188,7 +1188,7 @@ void SelectionVerb::perform(SPAction *action, void *data) sp_selected_path_break_apart(dt); break; case SP_VERB_SELECTION_ARRANGE: - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); dt->_dlg_mgr->showDialog("TileDialog"); //FIXME: denis: What's this string (to be changed) break; default: @@ -1929,7 +1929,7 @@ void ZoomVerb::perform(SPAction *action, void *data) dt->toggleColorProfAdjust(); break; case SP_VERB_VIEW_ICON_PREVIEW: - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); dt->_dlg_mgr->showDialog("IconPreviewPanel"); break; @@ -1948,7 +1948,7 @@ void DialogVerb::perform(SPAction *action, void *data) { if (reinterpret_cast(data) != SP_VERB_DIALOG_TOGGLE) { // unhide all when opening a new dialog - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); } g_return_if_fail(ensure_desktop_valid(action)); @@ -2011,7 +2011,7 @@ void DialogVerb::perform(SPAction *action, void *data) dt->_dlg_mgr->showDialog("UndoHistory"); break; case SP_VERB_DIALOG_TOGGLE: - INKSCAPE->dialogs_toggle(); + INKSCAPE.dialogs_toggle(); break; case SP_VERB_DIALOG_CLONETILER: //clonetiler_dialog(); @@ -2083,7 +2083,7 @@ void HelpVerb::perform(SPAction *action, void *data) */ case SP_VERB_HELP_MEMORY: - INKSCAPE->dialogs_unhide(); + INKSCAPE.dialogs_unhide(); dt->_dlg_mgr->showDialog("Memory"); break; default: diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp index ecc7890b9..532eecb0f 100644 --- a/src/widgets/box3d-toolbar.cpp +++ b/src/widgets/box3d-toolbar.cpp @@ -254,7 +254,7 @@ static void box3d_angle_z_value_changed(GtkAdjustment *adj, GObject *dataKludge) static void box3d_vp_state_changed( GtkToggleAction *act, GtkAction * /*box3d_angle*/, Proj::Axis axis ) { // TODO: Take all selected perspectives into account - std::list sel_persps = sp_desktop_selection(inkscape_active_desktop())->perspList(); + std::list sel_persps = sp_desktop_selection(INKSCAPE.active_desktop())->perspList(); if (sel_persps.empty()) { // this can happen when the document is created; we silently ignore it return; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 8822416a7..09b5d24a9 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -795,7 +795,7 @@ static void sp_desktop_widget_dispose(GObject *object) dtw->layer_selector->setDesktop(NULL); dtw->layer_selector->unreference(); - INKSCAPE->remove_desktop (dtw->desktop); // clears selection too + INKSCAPE.remove_desktop (dtw->desktop); // clears selection too dtw->modified_connection.disconnect(); dtw->desktop->destroy(); Inkscape::GC::release (dtw->desktop); @@ -1091,7 +1091,7 @@ SPDesktopWidget::shutdown() { g_assert(desktop != NULL); - if (INKSCAPE->sole_desktop_for_document(*desktop)) { + if (INKSCAPE.sole_desktop_for_document(*desktop)) { SPDocument *doc = desktop->doc(); if (doc->isModifiedSinceSave()) { GtkWidget *dialog; @@ -1672,7 +1672,7 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview) dtw->desktop = new SPDesktop(); dtw->stub = new SPDesktopWidget::WidgetStub (dtw); dtw->desktop->init (namedview, dtw->canvas, dtw->stub); - INKSCAPE->add_desktop (dtw->desktop); + INKSCAPE.add_desktop (dtw->desktop); // Add the shape geometry to libavoid for autorouting connectors. // This needs desktop set for its spacing preferences. @@ -1818,7 +1818,7 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*) } } - INKSCAPE->activate_desktop (desktop); + INKSCAPE.activate_desktop (desktop); return false; } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 9c27da1f8..62a6599f2 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1033,18 +1033,18 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) wd.win = dlg; wd.stop = 0; - INKSCAPE->signal_activate_desktop.connect(sigc::bind<0>(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd), INKSCAPE)); + INKSCAPE.signal_activate_desktop.connect(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd)); g_signal_connect(G_OBJECT(dlg), "event", G_CALLBACK(sp_dialog_event_handler), dlg); g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg); g_signal_connect(G_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); - INKSCAPE->signal_shut_down.connect( + INKSCAPE.signal_shut_down.connect( sigc::hide_return( sigc::bind(sigc::ptr_fun(&sp_gradient_vector_dialog_delete), (GtkWidget *) NULL, (GdkEvent *) NULL, (GtkWidget *) NULL) )); - INKSCAPE->signal_dialogs_hide.connect(sigc::bind(sigc::ptr_fun(>k_widget_hide), dlg)); - INKSCAPE->signal_dialogs_unhide.connect(sigc::bind(sigc::ptr_fun(>k_widget_show), dlg)); + INKSCAPE.signal_dialogs_hide.connect(sigc::bind(sigc::ptr_fun(>k_widget_hide), dlg)); + INKSCAPE.signal_dialogs_unhide.connect(sigc::bind(sigc::ptr_fun(>k_widget_show), dlg)); gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); @@ -1161,13 +1161,14 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien blocked = FALSE; } +// \FIXME this #if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_vector_dialog_destroy(GtkWidget * /*object*/, gpointer /*data*/) #else static void sp_gradient_vector_dialog_destroy(GtkObject * /*object*/, gpointer /*data*/) #endif { - sp_signal_disconnect_by_data(INKSCAPE, dlg); + //sp_signal_disconnect_by_data(INKSCAPE, dlg); wd.win = dlg = NULL; wd.stop = 0; } diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 284e436bf..db93c1552 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -468,7 +468,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb contextActions->push_back( act ); // Create the parent widget for x y w h tracker. - GtkWidget *spw = sp_widget_new_global(INKSCAPE); + GtkWidget *spw = sp_widget_new_global(); // Remember the desktop's canvas widget, to be used for defocusing. g_object_set_data(G_OBJECT(spw), "dtw", sp_desktop_canvas(desktop)); diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 08344d9b2..8feb5b994 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -58,15 +58,15 @@ public: #endif static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation); - static void modifySelectionCB(Application *inkscape, Selection *selection, guint flags, SPWidget *spw); - static void changeSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw); - static void setSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw); + static void modifySelectionCB(Selection *selection, guint flags, SPWidget *spw); + static void changeSelectionCB(Selection *selection, SPWidget *spw); + static void setSelectionCB(Selection *selection, SPWidget *spw); - static GtkWidget *constructGlobal(SPWidget *spw, Inkscape::Application *inkscape); + static GtkWidget *constructGlobal(SPWidget *spw); - void modifySelection(Application *inkscape, Selection *selection, guint flags); - void changeSelection(Application *inkscape, Selection *selection); - void setSelection(Application *inkscape, Selection *selection); + void modifySelection(Selection *selection, guint flags); + void changeSelection(Selection *selection); + void setSelection(Selection *selection); private: static GtkBinClass *parentClass; @@ -172,8 +172,6 @@ void SPWidgetImpl::classInit(SPWidgetClass *klass) void SPWidgetImpl::init(SPWidget *spw) { - spw->inkscape = NULL; - spw->_impl = new SPWidgetImpl(*spw); // ctor invoked after all other init } @@ -181,21 +179,12 @@ void SPWidgetImpl::dispose(GObject *object) { SPWidget *spw = reinterpret_cast(object); - if (spw->inkscape) { - // Disconnect signals - - // the checks are necessary because when destroy is caused by the program shutting down, - // the inkscape object may already be (partly?) invalid --bb - if (dynamic_cast(spw->inkscape)) { - spw->selModified.disconnect(); - spw->selChanged.disconnect(); - spw->selSet.disconnect(); - } - //if (G_IS_OBJECT(spw->inkscape) && G_OBJECT_GET_CLASS(spw->inkscape)) { - //sp_signal_disconnect_by_data(spw->inkscape, spw); - //} - spw->inkscape = NULL; - } + // Disconnect signals + if (Application::exists()) { + spw->selModified.disconnect(); + spw->selChanged.disconnect(); + spw->selSet.disconnect(); + } delete spw->_impl; spw->_impl = 0; @@ -209,23 +198,20 @@ void SPWidgetImpl::show(GtkWidget *widget) { SPWidget *spw = SP_WIDGET(widget); - if (spw->inkscape) { + if (Application::exists()) { // Connect signals - spw->selModified = spw->inkscape->signal_selection_modified.connect( - sigc::bind<0>( + spw->selModified = INKSCAPE.signal_selection_modified.connect( sigc::bind( - sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw), spw->inkscape - )); - spw->selChanged = spw->inkscape->signal_selection_changed.connect( - sigc::bind<0>( + sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw) + ); + spw->selChanged = INKSCAPE.signal_selection_changed.connect( sigc::bind( - sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw), spw->inkscape - )); - spw->selSet = spw->inkscape->signal_selection_set.connect( - sigc::bind<0>( + sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw) + ); + spw->selSet = INKSCAPE.signal_selection_set.connect( sigc::bind( - sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw), spw->inkscape - )); + sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw) + ); } if (reinterpret_cast(parentClass)->show) { @@ -237,7 +223,7 @@ void SPWidgetImpl::hide(GtkWidget *widget) { SPWidget *spw = SP_WIDGET (widget); - if (spw->inkscape) { + if (Application::exists()) { // Disconnect signals spw->selModified.disconnect(); spw->selChanged.disconnect(); @@ -313,27 +299,21 @@ void SPWidgetImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation) } } -GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, Inkscape::Application *inkscape) +GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw) { - g_return_val_if_fail(!spw->inkscape, NULL); - - spw->inkscape = inkscape; if (gtk_widget_get_visible(GTK_WIDGET(spw))) { - spw->selModified = spw->inkscape->signal_selection_modified.connect( - sigc::bind<0>( + spw->selModified = INKSCAPE.signal_selection_modified.connect( sigc::bind( - sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw), spw->inkscape - )); - spw->selChanged = spw->inkscape->signal_selection_changed.connect( - sigc::bind<0>( + sigc::ptr_fun(SPWidgetImpl::modifySelectionCB), spw) + ); + spw->selChanged = INKSCAPE.signal_selection_changed.connect( sigc::bind( - sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw), spw->inkscape - )); - spw->selSet = spw->inkscape->signal_selection_set.connect( - sigc::bind<0>( + sigc::ptr_fun(SPWidgetImpl::changeSelectionCB), spw) + ); + spw->selSet = INKSCAPE.signal_selection_set.connect( sigc::bind( - sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw), spw->inkscape - )); + sigc::ptr_fun(SPWidgetImpl::setSelectionCB), spw) + ); } g_signal_emit(spw, signals[CONSTRUCT], 0); @@ -341,32 +321,32 @@ GtkWidget *SPWidgetImpl::constructGlobal(SPWidget *spw, Inkscape::Application *i return GTK_WIDGET(spw); } -void SPWidgetImpl::modifySelectionCB(Application *inkscape, Selection *selection, guint flags, SPWidget *spw) +void SPWidgetImpl::modifySelectionCB(Selection *selection, guint flags, SPWidget *spw) { - spw->_impl->modifySelection(inkscape, selection, flags); + spw->_impl->modifySelection(selection, flags); } -void SPWidgetImpl::changeSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw) +void SPWidgetImpl::changeSelectionCB(Selection *selection, SPWidget *spw) { - spw->_impl->changeSelection(inkscape, selection); + spw->_impl->changeSelection(selection); } -void SPWidgetImpl::setSelectionCB(Application *inkscape, Selection *selection, SPWidget *spw) +void SPWidgetImpl::setSelectionCB(Selection *selection, SPWidget *spw) { - spw->_impl->setSelection(inkscape, selection); + spw->_impl->setSelection(selection); } -void SPWidgetImpl::modifySelection(Application * /*inkscape*/, Selection *selection, guint flags) +void SPWidgetImpl::modifySelection(Selection *selection, guint flags) { g_signal_emit(&_target, signals[MODIFY_SELECTION], 0, selection, flags); } -void SPWidgetImpl::changeSelection(Application * /*inkscape*/, Selection *selection) +void SPWidgetImpl::changeSelection(Selection *selection) { g_signal_emit(&_target, signals[CHANGE_SELECTION], 0, selection); } -void SPWidgetImpl::setSelection(Application * /*inkscape*/, Selection *selection) +void SPWidgetImpl::setSelection(Selection *selection) { // Emit "set_selection" signal g_signal_emit(&_target, signals[SET_SELECTION], 0, selection); @@ -377,11 +357,11 @@ void SPWidgetImpl::setSelection(Application * /*inkscape*/, Selection *selection // Methods -GtkWidget *sp_widget_new_global(Inkscape::Application *inkscape) +GtkWidget *sp_widget_new_global() { SPWidget *spw = reinterpret_cast(g_object_new(SP_TYPE_WIDGET, NULL)); - if (!SPWidgetImpl::constructGlobal(spw, inkscape)) { + if (!SPWidgetImpl::constructGlobal(spw)) { g_object_unref(spw); spw = 0; } diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h index 469ab2d92..b4696e66e 100644 --- a/src/widgets/sp-widget.h +++ b/src/widgets/sp-widget.h @@ -17,6 +17,7 @@ #include #include +#include "inkscape.h" #define SP_TYPE_WIDGET (SPWidget::getType()) #define SP_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_WIDGET, SPWidget)) @@ -27,7 +28,6 @@ namespace Inkscape { -struct Application; class Selection; class SPWidgetImpl; @@ -38,10 +38,7 @@ struct SPWidget { static GType getType(); - // - GtkBin bin; - Inkscape::Application *inkscape; sigc::connection selModified; sigc::connection selChanged; @@ -64,7 +61,7 @@ struct SPWidgetClass { /* fixme: Think (Lauris) */ /** Generic constructor for global widget. */ -GtkWidget *sp_widget_new_global(Inkscape::Application *inkscape); +GtkWidget *sp_widget_new_global(); #endif // SEEN_SP_WIDGET_H /* diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 00b6b5c91..b5867abaa 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -64,7 +64,7 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : sp_pixbuf_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("no-marker") ) ) ); sandbox = ink_markers_preview_doc (); - desktop = inkscape_active_desktop(); + desktop = INKSCAPE.active_desktop(); doc = sp_desktop_document(desktop); modified_connection = doc->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&MarkerComboBox::handleDefsModified), this))) ); -- cgit v1.2.3 From c985ea62dbebc06070613326acb01b623b00699e Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 1 Jul 2014 11:55:03 -0400 Subject: Fix build with DBUS (thanks ~suv) (bzr r13341.5.10) --- src/extension/dbus/application-interface.cpp | 4 ++-- src/extension/dbus/dbus-init.cpp | 10 +++++----- src/extension/dbus/document-interface.cpp | 2 +- src/test-helpers.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp index c0bc19d90..292832a4b 100644 --- a/src/extension/dbus/application-interface.cpp +++ b/src/extension/dbus/application-interface.cpp @@ -49,7 +49,7 @@ application_interface_init (ApplicationInterface *app_interface) static bool ensure_desktop_valid(GError **error) { - if (!inkscape_use_gui()) { + if (!INKSCAPE.use_gui()) { g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires a GUI"); return false; } @@ -59,7 +59,7 @@ ensure_desktop_valid(GError **error) static bool ensure_desktop_not_present(GError **error) { - if (inkscape_use_gui()) { + if (INKSCAPE.use_gui()) { g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires non-GUI (command line) mode"); return false; } diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp index 19b48e10d..21a1c6847 100644 --- a/src/extension/dbus/dbus-init.cpp +++ b/src/extension/dbus/dbus-init.cpp @@ -153,23 +153,23 @@ gchar * init_document (void) { // This is for command-line use only - g_assert(!inkscape_use_gui()); + g_assert(!INKSCAPE.use_gui()); // Create a blank document and get its selection model etc in an ActionContext SPDocument *doc = SPDocument::createNewDoc(NULL, 1, TRUE); - inkscape_add_document(doc); - return dbus_register_document(inkscape_action_context_for_document(doc)); + INKSCAPE.add_document(doc); + return dbus_register_document(INKSCAPE.action_context_for_document(doc)); } gchar * init_active_document() { - SPDocument *doc = inkscape_active_document(); + SPDocument *doc = INKSCAPE.active_document(); if (!doc) { return NULL; } - return dbus_register_document(inkscape_active_action_context()); + return dbus_register_document(INKSCAPEactive_action_context()); } gchar * diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index e3452f4ce..bd5f826d3 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -156,7 +156,7 @@ get_name_from_object (SPObject * obj) void desktop_ensure_active (SPDesktop* desk) { if (desk != SP_ACTIVE_DESKTOP) - inkscape_activate_desktop (desk); + INKSCAPE.activate_desktop (desk); return; } diff --git a/src/test-helpers.h b/src/test-helpers.h index d2507128c..d30449ebb 100644 --- a/src/test-helpers.h +++ b/src/test-helpers.h @@ -28,10 +28,10 @@ T* createSuiteAndDocument( void (*fun)(T*&) ) #endif Inkscape::GC::init(); - if ( !inkscape_get_instance() ) + if ( !Inkscape::Application::exists() ) { // Create the global inkscape object. - static_cast(g_object_new(inkscape_get_type(), NULL)); + Inkscape::Application::create("", false); } SPDocument* tmp = SPDocument::createNewDoc( NULL, TRUE, true ); -- cgit v1.2.3 From 02601ddcf2e84ddd6330f1aaa63025f50b23e2d5 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 24 Jul 2014 15:13:19 -0400 Subject: Fix typo in dbus api files (bzr r13341.5.11) --- src/extension/dbus/dbus-init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp index 21a1c6847..43830762c 100644 --- a/src/extension/dbus/dbus-init.cpp +++ b/src/extension/dbus/dbus-init.cpp @@ -169,7 +169,7 @@ init_active_document() return NULL; } - return dbus_register_document(INKSCAPEactive_action_context()); + return dbus_register_document(INKSCAPE.active_action_context()); } gchar * -- cgit v1.2.3 From b4f5e57056ed7db1974fe21741fcb7c6ff7aa0c2 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 24 Jul 2014 16:56:54 -0400 Subject: Fix crash bug when exporting PNG from CLI (bzr r13341.5.12) --- src/inkscape.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/inkscape.cpp b/src/inkscape.cpp index cca6918e2..94c3722cb 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -1165,10 +1165,12 @@ Inkscape::ActionContext Application::action_context_for_document(SPDocument *doc) { // If there are desktops, check them first to see if the document is bound to one of them - for (std::vector::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e ; ++iter) { - SPDesktop *desktop = *iter; - if (desktop->doc() == doc) { - return Inkscape::ActionContext(desktop); + if (_desktops != NULL) { + for (std::vector::iterator iter = _desktops->begin(), e = _desktops->end() ; iter != e ; ++iter) { + SPDesktop *desktop = *iter; + if (desktop->doc() == doc) { + return Inkscape::ActionContext(desktop); + } } } -- cgit v1.2.3 From fa9bd6393f316dab9303569b28f6b5d179fedd61 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sat, 27 Sep 2014 10:17:45 -0400 Subject: Update to experimental r13565 (bzr r13341.5.16) --- src/CMakeLists.txt | 1 - src/Makefile.am | 2 - src/Makefile_insert | 4 +- src/attribute-rel-util.h | 2 +- src/attributes.cpp | 2 + src/attributes.h | 2 + src/axis-manip.cpp | 9 + src/axis-manip.h | 37 +- src/box3d-side.h | 8 +- src/box3d.h | 20 +- src/cms-color-types.h | 5 +- src/cms-system.h | 8 +- src/color-profile.h | 21 +- src/color-rgba.h | 5 +- src/color.cpp | 46 +- src/color.h | 6 +- src/conn-avoid-ref.h | 2 +- src/context-fns.cpp | 13 +- src/context-fns.h | 15 +- src/debug/gdk-event-latency-tracker.cpp | 2 + src/debug/gdk-event-latency-tracker.h | 2 +- src/desktop-events.cpp | 2 +- src/desktop-style.cpp | 4 +- src/desktop-style.h | 3 +- src/dialogs/CMakeLists.txt | 11 - src/dialogs/Makefile_insert | 5 - src/dialogs/dialog-events.cpp | 254 --- src/dialogs/dialog-events.h | 74 - src/dialogs/makefile.in | 17 - src/dir-util.h | 6 +- src/display/cairo-utils.cpp | 6 +- src/display/cairo-utils.h | 9 +- src/display/canvas-arena.h | 8 +- src/display/canvas-axonomgrid.h | 8 +- src/display/canvas-bpath.cpp | 3 - src/display/canvas-grid.h | 10 +- src/display/canvas-temporary-item-list.cpp | 5 +- src/display/canvas-temporary-item-list.h | 5 +- src/display/canvas-temporary-item.cpp | 8 +- src/display/canvas-temporary-item.h | 11 +- src/display/canvas-text.cpp | 4 - src/display/curve.cpp | 20 +- src/display/curve.h | 20 +- src/display/drawing-context.h | 6 +- src/display/drawing-item.cpp | 5 +- src/display/drawing-item.h | 8 +- src/display/drawing-surface.h | 7 +- src/display/drawing.h | 12 +- src/display/gnome-canvas-acetate.h | 8 +- src/display/grayscale.cpp | 4 +- src/display/grayscale.h | 6 +- src/display/nr-3dutils.h | 11 +- src/display/nr-filter-blend.h | 4 +- src/display/nr-filter-colormatrix.h | 15 +- src/display/nr-filter-component-transfer.h | 6 +- src/display/nr-filter-composite.h | 4 +- src/display/nr-filter-convolve-matrix.h | 8 +- src/display/nr-filter-diffuselighting.h | 10 +- src/display/nr-filter-displacement-map.h | 4 +- src/display/nr-filter-flood.h | 5 +- src/display/nr-filter-gaussian.h | 4 +- src/display/nr-filter-image.h | 8 +- src/display/nr-filter-merge.h | 4 +- src/display/nr-filter-morphology.h | 4 +- src/display/nr-filter-offset.h | 4 +- src/display/nr-filter-primitive.h | 4 +- src/display/nr-filter-skeleton.h | 4 +- src/display/nr-filter-slot.h | 10 +- src/display/nr-filter-specularlighting.h | 12 +- src/display/nr-filter-tile.h | 4 +- src/display/nr-filter-turbulence.h | 5 +- src/display/nr-filter-types.h | 4 +- src/display/nr-filter-units.h | 4 +- src/display/nr-filter-utils.h | 7 +- src/display/nr-filter.h | 4 +- src/display/nr-light-types.h | 4 +- src/display/nr-light.cpp | 8 +- src/display/nr-light.h | 34 +- src/display/nr-svgfonts.h | 55 +- src/display/sp-canvas-item.h | 3 +- src/display/sp-canvas-util.h | 6 +- src/display/sp-canvas.cpp | 2 +- src/display/sp-canvas.h | 9 - src/document-private.h | 1 + src/document-undo.cpp | 13 - src/document.cpp | 2 +- src/document.h | 56 +- src/draw-anchor.cpp | 4 +- src/draw-anchor.h | 9 +- src/event-log.h | 8 - src/extension/implementation/script.cpp | 2 +- src/extension/internal/bitmap/crop.cpp | 2 +- src/extension/internal/bitmap/opacity.cpp | 2 +- src/extension/internal/cairo-render-context.h | 3 + src/extension/internal/cdr-input.cpp | 2 +- src/extension/internal/gdkpixbuf-input.cpp | 13 +- src/extension/internal/gdkpixbuf-input.h | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 2 +- src/extension/internal/vsd-input.cpp | 2 +- src/extension/prefdialog.cpp | 2 +- src/extract-uri.h | 4 +- src/factory.h | 2 +- src/file.h | 8 +- src/filter-chemistry.h | 9 +- src/filter-enums.h | 2 - src/filters/distantlight.h | 12 +- src/filters/pointlight.h | 16 +- src/filters/spotlight.h | 36 +- src/gc-anchored.h | 1 - src/gc-core.h | 1 - src/gradient-chemistry.h | 21 +- src/graphlayout.h | 13 +- src/helper-fns.h | 30 +- src/inkscape-version.h | 2 +- src/inkview.cpp | 10 - src/interface.cpp | 15 +- src/interface.h | 19 +- src/isinf.h | 2 +- src/isnormal.h | 19 - src/knot-holder-entity.h | 30 +- src/knot.h | 62 +- src/knotholder.cpp | 36 +- src/knotholder.h | 9 +- src/layer-manager.h | 11 +- src/layer-model.h | 6 +- src/libnrtype/Layout-TNG-Compute.cpp | 2 + src/line-geometry.h | 5 +- src/line-snapper.cpp | 5 +- src/line-snapper.h | 5 +- src/live_effects/CMakeLists.txt | 13 + src/live_effects/Makefile_insert | 16 + src/live_effects/effect-enum.h | 7 + src/live_effects/effect.cpp | 77 +- src/live_effects/effect.h | 11 + src/live_effects/lpe-attach-path.cpp | 198 ++ src/live_effects/lpe-attach-path.h | 52 + src/live_effects/lpe-bounding-box.cpp | 67 + src/live_effects/lpe-bounding-box.h | 37 + src/live_effects/lpe-bspline.cpp | 394 ++-- src/live_effects/lpe-copy_rotate.cpp | 1 + src/live_effects/lpe-ellipse_5pts.cpp | 214 ++ src/live_effects/lpe-ellipse_5pts.h | 50 + src/live_effects/lpe-fill-between-many.cpp | 78 + src/live_effects/lpe-fill-between-many.h | 36 + src/live_effects/lpe-fill-between-strokes.cpp | 116 ++ src/live_effects/lpe-fill-between-strokes.h | 38 + src/live_effects/lpe-fillet-chamfer.cpp | 163 +- src/live_effects/lpe-fillet-chamfer.h | 10 +- src/live_effects/lpe-interpolate_points.cpp | 2 +- src/live_effects/lpe-jointype.cpp | 190 ++ src/live_effects/lpe-jointype.h | 57 + src/live_effects/lpe-knot.cpp | 5 + src/live_effects/lpe-knot.h | 3 +- src/live_effects/lpe-powerstroke-interpolators.h | 40 + src/live_effects/lpe-powerstroke.cpp | 100 +- src/live_effects/lpe-powerstroke.h | 2 + src/live_effects/lpe-roughen.cpp | 595 +++--- src/live_effects/lpe-roughen.h | 64 +- src/live_effects/lpe-tangent_to_curve.cpp | 19 +- src/live_effects/lpe-tangent_to_curve.h | 1 - src/live_effects/lpe-taperstroke.cpp | 632 ++++++ src/live_effects/lpe-taperstroke.h | 72 + src/live_effects/lpeobject-reference.h | 6 +- src/live_effects/lpeobject.h | 4 +- src/live_effects/parameter/Makefile_insert | 4 + .../parameter/filletchamferpointarray.cpp | 263 ++- .../parameter/filletchamferpointarray.h | 8 +- src/live_effects/parameter/originalpatharray.cpp | 487 +++++ src/live_effects/parameter/originalpatharray.h | 122 ++ .../parameter/powerstrokepointarray.cpp | 43 +- src/live_effects/parameter/powerstrokepointarray.h | 23 +- src/live_effects/parameter/transformedpoint.cpp | 182 ++ src/live_effects/parameter/transformedpoint.h | 82 + src/live_effects/pathoutlineprovider.cpp | 803 ++++++++ src/live_effects/pathoutlineprovider.h | 55 + src/main-cmdlineact.h | 6 +- src/marker.h | 10 +- src/menus-skeleton.h | 3 + src/message-context.h | 15 +- src/message-stack.h | 31 +- src/number-opt-number.h | 30 +- src/object-edit.cpp | 140 +- src/object-hierarchy.cpp | 23 +- src/object-hierarchy.h | 3 +- src/path-chemistry.cpp | 8 + src/path-chemistry.h | 5 +- src/path-prefix.h | 16 +- src/persp3d-reference.h | 7 +- src/persp3d.h | 15 +- src/perspective-line.h | 1 - src/preferences-skeleton.h | 3 +- src/preferences.h | 6 +- src/prefix.cpp | 2 +- src/prefix.h | 2 +- src/print.h | 6 +- src/profile-manager.h | 5 +- src/proj_pt.cpp | 14 +- src/proj_pt.h | 16 +- src/rdf.h | 39 +- src/removeoverlap.h | 2 +- src/rubberband.h | 10 +- src/satisfied-guide-cns.h | 2 +- src/selcue.h | 8 +- src/selection-chemistry.cpp | 197 +- src/selection-chemistry.h | 31 +- src/selection-describer.h | 6 +- src/selection.h | 21 +- src/seltrans-handles.h | 14 +- src/seltrans.h | 67 +- src/shape-editor.h | 8 +- src/shortcuts.h | 11 +- src/snap-candidate.h | 5 +- src/snap-preferences.h | 18 +- src/snap.cpp | 2 +- src/snap.h | 1 + src/snapped-curve.h | 6 +- src/snapped-point.h | 7 +- src/snapper.h | 13 +- src/sp-anchor.h | 14 +- src/sp-clippath.h | 21 +- src/sp-conn-end-pair.h | 18 +- src/sp-conn-end.h | 13 +- src/sp-cursor.cpp | 9 +- src/sp-cursor.h | 9 +- src/sp-defs.h | 2 +- src/sp-desc.h | 6 +- src/sp-ellipse.h | 8 +- src/sp-filter-primitive.h | 12 +- src/sp-filter.h | 17 +- src/sp-flowdiv.h | 26 +- src/sp-flowregion.h | 8 +- src/sp-flowtext.h | 10 +- src/sp-font-face.h | 12 +- src/sp-font.h | 8 +- src/sp-glyph-kerning.h | 10 +- src/sp-glyph.h | 4 +- src/sp-gradient-vector.h | 5 +- src/sp-gradient.cpp | 21 +- src/sp-gradient.h | 48 +- src/sp-guide.cpp | 2 +- src/sp-guide.h | 9 +- src/sp-image.h | 13 +- src/sp-item-group.cpp | 12 + src/sp-item-group.h | 25 +- src/sp-item-notify-moveto.cpp | 9 +- src/sp-item-transform.cpp | 2 + src/sp-item-transform.h | 9 +- src/sp-item.cpp | 62 +- src/sp-item.h | 40 +- src/sp-line.h | 6 +- src/sp-linear-gradient.cpp | 2 + src/sp-linear-gradient.h | 4 +- src/sp-lpe-item.cpp | 10 +- src/sp-lpe-item.h | 10 +- src/sp-mask.h | 16 +- src/sp-mesh-array.cpp | 2 + src/sp-mesh-array.h | 64 +- src/sp-mesh-gradient.cpp | 2 + src/sp-mesh-gradient.h | 4 +- src/sp-mesh-patch.h | 6 +- src/sp-mesh-row.h | 5 +- src/sp-metadata.h | 9 +- src/sp-missing-glyph.h | 12 +- src/sp-namedview.cpp | 2 +- src/sp-namedview.h | 29 +- src/sp-object-group.h | 2 +- src/sp-object.cpp | 16 +- src/sp-object.h | 84 +- src/sp-offset.h | 18 +- src/sp-paint-server-reference.h | 3 +- src/sp-paint-server.h | 4 +- src/sp-path.h | 10 +- src/sp-pattern.h | 31 +- src/sp-polygon.h | 13 +- src/sp-polyline.h | 6 +- src/sp-radial-gradient.cpp | 2 + src/sp-radial-gradient.h | 8 +- src/sp-rect.h | 32 +- src/sp-root.h | 8 +- src/sp-script.h | 10 +- src/sp-shape.h | 16 +- src/sp-solid-color.cpp | 2 + src/sp-solid-color.h | 8 +- src/sp-spiral.h | 16 +- src/sp-star.h | 18 +- src/sp-stop.h | 13 +- src/sp-string.h | 4 +- src/sp-style-elem.h | 4 +- src/sp-switch.h | 10 +- src/sp-symbol.h | 18 +- src/sp-tag-use-reference.cpp | 156 ++ src/sp-tag-use-reference.h | 78 + src/sp-tag-use.cpp | 206 ++ src/sp-tag-use.h | 55 + src/sp-tag.cpp | 154 ++ src/sp-tag.h | 57 + src/sp-text.h | 18 +- src/sp-textpath.h | 7 +- src/sp-title.h | 6 +- src/sp-tref-reference.h | 8 +- src/sp-tref.h | 6 +- src/sp-tspan.h | 7 +- src/sp-use-reference.h | 8 +- src/sp-use.h | 15 +- src/splivarot.h | 7 +- src/streq.h | 1 - src/style-enums.h | 6 +- src/style-internal.cpp | 24 + src/style-internal.h | 2 +- src/style.h | 35 +- src/svg-view-widget.h | 2 +- src/svg-view.h | 13 +- src/svg/css-ostringstream.h | 5 +- src/svg/path-string.h | 4 +- src/svg/stringstream.h | 5 +- src/svg/svg-color.h | 13 +- src/svg/svg.h | 24 +- src/text-chemistry.h | 2 + src/text-editing.h | 19 +- src/transf_mat_3x4.h | 4 +- src/ui/CMakeLists.txt | 2 + src/ui/Makefile_insert | 2 + src/ui/dialog-events.cpp | 254 +++ src/ui/dialog-events.h | 74 + src/ui/dialog/Makefile_insert | 6 + src/ui/dialog/aboutbox.cpp | 18 +- src/ui/dialog/calligraphic-profile-rename.h | 2 +- src/ui/dialog/color-item.cpp | 2 + src/ui/dialog/dialog-manager.cpp | 6 + src/ui/dialog/dock-behavior.cpp | 2 +- src/ui/dialog/document-properties.cpp | 10 +- src/ui/dialog/export.cpp | 2 +- src/ui/dialog/filedialog.cpp | 2 +- src/ui/dialog/filedialog.h | 1 + src/ui/dialog/filedialogimpl-gtkmm.cpp | 2 +- src/ui/dialog/filedialogimpl-win32.cpp | 2 +- src/ui/dialog/find.cpp | 2 +- src/ui/dialog/floating-behavior.cpp | 2 +- src/ui/dialog/font-substitution.cpp | 2 +- src/ui/dialog/guides.cpp | 2 +- src/ui/dialog/lpe-fillet-chamfer-properties.cpp | 71 +- src/ui/dialog/lpe-fillet-chamfer-properties.h | 31 +- src/ui/dialog/lpe-powerstroke-properties.cpp | 211 ++ src/ui/dialog/lpe-powerstroke-properties.h | 99 + src/ui/dialog/objects.cpp | 2144 ++++++++++++++++++++ src/ui/dialog/objects.h | 263 +++ src/ui/dialog/ocaldialogs.cpp | 2 +- src/ui/dialog/ocaldialogs.h | 3 +- src/ui/dialog/swatches.cpp | 103 +- src/ui/dialog/swatches.h | 2 - src/ui/dialog/tags.cpp | 1165 +++++++++++ src/ui/dialog/tags.h | 181 ++ src/ui/dialog/xml-tree.cpp | 2 +- src/ui/tool/multi-path-manipulator.cpp | 6 +- src/ui/tool/multi-path-manipulator.h | 2 +- src/ui/tool/node.cpp | 36 +- src/ui/tool/path-manipulator.cpp | 50 +- src/ui/tools/freehand-base.cpp | 40 +- src/ui/tools/freehand-base.h | 5 +- src/ui/tools/node-tool.cpp | 41 +- src/ui/tools/pen-tool.cpp | 306 ++- src/ui/tools/pencil-tool.cpp | 9 +- src/ui/widget/Makefile_insert | 13 +- src/ui/widget/addtoicon.cpp | 157 ++ src/ui/widget/addtoicon.h | 98 + src/ui/widget/clipmaskicon.cpp | 184 ++ src/ui/widget/clipmaskicon.h | 102 + src/ui/widget/color-picker.cpp | 2 +- src/ui/widget/filter-effect-chooser.cpp | 2 + src/ui/widget/filter-effect-chooser.h | 4 +- src/ui/widget/highlight-picker.cpp | 214 ++ src/ui/widget/highlight-picker.h | 90 + src/ui/widget/insertordericon.cpp | 173 ++ src/ui/widget/insertordericon.h | 100 + src/ui/widget/layertypeicon.cpp | 174 ++ src/ui/widget/layertypeicon.h | 108 + src/unclump.cpp | 1 + src/unclump.h | 2 +- src/unicoderange.h | 14 +- src/uri-references.h | 6 +- src/uri.h | 35 +- src/vanishing-point.h | 12 +- src/verbs.cpp | 93 +- src/verbs.h | 54 +- src/version.cpp | 22 +- src/version.h | 12 +- src/widgets/dash-selector.cpp | 2 +- src/widgets/desktop-widget.cpp | 139 +- src/widgets/desktop-widget.h | 41 +- src/widgets/gradient-vector.cpp | 2 +- src/widgets/sp-color-icc-selector.cpp | 2 +- src/widgets/sp-color-notebook.cpp | 2 +- src/widgets/sp-color-scales.cpp | 2 +- src/widgets/sp-color-wheel-selector.cpp | 2 +- src/widgets/stroke-marker-selector.cpp | 2 +- src/widgets/stroke-style.cpp | 2 +- src/widgets/stroke-style.h | 4 +- src/xml/event.h | 2 +- src/xml/helper-observer.h | 70 +- src/xml/node-event-vector.h | 46 +- src/xml/node-observer.h | 6 +- src/xml/node.h | 15 +- src/xml/pi-node.h | 1 - src/xml/quote.h | 2 +- src/xml/rebase-hrefs.h | 9 +- src/xml/repr.h | 85 +- src/xml/simple-node.h | 18 +- 407 files changed, 13679 insertions(+), 3390 deletions(-) delete mode 100644 src/dialogs/CMakeLists.txt delete mode 100644 src/dialogs/Makefile_insert delete mode 100644 src/dialogs/dialog-events.cpp delete mode 100644 src/dialogs/dialog-events.h delete mode 100644 src/dialogs/makefile.in delete mode 100644 src/isnormal.h create mode 100644 src/live_effects/lpe-attach-path.cpp create mode 100644 src/live_effects/lpe-attach-path.h create mode 100644 src/live_effects/lpe-bounding-box.cpp create mode 100644 src/live_effects/lpe-bounding-box.h create mode 100644 src/live_effects/lpe-ellipse_5pts.cpp create mode 100644 src/live_effects/lpe-ellipse_5pts.h create mode 100644 src/live_effects/lpe-fill-between-many.cpp create mode 100644 src/live_effects/lpe-fill-between-many.h create mode 100644 src/live_effects/lpe-fill-between-strokes.cpp create mode 100644 src/live_effects/lpe-fill-between-strokes.h create mode 100644 src/live_effects/lpe-jointype.cpp create mode 100644 src/live_effects/lpe-jointype.h create mode 100644 src/live_effects/lpe-taperstroke.cpp create mode 100644 src/live_effects/lpe-taperstroke.h create mode 100644 src/live_effects/parameter/originalpatharray.cpp create mode 100644 src/live_effects/parameter/originalpatharray.h create mode 100644 src/live_effects/parameter/transformedpoint.cpp create mode 100644 src/live_effects/parameter/transformedpoint.h create mode 100644 src/live_effects/pathoutlineprovider.cpp create mode 100644 src/live_effects/pathoutlineprovider.h create mode 100644 src/sp-tag-use-reference.cpp create mode 100644 src/sp-tag-use-reference.h create mode 100644 src/sp-tag-use.cpp create mode 100644 src/sp-tag-use.h create mode 100644 src/sp-tag.cpp create mode 100644 src/sp-tag.h create mode 100644 src/ui/dialog-events.cpp create mode 100644 src/ui/dialog-events.h create mode 100644 src/ui/dialog/lpe-powerstroke-properties.cpp create mode 100644 src/ui/dialog/lpe-powerstroke-properties.h create mode 100644 src/ui/dialog/objects.cpp create mode 100644 src/ui/dialog/objects.h create mode 100644 src/ui/dialog/tags.cpp create mode 100644 src/ui/dialog/tags.h create mode 100644 src/ui/widget/addtoicon.cpp create mode 100644 src/ui/widget/addtoicon.h create mode 100644 src/ui/widget/clipmaskicon.cpp create mode 100644 src/ui/widget/clipmaskicon.h create mode 100644 src/ui/widget/highlight-picker.cpp create mode 100644 src/ui/widget/highlight-picker.h create mode 100644 src/ui/widget/insertordericon.cpp create mode 100644 src/ui/widget/insertordericon.h create mode 100644 src/ui/widget/layertypeicon.cpp create mode 100644 src/ui/widget/layertypeicon.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81b273da8..a2c95d2b0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -350,7 +350,6 @@ set(inkscape_SRC inkscape.h interface.h isinf.h - isnormal.h knot-enums.h knot-holder-entity.h knot.h diff --git a/src/Makefile.am b/src/Makefile.am index 282797a50..8fb7e23ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,7 +105,6 @@ endif # Include all partial makefiles from subdirectories include Makefile_insert -include dialogs/Makefile_insert include display/Makefile_insert include extension/Makefile_insert include extension/dbus/Makefile_insert @@ -144,7 +143,6 @@ include libdepixelize/Makefile_insert EXTRA_DIST += \ 2geom/makefile.in \ debug/makefile.in \ - dialogs/makefile.in \ display/makefile.in \ extension/implementation/makefile.in \ extension/internal/makefile.in \ diff --git a/src/Makefile_insert b/src/Makefile_insert index 4dadcd2d3..20695ed77 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -74,7 +74,6 @@ ink_common_sources += \ inkscape.cpp inkscape.h \ interface.cpp interface.h \ isinf.h \ - isnormal.h \ knot.cpp knot.h \ knot-enums.h \ knotholder.cpp knotholder.h \ @@ -200,6 +199,9 @@ ink_common_sources += \ sp-style-elem.cpp sp-style-elem.h \ sp-switch.cpp sp-switch.h \ sp-symbol.cpp sp-symbol.h \ + sp-tag.cpp sp-tag.h \ + sp-tag-use.cpp sp-tag-use.h \ + sp-tag-use-reference.cpp sp-tag-use-reference.h \ sp-text.cpp sp-text.h \ sp-textpath.h \ sp-title.cpp sp-title.h \ diff --git a/src/attribute-rel-util.h b/src/attribute-rel-util.h index 3a6661965..604987779 100644 --- a/src/attribute-rel-util.h +++ b/src/attribute-rel-util.h @@ -8,7 +8,7 @@ * Author: tavmjong */ -#include "glibmm/ustring.h" +#include #include "xml/sp-css-attr.h" using Inkscape::XML::Node; diff --git a/src/attributes.cpp b/src/attributes.cpp index 526476322..87bfdbe88 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -40,6 +40,7 @@ static SPStyleProp const props[] = { {SP_ATTR_TRANSFORM_CENTER_X, "inkscape:transform-center-x"}, {SP_ATTR_TRANSFORM_CENTER_Y, "inkscape:transform-center-y"}, {SP_ATTR_INKSCAPE_PATH_EFFECT, "inkscape:path-effect"}, + {SP_ATTR_INKSCAPE_HIGHLIGHT_COLOR, "inkscape:highlight-color"}, /* SPAnchor */ {SP_ATTR_XLINK_HREF, "xlink:href"}, {SP_ATTR_XLINK_TYPE, "xlink:type"}, @@ -50,6 +51,7 @@ static SPStyleProp const props[] = { {SP_ATTR_XLINK_ACTUATE, "xlink:actuate"}, {SP_ATTR_TARGET, "target"}, {SP_ATTR_INKSCAPE_GROUPMODE, "inkscape:groupmode"}, + {SP_ATTR_INKSCAPE_EXPANDED, "inkscape:expanded"}, /* SPRoot */ {SP_ATTR_VERSION, "version"}, {SP_ATTR_WIDTH, "width"}, diff --git a/src/attributes.h b/src/attributes.h index 7f18cb5ea..598d68fa3 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -40,6 +40,7 @@ enum SPAttributeEnum { SP_ATTR_TRANSFORM_CENTER_X, SP_ATTR_TRANSFORM_CENTER_Y, SP_ATTR_INKSCAPE_PATH_EFFECT, + SP_ATTR_INKSCAPE_HIGHLIGHT_COLOR, /* SPAnchor */ SP_ATTR_XLINK_HREF, SP_ATTR_XLINK_TYPE, @@ -51,6 +52,7 @@ enum SPAttributeEnum { SP_ATTR_TARGET, /* SPGroup */ SP_ATTR_INKSCAPE_GROUPMODE, + SP_ATTR_INKSCAPE_EXPANDED, /* SPRoot */ SP_ATTR_VERSION, SP_ATTR_WIDTH, diff --git a/src/axis-manip.cpp b/src/axis-manip.cpp index 1240d99e6..8955202c8 100644 --- a/src/axis-manip.cpp +++ b/src/axis-manip.cpp @@ -9,6 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include "axis-manip.h" namespace Proj { @@ -31,6 +32,14 @@ get_remaining_axes (Axis axis) { return std::make_pair (extract_first_axis_direction (plane), extract_second_axis_direction (plane)); } +char * string_from_axes (Box3D::Axis axis) { + GString *pstring = g_string_new(""); + if (axis & Box3D::X) g_string_append_printf (pstring, "X"); + if (axis & Box3D::Y) g_string_append_printf (pstring, "Y"); + if (axis & Box3D::Z) g_string_append_printf (pstring, "Z"); + return pstring->str; +} + } // namespace Box3D /* diff --git a/src/axis-manip.h b/src/axis-manip.h index 7842b4135..5e245939e 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -12,8 +12,9 @@ #ifndef SEEN_AXIS_MANIP_H #define SEEN_AXIS_MANIP_H +#include +#include #include -#include namespace Proj { @@ -34,7 +35,7 @@ enum Axis { extern Axis axes[4]; -inline gchar const * +inline char const* string_from_axis(Proj::Axis axis) { switch (axis) { case X: return "X"; break; @@ -77,18 +78,15 @@ inline int axis_to_int(Box3D::Axis axis) { switch (axis) { case Box3D::X: return 0; - break; case Box3D::Y: return 1; - break; case Box3D::Z: return 2; - break; case Box3D::NONE: return -1; - break; default: - g_assert_not_reached(); + assert(false); + return -1; // help compiler's flow analysis (-Werror=return-value) } } @@ -103,7 +101,8 @@ inline Proj::Axis toProj(Box3D::Axis axis) { case Box3D::NONE: return Proj::NONE; default: - g_assert_not_reached(); + assert(false); + return Proj::NONE; // help compiler's flow analysis (-Werror=return-value) } } @@ -126,7 +125,8 @@ inline Box3D::Axis toAffine(Proj::Axis axis) { case Proj::NONE: return Box3D::NONE; default: - g_assert_not_reached(); + assert(false); + return Box3D::NONE; // help compiler's flow analysis (-Werror=return-value) } } @@ -144,7 +144,7 @@ namespace Box3D { // (which is normally used to index an array). Return -1 if the bit sequence // does not specify a face. A face can either be given by its plane (e.g, XY) // or by the axis that is orthogonal to it (e.g., Z). -inline gint face_to_int (guint face_id) { +inline int face_to_int (unsigned int face_id) { switch (face_id) { case 1: return 0; case 2: return 1; @@ -164,7 +164,7 @@ inline gint face_to_int (guint face_id) { } } -inline gint int_to_face (guint id) { +inline int int_to_face (unsigned id) { switch (id) { case 0: return Box3D::YZ ^ Box3D::FRONT; case 1: return Box3D::XZ ^ Box3D::FRONT; @@ -176,7 +176,7 @@ inline gint int_to_face (guint id) { return Box3D::NONE; // should not be reached } -inline bool is_face_id (guint face_id) { +inline bool is_face_id (unsigned int face_id) { return !((face_id & 0x7) == 0x7); } @@ -186,8 +186,8 @@ inline gint opposite_face (guint face_id) { } **/ -inline guint number_of_axis_directions (Box3D::Axis axis) { - guint num = 0; +inline unsigned int number_of_axis_directions (Box3D::Axis axis) { + unsigned int num = 0; if (axis & Box3D::X) num++; if (axis & Box3D::Y) num++; if (axis & Box3D::Z) num++; @@ -238,14 +238,7 @@ inline Box3D::Axis get_perpendicular_axis_direction (Box3D::Axis dirs) { return Box3D::NONE; } -inline gchar * string_from_axes (Box3D::Axis axis) { - GString *pstring = g_string_new(""); - if (axis & Box3D::X) g_string_append_printf (pstring, "X"); - if (axis & Box3D::Y) g_string_append_printf (pstring, "Y"); - if (axis & Box3D::Z) g_string_append_printf (pstring, "Z"); - return pstring->str; -} - +char * string_from_axes (Box3D::Axis axis); std::pair get_remaining_axes (Axis axis); } // namespace Box3D diff --git a/src/box3d-side.h b/src/box3d-side.h index 04bd196c2..89b3b0399 100644 --- a/src/box3d-side.h +++ b/src/box3d-side.h @@ -36,16 +36,16 @@ public: static Box3DSide * createBox3DSide(SPBox3D *box); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void set(unsigned int key, gchar const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual void update(SPCtx *ctx, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); + virtual void update(SPCtx *ctx, unsigned int flags); virtual void set_shape(); }; void box3d_side_position_set (Box3DSide *side); // FIXME: Replace this by box3d_side_set_shape?? -gchar *box3d_side_axes_string(Box3DSide *side); +char *box3d_side_axes_string(Box3DSide *side); Persp3D *box3d_side_perspective(Box3DSide *side); diff --git a/src/box3d.h b/src/box3d.h index 4107d2452..60b966187 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -32,9 +32,9 @@ public: SPBox3D(); virtual ~SPBox3D(); - gint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom) + int z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom) - gchar *persp_href; + char *persp_href; Persp3DReference *persp_ref; Proj::Pt3 orig_corner0; @@ -45,7 +45,7 @@ public: Box3D::Axis swapped; // to indicate which coordinates are swapped during dragging - gint my_counter; // for debugging only + int my_counter; // for debugging only /** * Create a SPBox3D and append it to the parent. @@ -54,24 +54,24 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void set(unsigned int key, gchar const* value); - virtual void update(SPCtx *ctx, guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual void update(SPCtx *ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char* display_name(); virtual Geom::Affine set_transform(Geom::Affine const &transform); virtual void convert_to_guides() const; virtual const char* displayName() const; - virtual gchar *description() const; + virtual char *description() const; }; void box3d_position_set (SPBox3D *box); -Proj::Pt3 box3d_get_proj_corner (SPBox3D const *box, guint id); -Geom::Point box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords = true); +Proj::Pt3 box3d_get_proj_corner (SPBox3D const *box, unsigned int id); +Geom::Point box3d_get_corner_screen (SPBox3D const *box, unsigned int id, bool item_coords = true); Proj::Pt3 box3d_get_proj_center (SPBox3D *box); Geom::Point box3d_get_center_screen (SPBox3D *box); -void box3d_set_corner (SPBox3D *box, guint id, Geom::Point const &new_pos, Box3D::Axis movement, bool constrained); +void box3d_set_corner (SPBox3D *box, unsigned int id, Geom::Point const &new_pos, Box3D::Axis movement, bool constrained); void box3d_set_center (SPBox3D *box, Geom::Point const &new_pos, Geom::Point const &old_pos, Box3D::Axis movement, bool constrained); void box3d_corners_for_PLs (const SPBox3D * box, Proj::Axis axis, Geom::Point &corner1, Geom::Point &corner2, Geom::Point &corner3, Geom::Point &corner4); bool box3d_recompute_z_orders (SPBox3D *box); diff --git a/src/cms-color-types.h b/src/cms-color-types.h index 47157c243..b94c96029 100644 --- a/src/cms-color-types.h +++ b/src/cms-color-types.h @@ -10,15 +10,14 @@ # include "config.h" #endif // HAVE_CONFIG_H -#include - #if HAVE_LIBLCMS1 # include #endif #if HAVE_STDINT_H -# include +# include // uint8_t, etc #endif +typedef unsigned int guint32; typedef void * cmsHPROFILE; typedef void * cmsHTRANSFORM; diff --git a/src/cms-system.h b/src/cms-system.h index c528deb94..73d1a89c4 100644 --- a/src/cms-system.h +++ b/src/cms-system.h @@ -5,8 +5,6 @@ * Macros and fn declarations related to linear gradients. */ -#include -#include #include #include #include "cms-color-types.h" @@ -19,13 +17,13 @@ class ColorProfile; class CMSSystem { public: - static cmsHPROFILE getHandle( SPDocument* document, guint* intent, gchar const* name ); + static cmsHPROFILE getHandle( SPDocument* document, unsigned int* intent, char const* name ); static cmsHTRANSFORM getDisplayTransform(); static Glib::ustring getDisplayId( int screen, int monitor ); - static Glib::ustring setDisplayPer( gpointer buf, guint bufLen, int screen, int monitor ); + static Glib::ustring setDisplayPer( void* buf, unsigned int bufLen, int screen, int monitor ); static cmsHTRANSFORM getDisplayPer( Glib::ustring const& id ); @@ -39,7 +37,7 @@ public: static bool isPrintColorSpace(ColorProfile const *profile); - static gint getChannelCount(ColorProfile const *profile); + static int getChannelCount(ColorProfile const *profile); }; diff --git a/src/color-profile.h b/src/color-profile.h index 2da757b91..cb6b25945 100644 --- a/src/color-profile.h +++ b/src/color-profile.h @@ -2,7 +2,6 @@ #define SEEN_COLOR_PROFILE_H #include -#include #include #include #include "cms-color-types.h" @@ -31,7 +30,7 @@ public: ColorProfile(); virtual ~ColorProfile(); - friend cmsHPROFILE colorprofile_get_handle( SPDocument*, guint*, gchar const* ); + friend cmsHPROFILE colorprofile_get_handle( SPDocument*, unsigned int*, char const* ); friend class CMSSystem; static std::vector getBaseProfileDirs(); @@ -49,21 +48,21 @@ public: #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gchar* href; - gchar* local; - gchar* name; - gchar* intentStr; - guint rendering_intent; + char* href; + char* local; + char* name; + char* intentStr; + unsigned int rendering_intent; // FIXME: type the enum and hold that instead protected: ColorProfileImpl *impl; - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void release(); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; } // namespace Inkscape diff --git a/src/color-rgba.h b/src/color-rgba.h index ef7d9aee1..55cf68877 100644 --- a/src/color-rgba.h +++ b/src/color-rgba.h @@ -9,8 +9,9 @@ #ifndef SEEN_COLOR_RGBA_H #define SEEN_COLOR_RGBA_H -#include // g_assert() +#include #include "decimal-round.h" +typedef unsigned int guint32; /** * A class to contain a floating point RGBA color as one unit. @@ -96,7 +97,7 @@ public: * @return The requested value. */ float operator[](unsigned int const i) const { - g_assert( unsigned(i) < 4 ); + assert( unsigned(i) < 4 ); return _c[i]; } diff --git a/src/color.cpp b/src/color.cpp index dccd603b0..d7e8d25dd 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -12,13 +12,21 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include +#include + +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) + #include "color.h" #include "svg/svg-icc-color.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" +#define return_if_fail(x) if (!(x)) { printf("assertion failed: " #x); return; } +#define return_val_if_fail(x, val) if (!(x)) { printf("assertion failed: " #x); return val; } + using Inkscape::CSSOStringStream; using std::vector; @@ -118,7 +126,7 @@ static bool profileMatches( SVGICCColor const* first, SVGICCColor const* second && (first->colorProfile == second->colorProfile) && (first->colors.size() == second->colors.size()); if ( match ) { - for ( guint i = 0; i < first->colors.size(); i++ ) { + for ( unsigned i = 0; i < first->colors.size(); i++ ) { match &= (fabs(first->colors[i] - second->colors[i]) < PROFILE_EPSILON); } } @@ -132,12 +140,12 @@ static bool profileMatches( SVGICCColor const* first, SVGICCColor const* second */ void SPColor::set( float r, float g, float b ) { - g_return_if_fail(r >= 0.0); - g_return_if_fail(r <= 1.0); - g_return_if_fail(g >= 0.0); - g_return_if_fail(g <= 1.0); - g_return_if_fail(b >= 0.0); - g_return_if_fail(b <= 1.0); + return_if_fail(r >= 0.0); + return_if_fail(r <= 1.0); + return_if_fail(g >= 0.0); + return_if_fail(g <= 1.0); + return_if_fail(b >= 0.0); + return_if_fail(b <= 1.0); // TODO clear icc if set? v.c[0] = r; @@ -160,9 +168,9 @@ void SPColor::set( guint32 value ) * Convert SPColor with integer alpha value to 32bit RGBA value. * \pre alpha < 256 */ -guint32 SPColor::toRGBA32( gint alpha ) const +guint32 SPColor::toRGBA32( int alpha ) const { - g_return_val_if_fail (alpha <= 0xff, 0x0); + return_val_if_fail (alpha <= 0xff, 0x0); guint32 rgba = SP_RGBA32_U_COMPOSE( SP_COLOR_F_TO_U(v.c[0]), SP_COLOR_F_TO_U(v.c[1]), @@ -175,12 +183,12 @@ guint32 SPColor::toRGBA32( gint alpha ) const * Convert SPColor with float alpha value to 32bit RGBA value. * \pre color != NULL && 0 <= alpha <= 1 */ -guint32 SPColor::toRGBA32( gdouble alpha ) const +guint32 SPColor::toRGBA32( double alpha ) const { - g_return_val_if_fail(alpha >= 0.0, 0x0); - g_return_val_if_fail(alpha <= 1.0, 0x0); + return_val_if_fail(alpha >= 0.0, 0x0); + return_val_if_fail(alpha <= 1.0, 0x0); - return toRGBA32( static_cast(SP_COLOR_F_TO_U(alpha)) ); + return toRGBA32( static_cast(SP_COLOR_F_TO_U(alpha)) ); } std::string SPColor::toString() const @@ -215,8 +223,8 @@ std::string SPColor::toString() const void sp_color_get_rgb_floatv(SPColor const *color, float *rgb) { - g_return_if_fail (color != NULL); - g_return_if_fail (rgb != NULL); + return_if_fail (color != NULL); + return_if_fail (rgb != NULL); rgb[0] = color->v.c[0]; rgb[1] = color->v.c[1]; @@ -230,8 +238,8 @@ sp_color_get_rgb_floatv(SPColor const *color, float *rgb) void sp_color_get_cmyk_floatv(SPColor const *color, float *cmyk) { - g_return_if_fail (color != NULL); - g_return_if_fail (cmyk != NULL); + return_if_fail (color != NULL); + return_if_fail (cmyk != NULL); sp_color_rgb_to_cmyk_floatv( cmyk, color->v.c[0], @@ -284,7 +292,7 @@ sp_color_rgb_to_hsv_floatv (float *hsv, float r, float g, float b) void sp_color_hsv_to_rgb_floatv (float *rgb, float h, float s, float v) { - gdouble f, w, q, t, d; + double f, w, q, t, d; d = h * 5.99999999; f = d - floor (d); diff --git a/src/color.h b/src/color.h index 604dff0e3..887daf66b 100644 --- a/src/color.h +++ b/src/color.h @@ -13,8 +13,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include +typedef unsigned int guint32; // uint is guaranteed to hold up to 2^32 − 1 /* Useful composition macros */ @@ -52,8 +52,8 @@ struct SPColor { void set( float r, float g, float b ); void set( guint32 value ); - guint32 toRGBA32( gint alpha ) const; - guint32 toRGBA32( gdouble alpha ) const; + guint32 toRGBA32( int alpha ) const; + guint32 toRGBA32( double alpha ) const; std::string toString() const; diff --git a/src/conn-avoid-ref.h b/src/conn-avoid-ref.h index ce364abf1..e9e12118f 100644 --- a/src/conn-avoid-ref.h +++ b/src/conn-avoid-ref.h @@ -14,13 +14,13 @@ */ #include <2geom/point.h> -#include #include #include class SPDesktop; class SPObject; class SPItem; +typedef struct _GSList GSList; namespace Avoid { class ShapeRef; } class SPAvoidRef { diff --git a/src/context-fns.cpp b/src/context-fns.cpp index 1e30e51de..e1df53d98 100644 --- a/src/context-fns.cpp +++ b/src/context-fns.cpp @@ -1,17 +1,14 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include -#include "sp-item.h" + +#include "context-fns.h" #include "desktop.h" +#include "display/snap-indicator.h" #include "message-context.h" #include "message-stack.h" -#include "context-fns.h" #include "snap.h" -#include "ui/tools/tool-base.h" +#include "sp-item.h" #include "sp-namedview.h" -#include "display/snap-indicator.h" +#include "ui/tools/tool-base.h" static const double midpt_1_goldenratio = (1 + goldenratio) / 2; static const double midpt_goldenratio_2 = (goldenratio + 2) / 2; diff --git a/src/context-fns.h b/src/context-fns.h index bd48e5fb8..82554a6c9 100644 --- a/src/context-fns.h +++ b/src/context-fns.h @@ -2,7 +2,6 @@ #define SEEN_CONTEXT_FNS_H /* - * * * Authors: * @@ -11,11 +10,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include <2geom/forward.h> -class SPDesktop; -class SPItem; +class SPDesktop; +class SPItem; +typedef union _GdkEvent GdkEvent; + +const double goldenratio = 1.61803398874989484820; // golden ratio namespace Inkscape { namespace UI { @@ -25,12 +26,6 @@ class ToolBase; } } -} - -const double goldenratio = 1.61803398874989484820; // golden ratio - -namespace Inkscape -{ class MessageContext; class MessageStack; diff --git a/src/debug/gdk-event-latency-tracker.cpp b/src/debug/gdk-event-latency-tracker.cpp index b21675f53..4679f05f1 100644 --- a/src/debug/gdk-event-latency-tracker.cpp +++ b/src/debug/gdk-event-latency-tracker.cpp @@ -9,6 +9,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include "debug/gdk-event-latency-tracker.h" #include "preferences.h" diff --git a/src/debug/gdk-event-latency-tracker.h b/src/debug/gdk-event-latency-tracker.h index c3624e74f..0fdb18790 100644 --- a/src/debug/gdk-event-latency-tracker.h +++ b/src/debug/gdk-event-latency-tracker.h @@ -12,7 +12,7 @@ #ifndef SEEN_INKSCAPE_DEBUG_GDK_EVENT_LATENCY_TRACKER_H #define SEEN_INKSCAPE_DEBUG_GDK_EVENT_LATENCY_TRACKER_H -#include +typedef union _GdkEvent GdkEvent; #include #include diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 8be5e001b..332de3630 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -25,7 +25,7 @@ #include "desktop.h" #include "desktop-events.h" #include "desktop-handles.h" -#include "dialogs/dialog-events.h" +#include "ui/dialog-events.h" #include "display/canvas-axonomgrid.h" #include "display/canvas-grid.h" #include "display/guideline.h" diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 91359983b..2c20524a2 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1012,8 +1012,8 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) } else if (style->line_height.unit == SP_CSS_UNIT_PERCENT || style->font_size.computed == 0) { linespacing_current = style->line_height.value; linespacing_normal = false; - } else { // we need % here - linespacing_current = style->line_height.computed / style->font_size.computed; + } else { + linespacing_current = style->line_height.computed; linespacing_normal = false; } linespacing += linespacing_current; diff --git a/src/desktop-style.h b/src/desktop-style.h index fc20e97b9..40ca27e9e 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -13,13 +13,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include - class ColorRGBA; class SPCSSAttr; class SPDesktop; class SPObject; class SPStyle; +typedef struct _GSList GSList; namespace Inkscape { namespace XML { class Node; diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt deleted file mode 100644 index ca19c0b72..000000000 --- a/src/dialogs/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ - -set(dialogs_SRC - dialog-events.cpp - - # ------- - # Headers - dialog-events.h -) - -# add_inkscape_lib(dialogs_LIB "${dialogs_SRC}") -add_inkscape_source("${dialogs_SRC}") diff --git a/src/dialogs/Makefile_insert b/src/dialogs/Makefile_insert deleted file mode 100644 index f1ed89314..000000000 --- a/src/dialogs/Makefile_insert +++ /dev/null @@ -1,5 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - dialogs/dialog-events.cpp \ - dialogs/dialog-events.h diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp deleted file mode 100644 index c1d096197..000000000 --- a/src/dialogs/dialog-events.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/** - * @file - * Event handler for dialog windows. - */ -/* Authors: - * bulia byak - * Johan Engelen - * - * Copyright (C) 2003-2014 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include -#endif - -#include -#include -#include -#include "macros.h" -#include -#include "desktop.h" -#include "inkscape.h" -#include "preferences.h" -#include "ui/tools/tool-base.h" - -#include "dialog-events.h" - - -/** - * Remove focus from window to whoever it is transient for. - */ -void sp_dialog_defocus_cpp(Gtk::Window *win) -{ - //find out the document window we're transient for - Gtk::Window *w = win->get_transient_for(); - - //switch to it - if (w) { - w->present(); - } -} - -void -sp_dialog_defocus (GtkWindow *win) -{ - GtkWindow *w; - //find out the document window we're transient for - w = gtk_window_get_transient_for(GTK_WINDOW(win)); - //switch to it - - if (w) { - gtk_window_present (w); - } -} - - -/** - * Callback to defocus a widget's parent dialog. - */ -void sp_dialog_defocus_callback_cpp(Gtk::Entry *e) -{ - sp_dialog_defocus_cpp(dynamic_cast(e->get_toplevel())); -} - -void -sp_dialog_defocus_callback (GtkWindow * /*win*/, gpointer data) -{ - sp_dialog_defocus( GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(data))) ); -} - - - -void -sp_dialog_defocus_on_enter_cpp (Gtk::Entry *e) -{ - e->signal_activate().connect(sigc::bind(sigc::ptr_fun(&sp_dialog_defocus_callback_cpp), e)); -} - -void -sp_dialog_defocus_on_enter (GtkWidget *w) -{ - g_signal_connect ( G_OBJECT (w), "activate", - G_CALLBACK (sp_dialog_defocus_callback), w ); -} - - - -gboolean -sp_dialog_event_handler (GtkWindow *win, GdkEvent *event, gpointer data) -{ - -// if the focus is inside the Text and Font textview, do nothing - GObject *dlg = G_OBJECT(data); - if (g_object_get_data (dlg, "eatkeys")) { - return FALSE; - } - - gboolean ret = FALSE; - - switch (event->type) { - - case GDK_KEY_PRESS: - - switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) { - case GDK_KEY_Escape: - sp_dialog_defocus (win); - ret = TRUE; - break; - case GDK_KEY_F4: - case GDK_KEY_w: - case GDK_KEY_W: - // close dialog - if (MOD__CTRL_ONLY(event)) { - - /* this code sends a delete_event to the dialog, - * instead of just destroying it, so that the - * dialog can do some housekeeping, such as remember - * its position. - */ - GdkEventAny event; - GtkWidget *widget = GTK_WIDGET(win); - event.type = GDK_DELETE; - event.window = gtk_widget_get_window (widget); - event.send_event = TRUE; - g_object_ref (G_OBJECT (event.window)); - gtk_main_do_event(reinterpret_cast(&event)); - g_object_unref (G_OBJECT (event.window)); - - ret = TRUE; - } - break; - default: // pass keypress to the canvas - break; - } - default: - ; - } - - return ret; - -} - - - -/** - * Make the argument dialog transient to the currently active document - * window. - */ -void sp_transientize(GtkWidget *dialog) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -#ifndef WIN32 // FIXME: Temporary Win32 special code to enable transient dialogs - // _set_skip_taskbar_hint makes transient dialogs NON-transient! When dialogs - // are made transient (_set_transient_for), they are already removed from - // the taskbar in Win32. - if (prefs->getBool( "/options/dialogsskiptaskbar/value")) { - gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE); - } -#endif - - gint transient_policy = prefs->getIntLimited("/options/transientpolicy/value", 1, 0, 2); - -#ifdef WIN32 // Win32 special code to enable transient dialogs - transient_policy = 2; -#endif - - if (transient_policy) { - - // if there's an active document window, attach dialog to it as a transient: - - if ( SP_ACTIVE_DESKTOP ) - { - SP_ACTIVE_DESKTOP->setWindowTransient (dialog, transient_policy); - } - } -} // end of sp_transientize() - -void on_transientize (SPDesktop *desktop, win_data *wd ) -{ - sp_transientize_callback (desktop, wd); -} - -void -sp_transientize_callback ( SPDesktop *desktop, win_data *wd ) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint transient_policy = prefs->getIntLimited( "/options/transientpolicy/value", 1, 0, 2); - -#ifdef WIN32 // Win32 special code to enable transient dialogs - transient_policy = 1; -#endif - - if (!transient_policy) - return; - - if (wd->win) - { - desktop->setWindowTransient (wd->win, transient_policy); - } -} - -void on_dialog_hide (GtkWidget *w) -{ - if (w) - gtk_widget_hide (w); -} - -void on_dialog_unhide (GtkWidget *w) -{ - if (w) - gtk_widget_show (w); -} - -gboolean -sp_dialog_hide(GObject * /*object*/, gpointer data) -{ - GtkWidget *dlg = GTK_WIDGET(data); - - if (dlg) - gtk_widget_hide (dlg); - - return TRUE; -} - - - -gboolean -sp_dialog_unhide(GObject * /*object*/, gpointer data) -{ - GtkWidget *dlg = GTK_WIDGET(data); - - if (dlg) - gtk_widget_show (dlg); - - return TRUE; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/dialogs/dialog-events.h b/src/dialogs/dialog-events.h deleted file mode 100644 index b4a5d7c35..000000000 --- a/src/dialogs/dialog-events.h +++ /dev/null @@ -1,74 +0,0 @@ -/** @file - * @brief Event handler for dialog windows - */ -/* Authors: - * bulia byak - * - * Copyright (C) 2003-2014 authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_DIALOG_EVENTS_H -#define SEEN_DIALOG_EVENTS_H - - -/* - * event callback can only accept one argument, but we need two, - * hence this struct. - * each dialog has a local static copy: - * win is the dialog window - * stop is the transientize semaphore: when 0, retransientizing this dialog - * is allowed - */ - -namespace Gtk { -class Window; -class Entry; -} - -class SPDesktop; - -typedef struct { - GtkWidget *win; - guint stop; -} win_data; - - -gboolean sp_dialog_event_handler ( GtkWindow *win, - GdkEvent *event, - gpointer data ); - -void sp_dialog_defocus_cpp (Gtk::Window *win); -void sp_dialog_defocus_callback_cpp(Gtk::Entry *e); -void sp_dialog_defocus_on_enter_cpp(Gtk::Entry *e); - -void sp_dialog_defocus ( GtkWindow *win ); -void sp_dialog_defocus_callback ( GtkWindow *win, gpointer data ); -void sp_dialog_defocus_on_enter ( GtkWidget *w ); -void sp_transientize ( GtkWidget *win ); - -void on_transientize ( SPDesktop *desktop, - win_data *wd ); - -void sp_transientize_callback ( SPDesktop *desktop, - win_data *wd ); - -void on_dialog_hide (GtkWidget *w); -void on_dialog_unhide (GtkWidget *w); - -//gboolean sp_dialog_hide (GObject *object, gpointer data); -//gboolean sp_dialog_unhide (GObject *object, gpointer data); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/dialogs/makefile.in b/src/dialogs/makefile.in deleted file mode 100644 index 9acaf79a0..000000000 --- a/src/dialogs/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) dialogs/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) dialogs/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/dir-util.h b/src/dir-util.h index 17261af41..e78cad6a6 100644 --- a/src/dir-util.h +++ b/src/dir-util.h @@ -9,8 +9,8 @@ * */ -#include -#include +#include +#include /** * Returns a form of \a path relative to \a base if that is easy to construct (eg if \a path @@ -49,7 +49,7 @@ char *inkscape_rel2abs(char const *path, char const *base, char *result, size_t char *inkscape_abs2rel(char const *path, char const *base, char *result, size_t const size); -gchar *prepend_current_dir_if_relative(gchar const *filename); +gchar *prepend_current_dir_if_relative(char const *filename); #endif // !SEEN_DIR_UTIL_H diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index d6ff7b2f0..e1f12b04b 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -26,13 +26,13 @@ #include <2geom/path.h> #include <2geom/transforms.h> #include <2geom/sbasis-to-bezier.h> +#include + #include "color.h" #include "style.h" #include "helper/geom-curves.h" #include "display/cairo-templates.h" -static void ink_cairo_pixbuf_cleanup(guchar *, void *); - /** * Key for cairo_surface_t to keep track of current color interpolation value * Only the address of the structure is used, it is never initialized. See: @@ -1170,7 +1170,7 @@ GdkPixbuf *ink_pixbuf_create_from_cairo_surface(cairo_surface_t *s) * to gdk_pixbuf_new_from_data when creating a GdkPixbuf backed by * a Cairo surface. */ -static void ink_cairo_pixbuf_cleanup(guchar * /*pixels*/, void *data) +void ink_cairo_pixbuf_cleanup(guchar * /*pixels*/, void *data) { cairo_surface_t *surface = static_cast(data); cairo_surface_destroy(surface); diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index f252c4a44..2a7e460e8 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -12,15 +12,16 @@ #ifndef SEEN_INKSCAPE_DISPLAY_CAIRO_UTILS_H #define SEEN_INKSCAPE_DISPLAY_CAIRO_UTILS_H +#include <2geom/forward.h> #include -//#include // workaround -//#include #include -//#include -#include <2geom/forward.h> #include "style.h" struct SPColor; +typedef struct _GdkPixbuf GdkPixbuf; + +void ink_cairo_pixbuf_cleanup(unsigned char *, void *); +void convert_pixbuf_argb32_to_normal(GdkPixbuf *pb); namespace Inkscape { diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h index 26f19732d..15bbc2ee0 100644 --- a/src/display/canvas-arena.h +++ b/src/display/canvas-arena.h @@ -13,15 +13,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include <2geom/rect.h> + #include "display/drawing.h" #include "display/drawing-item.h" #include "display/sp-canvas.h" #include "display/sp-canvas-item.h" -G_BEGIN_DECLS - #define SP_TYPE_CANVAS_ARENA (sp_canvas_arena_get_type ()) #define SP_CANVAS_ARENA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CANVAS_ARENA, SPCanvasArena)) #define SP_CANVAS_ARENA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CANVAS_ARENA, SPCanvasArenaClass)) @@ -30,6 +28,7 @@ G_BEGIN_DECLS typedef struct _SPCanvasArena SPCanvasArena; typedef struct _SPCanvasArenaClass SPCanvasArenaClass; +typedef struct _cairo_surface cairo_surface_t; struct CachePrefObserver; namespace Inkscape { @@ -39,7 +38,6 @@ class DrawingItem; } // namespace Inkscape - struct _SPCanvasArena { SPCanvasItem item; @@ -70,6 +68,4 @@ void sp_canvas_arena_set_sticky (SPCanvasArena *ca, gboolean sticky); void sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, Geom::IntRect const &area); -G_END_DECLS - #endif // SEEN_SP_CANVAS_ARENA_H diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 3888a3dc4..92cdb4c50 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -26,11 +26,11 @@ public: CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); virtual ~CanvasAxonomGrid(); - void Update (Geom::Affine const &affine, unsigned int flags); - void Render (SPCanvasBuf *buf); + virtual void Update (Geom::Affine const &affine, unsigned int flags); + virtual void Render (SPCanvasBuf *buf); - void readRepr(); - void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive); + virtual void readRepr(); + virtual void onReprAttrChanged (Inkscape::XML::Node * repr, char const *key, char const *oldval, char const *newval, bool is_interactive); double lengthy; /**< The lengths of the primary y-axis */ double angle_deg[3]; /**< Angle of each axis (note that angle[2] == 0) */ diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 328409e12..46b59d25a 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -11,9 +11,6 @@ * */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif #include #include #include "desktop.h" diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 5a23dee52..557bd6dab 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -82,7 +82,7 @@ public: virtual void Render (SPCanvasBuf *buf) = 0; virtual void readRepr() = 0; - virtual void onReprAttrChanged (Inkscape::XML::Node * /*repr*/, const gchar */*key*/, const gchar */*oldval*/, const gchar */*newval*/, bool /*is_interactive*/) = 0; + virtual void onReprAttrChanged (Inkscape::XML::Node * /*repr*/, char const */*key*/, char const */*oldval*/, char const */*newval*/, bool /*is_interactive*/) = 0; Gtk::Widget * newWidget(); @@ -129,11 +129,11 @@ public: CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); virtual ~CanvasXYGrid(); - void Update (Geom::Affine const &affine, unsigned int flags); - void Render (SPCanvasBuf *buf); + virtual void Update (Geom::Affine const &affine, unsigned int flags); + virtual void Render (SPCanvasBuf *buf); - void readRepr(); - void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive); + virtual void readRepr(); + virtual void onReprAttrChanged (Inkscape::XML::Node * repr, char const *key, char const *oldval, char const *newval, bool is_interactive); Geom::Point spacing; /**< Spacing between elements of the grid */ bool scaled[2]; /**< Whether the grid is in scaled mode, which can diff --git a/src/display/canvas-temporary-item-list.cpp b/src/display/canvas-temporary-item-list.cpp index b0fec98b5..60ead11ce 100644 --- a/src/display/canvas-temporary-item-list.cpp +++ b/src/display/canvas-temporary-item-list.cpp @@ -10,9 +10,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/canvas-temporary-item-list.h" - #include "display/canvas-temporary-item.h" +#include "display/canvas-temporary-item-list.h" namespace Inkscape { namespace Display { @@ -35,7 +34,7 @@ TemporaryItemList::~TemporaryItemList() /* Note that TemporaryItem or TemporaryItemList is responsible for deletion and such, so this return pointer can safely be ignored. */ TemporaryItem * -TemporaryItemList::add_item(SPCanvasItem *item, guint lifetime) +TemporaryItemList::add_item(SPCanvasItem *item, unsigned int lifetime) { // beware of strange things happening due to very short timeouts TemporaryItem * tempitem = new TemporaryItem(item, lifetime); diff --git a/src/display/canvas-temporary-item-list.h b/src/display/canvas-temporary-item-list.h index d204c692f..471bb99b9 100644 --- a/src/display/canvas-temporary-item-list.h +++ b/src/display/canvas-temporary-item-list.h @@ -11,7 +11,6 @@ */ #include -#include struct SPCanvasItem; class SPDesktop; @@ -22,14 +21,14 @@ namespace Display { class TemporaryItem; /** - * Provides a class that can contain active TemporaryItem's on a desktop. + * Provides a class that can contain active TemporaryItem[s] on a desktop. */ class TemporaryItemList { public: TemporaryItemList(SPDesktop *desktop); virtual ~TemporaryItemList(); - TemporaryItem* add_item (SPCanvasItem *item, guint lifetime); + TemporaryItem* add_item (SPCanvasItem *item, unsigned int lifetime); void delete_item (TemporaryItem * tempitem); protected: diff --git a/src/display/canvas-temporary-item.cpp b/src/display/canvas-temporary-item.cpp index 551ea1536..f55c8bf4e 100644 --- a/src/display/canvas-temporary-item.cpp +++ b/src/display/canvas-temporary-item.cpp @@ -16,7 +16,7 @@ #include "display/canvas-temporary-item.h" -#include +#include #include "display/sp-canvas-item.h" namespace Inkscape { @@ -54,9 +54,9 @@ TemporaryItem::~TemporaryItem() } } -/* static method*/ -gboolean TemporaryItem::_timeout(gpointer data) { - TemporaryItem *tempitem = reinterpret_cast(data); +/* static method */ +int TemporaryItem::_timeout(void* data) { + TemporaryItem *tempitem = static_cast(data); tempitem->timeout_id = 0; tempitem->signal_timeout.emit(tempitem); delete tempitem; diff --git a/src/display/canvas-temporary-item.h b/src/display/canvas-temporary-item.h index 09d243fa1..39ca2fc65 100644 --- a/src/display/canvas-temporary-item.h +++ b/src/display/canvas-temporary-item.h @@ -11,9 +11,8 @@ */ -#include -#include -#include +#include +#include struct SPCanvasItem; @@ -25,7 +24,7 @@ namespace Display { */ class TemporaryItem { public: - TemporaryItem(SPCanvasItem *item, guint lifetime, bool destroy_on_deselect = false); + TemporaryItem(SPCanvasItem *item, unsigned int lifetime, bool destroy_on_deselect = false); virtual ~TemporaryItem(); sigc::signal signal_timeout; @@ -34,10 +33,10 @@ protected: friend class TemporaryItemList; SPCanvasItem * canvasitem; /** The item we are holding on to */ - guint timeout_id; /** ID by which glib knows the timeout event */ + unsigned int timeout_id; /** ID by which glib knows the timeout event */ bool destroy_on_deselect; // only destroy when parent item is deselected, not when mouse leaves - static gboolean _timeout(gpointer data); ///< callback for when lifetime expired + static int _timeout(void* data); ///< callback for when lifetime expired private: TemporaryItem(const TemporaryItem&); diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 88812af0a..5ad87b4ef 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include #include diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 0a39a8e7f..54a62939d 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -48,7 +48,7 @@ SPCurve::new_from_rect(Geom::Rect const &rect, bool all_four_sides) Geom::Point p = rect.corner(0); c->moveto(p); - for (int i=3; i>=1; i--) { + for (int i=3; i>=1; --i) { c->lineto(rect.corner(i)); } @@ -87,10 +87,10 @@ SPCurve::get_pathvector() const * Returns the number of segments of all paths summed * This count includes the closing line segment of a closed path. */ -guint +size_t SPCurve::get_segment_count() const { - guint nr = 0; + size_t nr = 0; for(Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { nr += (*it).size(); @@ -200,7 +200,7 @@ SPCurve::reset() * Calls SPCurve::moveto() with point made of given coordinates. */ void -SPCurve::moveto(gdouble x, gdouble y) +SPCurve::moveto(double x, double y) { moveto(Geom::Point(x, y)); } @@ -229,7 +229,7 @@ SPCurve::lineto(Geom::Point const &p) * Calls SPCurve::lineto( Geom::Point(x,y) ) */ void -SPCurve::lineto(gdouble x, gdouble y) +SPCurve::lineto(double x, double y) { lineto(Geom::Point(x,y)); } @@ -249,7 +249,7 @@ SPCurve::quadto(Geom::Point const &p1, Geom::Point const &p2) * All coordinates must be finite. */ void -SPCurve::quadto(gdouble x1, gdouble y1, gdouble x2, gdouble y2) +SPCurve::quadto(double x1, double y1, double x2, double y2) { quadto( Geom::Point(x1,y1), Geom::Point(x2,y2) ); } @@ -269,7 +269,7 @@ SPCurve::curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const * All coordinates must be finite. */ void -SPCurve::curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2) +SPCurve::curveto(double x0, double y0, double x1, double y1, double x2, double y2) { curveto( Geom::Point(x0,y0), Geom::Point(x1,y1), Geom::Point(x2,y2) ); } @@ -520,7 +520,7 @@ SPCurve::append(SPCurve const *curve2, * When one of the curves is empty, this curves path becomes the non-empty path. */ SPCurve * -SPCurve::append_continuous(SPCurve const *c1, gdouble tolerance) +SPCurve::append_continuous(SPCurve const *c1, double tolerance) { using Geom::X; using Geom::Y; @@ -630,10 +630,10 @@ SPCurve::move_endpoints(Geom::Point const &new_p0, Geom::Point const &new_p1) * Sum of nodes in all the paths. When a path is closed, and its closing line segment is of zero-length, * this function will not count the closing knot double (so basically ignores the closing line segment when it has zero length) */ -guint +size_t SPCurve::nodes_in_path() const { - guint nr = 0; + size_t nr = 0; for(Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { nr += (*it).size(); diff --git a/src/display/curve.h b/src/display/curve.h index b3f1e3702..5fad75b18 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -13,10 +13,12 @@ #ifndef SEEN_DISPLAY_CURVE_H #define SEEN_DISPLAY_CURVE_H -#include #include <2geom/forward.h> +#include #include +extern "C" { typedef struct _GSList GSList; } + /** * Wrapper around a Geom::PathVector object. */ @@ -37,8 +39,8 @@ public: SPCurve * copy() const; - guint get_segment_count() const; - guint nodes_in_path() const; + size_t get_segment_count() const; + size_t nodes_in_path() const; bool is_empty() const; bool is_closed() const; @@ -54,13 +56,13 @@ public: void reset(); void moveto(Geom::Point const &p); - void moveto(gdouble x, gdouble y); + void moveto(double x, double y); void lineto(Geom::Point const &p); - void lineto(gdouble x, gdouble y); + void lineto(double x, double y); void quadto(Geom::Point const &p1, Geom::Point const &p2); - void quadto(gdouble x1, gdouble y1, gdouble x2, gdouble y2); + void quadto(double x1, double y1, double x2, double y2); void curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2); - void curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2); + void curveto(double x0, double y0, double x1, double y1, double x2, double y2); void closepath(); void closepath_current(); void backspace(); @@ -71,14 +73,14 @@ public: void last_point_additive_move(Geom::Point const & p); void append(SPCurve const *curve2, bool use_lineto); - SPCurve * append_continuous(SPCurve const *c1, gdouble tolerance); + SPCurve * append_continuous(SPCurve const *c1, double tolerance); SPCurve * create_reverse() const; GSList * split() const; static SPCurve * concat(GSList const *list); protected: - gint _refcount; + size_t _refcount; Geom::PathVector _pathv; diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h index 0d82087c3..a15e0d0e5 100644 --- a/src/display/drawing-context.h +++ b/src/display/drawing-context.h @@ -12,13 +12,13 @@ #ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_CONTEXT_H #define SEEN_INKSCAPE_DISPLAY_DRAWING_CONTEXT_H -#include -#include -#include #include <2geom/affine.h> #include <2geom/angle.h> #include <2geom/rect.h> #include <2geom/transforms.h> +#include +#include +typedef unsigned int guint32; namespace Inkscape { diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index bd6fb41d8..56507bacb 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -825,9 +825,10 @@ DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags) { // Sometimes there's no BBOX in state, reason unknown (bug 992817) // I made this not an assert to remove the warning + // This warning clutters the console output, so commented out if (!(_state & STATE_BBOX) || !(_state & STATE_PICK)) { - g_warning("Invalid state when picking: STATE_BBOX = %d, STATE_PICK = %d", - _state & STATE_BBOX, _state & STATE_PICK); + /*g_warning("Invalid state when picking: STATE_BBOX = %d, STATE_PICK = %d", + _state & STATE_BBOX, _state & STATE_PICK);*/ return NULL; } // ignore invisible and insensitive items unless sticky diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 925bcbddb..dda5cd6ac 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -12,13 +12,13 @@ #ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H #define SEEN_INKSCAPE_DISPLAY_DRAWING_ITEM_H -#include -#include +#include <2geom/rect.h> +#include <2geom/affine.h> #include #include #include -#include <2geom/rect.h> -#include <2geom/affine.h> +#include +#include class SPStyle; diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index e937cca55..7bec1606a 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -14,11 +14,16 @@ #include #include -#include #include <2geom/affine.h> #include <2geom/rect.h> #include <2geom/transforms.h> +extern "C" { +typedef struct _cairo cairo_t; +typedef struct _cairo_surface cairo_surface_t; +typedef struct _cairo_region cairo_region_t; +} + namespace Inkscape { class DrawingContext; diff --git a/src/display/drawing.h b/src/display/drawing.h index cc74833ba..0c12b1510 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -12,18 +12,18 @@ #ifndef SEEN_INKSCAPE_DISPLAY_DRAWING_H #define SEEN_INKSCAPE_DISPLAY_DRAWING_H -#include -#include +#include <2geom/rect.h> #include #include +#include #include -#include <2geom/rect.h> + #include "display/drawing-item.h" #include "display/rendermode.h" #include "nr-filter-colormatrix.h" typedef struct _SPCanvasArena SPCanvasArena; - +typedef unsigned int guint32; namespace Inkscape { @@ -65,7 +65,7 @@ public: OutlineColors const &colors() const { return _colors; } - void setGrayscaleMatrix(gdouble value_matrix[20]); + void setGrayscaleMatrix(double value_matrix[20]); void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = DrawingItem::STATE_ALL, unsigned reset = 0); void render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags = 0); @@ -100,7 +100,7 @@ private: OutlineColors _colors; Filters::FilterColorMatrix::ColorMatrixMatrix _grayscale_colormatrix; - SPCanvasArena *_canvasarena; // may be NULL is this arena is not the screen + SPCanvasArena *_canvasarena; // may be NULL if this arena is not the screen // but used for export etc. friend class DrawingItem; diff --git a/src/display/gnome-canvas-acetate.h b/src/display/gnome-canvas-acetate.h index 447c3a9c4..3e1ba7661 100644 --- a/src/display/gnome-canvas-acetate.h +++ b/src/display/gnome-canvas-acetate.h @@ -15,10 +15,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "display/sp-canvas-item.h" - #define GNOME_TYPE_CANVAS_ACETATE (sp_canvas_acetate_get_type ()) #define SP_CANVAS_ACETATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_ACETATE, SPCanvasAcetate)) #define SP_CANVAS_ACETATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_ACETATE, SPCanvasAcetateClass)) @@ -27,17 +25,15 @@ struct SPCanvasAcetate { - SPCanvasItem item; + SPCanvasItem item; }; struct SPCanvasAcetateClass { - SPCanvasItemClass parent_class; + SPCanvasItemClass parent_class; }; GType sp_canvas_acetate_get_type (void); - - #endif // SEEN_SP_CANVAS_ACETATE_H /* diff --git a/src/display/grayscale.cpp b/src/display/grayscale.cpp index f59cf6d23..3c0031e87 100644 --- a/src/display/grayscale.cpp +++ b/src/display/grayscale.cpp @@ -36,7 +36,7 @@ guint32 process(guint32 rgba) { return process(SP_RGBA32_R_U(rgba), SP_RGBA32_G_U(rgba), SP_RGBA32_B_U(rgba), SP_RGBA32_A_U(rgba)); } -guint32 process(guchar r, guchar g, guchar b, guchar a) { +guint32 process(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { /** To reduce banding in gradients, this calculation is tweaked a bit * by outputing blue+1 or red+1 or both. The luminance is calculated @@ -62,7 +62,7 @@ guint32 process(guchar r, guchar g, guchar b, guchar a) { } } -guchar luminance(guchar r, guchar g, guchar b) { +unsigned char luminance(unsigned char r, unsigned char g, unsigned char b) { guint32 luminance = ( red_factor * r + green_factor * g + blue_factor * b ); diff --git a/src/display/grayscale.h b/src/display/grayscale.h index 18162e1f3..0ffe727da 100644 --- a/src/display/grayscale.h +++ b/src/display/grayscale.h @@ -10,15 +10,15 @@ * Released under GNU GPL */ -#include +typedef unsigned int guint32; /** * Provide methods to calculate grayscale values (e.g. convert rgba value to grayscale rgba value). */ namespace Grayscale { guint32 process(guint32 rgba); - guint32 process(guchar r, guchar g, guchar b, guchar a); - guchar luminance(guchar r, guchar g, guchar b); + guint32 process(unsigned char r, unsigned char g, unsigned char b, unsigned char a); + unsigned char luminance(unsigned char r, unsigned char g, unsigned char b); bool activeDesktopIsGrayscale(); }; diff --git a/src/display/nr-3dutils.h b/src/display/nr-3dutils.h index c278c81c6..eb773a9ad 100644 --- a/src/display/nr-3dutils.h +++ b/src/display/nr-3dutils.h @@ -1,5 +1,5 @@ -#ifndef __NR_3DUTILS_H__ -#define __NR_3DUTILS_H__ +#ifndef SEEN_NR_3DUTILS_H +#define SEEN_NR_3DUTILS_H /* * 3D utils. Definition of gdouble vectors of dimension 3 and of some basic @@ -14,7 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include <2geom/forward.h> namespace NR { @@ -51,7 +50,7 @@ const static Fvector EYE_VECTOR(0, 0, 1); * \param v a reference to a vector with double components * \return the euclidian norm of v */ -gdouble norm(const Fvector &v); +double norm(const Fvector &v); /** * Normalizes a vector @@ -67,7 +66,7 @@ void normalize_vector(Fvector &v); * \param b a Fvector reference * \return the scalar product of a and b */ -gdouble scalar_product(const Fvector &a, const Fvector &b); +double scalar_product(const Fvector &a, const Fvector &b); /** * Computes the normalized sum of two Fvectors @@ -88,7 +87,7 @@ void normalized_sum(Fvector &r, const Fvector &a, const Fvector &b); * \param z a reference to a z coordinate * \param z a reference to a transformation matrix */ -void convert_coord(gdouble &x, gdouble &y, gdouble &z, Geom::Affine const &trans); +void convert_coord(double &x, double &y, double &z, Geom::Affine const &trans); } /* namespace NR */ diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index c0504993b..30c9d6725 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_BLEND_H__ -#define __NR_FILTER_BLEND_H__ +#ifndef SEEN_NR_FILTER_BLEND_H +#define SEEN_NR_FILTER_BLEND_H /* * SVG feBlend renderer diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index c7e5e91d9..cc43f4914 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_COLOR_MATRIX_H__ -#define __NR_FILTER_COLOR_MATRIX_H__ +#ifndef SEEN_NR_FILTER_COLOR_MATRIX_H +#define SEEN_NR_FILTER_COLOR_MATRIX_H /* * feColorMatrix filter primitive renderer @@ -16,6 +16,9 @@ #include <2geom/forward.h> #include "display/nr-filter-primitive.h" +typedef unsigned int guint32; +typedef signed int gint32; + namespace Inkscape { namespace Filters { @@ -40,8 +43,8 @@ public: virtual double complexity(Geom::Affine const &ctm); virtual void set_type(FilterColorMatrixType type); - virtual void set_value(gdouble value); - virtual void set_values(std::vector const &values); + virtual void set_value(double value); + virtual void set_values(std::vector const &values); public: struct ColorMatrixMatrix { @@ -52,8 +55,8 @@ public: }; private: - std::vector values; - gdouble value; + std::vector values; + double value; FilterColorMatrixType type; }; diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index 558d097a8..7019dde37 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_COMPONENT_TRANSFER_H__ -#define __NR_FILTER_COMPONENT_TRANSFER_H__ +#ifndef SEEN_NR_FILTER_COMPONENT_TRANSFER_H +#define SEEN_NR_FILTER_COMPONENT_TRANSFER_H /* * feComponentTransfer filter primitive renderer @@ -40,7 +40,7 @@ public: virtual double complexity(Geom::Affine const &ctm); FilterComponentTransferType type[4]; - std::vector tableValues[4]; + std::vector tableValues[4]; double slope[4]; double intercept[4]; double amplitude[4]; diff --git a/src/display/nr-filter-composite.h b/src/display/nr-filter-composite.h index 95579cc0e..35756383b 100644 --- a/src/display/nr-filter-composite.h +++ b/src/display/nr-filter-composite.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_COMPOSITE_H__ -#define __NR_FILTER_COMPOSITE_H__ +#ifndef SEEN_NR_FILTER_COMPOSITE_H +#define SEEN_NR_FILTER_COMPOSITE_H /* * feComposite filter effect renderer diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index 4041ff96f..d2e38eb95 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_CONVOLVE_MATRIX_H__ -#define __NR_FILTER_CONVOLVE_MATRIX_H__ +#ifndef SEEN_NR_FILTER_CONVOLVE_MATRIX_H +#define SEEN_NR_FILTER_CONVOLVE_MATRIX_H /* * feConvolveMatrix filter primitive renderer @@ -48,10 +48,10 @@ public: void set_preserveAlpha(bool pa); private: - std::vector kernelMatrix; + std::vector kernelMatrix; int targetX, targetY; int orderX, orderY; - gdouble divisor, bias; + double divisor, bias; int dx, dy, kernelUnitLength; FilterConvolveMatrixEdgeMode edgeMode; bool preserveAlpha; diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 043a5eb39..7739b3ea6 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_DIFFUSELIGHTING_H__ -#define __NR_FILTER_DIFFUSELIGHTING_H__ +#ifndef SEEN_NR_FILTER_DIFFUSELIGHTING_H +#define SEEN_NR_FILTER_DIFFUSELIGHTING_H /* * feDiffuseLighting renderer @@ -13,7 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" @@ -23,6 +22,7 @@ class SPFeDistantLight; class SPFePointLight; class SPFeSpotLight; struct SVGICCColor; +typedef unsigned int guint32; namespace Inkscape { namespace Filters { @@ -43,8 +43,8 @@ public: SPFeSpotLight *spot; } light; LightType light_type; - gdouble diffuseConstant; - gdouble surfaceScale; + double diffuseConstant; + double surfaceScale; guint32 lighting_color; private: diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index a01930045..c4e2400fe 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_DISPLACEMENT_MAP_H__ -#define __NR_FILTER_DISPLACEMENT_MAP_H__ +#ifndef SEEN_NR_FILTER_DISPLACEMENT_MAP_H +#define SEEN_NR_FILTER_DISPLACEMENT_MAP_H /* * feDisplacementMap filter primitive renderer diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index 9a968047d..826aa981a 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_FLOOD_H__ -#define __NR_FILTER_FLOOD_H__ +#ifndef SEEN_NR_FILTER_FLOOD_H +#define SEEN_NR_FILTER_FLOOD_H /* * feFlood filter primitive renderer @@ -15,6 +15,7 @@ #include "display/nr-filter-primitive.h" struct SVGICCColor; +typedef unsigned int guint32; namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 1c35a0f1d..88c38247f 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_GAUSSIAN_H__ -#define __NR_FILTER_GAUSSIAN_H__ +#ifndef SEEN_NR_FILTER_GAUSSIAN_H +#define SEEN_NR_FILTER_GAUSSIAN_H /* * Gaussian blur renderer diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index 69691ac99..147a8ba6c 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_IMAGE_H__ -#define __NR_FILTER_IMAGE_H__ +#ifndef SEEN_NR_FILTER_IMAGE_H +#define SEEN_NR_FILTER_IMAGE_H /* * feImage filter primitive renderer @@ -34,7 +34,7 @@ public: virtual double complexity(Geom::Affine const &ctm); void set_document( SPDocument *document ); - void set_href(const gchar *href); + void set_href(char const *href); void set_align( unsigned int align ); void set_clip( unsigned int clip ); bool from_element; @@ -42,7 +42,7 @@ public: private: SPDocument *document; - gchar *feImageHref; + char *feImageHref; Inkscape::Pixbuf *image; float feImageX, feImageY, feImageWidth, feImageHeight; unsigned int aspect_align, aspect_clip; diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index 238f9a3e7..b20d663ab 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_MERGE_H__ -#define __NR_FILTER_MERGE_H__ +#ifndef SEEN_NR_FILTER_MERGE_H +#define SEEN_NR_FILTER_MERGE_H /* * feMerge filter effect renderer diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h index 0574ff4ad..cd7dfe775 100644 --- a/src/display/nr-filter-morphology.h +++ b/src/display/nr-filter-morphology.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_MORPHOLOGY_H__ -#define __NR_FILTER_MORPHOLOGY_H__ +#ifndef SEEN_NR_FILTER_MORPHOLOGY_H +#define SEEN_NR_FILTER_MORPHOLOGY_H /* * feMorphology filter primitive renderer diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index 1ecc1621e..c1ee1d82a 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_OFFSET_H__ -#define __NR_FILTER_OFFSET_H__ +#ifndef SEEN_NR_FILTER_OFFSET_H +#define SEEN_NR_FILTER_OFFSET_H /* * feOffset filter primitive renderer diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 62f350844..4b7577159 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -11,9 +11,9 @@ #ifndef SEEN_NR_FILTER_PRIMITIVE_H #define SEEN_NR_FILTER_PRIMITIVE_H -#include #include <2geom/forward.h> #include <2geom/rect.h> + #include "display/nr-filter-types.h" #include "svg/svg-length.h" @@ -31,7 +31,7 @@ public: virtual ~FilterPrimitive(); virtual void render_cairo(FilterSlot &slot); - virtual int render(FilterSlot & /*slot*/, FilterUnits const & /*units*/) { return 0; } + virtual int render(FilterSlot & /*slot*/, FilterUnits const & /*units*/) { return 0; } // pure virtual? virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &m); /** diff --git a/src/display/nr-filter-skeleton.h b/src/display/nr-filter-skeleton.h index 049c0df80..e17c244c1 100644 --- a/src/display/nr-filter-skeleton.h +++ b/src/display/nr-filter-skeleton.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_SKELETON_H__ -#define __NR_FILTER_SKELETON_H__ +#ifndef SEEN_NR_FILTER_SKELETON_H +#define SEEN_NR_FILTER_SKELETON_H /* * Filter primitive renderer skeleton class diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index f3c98b8d9..987dedfd1 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_SLOT_H__ -#define __NR_FILTER_SLOT_H__ +#ifndef SEEN_NR_FILTER_SLOT_H +#define SEEN_NR_FILTER_SLOT_H /* * A container class for filter slots. Allows for simple getting and @@ -15,10 +15,14 @@ */ #include -#include #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" +extern "C" { +typedef struct _cairo cairo_t; +typedef struct _cairo_surface cairo_surface_t; +} + namespace Inkscape { class DrawingContext; class DrawingItem; diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index c57e3a9ff..ff9cda450 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_SPECULARLIGHTING_H__ -#define __NR_FILTER_SPECULARLIGHTING_H__ +#ifndef SEEN_NR_FILTER_SPECULARLIGHTING_H +#define SEEN_NR_FILTER_SPECULARLIGHTING_H /* * feSpecularLighting renderer @@ -13,7 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" @@ -21,6 +20,7 @@ class SPFeDistantLight; class SPFePointLight; class SPFeSpotLight; struct SVGICCColor; +typedef unsigned int guint32; namespace Inkscape { namespace Filters { @@ -44,9 +44,9 @@ public: SPFeSpotLight *spot; } light; LightType light_type; - gdouble surfaceScale; - gdouble specularConstant; - gdouble specularExponent; + double surfaceScale; + double specularConstant; + double specularExponent; guint32 lighting_color; private: diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h index dc5b99a42..29087f2d6 100644 --- a/src/display/nr-filter-tile.h +++ b/src/display/nr-filter-tile.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_TILE_H__ -#define __NR_FILTER_TILE_H__ +#ifndef SEEN_NR_FILTER_TILE_H +#define SEEN_NR_FILTER_TILE_H /* * feTile filter primitive renderer diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index 360853364..ee8079133 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_TURBULENCE_H__ -#define __NR_FILTER_TURBULENCE_H__ +#ifndef SEEN_NR_FILTER_TURBULENCE_H +#define SEEN_NR_FILTER_TURBULENCE_H /* * feTurbulence filter primitive renderer @@ -22,6 +22,7 @@ */ #include <2geom/point.h> + #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" diff --git a/src/display/nr-filter-types.h b/src/display/nr-filter-types.h index 502bfe348..2e35d6da8 100644 --- a/src/display/nr-filter-types.h +++ b/src/display/nr-filter-types.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_TYPES_H__ -#define __NR_FILTER_TYPES_H__ +#ifndef SEEN_NR_FILTER_TYPES_H +#define SEEN_NR_FILTER_TYPES_H namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h index f918cf12e..0ee6c3707 100644 --- a/src/display/nr-filter-units.h +++ b/src/display/nr-filter-units.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_UNITS_H__ -#define __NR_FILTER_UNITS_H__ +#ifndef SEEN_NR_FILTER_UNITS_H +#define SEEN_NR_FILTER_UNITS_H /* * Utilities for handling coordinate system transformations in filters diff --git a/src/display/nr-filter-utils.h b/src/display/nr-filter-utils.h index 7e073168f..35a74d7c1 100644 --- a/src/display/nr-filter-utils.h +++ b/src/display/nr-filter-utils.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_UTILS_H__ -#define __NR_FILTER_UTILS_H__ +#ifndef SEEN_NR_FILTER_UTILS_H +#define SEEN_NR_FILTER_UTILS_H /** * @file @@ -26,7 +26,6 @@ namespace Filters { * \return 0 if the value is smaller than 0, 255 if it is greater 255, else v * \param v the value to clamp */ -__attribute__ ((const)) inline int clamp(int const val) { if (val < 0) return 0; if (val > 255) return 255; @@ -39,7 +38,6 @@ inline int clamp(int const val) { * \return 0 if the value is smaller than 0, 255^3 (16581375) if it is greater than 255^3, else v * \param v the value to clamp */ -__attribute__ ((const)) inline int clamp3(int const val) { if (val < 0) return 0; if (val > 16581375) return 16581375; @@ -59,7 +57,6 @@ inline int clamp3(int const val) { * \param val the value to clamp * \param alpha the maximum value to clamp to */ -__attribute__ ((const)) inline int clamp_alpha(int const val, int const alpha) { if (val < 0) return 0; if (val > alpha) return alpha; diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index f9dcf1d84..9a30efabd 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -1,5 +1,5 @@ -#ifndef __NR_FILTER_H__ -#define __NR_FILTER_H__ +#ifndef SEEN_NR_FILTER_H +#define SEEN_NR_FILTER_H /* * SVG filters rendering diff --git a/src/display/nr-light-types.h b/src/display/nr-light-types.h index 5c9acb324..8cc92db77 100644 --- a/src/display/nr-light-types.h +++ b/src/display/nr-light-types.h @@ -1,5 +1,5 @@ -#ifndef __NR_LIGHT_TYPES_H__ -#define __NR_LIGHT_TYPES_H__ +#ifndef SEEN_NR_LIGHT_TYPES_H +#define SEEN_NR_LIGHT_TYPES_H namespace Inkscape { namespace Filters { diff --git a/src/display/nr-light.cpp b/src/display/nr-light.cpp index 6331d1546..0e9a55a9f 100644 --- a/src/display/nr-light.cpp +++ b/src/display/nr-light.cpp @@ -51,7 +51,7 @@ PointLight::PointLight(SPFePointLight *light, guint32 lighting_color, const Geom PointLight::~PointLight() {} -void PointLight::light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z) { +void PointLight::light_vector(NR::Fvector &v, double x, double y, double z) { v[X_3D] = l_x - x; v[Y_3D] = l_y - y; v[Z_3D] = l_z - z; @@ -65,7 +65,7 @@ void PointLight::light_components(NR::Fvector &lc) { } SpotLight::SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Geom::Affine &trans) { - gdouble p_x, p_y, p_z; + double p_x, p_y, p_z; color = lighting_color; l_x = light->x; l_y = light->y; @@ -86,7 +86,7 @@ SpotLight::SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Geom::A SpotLight::~SpotLight() {} -void SpotLight::light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z) { +void SpotLight::light_vector(NR::Fvector &v, double x, double y, double z) { v[X_3D] = l_x - x; v[Y_3D] = l_y - y; v[Z_3D] = l_z - z; @@ -94,7 +94,7 @@ void SpotLight::light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z) { } void SpotLight::light_components(NR::Fvector &lc, const NR::Fvector &L) { - gdouble spmod = (-1) * NR::scalar_product(L, S); + double spmod = (-1) * NR::scalar_product(L, S); if (spmod <= cos_lca) spmod = 0; else diff --git a/src/display/nr-light.h b/src/display/nr-light.h index 0c1235483..94b573761 100644 --- a/src/display/nr-light.h +++ b/src/display/nr-light.h @@ -1,5 +1,6 @@ -#ifndef __NR_LIGHT_H__ -#define __NR_LIGHT_H__ +#ifndef SEEN_NR_LIGHT_H +#define SEEN_NR_LIGHT_H + /** \file * These classes provide tools to compute interesting objects relative to light * sources. Each class provides a constructor converting information contained @@ -8,14 +9,15 @@ * light color components (at a given point). */ -#include +#include <2geom/forward.h> + #include "display/nr-3dutils.h" #include "display/nr-light-types.h" -#include <2geom/forward.h> class SPFeDistantLight; class SPFePointLight; class SPFeSpotLight; +typedef unsigned int guint32; namespace Inkscape { namespace Filters { @@ -53,8 +55,8 @@ class DistantLight { private: guint32 color; - gdouble azimuth; //azimuth in rad - gdouble elevation; //elevation in rad + double azimuth; //azimuth in rad + double elevation; //elevation in rad }; class PointLight { @@ -80,7 +82,7 @@ class PointLight { * \param y y coordinate of the current point * \param z z coordinate of the current point */ - void light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z); + void light_vector(NR::Fvector &v, double x, double y, double z); /** * Computes the light components of the distant light @@ -92,9 +94,9 @@ class PointLight { private: guint32 color; //light position coordinates in render setting - gdouble l_x; - gdouble l_y; - gdouble l_z; + double l_x; + double l_y; + double l_z; }; class SpotLight { @@ -121,7 +123,7 @@ class SpotLight { * \param y y coordinate of the current point * \param z z coordinate of the current point */ - void light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z); + void light_vector(NR::Fvector &v, double x, double y, double z); /** * Computes the light components of the distant light at the current @@ -135,11 +137,11 @@ class SpotLight { private: guint32 color; //light position coordinates in render setting - gdouble l_x; - gdouble l_y; - gdouble l_z; - gdouble cos_lca; //cos of the limiting cone angle - gdouble speExp; //specular exponent; + double l_x; + double l_y; + double l_z; + double cos_lca; //cos of the limiting cone angle + double speExp; //specular exponent; NR::Fvector S; //unit vector from light position in the direction //the spot point at }; diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index e1bb047bb..21ab3ed02 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -1,4 +1,3 @@ -#include "config.h" #ifndef NR_SVGFONTS_H_SEEN #define NR_SVGFONTS_H_SEEN /* @@ -13,7 +12,7 @@ * Read the file 'COPYING' for more information. */ -#include "cairo.h" +#include #include class SvgFont; @@ -21,40 +20,50 @@ class SPFont; class SPGlyph; class SPMissingGlyph; -struct _GdkEventExpose; -typedef _GdkEventExpose GdkEventExpose; +extern "C" { typedef struct _GdkEventExpose GdkEventExpose; } namespace Gtk { class Widget; } -class UserFont{ +class UserFont { public: -UserFont(SvgFont* instance); -cairo_font_face_t* face; + UserFont(SvgFont* instance); + cairo_font_face_t* face; }; -class SvgFont{ +class SvgFont { public: -SvgFont(SPFont* spfont); -void refresh(); -cairo_font_face_t* get_font_face(); -cairo_status_t scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *metrics); -cairo_status_t scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, const char *utf8, int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *flags); -cairo_status_t scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics); + SvgFont(SPFont* spfont); + void refresh(); + cairo_font_face_t* get_font_face(); + cairo_status_t scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *metrics); + cairo_status_t scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, const char *utf8, int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *flags); + cairo_status_t scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics); -Geom::PathVector flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv); -void render_glyph_path(cairo_t* cr, Geom::PathVector* pathv); -void glyph_modified(SPObject *, unsigned int); + Geom::PathVector flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv); + void render_glyph_path(cairo_t* cr, Geom::PathVector* pathv); + void glyph_modified(SPObject *, unsigned int); private: -SPFont* font; -UserFont* userfont; -std::vector glyphs; -SPMissingGlyph* missingglyph; -sigc::connection glyph_modified_connection; + SPFont* font; + UserFont* userfont; + std::vector glyphs; + SPMissingGlyph* missingglyph; + sigc::connection glyph_modified_connection; -bool drawing_expose_cb (Gtk::Widget *widget, GdkEventExpose *event, gpointer data); + bool drawing_expose_cb (Gtk::Widget *widget, GdkEventExpose *event, void* data); }; #endif //#ifndef NR_SVGFONTS_H_SEEN + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index e19db928e..4870b33b0 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -23,8 +23,9 @@ # include "config.h" #endif -#include #include <2geom/rect.h> +#include + #include "ui/control-types.h" G_BEGIN_DECLS diff --git a/src/display/sp-canvas-util.h b/src/display/sp-canvas-util.h index 07323f31a..73135ed79 100644 --- a/src/display/sp-canvas-util.h +++ b/src/display/sp-canvas-util.h @@ -1,5 +1,5 @@ -#ifndef __SP_CANVAS_UTILS_H__ -#define __SP_CANVAS_UTILS_H__ +#ifndef SEEN_SP_CANVAS_UTILS_H +#define SEEN_SP_CANVAS_UTILS_H /* * Helper stuff for SPCanvas @@ -19,7 +19,7 @@ struct SPCanvasItem; struct SPCanvasBuf; namespace Geom { - class Affine; + class Affine; } /* Miscellaneous utility & convenience functions for general canvas objects */ diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 8434f6ae2..3dc4a7504 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1230,7 +1230,7 @@ static void sp_canvas_init(SPCanvas *canvas) { gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE); - //gtk_widget_set_double_buffered (GTK_WIDGET (canvas), TRUE); + gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE); gtk_widget_set_can_focus (GTK_WIDGET (canvas), TRUE); canvas->pick_event.type = GDK_LEAVE_NOTIFY; diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index adae30f35..48c3de2fc 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -22,15 +22,6 @@ # include "config.h" #endif -#ifdef HAVE_INTTYPES_H -# include -#else -# ifdef HAVE_STDINT_H -# include -# endif -#endif - -#include #include #include #include <2geom/affine.h> diff --git a/src/document-private.h b/src/document-private.h index ae189c2c0..a5033b3c2 100644 --- a/src/document-private.h +++ b/src/document-private.h @@ -34,6 +34,7 @@ class Event; } } +typedef struct _GHashTable GHashTable; struct SPDocumentPrivate { typedef std::map IDChangedSignalMap; diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 679223da6..57222f1cc 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -44,19 +44,6 @@ * (Lauris Kaplinski) */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - - - -#if HAVE_STRING_H -#endif - - -#if HAVE_STDLIB_H -#endif - #include #include #include "xml/repr.h" diff --git a/src/document.cpp b/src/document.cpp index c38cfa4ae..dd18186d4 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1373,7 +1373,7 @@ GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vectorpriv != NULL, NULL); diff --git a/src/document.h b/src/document.h index 7574e1bda..2f865367e 100644 --- a/src/document.h +++ b/src/document.h @@ -74,8 +74,8 @@ class SPDocument : public Inkscape::GC::Managed<>, public: typedef sigc::signal IDChangedSignal; typedef sigc::signal ResourcesChangedSignal; - typedef sigc::signal ModifiedSignal; - typedef sigc::signal URISetSignal; + typedef sigc::signal ModifiedSignal; + typedef sigc::signal URISetSignal; typedef sigc::signal ResizedSignal; typedef sigc::signal ReconstructionStart; typedef sigc::signal ReconstructionFinish; @@ -99,9 +99,9 @@ public: CRCascade *style_cascade; protected: - gchar *uri; ///< A filename (not a URI yet), or NULL - gchar *base; ///< To be used for resolving relative hrefs. - gchar *name; ///< basename(uri) or other human-readable label for the document. + char *uri; ///< A filename (not a URI yet), or NULL + char *base; ///< To be used for resolving relative hrefs. + char *name; ///< basename(uri) or other human-readable label for the document. public: @@ -111,10 +111,10 @@ public: Glib::ustring actionkey; /// Handler ID - guint modified_id; + unsigned modified_id; /// Connector rerouting handler ID - guint rerouting_handler_id; + unsigned rerouting_handler_id; Inkscape::ProfileManager* profileManager; @@ -136,15 +136,15 @@ public: Inkscape::XML::Document const *getReprDoc() const { return rdoc; } /** A filename (not a URI yet), or NULL */ - gchar const *getURI() const { return uri; } - void setUri(gchar const *uri); + char const *getURI() const { return uri; } + void setUri(char const *uri); /** To be used for resolving relative hrefs. */ - gchar const *getBase() const { return base; }; - void setBase( gchar const* base ); + char const *getBase() const { return base; }; + void setBase( char const* base ); /** basename(uri) or other human-readable label for the document. */ - gchar const* getName() const { return name; } + char const* getName() const { return name; } /** Return the main defs object for the document. */ SPDefs *getDefs(); @@ -172,10 +172,10 @@ public: sigc::connection connectResized(ResizedSignal::slot_type slot); sigc::connection connectCommit(CommitSignal::slot_type slot); - void bindObjectToId(gchar const *id, SPObject *object); + void bindObjectToId(char const *id, SPObject *object); SPObject *getObjectById(Glib::ustring const &id) const; - SPObject *getObjectById(gchar const *id) const; - sigc::connection connectIdChanged(const gchar *id, IDChangedSignal::slot_type slot); + SPObject *getObjectById(char const *id) const; + sigc::connection connectIdChanged(const char *id, IDChangedSignal::slot_type slot); void bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object); SPObject *getObjectByRepr(Inkscape::XML::Node *repr) const; @@ -221,12 +221,12 @@ public: sigc::connection _selection_changed_connection; sigc::connection _desktop_activated_connection; - sigc::connection connectResourcesChanged(const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); + sigc::connection connectResourcesChanged(char const *key, SPDocument::ResourcesChangedSignal::slot_type slot); void fitToRect(Geom::Rect const &rect, bool with_margins = false); - static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, + static SPDocument *createNewDoc(char const*uri, unsigned int keepalive, bool make_new = false, SPDocument *parent=NULL ); - static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + static SPDocument *createNewDocFromMem(char const*buffer, int length, unsigned int keepalive); SPDocument *createChildDoc(std::string const &uri); /** @@ -234,8 +234,8 @@ public: */ static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const &p, bool take_insensitive = false); - static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, - gchar const *base, gchar const *name, unsigned int keepalive, + static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri, + char const *base, char const *name, unsigned int keepalive, SPDocument *parent); SPDocument *doRef(); @@ -249,25 +249,25 @@ public: void setHeight(const Inkscape::Util::Quantity &height); void setViewBox(const Geom::Rect &viewBox); void requestModified(); - gint ensureUpToDate(); - bool addResource(const gchar *key, SPObject *object); - bool removeResource(const gchar *key, SPObject *object); - const GSList *getResourceList(const gchar *key) const; + int ensureUpToDate(); + bool addResource(char const *key, SPObject *object); + bool removeResource(char const *key, SPObject *object); + const GSList *getResourceList(char const *key) const; GSList *getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; GSList *getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; - SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, gboolean into_groups, SPItem *upto = NULL) const; + SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; GSList *getItemsAtPoints(unsigned const key, std::vector points) const; SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; - void changeUriAndHrefs(gchar const *uri); - void emitResizedSignal(gdouble width, gdouble height); + void changeUriAndHrefs(char const *uri); + void emitResizedSignal(double width, double height); unsigned int vacuumDocument(); void importDefs(SPDocument *source); private: - void do_change_uri(gchar const *const filename, bool const rebase); + void do_change_uri(char const *const filename, bool const rebase); void setupViewport(SPItemCtx *ctx); }; diff --git a/src/draw-anchor.cpp b/src/draw-anchor.cpp index 00db936e1..6b02bb607 100644 --- a/src/draw-anchor.cpp +++ b/src/draw-anchor.cpp @@ -30,7 +30,7 @@ using Inkscape::ControlManager; /** * Creates an anchor object and initializes it. */ -SPDrawAnchor *sp_draw_anchor_new(Inkscape::UI::Tools::FreehandBase *dc, SPCurve *curve, gboolean start, Geom::Point delta) +SPDrawAnchor *sp_draw_anchor_new(Inkscape::UI::Tools::FreehandBase *dc, SPCurve *curve, bool start, Geom::Point delta) { if (SP_IS_LPETOOL_CONTEXT(dc)) { // suppress all kinds of anchors in LPEToolContext @@ -73,7 +73,7 @@ SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor) * Test if point is near anchor, if so fill anchor on canvas and return * pointer to it or NULL. */ -SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate) +SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, bool activate) { SPCtrl *ctrl = SP_CTRL(anchor->ctrl); diff --git a/src/draw-anchor.h b/src/draw-anchor.h index e7b252186..1f7b55920 100644 --- a/src/draw-anchor.h +++ b/src/draw-anchor.h @@ -5,7 +5,6 @@ * Drawing anchors. */ -#include #include <2geom/point.h> namespace Inkscape { @@ -26,17 +25,17 @@ struct SPCanvasItem; struct SPDrawAnchor { Inkscape::UI::Tools::FreehandBase *dc; SPCurve *curve; - guint start : 1; - guint active : 1; + unsigned int start : 1; + unsigned int active : 1; Geom::Point dp; SPCanvasItem *ctrl; }; -SPDrawAnchor *sp_draw_anchor_new(Inkscape::UI::Tools::FreehandBase *dc, SPCurve *curve, gboolean start, +SPDrawAnchor *sp_draw_anchor_new(Inkscape::UI::Tools::FreehandBase *dc, SPCurve *curve, bool start, Geom::Point delta); SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor); -SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate); +SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, bool activate); #endif /* !SEEN_DRAW_ANCHOR_H */ diff --git a/src/event-log.h b/src/event-log.h index 7e3ba6817..6d4112a5a 100644 --- a/src/event-log.h +++ b/src/event-log.h @@ -11,14 +11,6 @@ #ifndef INKSCAPE_EVENT_LOG_H #define INKSCAPE_EVENT_LOG_H -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include -#endif - #include #include #include diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 1c13c27f1..5ee226ccf 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -26,7 +26,7 @@ #include "desktop-handles.h" #include "desktop.h" -#include "dialogs/dialog-events.h" +#include "ui/dialog-events.h" #include "extension/effect.h" #include "extension/output.h" #include "extension/input.h" diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp index 0e633afd6..02d92668b 100644 --- a/src/extension/internal/bitmap/crop.cpp +++ b/src/extension/internal/bitmap/crop.cpp @@ -74,7 +74,7 @@ Crop::init(void) "\n" "\n" "\n" - "" N_("Crop selected bitmap(s).") "\n" + "" N_("Crop selected bitmap(s)") "\n" "\n" "\n", new Crop()); } diff --git a/src/extension/internal/bitmap/opacity.cpp b/src/extension/internal/bitmap/opacity.cpp index 742cb7019..f9b4bbc27 100644 --- a/src/extension/internal/bitmap/opacity.cpp +++ b/src/extension/internal/bitmap/opacity.cpp @@ -43,7 +43,7 @@ Opacity::init(void) "\n" "\n" "\n" - "" N_("Modify opacity channel(s) of selected bitmap(s).") "\n" + "" N_("Modify opacity channel(s) of selected bitmap(s)") "\n" "\n" "\n", new Opacity()); } diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 8d3e63775..8071cae36 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -31,6 +31,9 @@ class SPClipPath; class SPMask; +typedef struct _PangoFont PangoFont; +typedef struct _PangoLayout PangoLayout; + namespace Inkscape { class Pixbuf; diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index fa5cb70f9..1de3f304b 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -40,7 +40,7 @@ #include "document-undo.h" #include "inkscape.h" -#include "dialogs/dialog-events.h" +#include "ui/dialog-events.h" #include #include "ui/widget/spinbutton.h" #include "ui/widget/frame.h" diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index da179bee0..28e44c461 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -1,21 +1,20 @@ -#ifdef HAVE_CONFIG_H -# include -#endif +#include + #include #include #include +#include "dir-util.h" +#include "display/cairo-utils.h" #include "document-private.h" -#include +#include "document-undo.h" #include "extension/input.h" #include "extension/system.h" +#include "image-resolution.h" #include "gdkpixbuf-input.h" #include "preferences.h" #include "selection-chemistry.h" #include "sp-image.h" -#include "document-undo.h" #include "util/units.h" -#include "image-resolution.h" -#include "display/cairo-utils.h" #include namespace Inkscape { diff --git a/src/extension/internal/gdkpixbuf-input.h b/src/extension/internal/gdkpixbuf-input.h index 597e7246b..2e03a96db 100644 --- a/src/extension/internal/gdkpixbuf-input.h +++ b/src/extension/internal/gdkpixbuf-input.h @@ -10,7 +10,7 @@ namespace Internal { class GdkpixbufInput : Inkscape::Extension::Implementation::Implementation { public: SPDocument *open(Inkscape::Extension::Input *mod, - gchar const *uri); + char const *uri); static void init(); }; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index bcaa8712f..e18d898f5 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -48,7 +48,7 @@ #include "inkscape.h" #include "util/units.h" -#include "dialogs/dialog-events.h" +#include "ui/dialog-events.h" #include #include "ui/widget/spinbutton.h" #include "ui/widget/frame.h" diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 0830ae2dd..2623d1ca7 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -41,7 +41,7 @@ #include "inkscape.h" #include "util/units.h" -#include "dialogs/dialog-events.h" +#include "ui/dialog-events.h" #include #include "ui/widget/spinbutton.h" #include "ui/widget/frame.h" diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index d1f83701f..af31f32b6 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -13,7 +13,7 @@ #include #include -#include "../dialogs/dialog-events.h" +#include "ui/dialog-events.h" #include "xml/repr.h" // Used to get SP_ACTIVE_DESKTOP diff --git a/src/extract-uri.h b/src/extract-uri.h index a6707f1a1..e9ee0b1d8 100644 --- a/src/extract-uri.h +++ b/src/extract-uri.h @@ -1,9 +1,7 @@ #ifndef SEEN_EXTRACT_URI_H #define SEEN_EXTRACT_URI_H -#include - -gchar *extract_uri(gchar const *s, gchar const** endptr = 0); +char *extract_uri(char const *s, char const** endptr = 0); #endif /* !SEEN_EXTRACT_URI_H */ diff --git a/src/factory.h b/src/factory.h index c76501cfd..c1288b460 100644 --- a/src/factory.h +++ b/src/factory.h @@ -91,7 +91,7 @@ struct NodeTraits { break; case Inkscape::XML::ELEMENT_NODE: { - gchar const *const sptype = node.attribute("sodipodi:type"); + char const *const sptype = node.attribute("sodipodi:type"); if (sptype) { name = sptype; diff --git a/src/file.h b/src/file.h index 7f80f3645..4ffbc8ec0 100644 --- a/src/file.h +++ b/src/file.h @@ -75,7 +75,7 @@ bool sp_file_open( * Displays a file open dialog. Calls sp_file_open on * an OK. */ -void sp_file_open_dialog (Gtk::Window &parentWindow, gpointer object, gpointer data); +void sp_file_open_dialog (Gtk::Window &parentWindow, void* object, void* data); /** * Reverts file to disk-copy on "YES" @@ -96,19 +96,19 @@ bool file_save_remote(SPDocument *doc, const Glib::ustring &uri, /** * */ -bool sp_file_save (Gtk::Window &parentWindow, gpointer object, gpointer data); +bool sp_file_save (Gtk::Window &parentWindow, void* object, void* data); /** * Saves the given document. Displays a file select dialog * to choose the new name. */ -bool sp_file_save_as (Gtk::Window &parentWindow, gpointer object, gpointer data); +bool sp_file_save_as (Gtk::Window &parentWindow, void* object, void* data); /** * Saves a copy of the given document. Displays a file select dialog * to choose a name for the copy. */ -bool sp_file_save_a_copy (Gtk::Window &parentWindow, gpointer object, gpointer data); +bool sp_file_save_a_copy (Gtk::Window &parentWindow, void* object, void* data); /** diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h index 2ac3ebe8f..104016845 100644 --- a/src/filter-chemistry.h +++ b/src/filter-chemistry.h @@ -14,8 +14,6 @@ #ifndef SEEN_SP_FILTER_CHEMISTRY_H #define SEEN_SP_FILTER_CHEMISTRY_H -#include - #include "display/nr-filter-types.h" class SPDocument; @@ -24,12 +22,11 @@ class SPFilterPrimitive; class SPItem; class SPObject; - SPFilterPrimitive *filter_add_primitive(SPFilter *filter, Inkscape::Filters::FilterPrimitiveType); SPFilter *new_filter (SPDocument *document); -SPFilter *new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation, double expansion, double expansionX, double expansionY, double width, double height); -SPFilter *new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mode, gdouble stdDeviation); -SPFilter *modify_filter_gaussian_blur_from_item (SPDocument *document, SPItem *item, gdouble stdDeviation); +SPFilter *new_filter_gaussian_blur (SPDocument *document, double stdDeviation, double expansion, double expansionX, double expansionY, double width, double height); +SPFilter *new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mode, double stdDeviation); +SPFilter *modify_filter_gaussian_blur_from_item (SPDocument *document, SPItem *item, double stdDeviation); void remove_filter (SPObject *item, bool recursive); void remove_filter_gaussian_blur (SPObject *item); bool filter_is_single_gaussian_blur(SPFilter *filter); diff --git a/src/filter-enums.h b/src/filter-enums.h index e6d656f8a..3ced5ab94 100644 --- a/src/filter-enums.h +++ b/src/filter-enums.h @@ -12,8 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include - #include "display/nr-filter-blend.h" #include "display/nr-filter-colormatrix.h" #include "display/nr-filter-component-transfer.h" diff --git a/src/filters/distantlight.h b/src/filters/distantlight.h index 0eebf768f..6490d987c 100644 --- a/src/filters/distantlight.h +++ b/src/filters/distantlight.h @@ -27,21 +27,21 @@ public: virtual ~SPFeDistantLight(); /** azimuth attribute */ - gfloat azimuth; - guint azimuth_set : 1; + float azimuth; + unsigned int azimuth_set : 1; /** elevation attribute */ - gfloat elevation; - guint elevation_set : 1; + float elevation; + unsigned int elevation_set : 1; protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif /* !SP_FEDISTANTLIGHT_H_SEEN */ diff --git a/src/filters/pointlight.h b/src/filters/pointlight.h index 3819d8ff5..1e26d45e7 100644 --- a/src/filters/pointlight.h +++ b/src/filters/pointlight.h @@ -26,24 +26,24 @@ public: virtual ~SPFePointLight(); /** x coordinate of the light source */ - gfloat x; - guint x_set : 1; + float x; + unsigned int x_set : 1; /** y coordinate of the light source */ - gfloat y; - guint y_set : 1; + float y; + unsigned int y_set : 1; /** z coordinate of the light source */ - gfloat z; - guint z_set : 1; + float z; + unsigned int z_set : 1; protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif /* !SP_FEPOINTLIGHT_H_SEEN */ diff --git a/src/filters/spotlight.h b/src/filters/spotlight.h index 8caf12858..7d5f6dd30 100644 --- a/src/filters/spotlight.h +++ b/src/filters/spotlight.h @@ -26,40 +26,40 @@ public: virtual ~SPFeSpotLight(); /** x coordinate of the light source */ - gfloat x; - guint x_set : 1; + float x; + unsigned int x_set : 1; /** y coordinate of the light source */ - gfloat y; - guint y_set : 1; + float y; + unsigned int y_set : 1; /** z coordinate of the light source */ - gfloat z; - guint z_set : 1; + float z; + unsigned int z_set : 1; /** x coordinate of the point the source is pointing at */ - gfloat pointsAtX; - guint pointsAtX_set : 1; + float pointsAtX; + unsigned int pointsAtX_set : 1; /** y coordinate of the point the source is pointing at */ - gfloat pointsAtY; - guint pointsAtY_set : 1; + float pointsAtY; + unsigned int pointsAtY_set : 1; /** z coordinate of the point the source is pointing at */ - gfloat pointsAtZ; - guint pointsAtZ_set : 1; + float pointsAtZ; + unsigned int pointsAtZ_set : 1; /** specular exponent (focus of the light) */ - gfloat specularExponent; - guint specularExponent_set : 1; + float specularExponent; + unsigned int specularExponent_set : 1; /** limiting cone angle */ - gfloat limitingConeAngle; - guint limitingConeAngle_set : 1; + float limitingConeAngle; + unsigned int limitingConeAngle_set : 1; //other fields protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif /* !SP_FESPOTLIGHT_H_SEEN */ diff --git a/src/gc-anchored.h b/src/gc-anchored.h index a20904dce..99b78c784 100644 --- a/src/gc-anchored.h +++ b/src/gc-anchored.h @@ -9,7 +9,6 @@ #ifndef SEEN_INKSCAPE_GC_ANCHORED_H #define SEEN_INKSCAPE_GC_ANCHORED_H -#include #include "gc-managed.h" namespace Inkscape { diff --git a/src/gc-core.h b/src/gc-core.h index 3957bda1a..d9d0bf4ff 100644 --- a/src/gc-core.h +++ b/src/gc-core.h @@ -24,7 +24,6 @@ #else # include #endif -#include namespace Inkscape { namespace GC { diff --git a/src/gradient-chemistry.h b/src/gradient-chemistry.h index 728874f88..792ccc72e 100644 --- a/src/gradient-chemistry.h +++ b/src/gradient-chemistry.h @@ -22,6 +22,7 @@ class SPCSSAttr; class SPItem; +typedef unsigned int guint32; /** * Either normalizes given gradient to vector, or returns fresh normalized @@ -53,7 +54,7 @@ SPGradient *sp_gradient_vector_for_object( SPDocument *doc, SPDesktop *desktop, void sp_object_ensure_fill_gradient_normalized (SPObject *object); void sp_object_ensure_stroke_gradient_normalized (SPObject *object); -SPGradient *sp_gradient_convert_to_userspace (SPGradient *gr, SPItem *item, const gchar *property); +SPGradient *sp_gradient_convert_to_userspace (SPGradient *gr, SPItem *item, const char *property); SPGradient *sp_gradient_reset_to_userspace (SPGradient *gr, SPItem *item); SPGradient *sp_gradient_fork_vector_if_necessary (SPGradient *gr); @@ -61,11 +62,11 @@ SPGradient *sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, boo SPStop* sp_last_stop(SPGradient *gradient); -SPStop* sp_get_stop_i(SPGradient *gradient, guint i); -guint sp_number_of_stops(SPGradient const *gradient); -guint sp_number_of_stops_before_stop(SPGradient const *gradient, SPStop *target); +SPStop* sp_get_stop_i(SPGradient *gradient, unsigned int i); +unsigned int sp_number_of_stops(SPGradient const *gradient); +unsigned int sp_number_of_stops_before_stop(SPGradient const *gradient, SPStop *target); -guint32 average_color(guint32 c1, guint32 c2, gdouble p = 0.5); +guint32 average_color(guint32 c1, guint32 c2, double p = 0.5); SPStop *sp_vector_add_stop(SPGradient *vector, SPStop* prev_stop, SPStop* next_stop, gfloat offset); @@ -86,20 +87,20 @@ void sp_gradient_unset_swatch(SPDesktop *desktop, std::string id); SPGradient *getGradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke); -void sp_item_gradient_set_coords(SPItem *item, GrPointType point_type, guint point_i, Geom::Point p_desk, Inkscape::PaintTarget fill_or_stroke, bool write_repr, bool scale); +void sp_item_gradient_set_coords(SPItem *item, GrPointType point_type, unsigned int point_i, Geom::Point p_desk, Inkscape::PaintTarget fill_or_stroke, bool write_repr, bool scale); /** * Returns the position of point point_type of the gradient applied to item (either fill_or_stroke), * in desktop coordinates. */ -Geom::Point getGradientCoords(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke); +Geom::Point getGradientCoords(SPItem *item, GrPointType point_type, unsigned int point_i, Inkscape::PaintTarget fill_or_stroke); SPGradient *sp_item_gradient_get_vector(SPItem *item, Inkscape::PaintTarget fill_or_stroke); SPGradientSpread sp_item_gradient_get_spread(SPItem *item, Inkscape::PaintTarget fill_or_stroke); -void sp_item_gradient_stop_set_style(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke, SPCSSAttr *stop); -guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke); -void sp_item_gradient_edit_stop(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke); +void sp_item_gradient_stop_set_style(SPItem *item, GrPointType point_type, unsigned int point_i, Inkscape::PaintTarget fill_or_stroke, SPCSSAttr *stop); +guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, unsigned int point_i, Inkscape::PaintTarget fill_or_stroke); +void sp_item_gradient_edit_stop(SPItem *item, GrPointType point_type, unsigned int point_i, Inkscape::PaintTarget fill_or_stroke); void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or_stroke); void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fill_or_stroke); diff --git a/src/graphlayout.h b/src/graphlayout.h index 6083ad77f..0ffb645b6 100644 --- a/src/graphlayout.h +++ b/src/graphlayout.h @@ -14,10 +14,15 @@ #ifndef SEEN_GRAPHLAYOUT_H #define SEEN_GRAPHLAYOUT_H -struct _GSList; -void graphlayout(_GSList const *const items); +#include + +typedef struct _GSList GSList; class SPItem; + +void graphlayout(GSList const *const items); + bool isConnector(SPItem const *const item); -#include -void filterConnectors(_GSList const *const items, std::list &filtered); + +void filterConnectors(GSList const *const items, std::list &filtered); + #endif // SEEN_GRAPHLAYOUT_H diff --git a/src/helper-fns.h b/src/helper-fns.h index 699fbbe11..2f1829c37 100644 --- a/src/helper-fns.h +++ b/src/helper-fns.h @@ -10,7 +10,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#include #include #include @@ -59,34 +59,6 @@ inline bool helperfns_read_bool(gchar const *value, bool default_value){ return default_value; } -/* convert ascii representation to double - * the function can only be used to convert numbers as given by gui elements that use localized representation - * numbers are delimeted by space - * @param value ascii representation of the number - * @param size number of elements in string - * @return the vector of the converted numbers - */ -/* -inline std::vector helperfns_read_vector(const gchar* value, int size){ - std::vector v(size, (gdouble) 0); - std::istringstream is(value); - for(int i = 0; i < size; i++){ - std::string str; - is >> str; - char *end; - - double ret = g_ascii_strtod(str.c_str(), &end); - if (*end) { - g_warning("helper-fns::helperfns_read_vector() Unable to convert \"%s\" to number", str.c_str()); - // We could leave this out, too. If strtod can't convert - // anything, it will return zero. - ret = 0; - } - v[i] = ret; - }; - return v; -} -*/ /* convert ascii representation to double * the function can only be used to convert numbers as given by gui elements that use localized representation * numbers are delimeted by space diff --git a/src/inkscape-version.h b/src/inkscape-version.h index 791351184..ff219047e 100644 --- a/src/inkscape-version.h +++ b/src/inkscape-version.h @@ -16,7 +16,7 @@ namespace Inkscape { -extern gchar const *version_string; ///< Full version string +extern char const *version_string; ///< Full version string } // namespace Inkscape diff --git a/src/inkview.cpp b/src/inkview.cpp index a44d755eb..0b7b4d35c 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -569,16 +569,6 @@ static void usage() exit(1); } -#if 0 -/* TODO !!! make this temporary stub unnecessary */ -Inkscape::Application *inkscape_get_instance() { return NULL; } -void inkscape_ref (void) {} -void inkscape_unref (void) {} -void inkscape_add_document (SPDocument *document) {} -void inkscape_remove_document (SPDocument *document) {} -#endif - - /* Local Variables: mode:c++ diff --git a/src/interface.cpp b/src/interface.cpp index 85cdbaf84..0099e8a83 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -57,7 +57,7 @@ #include "helper/gnome-utils.h" #include "helper/window.h" #include "io/sys.h" -#include "dialogs/dialog-events.h" +#include "ui/dialog-events.h" #include "message-context.h" #include "ui/uxmanager.h" #include "ui/clipboard.h" @@ -149,7 +149,7 @@ static void injectRenamedIcons(); static const int MIN_ONSCREEN_DISTANCE = 50; void -sp_create_window(SPViewWidget *vw, gboolean editable) +sp_create_window(SPViewWidget *vw, bool editable) { g_return_if_fail(vw != NULL); g_return_if_fail(SP_IS_VIEW_WIDGET(vw)); @@ -1756,6 +1756,13 @@ void ContextMenu::MakeItemMenu (void) } mi->show(); append(*mi); + + /*SSet Clip Group */ + mi = Gtk::manage(new Gtk::MenuItem(_("Create Clip G_roup"),1)); + mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::CreateGroupClip)); + mi->set_sensitive(TRUE); + mi->show(); + append(*mi); /* Set Clip */ mi = Gtk::manage(new Gtk::MenuItem(_("Set Cl_ip"), 1)); @@ -1867,6 +1874,10 @@ void ContextMenu::ReleaseMask(void) sp_selection_unset_mask(_desktop, false); } +void ContextMenu::CreateGroupClip(void) +{ + sp_selection_set_clipgroup(_desktop); +} void ContextMenu::SetClip(void) { diff --git a/src/interface.h b/src/interface.h index 215a3bfc9..6fb74046f 100644 --- a/src/interface.h +++ b/src/interface.h @@ -17,13 +17,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include -#endif +//#ifdef HAVE_CONFIG_H +//# include +//#endif #include @@ -50,7 +46,7 @@ class View; /** * Create a new document window. */ -void sp_create_window (SPViewWidget *vw, gboolean editable); +void sp_create_window (SPViewWidget *vw, bool editable); /** * \param widget unused @@ -87,15 +83,15 @@ unsigned int sp_ui_close_all (void); GtkWidget *sp_ui_main_menubar (Inkscape::UI::View::View *view); void sp_menu_append_recent_documents (GtkWidget *menu); -void sp_ui_dialog_title_string (Inkscape::Verb * verb, gchar* c); +void sp_ui_dialog_title_string (Inkscape::Verb * verb, char* c); Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view ); /** * */ -void sp_ui_error_dialog (const gchar * message); -bool sp_ui_overwrite_file (const gchar * filename); +void sp_ui_error_dialog (char const* message); +bool sp_ui_overwrite_file (char const* filename); /** @@ -187,6 +183,7 @@ class ContextMenu : public Gtk::Menu void SelectSameStrokeStyle(void); void SelectSameObjectType(void); void ItemCreateLink(void); + void CreateGroupClip(void); void SetMask(void); void ReleaseMask(void); void SetClip(void); diff --git a/src/isinf.h b/src/isinf.h index b4c56f79d..8d590b972 100644 --- a/src/isinf.h +++ b/src/isinf.h @@ -2,7 +2,7 @@ #define __ISINF_H__ /* - * Fix for missing std::isnormal with SOLARIS8/GCC3.2 + * Fix for missing std::isinf with SOLARIS8/GCC3.2 */ #if defined (SOLARIS) diff --git a/src/isnormal.h b/src/isnormal.h deleted file mode 100644 index d53105926..000000000 --- a/src/isnormal.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __ISNORMAL_H__ -#define __ISNORMAL_H__ - -/* - * Fix for missing std::isnormal with SOLARIS8/GCC3.2 - */ - -#if defined (SOLARIS) - - #include - #define isnormal(x) (fpclass(x) >= FP_NZERO) - -#else - - using std::isnormal; - -#endif - -#endif /* __ISNORMAL_H__ */ diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index dde60f515..43ab25e5c 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -14,11 +14,11 @@ * Released under GNU GPL */ -#include -#include "knot.h" #include <2geom/forward.h> -#include "snapper.h" + #include "display/sp-canvas-item.h" +#include "knot.h" +#include "snapper.h" class SPItem; class SPKnot; @@ -31,7 +31,7 @@ namespace LivePathEffect { } // namespace LivePathEffect } // namespace Inkscape -typedef void (* SPKnotHolderSetFunc) (SPItem *item, Geom::Point const &p, Geom::Point const &origin, guint state); +typedef void (* SPKnotHolderSetFunc) (SPItem *item, Geom::Point const &p, Geom::Point const &origin, unsigned int state); typedef Geom::Point (* SPKnotHolderGetFunc) (SPItem *item); /** @@ -50,22 +50,22 @@ public: virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, Inkscape::ControlType type = Inkscape::CTRL_TYPE_UNKNOWN, - const gchar *tip = "", + char const*tip = "", SPKnotShapeType shape = SP_KNOT_SHAPE_DIAMOND, SPKnotModeType mode = SP_KNOT_MODE_XOR, guint32 color = 0xffffff00); /* the get/set/click handlers are virtual functions; each handler class for a knot should be derived from KnotHolderEntity and override these functions */ - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) = 0; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) = 0; virtual Geom::Point knot_get() const = 0; - virtual void knot_click(guint /*state*/) {} + virtual void knot_click(unsigned int /*state*/) {} void update_knot(); //private: - Geom::Point snap_knot_position(Geom::Point const &p, guint state); - Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, guint state); + Geom::Point snap_knot_position(Geom::Point const &p, unsigned int state); + Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, unsigned int state); SPKnot *knot; SPItem *item; @@ -77,11 +77,11 @@ public: static int counter; /** Connection to \a knot's "moved" signal. */ - guint handler_id; + unsigned int handler_id; /** Connection to \a knot's "clicked" signal. */ - guint _click_handler_id; + unsigned int _click_handler_id; /** Connection to \a knot's "ungrabbed" signal. */ - guint _ungrab_handler_id; + unsigned int _ungrab_handler_id; private: sigc::connection _moved_connection; @@ -103,7 +103,7 @@ class PatternKnotHolderEntityXY : public KnotHolderEntity { public: PatternKnotHolderEntityXY(bool fill) : KnotHolderEntity(), _fill(fill) {} virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); private: // true if the entity tracks fill, false for stroke bool _fill; @@ -113,7 +113,7 @@ class PatternKnotHolderEntityAngle : public KnotHolderEntity { public: PatternKnotHolderEntityAngle(bool fill) : KnotHolderEntity(), _fill(fill) {} virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); private: bool _fill; }; @@ -122,7 +122,7 @@ class PatternKnotHolderEntityScale : public KnotHolderEntity { public: PatternKnotHolderEntityScale(bool fill) : KnotHolderEntity(), _fill(fill) {} virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); private: bool _fill; }; diff --git a/src/knot.h b/src/knot.h index b79614bcb..e3ad98e66 100644 --- a/src/knot.h +++ b/src/knot.h @@ -14,15 +14,19 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include <2geom/point.h> -#include "knot-enums.h" #include + +#include "knot-enums.h" #include "enums.h" class SPDesktop; -struct SPCanvasItem; class SPItem; +struct SPCanvasItem; + +typedef struct _GdkCursor GdkCursor; +typedef union _GdkEvent GdkEvent; +typedef unsigned int guint32; #define SP_KNOT(obj) (dynamic_cast(static_cast(obj))) #define SP_IS_KNOT(obj) (dynamic_cast(static_cast(obj)) != NULL) @@ -36,19 +40,17 @@ class SPItem; */ class SPKnot { public: - SPKnot(SPDesktop *desktop, gchar const *tip); + SPKnot(SPDesktop *desktop, char const *tip); virtual ~SPKnot(); - - int ref_count; - + int ref_count; // FIXME encapsulation SPDesktop *desktop; /**< Desktop we are on. */ SPCanvasItem *item; /**< Our CanvasItem. */ SPItem *owner; /**< Optional Owner Item */ - guint flags; + unsigned int flags; - guint size; /**< Always square. */ + unsigned int size; /**< Always square. */ Geom::Point pos; /**< Our desktop coordinates. */ Geom::Point grabbed_rel_pos; /**< Grabbed relative position. */ Geom::Point drag_origin; /**< Origin of drag. */ @@ -59,39 +61,41 @@ public: guint32 fill[SP_KNOT_VISIBLE_STATES]; guint32 stroke[SP_KNOT_VISIBLE_STATES]; - guchar *image[SP_KNOT_VISIBLE_STATES]; + unsigned char *image[SP_KNOT_VISIBLE_STATES]; GdkCursor *cursor[SP_KNOT_VISIBLE_STATES]; GdkCursor *saved_cursor; - gpointer pixbuf; + void* pixbuf; - gchar *tip; + char *tip; - gulong _event_handler_id; + unsigned long _event_handler_id; double pressure; /**< The tablet pen pressure when the knot is being dragged. */ - sigc::signal click_signal; - sigc::signal doubleclicked_signal; - sigc::signal grabbed_signal; - sigc::signal ungrabbed_signal; - sigc::signal moved_signal; + // FIXME: signals should NOT need to emit the object they came from, the callee should + // be able to figure that out + sigc::signal click_signal; + sigc::signal doubleclicked_signal; + sigc::signal grabbed_signal; + sigc::signal ungrabbed_signal; + sigc::signal moved_signal; sigc::signal event_signal; - sigc::signal request_signal; + sigc::signal request_signal; //TODO: all the members above should eventualle become private, accessible via setters/getters - void setSize(guint i); - void setShape(guint i); - void setAnchor(guint i); - void setMode(guint i); - void setPixbuf(gpointer p); + void setSize(unsigned int i); + void setShape(unsigned int i); + void setAnchor(unsigned int i); + void setMode(unsigned int i); + void setPixbuf(void* p); void setFill(guint32 normal, guint32 mouseover, guint32 dragging); void setStroke(guint32 normal, guint32 mouseover, guint32 dragging); - void setImage(guchar* normal, guchar* mouseover, guchar* dragging); + void setImage(unsigned char* normal, unsigned char* mouseover, unsigned char* dragging); void setCursor(GdkCursor* normal, GdkCursor* mouseover, GdkCursor* dragging); @@ -108,7 +112,7 @@ public: /** * Set flag in knot, with side effects. */ - void setFlag(guint flag, bool set); + void setFlag(unsigned int flag, bool set); /** * Update knot's pixbuf and set its control state. @@ -118,17 +122,17 @@ public: /** * Request or set new position for knot. */ - void requestPosition(Geom::Point const &pos, guint state); + void requestPosition(Geom::Point const &pos, unsigned int state); /** * Update knot for dragging and tell canvas an item was grabbed. */ - void startDragging(Geom::Point const &p, gint x, gint y, guint32 etime); + void startDragging(Geom::Point const &p, int x, int y, guint32 etime); /** * Move knot to new position and emits "moved" signal. */ - void setPosition(Geom::Point const &p, guint state); + void setPosition(Geom::Point const &p, unsigned int state); /** * Move knot to new position, without emitting a MOVED signal. diff --git a/src/knotholder.cpp b/src/knotholder.cpp index f0e69716b..b8d941bf7 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -154,8 +154,15 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) } // for drag, this is done by ungrabbed_handler, but for click we must do it here - DocumentUndo::done(saved_item->document, object_verb, - _("Change handle")); + + if (saved_item) { //increasingly aggressive sanity checks + if (saved_item->document) { + if (object_verb <= SP_VERB_LAST && object_verb >= SP_VERB_INVALID) { + DocumentUndo::done(saved_item->document, object_verb, + _("Change handle")); + } + } + } // else { abort(); } } void @@ -203,14 +210,16 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) /* do cleanup tasks (e.g., for LPE items write the parameter values * that were changed by dragging the handle to SVG) */ - if (SP_IS_LPE_ITEM(object)) { + if (dynamic_cast (object)) { // This writes all parameters to SVG. Is this sufficiently efficient or should we only // write the ones that were changed? - - Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(object)->getCurrentLPE(); - if (lpe) { - LivePathEffectObject *lpeobj = lpe->getLPEObj(); - lpeobj->updateRepr(); + SPLPEItem * lpeitem = SP_LPE_ITEM(object); + if (lpeitem) { + Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); + if (lpe) { + LivePathEffectObject *lpeobj = lpe->getLPEObj(); + lpeobj->updateRepr(); + } } } @@ -232,9 +241,14 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) else object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; } - - DocumentUndo::done(object->document, object_verb, - _("Move handle")); + if (object) { //increasingly aggressive sanity checks + if (object->document) { + if (object_verb <= SP_VERB_LAST && object_verb >= SP_VERB_INVALID) { + DocumentUndo::done(object->document, object_verb, + _("Move handle")); + } + } + } //else { abort(); } } } diff --git a/src/knotholder.h b/src/knotholder.h index dc2300105..d33adb610 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -17,7 +17,6 @@ * */ -#include #include <2geom/forward.h> #include #include @@ -47,9 +46,9 @@ public: void update_knots(); - void knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state); - void knot_clicked_handler(SPKnot *knot, guint state); - void knot_ungrabbed_handler(SPKnot *knot, guint); + void knot_moved_handler(SPKnot *knot, Geom::Point const &p, unsigned int state); + void knot_clicked_handler(SPKnot *knot, unsigned int state); + void knot_ungrabbed_handler(SPKnot *knot, unsigned int); void add(KnotHolderEntity *e); @@ -76,7 +75,7 @@ protected: SPKnotHolderReleasedFunc released; - gboolean local_change; ///< if true, no need to recreate knotholder if repr was changed. + bool local_change; ///< if true, no need to recreate knotholder if repr was changed. bool dragging; diff --git a/src/layer-manager.h b/src/layer-manager.h index 1b69324d5..9eea68004 100644 --- a/src/layer-manager.h +++ b/src/layer-manager.h @@ -10,11 +10,12 @@ #ifndef SEEN_INKSCAPE_LAYER_MANAGER_H #define SEEN_INKSCAPE_LAYER_MANAGER_H +#include +#include + #include "document-subset.h" #include "gc-finalized.h" #include "gc-soft-ptr.h" -#include -#include class SPDesktop; class SPDocument; @@ -29,8 +30,8 @@ public: virtual ~LayerManager(); void setCurrentLayer( SPObject* obj ); - void renameLayer( SPObject* obj, gchar const *label, bool uniquify ); - Glib::ustring getNextLayerName( SPObject* obj, gchar const *label); + void renameLayer( SPObject* obj, char const *label, bool uniquify ); + Glib::ustring getNextLayerName( SPObject* obj, char const *label); sigc::connection connectCurrentLayerChanged(const sigc::slot & slot) { return _layer_changed_signal.connect(slot); @@ -44,7 +45,7 @@ private: friend class LayerWatcher; class LayerWatcher; - void _objectModified( SPObject* obj, guint flags ); + void _objectModified( SPObject* obj, unsigned int flags ); void _setDocument(SPDocument *document); void _rebuild(); void _selectedLayerChanged(SPObject *layer); diff --git a/src/layer-model.h b/src/layer-model.h index 79b7fbe44..86aba63ef 100644 --- a/src/layer-model.h +++ b/src/layer-model.h @@ -22,12 +22,8 @@ * */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include #include +#include class SPDocument; class SPObject; diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 973db0165..7eb53446f 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -854,6 +854,8 @@ void Layout::Calculator::BrokenSpan::setZero() end_glyph_index = start_glyph_index = 0; ends_with_whitespace = false; each_whitespace_width = 0.0; + letter_spacing = 0.0; + word_spacing = 0.0; } template void Layout::Calculator::ParagraphInfo::free_sequence(T &seq) diff --git a/src/line-geometry.h b/src/line-geometry.h index d7be9570c..a77d6e1f3 100644 --- a/src/line-geometry.h +++ b/src/line-geometry.h @@ -12,13 +12,14 @@ #ifndef SEEN_LINE_GEOMETRY_H #define SEEN_LINE_GEOMETRY_H +#include <2geom/point.h> #include -#include "glib.h" + #include "axis-manip.h" // FIXME: This is only for Box3D::epsilon; move that to a better location -#include "2geom/point.h" #include "persp3d.h" class SPDesktop; +typedef unsigned int guint32; namespace Box3D { diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 930b7fca9..6122b133a 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -11,9 +11,10 @@ */ #include <2geom/line.h> +#include + #include "line-snapper.h" #include "snapped-line.h" -//#include #include "snap.h" Inkscape::LineSnapper::LineSnapper(SnapManager *sm, Geom::Coord const d) : Snapper(sm, d) @@ -37,7 +38,7 @@ void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr, Geom::Point const p1 = i->second; // point at guide/grid line Geom::Point const p2 = p1 + Geom::rot90(i->first); // 2nd point at guide/grid line // std::cout << " line through " << i->second << " with normal " << i->first; - g_assert(i->first != Geom::Point(0,0)); // we cannot project on an linesegment of zero length + assert(i->first != Geom::Point(0,0)); // we cannot project on an linesegment of zero length Geom::Point const p_proj = Geom::projection(p.getPoint(), Geom::Line(p1, p2)); Geom::Coord const dist = Geom::L2(p_proj - p.getPoint()); diff --git a/src/line-snapper.h b/src/line-snapper.h index 4b165e0a5..b2fc3d389 100644 --- a/src/line-snapper.h +++ b/src/line-snapper.h @@ -12,10 +12,9 @@ #include "snapper.h" -namespace Inkscape -{ -class SnapCandidatePoint; +namespace Inkscape { +class SnapCandidatePoint; /** * Superclass for snappers to horizontal and vertical lines. diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index d126aca9f..30c2b2f41 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -2,8 +2,10 @@ set(live_effects_SRC effect.cpp lpe-angle_bisector.cpp + lpe-attach-path.cpp lpe-bendpath.cpp lpe-boolops.cpp + lpe-bounding-box.cpp lpe-circle_3pts.cpp lpe-circle_with_radius.cpp lpe-clone-original.cpp @@ -11,9 +13,12 @@ set(live_effects_SRC lpe-copy_rotate.cpp lpe-curvestitch.cpp lpe-dynastroke.cpp + lpe-ellipse-5pts.cpp lpe-envelope.cpp lpe-envelope-perspective.cpp lpe-extrude.cpp + lpe-fill-between-many.cpp + lpe-fill-between-strokes.cpp lpe-fillet-chamfer.cpp lpe-gears.cpp lpe-interpolate.cpp @@ -55,11 +60,13 @@ set(live_effects_SRC parameter/parameter.cpp parameter/path.cpp parameter/originalpath.cpp + parameter/originalpatharray.cpp parameter/path-reference.cpp parameter/point.cpp parameter/powerstrokepointarray.cpp parameter/random.cpp parameter/text.cpp + paramter/transformedpoint.cpp parameter/togglebutton.cpp parameter/unit.cpp parameter/vector.cpp @@ -70,8 +77,10 @@ set(live_effects_SRC effect-enum.h effect.h lpe-angle_bisector.h + lpe-attach-path.h lpe-bendpath.h lpe-boolops.h + lpe-bounding-box.h lpe-circle_3pts.h lpe-circle_with_radius.h lpe-clone-original.h @@ -79,8 +88,11 @@ set(live_effects_SRC lpe-copy_rotate.h lpe-curvestitch.h lpe-dynastroke.h + lpe-ellipse-5pts.h lpe-envelope.h lpe-extrude.h + lpe-fill-between-many.h + lpe-fill-between-strokes.h lpe-fillet-chamfer.h lpe-gears.h lpe-interpolate.h @@ -125,6 +137,7 @@ set(live_effects_SRC parameter/path-reference.h parameter/path.h parameter/originalpath.h + parameter/originalpatharray.h parameter/point.h parameter/powerstrokepointarray.h parameter/random.h diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index 1b8f587e1..f18dcdef0 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -97,5 +97,21 @@ ink_common_sources += \ live_effects/lpe-path_length.h \ live_effects/lpe-line_segment.cpp \ live_effects/lpe-line_segment.h \ + live_effects/lpe-bounding-box.cpp \ + live_effects/lpe-bounding-box.h \ + live_effects/lpe-attach-path.cpp \ + live_effects/lpe-attach-path.h \ + live_effects/lpe-fill-between-strokes.cpp \ + live_effects/lpe-fill-between-strokes.h \ + live_effects/lpe-fill-between-many.cpp \ + live_effects/lpe-fill-between-many.h \ + live_effects/lpe-ellipse_5pts.cpp \ + live_effects/lpe-ellipse_5pts.h \ + live_effects/pathoutlineprovider.cpp \ + live_effects/pathoutlineprovider.h \ + live_effects/lpe-jointype.cpp \ + live_effects/lpe-jointype.h \ + live_effects/lpe-taperstroke.cpp \ + live_effects/lpe-taperstroke.h \ live_effects/lpe-envelope-perspective.cpp \ live_effects/lpe-envelope-perspective.h diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 30dbf4092..c53f1a5b9 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -56,6 +56,13 @@ enum EffectType { EXTRUDE, POWERSTROKE, CLONE_ORIGINAL, + ATTACH_PATH, + FILL_BETWEEN_STROKES, + FILL_BETWEEN_MANY, + ELLIPSE_5PTS, + BOUNDING_BOX, + JOIN_TYPE, + TAPER_STROKE, ENVELOPE_PERSPECTIVE, FILLET_CHAMFER, INVALID_LPE // This must be last (I made it such that it is not needed anymore I think..., Don't trust on it being last. - johan) diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index b012e3ab1..87562ddc4 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -5,6 +5,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +//#define LPE_ENABLE_TEST_EFFECTS //uncomment for toy effects + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -19,7 +21,6 @@ #include "live_effects/lpe-rough-hatches.h" #include "live_effects/lpe-dynastroke.h" #include "live_effects/lpe-test-doEffect-stack.h" -#include "live_effects/lpe-bspline.h" #include "live_effects/lpe-gears.h" #include "live_effects/lpe-curvestitch.h" #include "live_effects/lpe-circle_with_radius.h" @@ -51,6 +52,14 @@ #include "live_effects/lpe-extrude.h" #include "live_effects/lpe-powerstroke.h" #include "live_effects/lpe-clone-original.h" +#include "live_effects/lpe-bspline.h" +#include "live_effects/lpe-attach-path.h" +#include "live_effects/lpe-fill-between-strokes.h" +#include "live_effects/lpe-fill-between-many.h" +#include "live_effects/lpe-ellipse_5pts.h" +#include "live_effects/lpe-bounding-box.h" +#include "live_effects/lpe-jointype.h" +#include "live_effects/lpe-taperstroke.h" #include "live_effects/lpe-envelope-perspective.h" #include "live_effects/lpe-fillet-chamfer.h" @@ -132,10 +141,18 @@ const Util::EnumData LPETypeData[] = { {SHOW_HANDLES, N_("Show handles"), "show_handles"}, {ROUGHEN, N_("Roughen"), "roughen"}, {BSPLINE, N_("BSpline"), "bspline"}, - {SIMPLIFY, N_("Simplify"), "simplify"}, - {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, - // TRANSLATORS: "Envelope Perspective" should be equivalent to "perspective transformation" - {ENVELOPE_PERSPECTIVE, N_("Envelope Perspective"), "envelope-perspective"}, + {JOIN_TYPE, N_("Join type"), "join_type"}, + {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, +/* Ponyscape */ + {ATTACH_PATH, N_("Attach path"), "attach_path"}, + {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"}, + {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"}, + {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"}, + {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, +/* 0.91 */ + {SIMPLIFY, N_("Simplify"), "simplify"}, + {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, + {ENVELOPE_PERSPECTIVE, N_("Envelope-Perspective"), "envelope-perspective"}, {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, }; @@ -267,6 +284,27 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case CLONE_ORIGINAL: neweffect = static_cast ( new LPECloneOriginal(lpeobj) ); break; + case ATTACH_PATH: + neweffect = static_cast ( new LPEAttachPath(lpeobj) ); + break; + case FILL_BETWEEN_STROKES: + neweffect = static_cast ( new LPEFillBetweenStrokes(lpeobj) ); + break; + case FILL_BETWEEN_MANY: + neweffect = static_cast ( new LPEFillBetweenMany(lpeobj) ); + break; + case ELLIPSE_5PTS: + neweffect = static_cast ( new LPEEllipse5Pts(lpeobj) ); + break; + case BOUNDING_BOX: + neweffect = static_cast ( new LPEBoundingBox(lpeobj) ); + break; + case JOIN_TYPE: + neweffect = static_cast ( new LPEJoinType(lpeobj) ); + break; + case TAPER_STROKE: + neweffect = static_cast ( new LPETaperStroke(lpeobj) ); + break; case SIMPLIFY: neweffect = static_cast ( new LPESimplify(lpeobj) ); break; @@ -286,7 +324,7 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) neweffect = static_cast ( new LPEShowHandles(lpeobj) ); break; default: - g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); + g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); neweffect = NULL; break; } @@ -369,6 +407,33 @@ Effect::doBeforeEffect (SPLPEItem const*/*lpeitem*/) //Do nothing for simple effects } +void Effect::doAfterEffect (SPLPEItem const* /*lpeitem*/) +{ +} + +void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/) +{ +} + +//secret impl methods (shhhh!) +void Effect::doOnApply_impl(SPLPEItem const* lpeitem) +{ + sp_lpe_item = const_cast(lpeitem); + /*sp_curve = SP_SHAPE(sp_lpe_item)->getCurve(); + pathvector_before_effect = sp_curve->get_pathvector();*/ + doOnApply(lpeitem); +} + +void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem) +{ + sp_lpe_item = const_cast(lpeitem); + //printf("(SPLPEITEM*) %p\n", sp_lpe_item); + sp_curve = SP_SHAPE(sp_lpe_item)->getCurve(); + pathvector_before_effect = sp_curve->get_pathvector(); + + doBeforeEffect(lpeitem); +} + /** * Effects can have a parameter path set before they are applied by accepting a nonzero number of * mouse clicks. This method activates the pen context, which waits for the specified number of diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 940770616..a486e8491 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -53,8 +53,16 @@ public: EffectType effectType() const; + //basically, to get this method called before the derived classes, a bit + //of indirection is needed. We first call these methods, then the below. + void doOnApply_impl(SPLPEItem const* lpeitem); + void doBeforeEffect_impl(SPLPEItem const* lpeitem); + virtual void doOnApply (SPLPEItem const* lpeitem); virtual void doBeforeEffect (SPLPEItem const* lpeitem); + + virtual void doAfterEffect (SPLPEItem const* lpeitem); + virtual void doOnRemove (SPLPEItem const* lpeitem); void writeParamsToSVG(); @@ -147,6 +155,9 @@ protected: // instead of normally 'splitting' the path into continuous pwd2 paths and calling doEffect_pwd2 for each. bool concatenate_before_pwd2; + SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them. + SPCurve * sp_curve; + std::vector pathvector_before_effect; private: bool provides_own_flash_paths; // if true, the standard flash path is suppressed diff --git a/src/live_effects/lpe-attach-path.cpp b/src/live_effects/lpe-attach-path.cpp new file mode 100644 index 000000000..768c66ee2 --- /dev/null +++ b/src/live_effects/lpe-attach-path.cpp @@ -0,0 +1,198 @@ +/* + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include +#include + +#include "live_effects/lpe-attach-path.h" + +#include "display/curve.h" +#include "sp-item.h" +#include "2geom/path.h" +#include "sp-shape.h" +#include "sp-text.h" +#include "2geom/bezier-curve.h" +#include "2geom/path-sink.h" +#include "parameter/parameter.h" +#include "live_effects/parameter/point.h" +#include "parameter/originalpath.h" +#include "2geom/affine.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPEAttachPath::LPEAttachPath(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + start_path(_("Start path:"), _("Path to attach to the start of this path"), "startpath", &wr, this), + start_path_position(_("Start path position:"), _("Position to attach path start to"), "startposition", &wr, this, 0.0), + start_path_curve_start(_("Start path curve start:"), _("Starting curve"), "startcurvestart", &wr, this, Geom::Point(20,0)/*, true*/), + start_path_curve_end(_("Start path curve end:"), _("Ending curve"), "startcurveend", &wr, this, Geom::Point(20,0)/*, true*/), + end_path(_("End path:"), _("Path to attach to the end of this path"), "endpath", &wr, this), + end_path_position(_("End path position:"), _("Position to attach path end to"), "endposition", &wr, this, 0.0), + end_path_curve_start(_("End path curve start:"), _("Starting curve"), "endcurvestart", &wr, this, Geom::Point(20,0)/*, true*/), + end_path_curve_end(_("End path curve end:"), _("Ending curve"), "endcurveend", &wr, this, Geom::Point(20,0)/*, true*/) +{ + registerParameter(&start_path); + registerParameter(&start_path_position); + registerParameter(&start_path_curve_start); + registerParameter(&start_path_curve_end); + + registerParameter(&end_path); + registerParameter(&end_path_position); + registerParameter(&end_path_curve_start); + registerParameter(&end_path_curve_end); + + //perceived_path = true; + show_orig_path = true; + curve_start_previous_origin = start_path_curve_end.getOrigin(); + curve_end_previous_origin = end_path_curve_end.getOrigin(); +} + +LPEAttachPath::~LPEAttachPath() +{ + +} + +void LPEAttachPath::resetDefaults(SPItem const * /*item*/) +{ + curve_start_previous_origin = start_path_curve_end.getOrigin(); + curve_end_previous_origin = end_path_curve_end.getOrigin(); +} + +void LPEAttachPath::doEffect (SPCurve * curve) +{ + std::vector this_pathv = curve->get_pathvector(); + if (sp_lpe_item && !this_pathv.empty()) { + Geom::Path p = Geom::Path(this_pathv.front().initialPoint()); + + bool set_start_end = start_path_curve_end.getOrigin() != curve_start_previous_origin; + bool set_end_end = end_path_curve_end.getOrigin() != curve_end_previous_origin; + + if (start_path.linksToPath()) { + + std::vector linked_pathv = start_path.get_pathvector(); + Geom::Affine linkedtransform = start_path.getObject()->getRelativeTransform(sp_lpe_item); + + if ( !linked_pathv.empty() ) + { + Geom::Path transformedpath = linked_pathv.front() * linkedtransform; + start_path_curve_start.setOrigin(this_pathv.front().initialPoint()); + + std::vector derivs = this_pathv.front().front().pointAndDerivatives(0, 3); + + for (unsigned deriv_n = 1; deriv_n < derivs.size(); deriv_n++) { + Geom::Coord length = derivs[deriv_n].length(); + if ( ! Geom::are_near(length, 0) ) { + if (set_start_end) { + start_path_position.param_set_value(transformedpath.nearestPoint(start_path_curve_end.getOrigin())); + } + + if (start_path_position > transformedpath.size()) { + start_path_position.param_set_value(transformedpath.size()); + } else if (start_path_position < 0) { + start_path_position.param_set_value(0); + } + const Geom::Curve *c = start_path_position >= transformedpath.size() ? &transformedpath.back() : &transformedpath.at_index((int)start_path_position); + + std::vector derivs_2 = c->pointAndDerivatives(start_path_position >= transformedpath.size() ? 1 : (start_path_position - (int)start_path_position), 3); + for (unsigned deriv_n_2 = 1; deriv_n_2 < derivs_2.size(); deriv_n_2++) { + Geom::Coord length_2 = derivs[deriv_n_2].length(); + if ( ! Geom::are_near(length_2, 0) ) { + start_path_curve_end.setOrigin(derivs_2[0]); + curve_start_previous_origin = start_path_curve_end.getOrigin(); + + double startangle = atan2(start_path_curve_start.getVector().y(), start_path_curve_start.getVector().x()); + double endangle = atan2(start_path_curve_end.getVector().y(), start_path_curve_end.getVector().x()); + double startderiv = atan2(derivs[deriv_n].y(), derivs[deriv_n].x()); + double endderiv = atan2(derivs_2[deriv_n_2].y(), derivs_2[deriv_n_2].x()); + Geom::Point pt1 = Geom::Point(start_path_curve_start.getVector().length() * cos(startangle + startderiv), start_path_curve_start.getVector().length() * sin(startangle + startderiv)); + Geom::Point pt2 = Geom::Point(start_path_curve_end.getVector().length() * cos(endangle + endderiv), start_path_curve_end.getVector().length() * sin(endangle + endderiv)); + p = Geom::Path(derivs_2[0]); + p.appendNew(-pt2 + derivs_2[0], -pt1 + this_pathv.front().initialPoint(), this_pathv.front().initialPoint()); + break; + + } + } + break; + } + } + } + } + + p.append(this_pathv.front()); + + if (end_path.linksToPath()) { + + std::vector linked_pathv = end_path.get_pathvector(); + Geom::Affine linkedtransform = end_path.getObject()->getRelativeTransform(sp_lpe_item); + + if ( !linked_pathv.empty() ) + { + Geom::Path transformedpath = linked_pathv.front() * linkedtransform; + Geom::Curve * last_seg_reverse = this_pathv.front().back().reverse(); + + end_path_curve_start.setOrigin(last_seg_reverse->initialPoint()); + + std::vector derivs = last_seg_reverse->pointAndDerivatives(0, 3); + for (unsigned deriv_n = 1; deriv_n < derivs.size(); deriv_n++) { + Geom::Coord length = derivs[deriv_n].length(); + if ( ! Geom::are_near(length, 0) ) { + if (set_end_end) { + end_path_position.param_set_value(transformedpath.nearestPoint(end_path_curve_end.getOrigin())); + } + + if (end_path_position > transformedpath.size()) { + end_path_position.param_set_value(transformedpath.size()); + } else if (end_path_position < 0) { + end_path_position.param_set_value(0); + } + const Geom::Curve *c = end_path_position >= transformedpath.size() ? &transformedpath.back() : &transformedpath.at_index((int)end_path_position); + + std::vector derivs_2 = c->pointAndDerivatives(end_path_position >= transformedpath.size() ? 1 : (end_path_position - (int)end_path_position), 3); + for (unsigned deriv_n_2 = 1; deriv_n_2 < derivs_2.size(); deriv_n_2++) { + Geom::Coord length_2 = derivs[deriv_n_2].length(); + if ( ! Geom::are_near(length_2, 0) ) { + + end_path_curve_end.setOrigin(derivs_2[0]); + curve_end_previous_origin = end_path_curve_end.getOrigin(); + + double startangle = atan2(end_path_curve_start.getVector().y(), end_path_curve_start.getVector().x()); + double endangle = atan2(end_path_curve_end.getVector().y(), end_path_curve_end.getVector().x()); + double startderiv = atan2(derivs[deriv_n].y(), derivs[deriv_n].x()); + double endderiv = atan2(derivs_2[deriv_n_2].y(), derivs_2[deriv_n_2].x()); + Geom::Point pt1 = Geom::Point(end_path_curve_start.getVector().length() * cos(startangle + startderiv), end_path_curve_start.getVector().length() * sin(startangle + startderiv)); + Geom::Point pt2 = Geom::Point(end_path_curve_end.getVector().length() * cos(endangle + endderiv), end_path_curve_end.getVector().length() * sin(endangle + endderiv)); + p.appendNew(-pt1 + this_pathv.front().finalPoint(), -pt2 + derivs_2[0], derivs_2[0]); + + break; + + } + } + break; + } + } + delete last_seg_reverse; + } + } + Geom::PathVector outvector; + outvector.push_back(p); + curve->set_pathvector(outvector); + } +} + +} // namespace LivePathEffect +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-attach-path.h b/src/live_effects/lpe-attach-path.h new file mode 100644 index 000000000..1d6c590d1 --- /dev/null +++ b/src/live_effects/lpe-attach-path.h @@ -0,0 +1,52 @@ +#ifndef INKSCAPE_LPE_ATTACH_PATH_H +#define INKSCAPE_LPE_ATTACH_PATH_H + +/* + * Inkscape::LPEAttachPath + * + * Copyright (C) Ted Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/parameter/parameter.h" +#include "live_effects/parameter/point.h" +#include "live_effects/parameter/originalpath.h" +#include "live_effects/parameter/vector.h" +#include "live_effects/parameter/bool.h" +#include "live_effects/parameter/transformedpoint.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEAttachPath : public Effect { +public: + LPEAttachPath(LivePathEffectObject *lpeobject); + virtual ~LPEAttachPath(); + + virtual void doEffect (SPCurve * curve); + virtual void resetDefaults(SPItem const * item); + +private: + LPEAttachPath(const LPEAttachPath&); + LPEAttachPath& operator=(const LPEAttachPath&); + + Geom::Point curve_start_previous_origin; + Geom::Point curve_end_previous_origin; + + OriginalPathParam start_path; + ScalarParam start_path_position; + TransformedPointParam start_path_curve_start; + VectorParam start_path_curve_end; + + OriginalPathParam end_path; + ScalarParam end_path_position; + TransformedPointParam end_path_curve_start; + VectorParam end_path_curve_end; +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape + +#endif diff --git a/src/live_effects/lpe-bounding-box.cpp b/src/live_effects/lpe-bounding-box.cpp new file mode 100644 index 000000000..bafd5e70e --- /dev/null +++ b/src/live_effects/lpe-bounding-box.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include + +#include "live_effects/lpe-bounding-box.h" + +#include "display/curve.h" +#include "sp-item.h" +#include "2geom/path.h" +#include "sp-shape.h" +#include "sp-text.h" +#include "2geom/bezier-curve.h" +#include "lpe-bounding-box.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPEBoundingBox::LPEBoundingBox(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + linked_path(_("Linked path:"), _("Path from which to take the original path data"), "linkedpath", &wr, this), + visual_bounds(_("Visual Bounds"), _("Uses the visual bounding box"), "visualbounds", &wr, this) +{ + registerParameter( dynamic_cast(&linked_path) ); + registerParameter( dynamic_cast(&visual_bounds) ); + //perceived_path = true; +} + +LPEBoundingBox::~LPEBoundingBox() +{ + +} + +void LPEBoundingBox::doEffect (SPCurve * curve) +{ + if (curve) { + if ( linked_path.linksToPath() && linked_path.getObject() ) { + SPItem * item = linked_path.getObject(); + Geom::OptRect bbox = visual_bounds.get_value() ? item->visualBounds() : item->geometricBounds(); + Geom::Path p(Geom::Point(bbox->left(), bbox->top())); + p.appendNew(Geom::Point(bbox->right(), bbox->top())); + p.appendNew(Geom::Point(bbox->right(), bbox->bottom())); + p.appendNew(Geom::Point(bbox->left(), bbox->bottom())); + p.appendNew(Geom::Point(bbox->left(), bbox->top())); + std::vector out; + out.push_back(p); + curve->set_pathvector(out); + } + } +} + +} // namespace LivePathEffect +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-bounding-box.h b/src/live_effects/lpe-bounding-box.h new file mode 100644 index 000000000..d028a20ac --- /dev/null +++ b/src/live_effects/lpe-bounding-box.h @@ -0,0 +1,37 @@ +#ifndef INKSCAPE_LPE_BOUNDING_BOX_H +#define INKSCAPE_LPE_BOUNDING_BOX_H + +/* + * Inkscape::LPEFillBetweenStrokes + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/parameter/originalpath.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEBoundingBox : public Effect { +public: + LPEBoundingBox(LivePathEffectObject *lpeobject); + virtual ~LPEBoundingBox(); + + virtual void doEffect (SPCurve * curve); + +private: + OriginalPathParam linked_path; + BoolParam visual_bounds; + +private: + LPEBoundingBox(const LPEBoundingBox&); + LPEBoundingBox& operator=(const LPEBoundingBox&); +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape + +#endif diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 3a6dca795..d45afb0d9 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -52,19 +52,24 @@ using Inkscape::DocumentUndo; namespace Inkscape { namespace LivePathEffect { +const double handleCubicGap = 0.01; +const double noPower = 0.0; +const double defaultStartPower = 0.3334; +const double defaultEndPower = 0.6667; + LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject), steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2), ignoreCusp(_("Ignore cusp nodes"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), onlySelected(_("Change only selected nodes"), _("Change only selected nodes"), "onlySelected", &wr, this, false), - weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 0.3334) + weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, defaultStartPower) { registerParameter(&weight); registerParameter(&steps); registerParameter(&ignoreCusp); registerParameter(&onlySelected); - weight.param_set_range(0.0000, 1); + weight.param_set_range(noPower, 1); weight.param_set_increments(0.1, 0.1); weight.param_set_digits(4); @@ -97,192 +102,136 @@ void LPEBSpline::createAndApply(const char *name, SPDocument *doc, SPItem *item) void LPEBSpline::doEffect(SPCurve *curve) { - if (curve->get_segment_count() < 1) + if (curve->get_segment_count() < 1){ return; - // Make copy of old path as it is changed during processing + } + Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el - //penúltimo for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... if (path_it->empty()) continue; - //Itreadores - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = - ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = - path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se - //calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores + Geom::Path::const_iterator curve_it1 = path_it->begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); + Geom::Path::const_iterator curve_endit = path_it->end_default(); SPCurve *nCurve = new SPCurve(); Geom::Point previousNode(0, 0); Geom::Point node(0, 0); Geom::Point pointAt1(0, 0); Geom::Point pointAt2(0, 0); Geom::Point nextPointAt1(0, 0); - Geom::Point nextPointAt2(0, 0); - Geom::Point nextPointAt3(0, 0); Geom::D2 SBasisIn; Geom::D2 SBasisOut; Geom::D2 SBasisHelper; Geom::CubicBezier const *cubic = NULL; if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the - // closing line segment has zerolength. - const Geom::Curve &closingline = - path_it->back_closed(); // the closing line segment is always of type - // Geom::LineSegment. + const Geom::Curve &closingline = path_it->back_closed(); if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for - // *exact* zero length, which goes wrong for relative coordinates and - // rounding errors... - // the closing line segment has zero-length. So stop before that one! curve_endit = path_it->end_open(); } } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo - //BSPline nCurve->moveto(curve_it1->initialPoint()); - //Recorremos todos los segmentos menos el último - while (curve_it2 != curve_endit) { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path - //recto de entrada y de salida + while (curve_it1 != curve_endit) { SPCurve *in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); cubic = dynamic_cast(&*curve_it1); if (cubic) { SBasisIn = in->first_segment()->toSBasis(); - pointAt1 = SBasisIn.valueAt( - Geom::nearest_point((*cubic)[1], *in->first_segment())); - pointAt2 = SBasisIn.valueAt( - Geom::nearest_point((*cubic)[2], *in->first_segment())); + if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) { + pointAt1 = SBasisIn.valueAt(defaultStartPower); + } else { + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1], *in->first_segment())); + } + if(are_near((*cubic)[2],(*cubic)[3]) && !are_near((*cubic)[1],(*cubic)[0])) { + pointAt2 = SBasisIn.valueAt(defaultEndPower); + } else { + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2], *in->first_segment())); + } } else { pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); } in->reset(); delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - SPCurve *out = new SPCurve(); - out->moveto(curve_it2->initialPoint()); - out->lineto(curve_it2->finalPoint()); - cubic = dynamic_cast(&*curve_it2); - if (cubic) { - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt1 = SBasisOut.valueAt( - Geom::nearest_point((*cubic)[1], *out->first_segment())); - nextPointAt2 = SBasisOut.valueAt( - Geom::nearest_point((*cubic)[2], *out->first_segment())); - ; - nextPointAt3 = out->first_segment()->finalPoint(); + if ( curve_it2 != curve_endit ) { + SPCurve *out = new SPCurve(); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + cubic = dynamic_cast(&*curve_it2); + if (cubic) { + SBasisOut = out->first_segment()->toSBasis(); + if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) { + nextPointAt1 = SBasisIn.valueAt(defaultStartPower); + } else { + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1], *out->first_segment())); + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + } + out->reset(); + delete out; + } + Geom::Point startNode = path_it->begin()->initialPoint(); + if (path_it->closed() && curve_it2 == curve_endit) { + SPCurve *start = new SPCurve(); + start->moveto(path_it->begin()->initialPoint()); + start->lineto(path_it->begin()->finalPoint()); + Geom::D2 SBasisStart = start->first_segment()->toSBasis(); + SPCurve *lineHelper = new SPCurve(); + cubic = dynamic_cast(&*path_it->begin()); + if (cubic) { + lineHelper->moveto(SBasisStart.valueAt( + Geom::nearest_point((*cubic)[1], *start->first_segment()))); + } else { + lineHelper->moveto(start->first_segment()->initialPoint()); + } + start->reset(); + delete start; + + SPCurve *end = new SPCurve(); + end->moveto(curve_it1->initialPoint()); + end->lineto(curve_it1->finalPoint()); + Geom::D2 SBasisEnd = end->first_segment()->toSBasis(); + cubic = dynamic_cast(&*curve_it1); + if (cubic) { + lineHelper->lineto(SBasisEnd.valueAt( + Geom::nearest_point((*cubic)[2], *end->first_segment()))); + } else { + lineHelper->lineto(end->first_segment()->finalPoint()); + } + end->reset(); + delete end; + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + delete lineHelper; + startNode = SBasisHelper.valueAt(0.5); + nCurve->curveto(pointAt1, pointAt2, startNode); + nCurve->move_endpoints(startNode, startNode); + } else if ( curve_it2 == curve_endit) { + nCurve->curveto(pointAt1, pointAt2, curve_it1->finalPoint()); + nCurve->move_endpoints(path_it->begin()->initialPoint(), curve_it1->finalPoint()); } else { - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); + SPCurve *lineHelper = new SPCurve(); + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + delete lineHelper; + previousNode = node; + node = SBasisHelper.valueAt(0.5); + Geom::CubicBezier const *cubic2 = dynamic_cast(&*curve_it1); + if((cubic && are_near((*cubic)[0],(*cubic)[1])) || (cubic2 && are_near((*cubic2)[2],(*cubic2)[3]))) { + node = curve_it1->finalPoint(); + } + nCurve->curveto(pointAt1, pointAt2, node); } - out->reset(); - delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente - //de - //los manejadores de la curva - SPCurve *lineHelper = new SPCurve(); - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - delete lineHelper; - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de - //principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); - nCurve->curveto(pointAt1, pointAt2, node); - //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; } - SPCurve *out = new SPCurve(); - out->moveto(curve_it1->initialPoint()); - out->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - if (cubic) { - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1], *out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2], *out->first_segment())); - nextPointAt3 = out->first_segment()->finalPoint(); - } else { - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - } - out->reset(); - delete out; - //Si está cerrada la curva, la cerramos sobre el valor guardado - //previamente - //Si no finalizamos en el punto final - Geom::Point startNode = path_it->begin()->initialPoint(); - if (path_it->closed()) { - SPCurve *start = new SPCurve(); - start->moveto(path_it->begin()->initialPoint()); - start->lineto(path_it->begin()->finalPoint()); - Geom::D2 SBasisStart = start->first_segment()->toSBasis(); - SPCurve *lineHelper = new SPCurve(); - cubic = dynamic_cast(&*path_it->begin()); - if (cubic) { - lineHelper->moveto(SBasisStart.valueAt( - Geom::nearest_point((*cubic)[1], *start->first_segment()))); - } else { - lineHelper->moveto(start->first_segment()->initialPoint()); - } - start->reset(); - delete start; - - SPCurve *end = new SPCurve(); - end->moveto(curve_it1->initialPoint()); - end->lineto(curve_it1->finalPoint()); - Geom::D2 SBasisEnd = end->first_segment()->toSBasis(); - - cubic = dynamic_cast(&*curve_it1); - if (cubic) { - lineHelper->lineto(SBasisEnd.valueAt( - Geom::nearest_point((*cubic)[2], *end->first_segment()))); - } else { - lineHelper->lineto(end->first_segment()->finalPoint()); - } - end->reset(); - delete end; - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - delete lineHelper; - startNode = SBasisHelper.valueAt(0.5); - nCurve->curveto(nextPointAt1, nextPointAt2, startNode); - nCurve->move_endpoints(startNode, startNode); - } else { - SPCurve *start = new SPCurve(); - start->moveto(path_it->begin()->initialPoint()); - start->lineto(path_it->begin()->finalPoint()); - startNode = start->first_segment()->initialPoint(); - start->reset(); - delete start; - nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->move_endpoints(startNode, nextPointAt3); - } //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); @@ -349,22 +298,22 @@ Gtk::Widget *LPEBSpline::newWidget() void LPEBSpline::toDefaultWeight(Gtk::Widget *widgWeight) { - weight.param_set_value(0.3334); - changeWeight(0.3334); + weight.param_set_value(defaultStartPower); + changeWeight(defaultStartPower); Gtk::HBox * scalarParameter = dynamic_cast(widgWeight); std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); Gtk::Entry* entryWidg = dynamic_cast(childList[1]); - entryWidg->set_text("0.3334"); + entryWidg->set_text("defaultStartPower"); } void LPEBSpline::toMakeCusp(Gtk::Widget *widgWeight) { - weight.param_set_value(0.0000); - changeWeight(0.0000); + weight.param_set_value(noPower); + changeWeight(noPower); Gtk::HBox * scalarParameter = dynamic_cast(widgWeight); std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); Gtk::Entry* entryWidg = dynamic_cast(childList[1]); - entryWidg->set_text("0.0000"); + entryWidg->set_text("noPower"); } void LPEBSpline::toWeight() @@ -402,7 +351,7 @@ bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint) for (std::vector::iterator i = points.begin(); i != points.end(); ++i) { Geom::Point p = *i; - if (Geom::are_near(p, nodePoint, 0.0001)) { + if (Geom::are_near(p, nodePoint, handleCubicGap)) { return true; } else { } @@ -463,10 +412,6 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) Geom::Point pointAt1(0, 0); Geom::Point pointAt2(0, 0); Geom::Point pointAt3(0, 0); - Geom::Point nextPointAt0(0, 0); - Geom::Point nextPointAt1(0, 0); - Geom::Point nextPointAt2(0, 0); - Geom::Point nextPointAt3(0, 0); Geom::D2 SBasisIn; Geom::D2 SBasisOut; Geom::CubicBezier const *cubic = NULL; @@ -490,7 +435,7 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) //BSPline nCurve->moveto(curve_it1->initialPoint()); //Recorremos todos los segmentos menos el último - while (curve_it2 != curve_endit) { + while (curve_it1 != curve_endit) { //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path //recto de entrada y de salida @@ -505,33 +450,33 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) if (cubic) { if (!ignoreCusp || !Geom::are_near((*cubic)[1], pointAt0)) { pointAt1 = SBasisIn.valueAt(weightValue); - if (weightValue != 0.0000) { + if (weightValue != noPower) { pointAt1 = - Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + Geom::Point(pointAt1[X] + handleCubicGap, pointAt1[Y] + handleCubicGap); } } else { pointAt1 = in->first_segment()->initialPoint(); } if (!ignoreCusp || !Geom::are_near((*cubic)[2], pointAt3)) { pointAt2 = SBasisIn.valueAt(1 - weightValue); - if (weightValue != 0.0000) { + if (weightValue != noPower) { pointAt2 = - Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + Geom::Point(pointAt2[X] + handleCubicGap, pointAt2[Y] + handleCubicGap); } } else { pointAt2 = in->first_segment()->finalPoint(); } } else { - if (!ignoreCusp && weightValue != 0.0000) { + if (!ignoreCusp && weightValue != noPower) { pointAt1 = SBasisIn.valueAt(weightValue); - if (weightValue != 0.0000) { + if (weightValue != noPower) { pointAt1 = - Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + Geom::Point(pointAt1[X] + handleCubicGap, pointAt1[Y] + handleCubicGap); } pointAt2 = SBasisIn.valueAt(1 - weightValue); - if (weightValue != 0.0000) { + if (weightValue != noPower) { pointAt2 = - Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + Geom::Point(pointAt2[X] + handleCubicGap, pointAt2[Y] + handleCubicGap); } } else { pointAt1 = in->first_segment()->initialPoint(); @@ -543,9 +488,9 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) if (!ignoreCusp || !Geom::are_near((*cubic)[1], pointAt0)) { if (nodeIsSelected(pointAt0)) { pointAt1 = SBasisIn.valueAt(weightValue); - if (weightValue != 0.0000) { + if (weightValue != noPower) { pointAt1 = - Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + Geom::Point(pointAt1[X] + handleCubicGap, pointAt1[Y] + handleCubicGap); } } else { pointAt1 = (*cubic)[1]; @@ -556,9 +501,9 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) if (!ignoreCusp || !Geom::are_near((*cubic)[2], pointAt3)) { if (nodeIsSelected(pointAt3)) { pointAt2 = SBasisIn.valueAt(1 - weightValue); - if (weightValue != 0.0000) { + if (weightValue != noPower) { pointAt2 = - Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + Geom::Point(pointAt2[X] + handleCubicGap, pointAt2[Y] + handleCubicGap); } } else { pointAt2 = (*cubic)[2]; @@ -567,18 +512,18 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) pointAt2 = in->first_segment()->finalPoint(); } } else { - if (!ignoreCusp && weightValue != 0.000) { + if (!ignoreCusp && weightValue != noPower) { if (nodeIsSelected(pointAt0)) { pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = - Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + Geom::Point(pointAt1[X] + handleCubicGap, pointAt1[Y] + handleCubicGap); } else { pointAt1 = in->first_segment()->initialPoint(); } if (nodeIsSelected(pointAt3)) { pointAt2 = SBasisIn.valueAt(weightValue); pointAt2 = - Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + Geom::Point(pointAt2[X] + handleCubicGap, pointAt2[Y] + handleCubicGap); } else { pointAt2 = in->first_segment()->finalPoint(); } @@ -601,110 +546,11 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) ++curve_it1; ++curve_it2; } - SPCurve *out = new SPCurve(); - out->moveto(curve_it1->initialPoint()); - out->lineto(curve_it1->finalPoint()); - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt0 = out->first_segment()->initialPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - cubic = dynamic_cast(&*curve_it1); - if (!onlySelected) { - if (cubic) { - if (!ignoreCusp || !Geom::are_near((*cubic)[1], nextPointAt0)) { - nextPointAt1 = SBasisOut.valueAt(weightValue); - if (weightValue != 0.0000) { - nextPointAt1 = - Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); - } - } else { - nextPointAt1 = out->first_segment()->initialPoint(); - } - if (!ignoreCusp || !Geom::are_near((*cubic)[2], nextPointAt3)) { - nextPointAt2 = SBasisOut.valueAt(1 - weightValue); - if (weightValue != 0.0000) { - nextPointAt2 = - Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); - } - } else { - nextPointAt2 = out->first_segment()->finalPoint(); - } - } else { - if (!ignoreCusp && weightValue != 0.0000) { - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = - Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); - nextPointAt2 = SBasisOut.valueAt(1 - weightValue); - nextPointAt2 = - Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); - } else { - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - } - } - } else { - if (cubic) { - if (!ignoreCusp || !Geom::are_near((*cubic)[1], nextPointAt0)) { - if (nodeIsSelected(nextPointAt0)) { - nextPointAt1 = SBasisOut.valueAt(weightValue); - if (weightValue != 0.0000) { - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001, - nextPointAt1[Y] + 0.0001); - } - } else { - nextPointAt1 = (*cubic)[1]; - } - } else { - nextPointAt1 = out->first_segment()->initialPoint(); - } - if (!ignoreCusp || !Geom::are_near((*cubic)[2], nextPointAt3)) { - if (nodeIsSelected(nextPointAt3)) { - nextPointAt2 = SBasisOut.valueAt(1 - weightValue); - if (weightValue != 0.0000) { - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001, - nextPointAt2[Y] + 0.0001); - } - } else { - nextPointAt2 = (*cubic)[2]; - } - } else { - nextPointAt2 = out->first_segment()->finalPoint(); - } - } else { - if (!ignoreCusp && weightValue != 0.0000) { - if (nodeIsSelected(nextPointAt0)) { - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = - Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); - } else { - nextPointAt1 = out->first_segment()->initialPoint(); - } - if (nodeIsSelected(nextPointAt3)) { - nextPointAt2 = SBasisOut.valueAt(weightValue); - nextPointAt2 = - Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); - } else { - nextPointAt2 = out->first_segment()->finalPoint(); - } - } else { - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - } - } - } - out->reset(); - delete out; - //Aberiguamos la ultima parte de la curva correspondiente al último - //segmento - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); if (path_it->closed()) { - nCurve->curveto(nextPointAt1, nextPointAt2, - path_it->begin()->initialPoint()); nCurve->move_endpoints(path_it->begin()->initialPoint(), path_it->begin()->initialPoint()); } else { - nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->move_endpoints(path_it->begin()->initialPoint(), nextPointAt3); + nCurve->move_endpoints(path_it->begin()->initialPoint(), pointAt3); } //y cerramos la curva if (path_it->closed()) { diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 65bbcdad1..e466093d3 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -12,6 +12,7 @@ */ #include +#include #include "live_effects/lpe-copy_rotate.h" #include "sp-shape.h" diff --git a/src/live_effects/lpe-ellipse_5pts.cpp b/src/live_effects/lpe-ellipse_5pts.cpp new file mode 100644 index 000000000..b0a5919fe --- /dev/null +++ b/src/live_effects/lpe-ellipse_5pts.cpp @@ -0,0 +1,214 @@ +/** \file + * LPE "Ellipse through 5 points" implementation + */ + +/* + * Authors: + * Theodore Janeczko + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/lpe-ellipse_5pts.h" + +// You might need to include other 2geom files. You can add them here: +#include +#include <2geom/path.h> +#include <2geom/circle.h> +#include <2geom/ellipse.h> +#include <2geom/path-sink.h> +#include "inkscape.h" +#include "desktop.h" +#include "message-stack.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPEEllipse5Pts::LPEEllipse5Pts(LivePathEffectObject *lpeobject) : + Effect(lpeobject) +{ + //perceived_path = true; +} + +LPEEllipse5Pts::~LPEEllipse5Pts() +{ +} + +static double _det3(double (*mat)[3]) +{ + for (int i = 0; i < 2; i++) + { + for (int j = i + 1; j < 3; j++) + { + for (int k = i + 1; k < 3; k++) + { + mat[j][k] = (mat[j][k] * mat[i][i] - mat[j][i] * mat[i][k]); + if (i) mat[j][k] /= mat[i-1][i-1]; + } + } + } + return mat[2][2]; +} +static double _det5(double (*mat)[5]) +{ + for (int i = 0; i < 4; i++) + { + for (int j = i + 1; j < 5; j++) + { + for (int k = i + 1; k < 5; k++) + { + mat[j][k] = (mat[j][k] * mat[i][i] - mat[j][i] * mat[i][k]); + if (i) mat[j][k] /= mat[i-1][i-1]; + } + } + } + return mat[4][4]; +} + +std::vector +LPEEllipse5Pts::doEffect_path (std::vector const & path_in) +{ + std::vector path_out = std::vector(); + + if (path_in[0].size() < 4) { + + SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Five points required for constructing an ellipse")); + return path_in; + } + // we assume that the path has >= 3 nodes + Geom::Point A = path_in[0].initialPoint(); + Geom::Point B = path_in[0].pointAt(1); + Geom::Point C = path_in[0].pointAt(2); + Geom::Point D = path_in[0].pointAt(3); + Geom::Point E = path_in[0].pointAt(4); + + using namespace Geom; + + double rowmajor_matrix[5][6] = + { + {A.x()*A.x(), A.x()*A.y(), A.y()*A.y(), A.x(), A.y(), 1}, + {B.x()*B.x(), B.x()*B.y(), B.y()*B.y(), B.x(), B.y(), 1}, + {C.x()*C.x(), C.x()*C.y(), C.y()*C.y(), C.x(), C.y(), 1}, + {D.x()*D.x(), D.x()*D.y(), D.y()*D.y(), D.x(), D.y(), 1}, + {E.x()*E.x(), E.x()*E.y(), E.y()*E.y(), E.x(), E.y(), 1} + }; + + double mat_a[5][5] = + { + {rowmajor_matrix[0][1], rowmajor_matrix[1][1], rowmajor_matrix[2][1], rowmajor_matrix[3][1], rowmajor_matrix[4][1]}, + {rowmajor_matrix[0][2], rowmajor_matrix[1][2], rowmajor_matrix[2][2], rowmajor_matrix[3][2], rowmajor_matrix[4][2]}, + {rowmajor_matrix[0][3], rowmajor_matrix[1][3], rowmajor_matrix[2][3], rowmajor_matrix[3][3], rowmajor_matrix[4][3]}, + {rowmajor_matrix[0][4], rowmajor_matrix[1][4], rowmajor_matrix[2][4], rowmajor_matrix[3][4], rowmajor_matrix[4][4]}, + {rowmajor_matrix[0][5], rowmajor_matrix[1][5], rowmajor_matrix[2][5], rowmajor_matrix[3][5], rowmajor_matrix[4][5]} + }; + double mat_b[5][5] = + { + {rowmajor_matrix[0][0], rowmajor_matrix[1][0], rowmajor_matrix[2][0], rowmajor_matrix[3][0], rowmajor_matrix[4][0]}, + {rowmajor_matrix[0][2], rowmajor_matrix[1][2], rowmajor_matrix[2][2], rowmajor_matrix[3][2], rowmajor_matrix[4][2]}, + {rowmajor_matrix[0][3], rowmajor_matrix[1][3], rowmajor_matrix[2][3], rowmajor_matrix[3][3], rowmajor_matrix[4][3]}, + {rowmajor_matrix[0][4], rowmajor_matrix[1][4], rowmajor_matrix[2][4], rowmajor_matrix[3][4], rowmajor_matrix[4][4]}, + {rowmajor_matrix[0][5], rowmajor_matrix[1][5], rowmajor_matrix[2][5], rowmajor_matrix[3][5], rowmajor_matrix[4][5]} + }; + double mat_c[5][5] = + { + {rowmajor_matrix[0][0], rowmajor_matrix[1][0], rowmajor_matrix[2][0], rowmajor_matrix[3][0], rowmajor_matrix[4][0]}, + {rowmajor_matrix[0][1], rowmajor_matrix[1][1], rowmajor_matrix[2][1], rowmajor_matrix[3][1], rowmajor_matrix[4][1]}, + {rowmajor_matrix[0][3], rowmajor_matrix[1][3], rowmajor_matrix[2][3], rowmajor_matrix[3][3], rowmajor_matrix[4][3]}, + {rowmajor_matrix[0][4], rowmajor_matrix[1][4], rowmajor_matrix[2][4], rowmajor_matrix[3][4], rowmajor_matrix[4][4]}, + {rowmajor_matrix[0][5], rowmajor_matrix[1][5], rowmajor_matrix[2][5], rowmajor_matrix[3][5], rowmajor_matrix[4][5]} + }; + double mat_d[5][5] = + { + {rowmajor_matrix[0][0], rowmajor_matrix[1][0], rowmajor_matrix[2][0], rowmajor_matrix[3][0], rowmajor_matrix[4][0]}, + {rowmajor_matrix[0][1], rowmajor_matrix[1][1], rowmajor_matrix[2][1], rowmajor_matrix[3][1], rowmajor_matrix[4][1]}, + {rowmajor_matrix[0][2], rowmajor_matrix[1][2], rowmajor_matrix[2][2], rowmajor_matrix[3][2], rowmajor_matrix[4][2]}, + {rowmajor_matrix[0][4], rowmajor_matrix[1][4], rowmajor_matrix[2][4], rowmajor_matrix[3][4], rowmajor_matrix[4][4]}, + {rowmajor_matrix[0][5], rowmajor_matrix[1][5], rowmajor_matrix[2][5], rowmajor_matrix[3][5], rowmajor_matrix[4][5]} + }; + double mat_e[5][5] = + { + {rowmajor_matrix[0][0], rowmajor_matrix[1][0], rowmajor_matrix[2][0], rowmajor_matrix[3][0], rowmajor_matrix[4][0]}, + {rowmajor_matrix[0][1], rowmajor_matrix[1][1], rowmajor_matrix[2][1], rowmajor_matrix[3][1], rowmajor_matrix[4][1]}, + {rowmajor_matrix[0][2], rowmajor_matrix[1][2], rowmajor_matrix[2][2], rowmajor_matrix[3][2], rowmajor_matrix[4][2]}, + {rowmajor_matrix[0][3], rowmajor_matrix[1][3], rowmajor_matrix[2][3], rowmajor_matrix[3][3], rowmajor_matrix[4][3]}, + {rowmajor_matrix[0][5], rowmajor_matrix[1][5], rowmajor_matrix[2][5], rowmajor_matrix[3][5], rowmajor_matrix[4][5]} + }; + double mat_f[5][5] = + { + {rowmajor_matrix[0][0], rowmajor_matrix[1][0], rowmajor_matrix[2][0], rowmajor_matrix[3][0], rowmajor_matrix[4][0]}, + {rowmajor_matrix[0][1], rowmajor_matrix[1][1], rowmajor_matrix[2][1], rowmajor_matrix[3][1], rowmajor_matrix[4][1]}, + {rowmajor_matrix[0][2], rowmajor_matrix[1][2], rowmajor_matrix[2][2], rowmajor_matrix[3][2], rowmajor_matrix[4][2]}, + {rowmajor_matrix[0][3], rowmajor_matrix[1][3], rowmajor_matrix[2][3], rowmajor_matrix[3][3], rowmajor_matrix[4][3]}, + {rowmajor_matrix[0][4], rowmajor_matrix[1][4], rowmajor_matrix[2][4], rowmajor_matrix[3][4], rowmajor_matrix[4][4]} + }; + + double a1 = _det5(mat_a); + double b1 = -_det5(mat_b); + double c1 = _det5(mat_c); + double d1 = -_det5(mat_d); + double e1 = _det5(mat_e); + double f1 = -_det5(mat_f); + + double mat_check[][3] = + { + {a1, b1/2, d1/2}, + {b1/2, c1, e1/2}, + {d1/2, e1/2, f1} + }; + + if (_det3(mat_check) == 0 || a1*c1 - b1*b1/4 <= 0) { + SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No ellipse found for specified points")); + return path_in; + } + + Geom::Ellipse el(a1, b1, c1, d1, e1, f1); + + double s, e; + double x0, y0, x1, y1, x2, y2, x3, y3; + double len; + + // figure out if we have a slice, guarding against rounding errors + + Path p(Geom::Point(cos(0), sin(0))); + + double end = 2 * M_PI; + for (s = 0; s < end; s += M_PI_2) { + e = s + M_PI_2; + if (e > end) + e = end; + len = 4*tan((e - s)/4)/3; + x0 = cos(s); + y0 = sin(s); + x1 = x0 + len * cos(s + M_PI_2); + y1 = y0 + len * sin(s + M_PI_2); + x3 = cos(e); + y3 = sin(e); + x2 = x3 + len * cos(e - M_PI_2); + y2 = y3 + len * sin(e - M_PI_2); + p.appendNew(Geom::Point(x1,y1), Geom::Point(x2,y2), Geom::Point(x3,y3)); + } + + Geom::Affine aff = Geom::Scale(el.ray(Geom::X), el.ray(Geom::Y)) * Geom::Rotate(el.rot_angle()) * Geom::Translate(el.center()); + + path_out.push_back(p * aff); + + return path_out; +} + +/* ######################## */ + +} //namespace LivePathEffect +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-ellipse_5pts.h b/src/live_effects/lpe-ellipse_5pts.h new file mode 100644 index 000000000..d3b1fccfa --- /dev/null +++ b/src/live_effects/lpe-ellipse_5pts.h @@ -0,0 +1,50 @@ +#ifndef INKSCAPE_LPE_ELLIPSE_5PTS_H +#define INKSCAPE_LPE_ELLIPSE_5PTS_H + +/** \file + * LPE "Ellipse through 5 points" implementation + */ + +/* + * Authors: + * Theodore Janeczko + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/parameter/parameter.h" +#include "live_effects/parameter/point.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEEllipse5Pts : public Effect { +public: + LPEEllipse5Pts(LivePathEffectObject *lpeobject); + virtual ~LPEEllipse5Pts(); + + virtual std::vector doEffect_path (std::vector const & path_in); + +private: + LPEEllipse5Pts(const LPEEllipse5Pts&); + LPEEllipse5Pts& operator=(const LPEEllipse5Pts&); +}; + +} //namespace LivePathEffect +} //namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp new file mode 100644 index 000000000..7cf354044 --- /dev/null +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include + +#include "live_effects/lpe-fill-between-many.h" + +#include "display/curve.h" +#include "sp-item.h" +#include "2geom/path.h" +#include "sp-shape.h" +#include "sp-text.h" +#include "2geom/bezier-curve.h" + +#include + +namespace Inkscape { +namespace LivePathEffect { + +LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + linked_paths(_("Linked path:"), _("Paths from which to take the original path data"), "linkedpaths", &wr, this) +{ + registerParameter( dynamic_cast(&linked_paths) ); + //perceived_path = true; +} + +LPEFillBetweenMany::~LPEFillBetweenMany() +{ + +} + +void LPEFillBetweenMany::doEffect (SPCurve * curve) +{ + std::vector res_pathv; + SPItem * firstObj = NULL; + for (std::vector::iterator iter = linked_paths._vector.begin(); iter != linked_paths._vector.end(); iter++) { + SPObject *obj; + if ((*iter)->ref.isAttached() && (obj = (*iter)->ref.getObject()) && SP_IS_ITEM(obj) && !(*iter)->_pathvector.empty()) { + Geom::Path linked_path; + if ((*iter)->reversed) { + linked_path = (*iter)->_pathvector.front().reverse(); + } else { + linked_path = (*iter)->_pathvector.front(); + } + + if (!res_pathv.empty()) { + linked_path = linked_path * SP_ITEM(obj)->getRelativeTransform(firstObj); + res_pathv.front().appendNew(linked_path.initialPoint()); + res_pathv.front().append(linked_path); + } else { + firstObj = SP_ITEM(obj); + res_pathv.push_back(linked_path); + } + } + } + if (!res_pathv.empty()) { + res_pathv.front().close(); + } + curve->set_pathvector(res_pathv); +} + +} // namespace LivePathEffect +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-fill-between-many.h b/src/live_effects/lpe-fill-between-many.h new file mode 100644 index 000000000..99ee8b15f --- /dev/null +++ b/src/live_effects/lpe-fill-between-many.h @@ -0,0 +1,36 @@ +#ifndef INKSCAPE_LPE_FILL_BETWEEN_MANY_H +#define INKSCAPE_LPE_FILL_BETWEEN_MANY_H + +/* + * Inkscape::LPEFillBetweenStrokes + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/parameter/originalpatharray.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEFillBetweenMany : public Effect { +public: + LPEFillBetweenMany(LivePathEffectObject *lpeobject); + virtual ~LPEFillBetweenMany(); + + virtual void doEffect (SPCurve * curve); + +private: + OriginalPathArrayParam linked_paths; + +private: + LPEFillBetweenMany(const LPEFillBetweenMany&); + LPEFillBetweenMany& operator=(const LPEFillBetweenMany&); +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape + +#endif diff --git a/src/live_effects/lpe-fill-between-strokes.cpp b/src/live_effects/lpe-fill-between-strokes.cpp new file mode 100644 index 000000000..e72979ed0 --- /dev/null +++ b/src/live_effects/lpe-fill-between-strokes.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include + +#include "live_effects/lpe-fill-between-strokes.h" + +#include "display/curve.h" +#include "sp-item.h" +#include "2geom/path.h" +#include "sp-shape.h" +#include "sp-text.h" +#include "2geom/bezier-curve.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPEFillBetweenStrokes::LPEFillBetweenStrokes(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + linked_path(_("Linked path:"), _("Path from which to take the original path data"), "linkedpath", &wr, this), + second_path(_("Second path:"), _("Second path from which to take the original path data"), "secondpath", &wr, this), + reverse_second(_("Reverse Second"), _("Reverses the second path order"), "reversesecond", &wr, this) +{ + registerParameter( dynamic_cast(&linked_path) ); + registerParameter( dynamic_cast(&second_path) ); + registerParameter( dynamic_cast(&reverse_second) ); + //perceived_path = true; +} + +LPEFillBetweenStrokes::~LPEFillBetweenStrokes() +{ + +} + +void LPEFillBetweenStrokes::doEffect (SPCurve * curve) +{ + if (curve) { + if ( linked_path.linksToPath() && second_path.linksToPath() && linked_path.getObject() && second_path.getObject() ) { + std::vector linked_pathv = linked_path.get_pathvector(); + std::vector second_pathv = second_path.get_pathvector(); + std::vector result_linked_pathv; + std::vector result_second_pathv; + Geom::Affine second_transform = second_path.getObject()->getRelativeTransform(linked_path.getObject()); + + for (std::vector::iterator iter = linked_pathv.begin(); iter != linked_pathv.end(); ++iter) + { + result_linked_pathv.push_back((*iter)); + } + for (std::vector::iterator iter = second_pathv.begin(); iter != second_pathv.end(); ++iter) + { + result_second_pathv.push_back((*iter) * second_transform); + } + + if ( !result_linked_pathv.empty() && !result_second_pathv.empty() && !result_linked_pathv.front().closed() ) { + if (reverse_second.get_value()) + { + result_linked_pathv.front().appendNew(result_second_pathv.front().finalPoint()); + result_linked_pathv.front().append(result_second_pathv.front().reverse()); + } + else + { + result_linked_pathv.front().appendNew(result_second_pathv.front().initialPoint()); + result_linked_pathv.front().append(result_second_pathv.front()); + } + curve->set_pathvector(result_linked_pathv); + } + else if ( !result_linked_pathv.empty() ) { + curve->set_pathvector(result_linked_pathv); + } + else if ( !result_second_pathv.empty() ) { + curve->set_pathvector(result_second_pathv); + } + } + else if ( linked_path.linksToPath() && linked_path.getObject() ) { + std::vector linked_pathv = linked_path.get_pathvector(); + std::vector result_pathv; + + for (std::vector::iterator iter = linked_pathv.begin(); iter != linked_pathv.end(); ++iter) + { + result_pathv.push_back((*iter)); + } + if ( !result_pathv.empty() ) { + curve->set_pathvector(result_pathv); + } + } + else if ( second_path.linksToPath() && second_path.getObject() ) { + std::vector second_pathv = second_path.get_pathvector(); + std::vector result_pathv; + + for (std::vector::iterator iter = second_pathv.begin(); iter != second_pathv.end(); ++iter) + { + result_pathv.push_back((*iter)); + } + if ( !result_pathv.empty() ) { + curve->set_pathvector(result_pathv); + } + } + } +} + +} // namespace LivePathEffect +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-fill-between-strokes.h b/src/live_effects/lpe-fill-between-strokes.h new file mode 100644 index 000000000..ec57b1852 --- /dev/null +++ b/src/live_effects/lpe-fill-between-strokes.h @@ -0,0 +1,38 @@ +#ifndef INKSCAPE_LPE_FILL_BETWEEN_STROKES_H +#define INKSCAPE_LPE_FILL_BETWEEN_STROKES_H + +/* + * Inkscape::LPEFillBetweenStrokes + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/parameter/originalpath.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEFillBetweenStrokes : public Effect { +public: + LPEFillBetweenStrokes(LivePathEffectObject *lpeobject); + virtual ~LPEFillBetweenStrokes(); + + virtual void doEffect (SPCurve * curve); + +private: + OriginalPathParam linked_path; + OriginalPathParam second_path; + BoolParam reverse_second; + +private: + LPEFillBetweenStrokes(const LPEFillBetweenStrokes&); + LPEFillBetweenStrokes& operator=(const LPEFillBetweenStrokes&); +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape + +#endif diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index bfb2c3ba4..857e9d9cc 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -22,6 +22,9 @@ #include "desktop.h" #include "display/curve.h" #include "helper/geom-nodetype.h" +#include "helper/geom-curves.h" +#include "helper/geom.h" + #include "live_effects/parameter/filletchamferpointarray.h" // for programmatically updating knots @@ -49,6 +52,8 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : ignore_radius_0(_("Ignore 0 radius knots"), _("Ignore 0 radius knots"), "ignore_radius_0", &wr, this, false), only_selected(_("Change only selected nodes"), _("Change only selected nodes"), "only_selected", &wr, this, false), flexible(_("Flexible radius size (%)"), _("Flexible radius size (%)"), "flexible", &wr, this, false), + force_arcs(_("Use arcs in cubic curves"), _("Use arcs in cubic curves"), "force_arcs", &wr, this, false), + use_knot_distance(_("Use knots distance instead radius"), _("Use knots distance instead radius"), "use_knot_distance", &wr, this, false), unit(_("Unit"), _("Unit"), "unit", &wr, this), radius(_("Radius (unit or %)"), _("Radius, in unit or %"), "radius", &wr, this, 0.), helper_size(_("Helper size with direction"), _("Helper size with direction"), "helper_size", &wr, this, 0) @@ -58,9 +63,11 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : registerParameter(&radius); registerParameter(&helper_size); registerParameter(&flexible); + registerParameter(&use_knot_distance); registerParameter(&ignore_radius_0); registerParameter(&only_selected); registerParameter(&hide_knots); + registerParameter(&force_arcs); radius.param_set_range(0., infinity()); radius.param_set_increments(1, 1); @@ -270,10 +277,10 @@ void LPEFilletChamfer::doUpdateFillet(std::vector const& original_pa } std::vector filletChamferData = fillet_chamfer_values.data(); std::vector result; + std::vector original_pathv_processed = pathv_to_linear_and_cubic_beziers(original_pathv); int counter = 0; - for (PathVector::const_iterator path_it = original_pathv.begin(); - path_it != original_pathv.end(); ++path_it) { - int pathCounter = 0; + for (PathVector::const_iterator path_it = original_pathv_processed.begin(); + path_it != original_pathv_processed.end(); ++path_it) { if (path_it->empty()) continue; @@ -289,6 +296,9 @@ void LPEFilletChamfer::doUpdateFillet(std::vector const& original_pa double powerend = 0; while (curve_it1 != curve_endit) { powerend = power; + if (power < 0 && !use_knot_distance) { + powerend = fillet_chamfer_values.rad_to_len(counter,powerend); + } if (power > 0) { powerend = counter + (power / 100); } @@ -306,7 +316,6 @@ void LPEFilletChamfer::doUpdateFillet(std::vector const& original_pa ++curve_it1; ++curve_it2; counter++; - pathCounter++; } } fillet_chamfer_values.param_set_and_write_new_value(result); @@ -334,8 +343,9 @@ void LPEFilletChamfer::doChangeType(std::vector const& original_path } std::vector filletChamferData = fillet_chamfer_values.data(); std::vector result; + std::vector original_pathv_processed = pathv_to_linear_and_cubic_beziers(original_pathv); int counter = 0; - for (PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + for (PathVector::const_iterator path_it = original_pathv_processed.begin(); path_it != original_pathv_processed.end(); ++path_it) { int pathCounter = 0; if (path_it->empty()) continue; @@ -378,7 +388,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) { if (SP_IS_SHAPE(lpeItem)) { std::vector point; - PathVector const &original_pathv = SP_SHAPE(lpeItem)->_curve->get_pathvector(); + PathVector const &original_pathv = pathv_to_linear_and_cubic_beziers(SP_SHAPE(lpeItem)->_curve->get_pathvector()); Piecewise > pwd2_in = paths_to_pw(original_pathv); for (PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { if (path_it->empty()) @@ -401,10 +411,15 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) } int counter = 0; while (curve_it1 != curve_endit) { + std::pair positions = fillet_chamfer_values.get_positions(counter, original_pathv); Geom::NodeType nodetype; - if (counter == 0) { + if (positions.second == 0) { if (path_it->closed()) { - nodetype = get_nodetype(path_it->back_default(), *curve_it1); + Piecewise > u; + u.push_cut(0); + u.push(pwd2_in[fillet_chamfer_values.last_index(counter, original_pathv)], 1); + Geom::Curve const * A = path_from_piecewise(u, 0.1)[0][0].duplicate(); + nodetype = get_nodetype(*A, *curve_it1); } else { nodetype = NODE_NONE; } @@ -433,12 +448,15 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) { if (SP_IS_SHAPE(lpeItem)) { fillet_chamfer_values.set_helper_size(helper_size); + fillet_chamfer_values.set_use_distance(use_knot_distance); fillet_chamfer_values.set_unit(unit.get_abbreviation()); - SPCurve *c = SP_IS_PATH(lpeItem) ? static_cast(lpeItem)->get_original_curve() : SP_SHAPE(lpeItem)->getCurve(); + SPCurve *c = SP_IS_PATH(lpeItem) ? static_cast(lpeItem) + ->get_original_curve() + : SP_SHAPE(lpeItem)->getCurve(); std::vector filletChamferData = fillet_chamfer_values.data(); if (!filletChamferData.empty() && getKnotsNumber(c) != (int) filletChamferData.size()) { - PathVector const original_pathv = c->get_pathvector(); + PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); Piecewise > pwd2_in = paths_to_pw(original_pathv); fillet_chamfer_values.recalculate_controlpoints_for_new_pwd2(pwd2_in); } @@ -450,7 +468,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) int LPEFilletChamfer::getKnotsNumber(SPCurve const *c) { int nKnots = c->nodes_in_path(); - PathVector const pv = c->get_pathvector(); + PathVector const pv = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); for (std::vector::const_iterator path_it = pv.begin(); path_it != pv.end(); ++path_it) { if (!(*path_it).closed()) { @@ -464,8 +482,7 @@ void LPEFilletChamfer::adjustForNewPath(std::vector const &path_in) { if (!path_in.empty()) { - fillet_chamfer_values.recalculate_controlpoints_for_new_pwd2(path_in[0] - .toPwSb()); + fillet_chamfer_values.recalculate_controlpoints_for_new_pwd2(pathv_to_linear_and_cubic_beziers(path_in)[0].toPwSb()); } } @@ -473,17 +490,17 @@ std::vector LPEFilletChamfer::doEffect_path(std::vector const &path_in) { std::vector pathvector_out; - Piecewise > pwd2_in = paths_to_pw(path_in); + Piecewise > pwd2_in = paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)); pwd2_in = remove_short_cuts(pwd2_in, .01); Piecewise > der = derivative(pwd2_in); Piecewise > n = rot90(unitVector(der)); fillet_chamfer_values.set_pwd2(pwd2_in, n); std::vector filletChamferData = fillet_chamfer_values.data(); unsigned int counter = 0; - //from http://launchpadlibrarian.net/12692602/rcp.svg const double K = (4.0 / 3.0) * (sqrt(2.0) - 1.0); - for (PathVector::const_iterator path_it = path_in.begin(); - path_it != path_in.end(); ++path_it) { + std::vector path_in_processed = pathv_to_linear_and_cubic_beziers(path_in); + for (PathVector::const_iterator path_it = path_in_processed.begin(); + path_it != path_in_processed.end(); ++path_it) { if (path_it->empty()) continue; Geom::Path path_out; @@ -504,81 +521,24 @@ LPEFilletChamfer::doEffect_path(std::vector const &path_in) } unsigned int counterCurves = 0; while (curve_it1 != curve_endit) { - Coord it1_length = (*curve_it1).length(tolerance); - double time_it1, time_it2, time_it1_B, intpart; - time_it1 = modf( - fillet_chamfer_values.to_time(counter, filletChamferData[counter][X]), - &intpart); - if (filletChamferData[counter][Y] == 0) { - time_it1 = 0; - } - if (path_it->closed() && curve_it2 == curve_endit) { - time_it2 = modf(fillet_chamfer_values.to_time( - counter - counterCurves, - filletChamferData[counter - counterCurves][X]), - &intpart); - } else if (!path_it->closed() && curve_it2 == curve_endit){ - time_it2 = 0; - } else { - time_it2 = modf(fillet_chamfer_values.to_time( - counter + 1, filletChamferData[counter + 1][X]), - &intpart); - } - double resultLenght = 0; - time_it1_B = 1; - if (path_it->closed() && curve_it2 == curve_endit) { - resultLenght = - it1_length + fillet_chamfer_values.to_len( - counter - counterCurves, - filletChamferData[counter - counterCurves][X]); - } else if (!path_it->closed() && curve_it2 == curve_endit){ - resultLenght = 0; - } else { - resultLenght = - it1_length + fillet_chamfer_values.to_len( - counter + 1, filletChamferData[counter + 1][X]); - } - if (resultLenght > 0 && time_it2 != 0) { - time_it1_B = modf(fillet_chamfer_values.to_time(counter, -resultLenght), - &intpart); - } else { - if (time_it2 == 0) { - time_it1_B = 1; - } else { - time_it1_B = gapHelper; - } - } - if (path_it->closed() && curve_it2 == curve_endit && - filletChamferData[counter - counterCurves][Y] == 0) { - time_it1_B = 1; - time_it2 = 0; - } else if (path_it->size() > counterCurves + 1 && - filletChamferData[counter + 1][Y] == 0) { - time_it1_B = 1; - time_it2 = 0; + Curve *curve_it2Fixed = (*path_it->begin()).duplicate(); + if(!path_it->closed() || curve_it2 != curve_endit){ + curve_it2Fixed = (*curve_it2).duplicate(); } - if (time_it1_B < time_it1) { - time_it1_B = time_it1 + gapHelper; - } - Curve *knotCurve1 = curve_it1->portion(time_it1, time_it1_B); + bool last = curve_it2 == curve_endit; + std::vector times = fillet_chamfer_values.get_times(counter, path_in, last); + Curve *knotCurve1 = curve_it1->portion(times[0], times[1]); if (counterCurves > 0) { knotCurve1->setInitial(path_out.finalPoint()); } else { - path_out.start((*curve_it1).pointAt(time_it1)); - } - Curve *knotCurve2 = (*path_it).front().portion(time_it2, 1); - if (curve_it2 != curve_endit) { - knotCurve2 = (*curve_it2).portion(time_it2, 1); + path_out.start((*curve_it1).pointAt(times[0])); } + Curve *knotCurve2 = curve_it2Fixed->portion(times[2], 1); Point startArcPoint = knotCurve1->finalPoint(); - Point endArcPoint = (*path_it).front().pointAt(time_it2); - if (curve_it2 != curve_endit) { - endArcPoint = (*curve_it2).pointAt(time_it2); - } + Point endArcPoint = curve_it2Fixed->pointAt(times[2]); double k1 = distance(startArcPoint, curve_it1->finalPoint()) * K; double k2 = distance(endArcPoint, curve_it1->finalPoint()) * K; - Geom::CubicBezier const *cubic1 = - dynamic_cast(&*knotCurve1); + Geom::CubicBezier const *cubic1 = dynamic_cast(&*knotCurve1); Ray ray1(startArcPoint, curve_it1->finalPoint()); if (cubic1) { ray1.setPoints((*cubic1)[2], startArcPoint); @@ -591,8 +551,7 @@ LPEFilletChamfer::doEffect_path(std::vector const &path_in) ray2.setPoints(endArcPoint, (*cubic2)[1]); } Point handle2 = endArcPoint - Point::polar(ray2.angle(),k2); - bool ccwToggle = cross(curve_it1->finalPoint() - startArcPoint, - endArcPoint - startArcPoint) < 0; + bool ccwToggle = cross(curve_it1->finalPoint() - startArcPoint, endArcPoint - startArcPoint) < 0; double angle = angle_between(ray1, ray2, ccwToggle); double handleAngle = ray1.angle() - angle; if (ccwToggle) { @@ -604,14 +563,22 @@ LPEFilletChamfer::doEffect_path(std::vector const &path_in) handleAngle = ray2.angle() - angle; } Point inverseHandle2 = endArcPoint - Point::polar(handleAngle,k2); - if (time_it1_B != 1) { - if (time_it1_B != gapHelper && time_it1_B != time_it1 + gapHelper) { + //straigth lines arc based + Line const x_line(Geom::Point(0,0),Geom::Point(1,0)); + Line const angled_line(startArcPoint,endArcPoint); + double angleArc = Geom::angle_between( x_line,angled_line); + double radius = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint))/sin(angle/2.0); + Coord rx = radius; + Coord ry = rx; + + if (times[1] != 1) { + if (times[1] != gapHelper && times[1] != times[0] + gapHelper) { path_out.append(*knotCurve1); } int type = 0; - if(path_it->closed() && curve_it2 == curve_endit){ + if(path_it->closed() && last){ type = abs(filletChamferData[counter - counterCurves][Y]); - } else if (!path_it->closed() && curve_it2 == curve_endit){ + } else if (!path_it->closed() && last){ //0 } else { type = abs(filletChamferData[counter + 1][Y]); @@ -624,15 +591,23 @@ LPEFilletChamfer::doEffect_path(std::vector const &path_in) } path_out.appendNew(endArcPoint); } else if (type == 2) { - path_out.appendNew(inverseHandle1, inverseHandle2, - endArcPoint); + if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed)) || force_arcs){ + ccwToggle = ccwToggle?0:1; + path_out.appendNew(rx, ry, angleArc, 0, ccwToggle, endArcPoint); + }else{ + path_out.appendNew(inverseHandle1, inverseHandle2, endArcPoint); + } } else { - path_out.appendNew(handle1, handle2, endArcPoint); + if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed)) || force_arcs){ + path_out.appendNew(rx, ry, angleArc, 0, ccwToggle, endArcPoint); + } else { + path_out.appendNew(handle1, handle2, endArcPoint); + } } } else { path_out.append(*knotCurve1); } - if (path_it->closed() && curve_it2 == curve_endit) { + if (path_it->closed() && last) { path_out.close(); } ++curve_it1; diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index 420425650..49b407b71 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -15,7 +15,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#if defined(GLIBMM_DISABLE_DEPRECATED) && defined(HAVE_GLIBMM_THREADS_H) +# include +#endif #include "live_effects/parameter/enum.h" #include "live_effects/parameter/bool.h" @@ -61,6 +67,8 @@ private: BoolParam ignore_radius_0; BoolParam only_selected; BoolParam flexible; + BoolParam force_arcs; + BoolParam use_knot_distance; UnitParam unit; ScalarParam radius; ScalarParam helper_size; diff --git a/src/live_effects/lpe-interpolate_points.cpp b/src/live_effects/lpe-interpolate_points.cpp index 865b46ca7..4ac139752 100644 --- a/src/live_effects/lpe-interpolate_points.cpp +++ b/src/live_effects/lpe-interpolate_points.cpp @@ -40,7 +40,7 @@ LPEInterpolatePoints::LPEInterpolatePoints(LivePathEffectObject *lpeobject) { show_orig_path = false; - registerParameter( dynamic_cast(&interpolator_type) ); + registerParameter( &interpolator_type ); } LPEInterpolatePoints::~LPEInterpolatePoints() diff --git a/src/live_effects/lpe-jointype.cpp b/src/live_effects/lpe-jointype.cpp new file mode 100644 index 000000000..bf2526986 --- /dev/null +++ b/src/live_effects/lpe-jointype.cpp @@ -0,0 +1,190 @@ +/* Authors: +* +* Liam P White +* +* Copyright (C) 2014 Authors +* +* Released under GNU GPL v2, read the file 'COPYING' for more information +*/ + +#include "live_effects/parameter/enum.h" +#include "live_effects/pathoutlineprovider.h" + +#include "sp-shape.h" +#include "style.h" +#include "xml/repr.h" +#include "sp-paint-server.h" +#include "svg/svg-color.h" +#include "desktop-style.h" +#include "svg/css-ostringstream.h" +#include "display/curve.h" + +#include <2geom/path.h> +#include <2geom/svg-elliptical-arc.h> + +#include "lpe-jointype.h" + +namespace Inkscape { +namespace LivePathEffect { + +static const Util::EnumData JoinTypeData[] = { + {LINEJOIN_STRAIGHT, N_("Beveled"), "bevel"}, + {LINEJOIN_ROUND, N_("Rounded"), "round"}, + {LINEJOIN_POINTY, N_("Miter"), "miter"}, + {LINEJOIN_REFLECTED, N_("Reflected"), "extrapolated"}, + {LINEJOIN_EXTRAPOLATED, N_("Extrapolated arc"), "extrp_arc"} +}; + +static const Util::EnumData CapTypeData[] = { + {BUTT_STRAIGHT, N_("Butt"), "butt"}, + {BUTT_ROUND, N_("Rounded"), "round"}, + {BUTT_SQUARE, N_("Square"), "square"}, + {BUTT_POINTY, N_("Peak"), "peak"}, + {BUTT_LEANED, N_("Leaned"), "leaned"} +}; + +static const Util::EnumDataConverter CapTypeConverter(CapTypeData, sizeof(CapTypeData)/sizeof(*CapTypeData)); +static const Util::EnumDataConverter JoinTypeConverter(JoinTypeData, sizeof(JoinTypeData)/sizeof(*JoinTypeData)); + +LPEJoinType::LPEJoinType(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + line_width(_("Line width"), _("Thickness of the stroke"), "line_width", &wr, this, 1.), + linecap_type(_("Line cap"), _("The end shape of the stroke"), "linecap_type", CapTypeConverter, &wr, this, butt_straight), + linejoin_type(_("Join:"), _("Determines the shape of the path's corners"), "linejoin_type", JoinTypeConverter, &wr, this, LINEJOIN_EXTRAPOLATED), + start_lean(_("Start path lean"), _("Start path lean"), "start_lean", &wr, this, 0.), + end_lean(_("End path lean"), _("End path lean"), "end_lean", &wr, this, 0.), + miter_limit(_("Miter limit:"), _("Maximum length of the miter join (in units of stroke width)"), "miter_limit", &wr, this, 100.), + attempt_force_join(_("Force miter"), _("Overrides the miter limit and forces a join."), "attempt_force_join", &wr, this, true) +{ + show_orig_path = true; + registerParameter(&linecap_type); + registerParameter(&line_width); + registerParameter(&linejoin_type); + registerParameter(&start_lean); + registerParameter(&end_lean); + registerParameter(&miter_limit); + registerParameter(&attempt_force_join); + was_initialized = false; + start_lean.param_set_range(-1,1); + start_lean.param_set_increments(0.1, 0.1); + start_lean.param_set_digits(4); + end_lean.param_set_range(-1,1); + end_lean.param_set_increments(0.1, 0.1); + end_lean.param_set_digits(4); +} + +LPEJoinType::~LPEJoinType() +{ +} + +//from LPEPowerStroke -- sets fill if stroke color because we will +//be converting to a fill to make the new join. + +void LPEJoinType::doOnApply(SPLPEItem const* lpeitem) +{ + if (SP_IS_SHAPE(lpeitem)) { + SPLPEItem* item = const_cast(lpeitem); + double width = (lpeitem && lpeitem->style) ? lpeitem->style->stroke_width.computed : 1.; + + SPCSSAttr *css = sp_repr_css_attr_new (); + if (true) { + if (lpeitem->style->stroke.isPaintserver()) { + SPPaintServer * server = lpeitem->style->getStrokePaintServer(); + if (server) { + Glib::ustring str; + str += "url(#"; + str += server->getId(); + str += ")"; + sp_repr_css_set_property (css, "fill", str.c_str()); + } + } else if (lpeitem->style->stroke.isColor()) { + gchar c[64]; + sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); + sp_repr_css_set_property (css, "fill", c); + } else { + sp_repr_css_set_property (css, "fill", "none"); + } + } else { + sp_repr_css_unset_property (css, "fill"); + } + + sp_repr_css_set_property(css, "stroke", "none"); + + sp_desktop_apply_css_recursive(item, css, true); + sp_repr_css_attr_unref (css); + if (!was_initialized) + { + was_initialized = true; + line_width.param_set_value(width); + } + } else { + g_warning("LPE Join Type can only be applied to paths (not groups)."); + } +} + +//from LPEPowerStroke -- sets stroke color from existing fill color + +void LPEJoinType::doOnRemove(SPLPEItem const* lpeitem) +{ + + if (SP_IS_SHAPE(lpeitem)) { + SPLPEItem *item = const_cast(lpeitem); + + SPCSSAttr *css = sp_repr_css_attr_new (); + if (true) { + if (lpeitem->style->fill.isPaintserver()) { + SPPaintServer * server = lpeitem->style->getFillPaintServer(); + if (server) { + Glib::ustring str; + str += "url(#"; + str += server->getId(); + str += ")"; + sp_repr_css_set_property (css, "stroke", str.c_str()); + } + } else if (lpeitem->style->fill.isColor()) { + gchar c[64]; + sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); + sp_repr_css_set_property (css, "stroke", c); + } else { + sp_repr_css_set_property (css, "stroke", "none"); + } + } else { + sp_repr_css_unset_property (css, "stroke"); + } + + Inkscape::CSSOStringStream os; + os << fabs(line_width); + sp_repr_css_set_property (css, "stroke-width", os.str().c_str()); + + sp_repr_css_set_property(css, "fill", "none"); + + sp_desktop_apply_css_recursive(item, css, true); + sp_repr_css_attr_unref (css); + item->updateRepr(); + } +} + +// NOTE: I originally had all the outliner functions defined in here, but they were actually useful +// enough for other LPEs so I moved them all into pathoutlineprovider.cpp. The code here is just a +// wrapper around it. +std::vector LPEJoinType::doEffect_path(std::vector const & path_in) +{ + return Outline::PathVectorOutline(path_in, line_width, static_cast(linecap_type.get_value()), + static_cast(linejoin_type.get_value()), + (attempt_force_join ? std::numeric_limits::max() : miter_limit), + start_lean/2 ,end_lean/2); +} + +} // namespace LivePathEffect +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/live_effects/lpe-jointype.h b/src/live_effects/lpe-jointype.h new file mode 100644 index 000000000..73705666d --- /dev/null +++ b/src/live_effects/lpe-jointype.h @@ -0,0 +1,57 @@ +/* Authors: + * Liam P White + * + * Copyright (C) 2014 Authors + * + * Released under GNU GPL v2, read the file COPYING for more information + */ + +#ifndef INKSCAPE_LPE_JOINTYPE_H +#define INKSCAPE_LPE_JOINTYPE_H + +#include "live_effects/effect.h" +#include "live_effects/parameter/parameter.h" +#include "live_effects/parameter/point.h" +#include "live_effects/parameter/enum.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEJoinType : public Effect { +public: + LPEJoinType(LivePathEffectObject *lpeobject); + virtual ~LPEJoinType(); + + virtual void doOnApply(SPLPEItem const* lpeitem); + virtual void doOnRemove(SPLPEItem const* lpeitem); + virtual std::vector doEffect_path (std::vector const & path_in); + +private: + LPEJoinType(const LPEJoinType&); + LPEJoinType& operator=(const LPEJoinType&); + + ScalarParam line_width; + EnumParam linecap_type; + EnumParam linejoin_type; + ScalarParam start_lean; + ScalarParam end_lean; + ScalarParam miter_limit; + BoolParam attempt_force_join; + bool was_initialized; +}; + +} //namespace LivePathEffect +} //namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index cac3a9347..3876aa24b 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -22,6 +22,7 @@ #include "knotholder.h" #include +#include #include <2geom/sbasis-to-bezier.h> #include <2geom/sbasis.h> @@ -536,6 +537,10 @@ LPEKnot::doBeforeEffect (SPLPEItem const* lpeitem) { using namespace Geom; original_bbox(lpeitem); + + if (SP_IS_PATH(lpeitem)) { + supplied_path = SP_PATH(lpeitem)->getCurve()->get_pathvector(); + } gpaths.clear(); gstroke_widths.clear(); diff --git a/src/live_effects/lpe-knot.h b/src/live_effects/lpe-knot.h index f926bf085..080f32de2 100644 --- a/src/live_effects/lpe-knot.h +++ b/src/live_effects/lpe-knot.h @@ -64,7 +64,8 @@ public: void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: - virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); + std::vector supplied_path; //for knotholder business private: void updateSwitcher(); diff --git a/src/live_effects/lpe-powerstroke-interpolators.h b/src/live_effects/lpe-powerstroke-interpolators.h index 986bd3544..3cde0b4b3 100644 --- a/src/live_effects/lpe-powerstroke-interpolators.h +++ b/src/live_effects/lpe-powerstroke-interpolators.h @@ -28,6 +28,7 @@ enum InterpolatorType { INTERP_CUBICBEZIER, INTERP_CUBICBEZIER_JOHAN, INTERP_SPIRO, + INTERP_CUBICBEZIER_SMOOTH, INTERP_CENTRIPETAL_CATMULLROM }; @@ -134,6 +135,43 @@ private: CubicBezierJohan& operator=(const CubicBezierJohan&); }; +/// @todo invent name for this class +class CubicBezierSmooth : public Interpolator { +public: + CubicBezierSmooth(double beta = 0.2) { + _beta = beta; + }; + virtual ~CubicBezierSmooth() {}; + + virtual Path interpolateToPath(std::vector const &points) const { + Path fit; + fit.start(points.at(0)); + unsigned int num_points = points.size(); + for (unsigned int i = 1; i < num_points; ++i) { + Point p0 = points.at(i-1); + Point p1 = points.at(i); + Point dx = Point(p1[X] - p0[X], 0); + if (i == 1) { + fit.appendNew(p0, p1-0.75*dx, p1); + } else if (i == points.size() - 1) { + fit.appendNew(p0+0.75*dx, p1, p1); + } else { + fit.appendNew(p0+_beta*dx, p1-_beta*dx, p1); + } + } + return fit; + }; + + void setBeta(double beta) { + _beta = beta; + } + + double _beta; + +private: + CubicBezierSmooth(const CubicBezierSmooth&); + CubicBezierSmooth& operator=(const CubicBezierSmooth&); +}; class SpiroInterpolator : public Interpolator { public: @@ -261,6 +299,8 @@ Interpolator::create(InterpolatorType type) { return new Geom::Interpolate::CubicBezierJohan(); case INTERP_SPIRO: return new Geom::Interpolate::SpiroInterpolator(); + case INTERP_CUBICBEZIER_SMOOTH: + return new Geom::Interpolate::CubicBezierSmooth(); case INTERP_CENTRIPETAL_CATMULLROM: return new Geom::Interpolate::CentripetalCatmullRomInterpolator(); default: diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 5bfe88ed1..b1951d978 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -15,6 +15,11 @@ #include "sp-shape.h" #include "style.h" +#include "xml/repr.h" +#include "sp-paint-server.h" +#include "svg/svg-color.h" +#include "desktop-style.h" +#include "svg/css-ostringstream.h" #include "display/curve.h" #include <2geom/path.h> @@ -185,6 +190,7 @@ namespace Inkscape { namespace LivePathEffect { static const Util::EnumData InterpolatorTypeData[] = { + {Geom::Interpolate::INTERP_CUBICBEZIER_SMOOTH, N_("CubicBezierSmooth"), "CubicBezierSmooth"}, {Geom::Interpolate::INTERP_LINEAR , N_("Linear"), "Linear"}, {Geom::Interpolate::INTERP_CUBICBEZIER , N_("CubicBezierFit"), "CubicBezierFit"}, {Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN , N_("CubicBezierJohan"), "CubicBezierJohan"}, @@ -223,9 +229,7 @@ static const Util::EnumData LineJoinTypeData[] = { {LINEJOIN_EXTRP_MITER, N_("Extrapolated"), "extrapolated"}, {LINEJOIN_MITER, N_("Miter"), "miter"}, {LINEJOIN_SPIRO, N_("Spiro"), "spiro"}, -#ifdef LPE_ENABLE_TEST_EFFECTS {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"}, -#endif }; static const Util::EnumDataConverter LineJoinTypeConverter(LineJoinTypeData, sizeof(LineJoinTypeData)/sizeof(*LineJoinTypeData)); @@ -233,12 +237,12 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this), sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve"), "sort_points", &wr, this, true), - interpolator_type(_("Interpolator type:"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), + interpolator_type(_("Interpolator type:"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER), interpolator_beta(_("Smoothness:"), _("Sets the smoothness for the CubicBezierJohan interpolator; 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2), - start_linecap_type(_("Start cap:"), _("Determines the shape of the path's start"), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), - linejoin_type(_("Join:"), _("Determines the shape of the path's corners"), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND), + start_linecap_type(_("Start cap:"), _("Determines the shape of the path's start"), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_BUTT), + linejoin_type(_("Join:"), _("Determines the shape of the path's corners"), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_EXTRP_MITER_ARC), miter_limit(_("Miter limit:"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.), - end_linecap_type(_("End cap:"), _("Determines the shape of the path's end"), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) + end_linecap_type(_("End cap:"), _("Determines the shape of the path's end"), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_BUTT) { show_orig_path = true; @@ -267,20 +271,52 @@ void LPEPowerStroke::doOnApply(SPLPEItem const* lpeitem) { if (SP_IS_SHAPE(lpeitem)) { + SPLPEItem* item = const_cast(lpeitem); std::vector points; Geom::PathVector const &pathv = SP_SHAPE(lpeitem)->_curve->get_pathvector(); - double width = (lpeitem && lpeitem->style) ? lpeitem->style->stroke_width.computed : 1.; + double width = (lpeitem && lpeitem->style) ? lpeitem->style->stroke_width.computed / 2 : 1.; + + SPCSSAttr *css = sp_repr_css_attr_new (); + if (true) { + if (lpeitem->style->stroke.isPaintserver()) { + SPPaintServer * server = lpeitem->style->getStrokePaintServer(); + if (server) { + Glib::ustring str; + str += "url(#"; + str += server->getId(); + str += ")"; + sp_repr_css_set_property (css, "fill", str.c_str()); + } + } else if (lpeitem->style->stroke.isColor()) { + gchar c[64]; + sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); + sp_repr_css_set_property (css, "fill", c); + } else { + sp_repr_css_set_property (css, "fill", "none"); + } + } else { + sp_repr_css_unset_property (css, "fill"); + } + + sp_repr_css_set_property(css, "stroke", "none"); + + sp_desktop_apply_css_recursive(item, css, true); + sp_repr_css_attr_unref (css); + + item->updateRepr(); if (pathv.empty()) { - points.push_back( Geom::Point(0.,width) ); + points.push_back( Geom::Point(0.2,width) ); points.push_back( Geom::Point(0.5,width) ); - points.push_back( Geom::Point(1.,width) ); + points.push_back( Geom::Point(0.8,width) ); } else { Geom::Path const &path = pathv.front(); Geom::Path::size_type const size = path.size_default(); - points.push_back( Geom::Point(0.,width) ); + if (!path.closed()) { + points.push_back( Geom::Point(0.2,width) ); + } points.push_back( Geom::Point(0.5*size,width) ); if (!path.closed()) { - points.push_back( Geom::Point(size,width) ); + points.push_back( Geom::Point(size - 0.2,width) ); } } offset_points.param_set_and_write_new_value(points); @@ -289,6 +325,45 @@ LPEPowerStroke::doOnApply(SPLPEItem const* lpeitem) } } +void LPEPowerStroke::doOnRemove(SPLPEItem const* lpeitem) +{ + if (SP_IS_SHAPE(lpeitem)) { + SPLPEItem *item = const_cast(lpeitem); + SPCSSAttr *css = sp_repr_css_attr_new (); + if (true) { + if (lpeitem->style->fill.isPaintserver()) { + SPPaintServer * server = lpeitem->style->getFillPaintServer(); + if (server) { + Glib::ustring str; + str += "url(#"; + str += server->getId(); + str += ")"; + sp_repr_css_set_property (css, "stroke", str.c_str()); + } + } else if (lpeitem->style->fill.isColor()) { + gchar c[64]; + sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); + sp_repr_css_set_property (css, "stroke", c); + } else { + sp_repr_css_set_property (css, "stroke", "none"); + } + } else { + sp_repr_css_unset_property (css, "stroke"); + } + + Inkscape::CSSOStringStream os; + os << offset_points.median_width() * 2; + sp_repr_css_set_property (css, "stroke-width", os.str().c_str()); + + sp_repr_css_set_property(css, "fill", "none"); + + sp_desktop_apply_css_recursive(item, css, true); + sp_repr_css_attr_unref (css); + + item->updateRepr(); + } +} + void LPEPowerStroke::adjustForNewPath(std::vector const & path_in) { @@ -588,6 +663,9 @@ LPEPowerStroke::doEffect_path (std::vector const & path_in) if (Geom::Interpolate::CubicBezierJohan *johan = dynamic_cast(interpolator)) { johan->setBeta(interpolator_beta); } + if (Geom::Interpolate::CubicBezierSmooth *smooth = dynamic_cast(interpolator)) { + smooth->setBeta(interpolator_beta); + } Geom::Path strokepath = interpolator->interpolateToPath(ts); delete interpolator; diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 7bc736820..a773434aa 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -25,9 +25,11 @@ public: LPEPowerStroke(LivePathEffectObject *lpeobject); virtual ~LPEPowerStroke(); + virtual std::vector doEffect_path (std::vector const & path_in); virtual void doOnApply(SPLPEItem const* lpeitem); + virtual void doOnRemove(SPLPEItem const* lpeitem); // methods called by path-manipulator upon edits void adjustForNewPath(std::vector const & path_in); diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 5f6acd6f4..b9d575e06 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -1,10 +1,21 @@ -/* +/** + * @file + * Roughen LPE implementation. Creates roughen paths. + */ +/* Authors: + * Jabier Arraiza Cenoz + * + * Thanks to all people involved specialy to Josh Andler for the idea and to the + * original extensions authors. + * + * Copyright (C) 2014 Authors + * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "live_effects/lpe-roughen.h" -#include +#include +#include "live_effects/lpe-roughen.h" #include "display/curve.h" #include "live_effects/parameter/parameter.h" #include "helper/geom.h" @@ -15,375 +26,299 @@ namespace Inkscape { namespace LivePathEffect { static const Util::EnumData DivisionMethodData[DM_END] = { - { DM_SEGMENTS, N_("By number of segments"), "segments" }, - { DM_SIZE, N_("By max. segment size"), "size" } + { DM_SEGMENTS, N_("By number of segments"), "segments" }, + { DM_SIZE, N_("By max. segment size"), "size" } }; static const Util::EnumDataConverter - DMConverter(DivisionMethodData, DM_END); +DMConverter(DivisionMethodData, DM_END); LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - unit(_("Unit:"), _("Unit"), "unit", &wr, this), - method(_("Method:"), _("Division method"), "method", DMConverter, &wr, + unit(_("Unit"), _("Unit"), "unit", &wr, this), + method(_("Method"), _("Division method"), "method", DMConverter, &wr, this, DM_SEGMENTS), - maxSegmentSize(_("Max. segment size:"), _("Max. segment size"), + maxSegmentSize(_("Max. segment size"), _("Max. segment size"), "maxSegmentSize", &wr, this, 10.), - segments(_("Number of segments:"), _("Number of segments"), "segments", + segments(_("Number of segments"), _("Number of segments"), "segments", &wr, this, 2), - displaceX(_("Max. displacement in X:"), _("Max. displacement in X"), + displaceX(_("Max. displacement in X"), _("Max. displacement in X"), "displaceX", &wr, this, 10.), - displaceY(_("Max. displacement in Y:"), _("Max. displacement in Y"), + displaceY(_("Max. displacement in Y"), _("Max. displacement in Y"), "displaceY", &wr, this, 10.), shiftNodes(_("Shift nodes"), _("Shift nodes"), "shiftNodes", &wr, this, true), shiftNodeHandles(_("Shift node handles"), _("Shift node handles"), - "shiftNodeHandles", &wr, this, true) { - registerParameter(dynamic_cast(&unit)); - registerParameter(dynamic_cast(&method)); - registerParameter(dynamic_cast(&maxSegmentSize)); - registerParameter(dynamic_cast(&segments)); - registerParameter(dynamic_cast(&displaceX)); - registerParameter(dynamic_cast(&displaceY)); - registerParameter(dynamic_cast(&shiftNodes)); - registerParameter(dynamic_cast(&shiftNodeHandles)); - displaceX.param_set_range(0., Geom::infinity()); - displaceY.param_set_range(0., Geom::infinity()); - maxSegmentSize.param_set_range(0., Geom::infinity()); - maxSegmentSize.param_set_increments(1, 1); - maxSegmentSize.param_set_digits(1); - segments.param_set_range(1, Geom::infinity()); - segments.param_set_increments(1, 1); - segments.param_set_digits(0); + "shiftNodeHandles", &wr, this, true) +{ + registerParameter(&unit); + registerParameter(&method); + registerParameter(&maxSegmentSize); + registerParameter(&segments); + registerParameter(&displaceX); + registerParameter(&displaceY); + registerParameter(&shiftNodes); + registerParameter(&shiftNodeHandles); + displaceX.param_set_range(0., Geom::infinity()); + displaceY.param_set_range(0., Geom::infinity()); + maxSegmentSize.param_set_range(0., Geom::infinity()); + maxSegmentSize.param_set_increments(1, 1); + maxSegmentSize.param_set_digits(1); + segments.param_set_range(1, Geom::infinity()); + segments.param_set_increments(1, 1); + segments.param_set_digits(0); } LPERoughen::~LPERoughen() {} -void LPERoughen::doBeforeEffect(SPLPEItem const */*lpeitem*/) { - displaceX.resetRandomizer(); - displaceY.resetRandomizer(); - srand(1); +void LPERoughen::doBeforeEffect(SPLPEItem const */*lpeitem*/) +{ + displaceX.resetRandomizer(); + displaceY.resetRandomizer(); + srand(1); } -Gtk::Widget *LPERoughen::newWidget() { - // use manage here, because after deletion of Effect object, others might - // still be pointing to this widget. - Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); - vbox->set_border_width(5); - vbox->set_homogeneous(false); - vbox->set_spacing(2); - std::vector::iterator it = param_vector.begin(); - while (it != param_vector.end()) { - if ((*it)->widget_is_visible) { - Parameter *param = *it; - Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); - if (param->param_key == "unit") { - Gtk::Label *unitLabel = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Roughen unit")), Gtk::ALIGN_START)); - unitLabel->set_use_markup(true); - vbox->pack_start(*unitLabel, false, false, 2); -#if WITH_GTKMM_3_0 - vbox->pack_start(*Gtk::manage(new Gtk::Separator()), -#else - vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), -#endif - Gtk::PACK_EXPAND_WIDGET); - } - if (param->param_key == "method") { - Gtk::Label *methodLabel = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Add nodes Subdivide each segment")), - Gtk::ALIGN_START)); - methodLabel->set_use_markup(true); - vbox->pack_start(*methodLabel, false, false, 2); -#if WITH_GTKMM_3_0 - vbox->pack_start(*Gtk::manage(new Gtk::Separator()), -#else - vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), -#endif - Gtk::PACK_EXPAND_WIDGET); - } - if (param->param_key == "displaceX") { - Gtk::Label *displaceXLabel = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Jitter nodes Move nodes/handles")), - Gtk::ALIGN_START)); - displaceXLabel->set_use_markup(true); - vbox->pack_start(*displaceXLabel, false, false, 2); -#if WITH_GTKMM_3_0 - vbox->pack_start(*Gtk::manage(new Gtk::Separator()), -#else - vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), -#endif - Gtk::PACK_EXPAND_WIDGET); - } - Glib::ustring *tip = param->param_getTooltip(); - if (widg) { - vbox->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); +Gtk::Widget *LPERoughen::newWidget() +{ + Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); + vbox->set_border_width(5); + vbox->set_homogeneous(false); + vbox->set_spacing(2); + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter *param = *it; + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + if (param->param_key == "unit") { + Gtk::Label *unitLabel = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Roughen unit")), Gtk::ALIGN_START)); + unitLabel->set_use_markup(true); + vbox->pack_start(*unitLabel, false, false, 2); + vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + Gtk::PACK_EXPAND_WIDGET); + } + if (param->param_key == "method") { + Gtk::Label *methodLabel = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Add nodes Subdivide each segment")), + Gtk::ALIGN_START)); + methodLabel->set_use_markup(true); + vbox->pack_start(*methodLabel, false, false, 2); + vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + Gtk::PACK_EXPAND_WIDGET); + } + if (param->param_key == "displaceX") { + Gtk::Label *displaceXLabel = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Jitter nodes Move nodes/handles")), + Gtk::ALIGN_START)); + displaceXLabel->set_use_markup(true); + vbox->pack_start(*displaceXLabel, false, false, 2); + vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + Gtk::PACK_EXPAND_WIDGET); + } + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } } - } - } - ++it; - } - return dynamic_cast(vbox); + ++it; + } + return dynamic_cast(vbox); } -double LPERoughen::sign(double randNumber) { - if (rand() % 100 < 49) { - randNumber *= -1.; - } - return randNumber; +double LPERoughen::sign(double randNumber) +{ + if (rand() % 100 < 49) { + randNumber *= -1.; + } + return randNumber; } -Geom::Point LPERoughen::randomize() { - double displaceXParsed = Inkscape::Util::Quantity::convert( - displaceX, unit.get_abbreviation(), "px"); - double displaceYParsed = Inkscape::Util::Quantity::convert( - displaceY, unit.get_abbreviation(), "px"); - //maybe is better divide this point by 2... - Geom::Point output = - Geom::Point(sign(displaceXParsed), sign(displaceYParsed)); - return output; -} +Geom::Point LPERoughen::randomize() +{ + double displaceXParsed = Inkscape::Util::Quantity::convert( + displaceX, unit.get_abbreviation(), "px"); + double displaceYParsed = Inkscape::Util::Quantity::convert( + displaceY, unit.get_abbreviation(), "px"); -void LPERoughen::doEffect(SPCurve *curve) { - Geom::PathVector const original_pathv = - pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); - curve->reset(); + Geom::Point output = Geom::Point(sign(displaceXParsed), sign(displaceYParsed)); + return output; +} - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el - //penúltimo - for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); - path_it != original_pathv.end(); ++path_it) { - //Si está vacío... - if (path_it->empty()) - continue; - //Itreadores +void LPERoughen::doEffect(SPCurve *curve) +{ + Geom::PathVector const original_pathv = + pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); + curve->reset(); + for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); + path_it != original_pathv.end(); ++path_it) { + if (path_it->empty()) + continue; - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = - ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = - path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se - //calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores - SPCurve *nCurve = new SPCurve(); - if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the - // closing line segment has zerolength. - const Geom::Curve &closingline = - path_it->back_closed(); // the closing line segment is always of type - // Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for - // *exact* zero length, which goes wrong for relative coordinates and - // rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } - } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo - //BSPline - Geom::Point initialMove(0, 0); - if (shiftNodes) { - initialMove = randomize(); - } - Geom::Point initialPoint = curve_it1->initialPoint() + initialMove; - nCurve->moveto(initialPoint); - Geom::Point A0(0, 0); - Geom::Point A1(0, 0); - Geom::Point A2(0, 0); - Geom::Point A3(0, 0); - while (curve_it2 != curve_endit) { - //aumentamos los valores para el siguiente paso en el bucle - //Recorremos todos los segmentos menos el último - Geom::CubicBezier const *cubic = NULL; - A0 = curve_it1->initialPoint(); - A1 = curve_it1->initialPoint(); - A2 = curve_it1->finalPoint(); - A3 = curve_it1->finalPoint(); - cubic = dynamic_cast(&*curve_it1); - if (cubic) { - A1 = (*cubic)[1]; - if (shiftNodes) { - A1 = (*cubic)[1] + initialMove; + Geom::Path::const_iterator curve_it1 = path_it->begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); + Geom::Path::const_iterator curve_endit = path_it->end_default(); + SPCurve *nCurve = new SPCurve(); + if (path_it->closed()) { + const Geom::Curve &closingline = + path_it->back_closed(); + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + curve_endit = path_it->end_open(); + } } - A2 = (*cubic)[2]; - nCurve->curveto(A1, A2, A3); - } else { - nCurve->lineto(A3); - } - double length = Inkscape::Util::Quantity::convert( - curve_it1->length(0.001), "px", unit.get_abbreviation()); - unsigned int splits = 0; - if (method == DM_SEGMENTS) { - splits = segments; - } else { - splits = ceil(length / maxSegmentSize); - } - for (unsigned int t = splits; t >= 1; t--) { - if (t == 1 && splits != 1) { - continue; + Geom::Point initialMove(0, 0); + if (shiftNodes) { + initialMove = randomize(); } - const SPCurve *tmp; - if (splits == 1) { - tmp = jitter(nCurve->last_segment()); - } else { - tmp = addNodesAndJitter(nCurve->last_segment(), 1. / t); + Geom::Point initialPoint = curve_it1->initialPoint() + initialMove; + nCurve->moveto(initialPoint); + Geom::Point A0(0, 0); + Geom::Point A1(0, 0); + Geom::Point A2(0, 0); + Geom::Point A3(0, 0); + while (curve_it1 != curve_endit) { + Geom::CubicBezier const *cubic = NULL; + A0 = curve_it1->initialPoint(); + A1 = curve_it1->initialPoint(); + A2 = curve_it1->finalPoint(); + A3 = curve_it1->finalPoint(); + cubic = dynamic_cast(&*curve_it1); + if (cubic) { + A1 = (*cubic)[1]; + if (shiftNodes) { + A1 = (*cubic)[1] + initialMove; + } + A2 = (*cubic)[2]; + nCurve->curveto(A1, A2, A3); + } else { + nCurve->lineto(A3); + } + double length = Inkscape::Util::Quantity::convert( + curve_it1->length(0.001), "px", unit.get_abbreviation()); + std::size_t splits = 0; + if (method == DM_SEGMENTS) { + splits = segments; + } else { + splits = ceil(length / maxSegmentSize); + } + for (unsigned int t = splits; t >= 1; t--) { + if (t == 1 && splits != 1) { + continue; + } + const SPCurve *tmp; + if (splits == 1) { + tmp = jitter(nCurve->last_segment()); + } else { + tmp = addNodesAndJitter(nCurve->last_segment(), 1. / t); + } + if (nCurve->get_segment_count() > 1) { + nCurve->backspace(); + nCurve->append_continuous(tmp, 0.001); + } else { + nCurve = tmp->copy(); + } + delete tmp; + } + ++curve_it1; + if(curve_it2 != curve_endit) { + ++curve_it2; + } } - if (nCurve->get_segment_count() > 1) { - nCurve->backspace(); - nCurve->append_continuous(tmp, 0.001); - } else { - nCurve = tmp->copy(); + if (path_it->closed()) { + nCurve->closepath_current(); } - delete tmp; - } - ++curve_it1; - ++curve_it2; + curve->append(nCurve, false); + nCurve->reset(); + delete nCurve; } - Geom::CubicBezier const *cubic = NULL; - A0 = curve_it1->initialPoint(); - A1 = curve_it1->initialPoint(); - A2 = curve_it1->finalPoint(); - A3 = curve_it1->finalPoint(); - cubic = dynamic_cast(&*curve_it1); - if (cubic) { - A1 = (*cubic)[1]; - A2 = (*cubic)[2]; - if (path_it->closed()) { - A2 = A2 + initialMove; - A3 = initialPoint; - } - nCurve->curveto(A1, A2, A3); - } else { - if (path_it->closed()) { - A3 = initialPoint; - } - nCurve->lineto(A3); +} + +SPCurve *LPERoughen::addNodesAndJitter(const Geom::Curve *A, double t) +{ + SPCurve *out = new SPCurve(); + Geom::CubicBezier const *cubic = dynamic_cast(&*A); + Geom::Point A1(0, 0); + Geom::Point A2(0, 0); + Geom::Point A3(0, 0); + Geom::Point B1(0, 0); + Geom::Point B2(0, 0); + Geom::Point B3(0, 0); + if (shiftNodes) { + A3 = randomize(); + B3 = randomize(); } - double length = Inkscape::Util::Quantity::convert( - curve_it1->length(0.001), "px", unit.get_abbreviation()); - unsigned int splits = 0; - if (method == DM_SEGMENTS) { - splits = segments; + if (shiftNodeHandles) { + A1 = randomize(); + A2 = randomize(); + B1 = randomize(); + B2 = randomize(); } else { - splits = ceil(length / maxSegmentSize); + A2 = A3; + B1 = A3; + B2 = B3; } - for (unsigned int t = splits; t >= 1; t--) { - if (t == 1 && splits != 1) { - continue; - } - const SPCurve *tmp; - if (splits == 1) { - tmp = jitter(nCurve->last_segment()); - } else { - tmp = addNodesAndJitter(nCurve->last_segment(), 1. / t); - } - if (nCurve->get_segment_count() > 1) { - nCurve->backspace(); - nCurve->append_continuous(tmp, 0.001); - } else { - nCurve = tmp->copy(); - } - delete tmp; - } - //y cerramos la curva - if (path_it->closed()) { - nCurve->closepath_current(); + if (cubic) { + std::pair div = cubic->subdivide(t); + std::vector seg1 = div.first.points(), + seg2 = div.second.points(); + out->moveto(seg1[0]); + out->curveto(seg1[1] + A1, seg1[2] + A2, seg1[3] + A3); + out->curveto(seg2[1] + B1, seg2[2], seg2[3]); + } else if (shiftNodeHandles) { + out->moveto(A->initialPoint()); + out->curveto(A->pointAt(t / 3) + A1, A->pointAt((t / 3) * 2) + A2, + A->pointAt(t) + A3); + out->curveto(A->pointAt(t + (t / 3)) + B1, A->pointAt(t + ((t / 3) * 2)), + A->finalPoint()); + } else { + out->moveto(A->initialPoint()); + out->lineto(A->pointAt(t) + A3); + out->lineto(A->finalPoint()); } - curve->append(nCurve, false); - nCurve->reset(); - delete nCurve; - } -} - -SPCurve *LPERoughen::addNodesAndJitter(const Geom::Curve *A, double t) { - SPCurve *out = new SPCurve(); - Geom::CubicBezier const *cubic = dynamic_cast(&*A); - Geom::Point A1(0, 0); - Geom::Point A2(0, 0); - Geom::Point A3(0, 0); - Geom::Point B1(0, 0); - Geom::Point B2(0, 0); - Geom::Point B3(0, 0); - if (shiftNodes) { - A3 = randomize(); - B3 = randomize(); - } - if (shiftNodeHandles) { - A1 = randomize(); - A2 = randomize(); - B1 = randomize(); - B2 = randomize(); - } else { - A2 = A3; - B1 = A3; - B2 = B3; - } - if (cubic) { - std::pair div = cubic->subdivide(t); - std::vector seg1 = div.first.points(), - seg2 = div.second.points(); - out->moveto(seg1[0]); - out->curveto(seg1[1] + A1, seg1[2] + A2, seg1[3] + A3); - out->curveto(seg2[1] + B1, seg2[2], seg2[3]); - } else if (shiftNodeHandles) { - out->moveto(A->initialPoint()); - out->curveto(A->pointAt(t / 3) + A1, A->pointAt((t / 3) * 2) + A2, - A->pointAt(t) + A3); - out->curveto(A->pointAt(t + (t / 3)) + B1, A->pointAt(t + ((t / 3) * 2)), - A->finalPoint()); - } else { - out->moveto(A->initialPoint()); - out->lineto(A->pointAt(t) + A3); - out->lineto(A->finalPoint()); - } - return out; + return out; } -SPCurve *LPERoughen::jitter(const Geom::Curve *A) { - SPCurve *out = new SPCurve(); - Geom::CubicBezier const *cubic = dynamic_cast(&*A); - Geom::Point A1(0, 0); - Geom::Point A2(0, 0); - Geom::Point A3(0, 0); - if (shiftNodes) { - A3 = randomize(); - } - if (shiftNodeHandles) { - A1 = randomize(); - A2 = randomize(); - } else { - A2 = A3; - } - if (cubic) { - out->moveto((*cubic)[0]); - out->curveto((*cubic)[1] + A1, (*cubic)[2] + A2, (*cubic)[3] + A3); - } else if (shiftNodeHandles) { - out->moveto(A->initialPoint()); - out->curveto(A->pointAt(0.3333) + A1, A->pointAt(0.6666) + A2, - A->finalPoint() + A3); - } else { - out->moveto(A->initialPoint()); - out->lineto(A->finalPoint() + A3); - } - return out; +SPCurve *LPERoughen::jitter(const Geom::Curve *A) +{ + SPCurve *out = new SPCurve(); + Geom::CubicBezier const *cubic = dynamic_cast(&*A); + Geom::Point A1(0, 0); + Geom::Point A2(0, 0); + Geom::Point A3(0, 0); + if (shiftNodes) { + A3 = randomize(); + } + if (shiftNodeHandles) { + A1 = randomize(); + A2 = randomize(); + } else { + A2 = A3; + } + if (cubic) { + out->moveto((*cubic)[0]); + out->curveto((*cubic)[1] + A1, (*cubic)[2] + A2, (*cubic)[3] + A3); + } else if (shiftNodeHandles) { + out->moveto(A->initialPoint()); + out->curveto(A->pointAt(0.3333) + A1, A->pointAt(0.6666) + A2, + A->finalPoint() + A3); + } else { + out->moveto(A->initialPoint()); + out->lineto(A->finalPoint() + A3); + } + return out; } -Geom::Point LPERoughen::tpoint(Geom::Point A, Geom::Point B, double t) { - using Geom::X; - using Geom::Y; - return Geom::Point(A[X] + t * (B[X] - A[X]), A[Y] + t * (B[Y] - A[Y])); +Geom::Point LPERoughen::tpoint(Geom::Point A, Geom::Point B, double t) +{ + using Geom::X; + using Geom::Y; + return Geom::Point(A[X] + t * (B[X] - A[X]), A[Y] + t * (B[Y] - A[Y])); } }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index cc7784dc0..7e99b47bf 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -1,11 +1,17 @@ -#ifndef INKSCAPE_LPE_ROUGHEN_H -#define INKSCAPE_LPE_ROUGHEN_H - -/* - * Inkscape::LPERoughen +/** @file + * @brief Roughen LPE effect, see lpe-roughen.cpp. + */ +/* Authors: + * Jabier Arraiza Cenoz + * + * Copyright (C) 2014 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ + +#ifndef INKSCAPE_LPE_ROUGHEN_H +#define INKSCAPE_LPE_ROUGHEN_H + #include "live_effects/parameter/enum.h" #include "live_effects/effect.h" #include "live_effects/parameter/parameter.h" @@ -18,37 +24,37 @@ namespace Inkscape { namespace LivePathEffect { enum DivisionMethod { - DM_SEGMENTS, - DM_SIZE, - DM_END + DM_SEGMENTS, + DM_SIZE, + DM_END }; class LPERoughen : public Effect { public: - LPERoughen(LivePathEffectObject *lpeobject); - virtual ~LPERoughen(); - - virtual void doEffect(SPCurve *curve); - virtual double sign(double randNumber); - virtual Geom::Point randomize(); - virtual void doBeforeEffect(SPLPEItem const */*lpeitem*/); - virtual SPCurve *addNodesAndJitter(const Geom::Curve *A, double t); - virtual SPCurve *jitter(const Geom::Curve *A); - virtual Geom::Point tpoint(Geom::Point A, Geom::Point B, double t = 0.5); - virtual Gtk::Widget *newWidget(); + LPERoughen(LivePathEffectObject *lpeobject); + virtual ~LPERoughen(); + + virtual void doEffect(SPCurve *curve); + virtual double sign(double randNumber); + virtual Geom::Point randomize(); + virtual void doBeforeEffect(SPLPEItem const */*lpeitem*/); + virtual SPCurve *addNodesAndJitter(const Geom::Curve *A, double t); + virtual SPCurve *jitter(const Geom::Curve *A); + virtual Geom::Point tpoint(Geom::Point A, Geom::Point B, double t = 0.5); + virtual Gtk::Widget *newWidget(); private: - UnitParam unit; - EnumParam method; - ScalarParam maxSegmentSize; - ScalarParam segments; - RandomParam displaceX; - RandomParam displaceY; - BoolParam shiftNodes; - BoolParam shiftNodeHandles; - LPERoughen(const LPERoughen &); - LPERoughen &operator=(const LPERoughen &); + UnitParam unit; + EnumParam method; + ScalarParam maxSegmentSize; + ScalarParam segments; + RandomParam displaceX; + RandomParam displaceY; + BoolParam shiftNodes; + BoolParam shiftNodeHandles; + LPERoughen(const LPERoughen &); + LPERoughen &operator=(const LPERoughen &); }; diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index dbebdf7fb..bce4876af 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -16,8 +16,6 @@ #include #include "live_effects/lpe-tangent_to_curve.h" -// FIXME: The following are only needed to convert the path's SPCurve* to pwd2. -// There must be a more convenient way to achieve this. #include "sp-path.h" #include "display/curve.h" @@ -108,13 +106,13 @@ LPETangentToCurve::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desk { KnotHolderEntity *e = new TtC::KnotHolderEntityLeftEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the \"left\" end of the tangent") ); + _("Adjust the left end of the tangent") ); knotholder->add(e); } { KnotHolderEntity *e = new TtC::KnotHolderEntityRightEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the \"right\" end of the tangent") ); + _("Adjust the right end of the tangent") ); knotholder->add(e); } }; @@ -130,14 +128,13 @@ KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point const s = snap_knot_position(p, state); - // FIXME: There must be a better way of converting the path's SPCurve* to pwd2. - SPCurve *curve = SP_PATH(item)->get_curve_for_edit(); - Geom::PathVector pathv = curve->get_pathvector(); - Piecewise > pwd2; - for (unsigned int i=0; i < pathv.size(); i++) { - pwd2.concat(pathv[i].toPwSb()); + if ( !SP_IS_SHAPE(lpe->sp_lpe_item) ) { + //lpe->t_attach.param_set_value(0); + g_warning("LPEItem is not a path! %s:%d\n", __FILE__, __LINE__); + return; } - + Piecewise > pwd2 = paths_to_pw( lpe->pathvector_before_effect ); + double t0 = nearest_point(s, pwd2); lpe->t_attach.param_set_value(t0); diff --git a/src/live_effects/lpe-tangent_to_curve.h b/src/live_effects/lpe-tangent_to_curve.h index 309afc14b..8e44c01d1 100644 --- a/src/live_effects/lpe-tangent_to_curve.h +++ b/src/live_effects/lpe-tangent_to_curve.h @@ -34,7 +34,6 @@ class LPETangentToCurve : public Effect { public: LPETangentToCurve(LivePathEffectObject *lpeobject); virtual ~LPETangentToCurve(); - virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); diff --git a/src/live_effects/lpe-taperstroke.cpp b/src/live_effects/lpe-taperstroke.cpp new file mode 100644 index 000000000..b595b8d55 --- /dev/null +++ b/src/live_effects/lpe-taperstroke.cpp @@ -0,0 +1,632 @@ +/** + * @file + * Taper Stroke path effect, provided as an alternative to Power Strokes + * for otherwise constant-width paths. + * + * Authors: + * Liam P White + * + * Copyright (C) 2014 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/lpe-taperstroke.h" + +#include <2geom/path.h> +#include <2geom/shape.h> +#include <2geom/path.h> +#include <2geom/circle.h> +#include <2geom/sbasis-to-bezier.h> + +#include "pathoutlineprovider.h" +#include "display/curve.h" +#include "sp-shape.h" +#include "style.h" +#include "xml/repr.h" +#include "sp-paint-server.h" +#include "svg/svg-color.h" +#include "desktop-style.h" +#include "svg/css-ostringstream.h" +#include "svg/svg.h" + +#include "knot-holder-entity.h" +#include "knotholder.h" + +#include + +template +inline bool withinRange(T value, T low, T high) { + return (value > low && value < high); +} + +namespace Inkscape { +namespace LivePathEffect { + +namespace TpS { + class KnotHolderEntityAttachBegin : public LPEKnotHolderEntity { + public: + KnotHolderEntityAttachBegin(LPETaperStroke * effect) : LPEKnotHolderEntity(effect) {} + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; + }; + + class KnotHolderEntityAttachEnd : public LPEKnotHolderEntity { + public: + KnotHolderEntityAttachEnd(LPETaperStroke * effect) : LPEKnotHolderEntity(effect) {} + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; + }; +} // TpS + +static const Util::EnumData JoinType[] = { + {LINEJOIN_STRAIGHT, N_("Beveled"), "bevel"}, + {LINEJOIN_ROUND, N_("Rounded"), "round"}, + {LINEJOIN_REFLECTED, N_("Reflected"), "reflected"}, + {LINEJOIN_POINTY, N_("Miter"), "miter"}, + {LINEJOIN_EXTRAPOLATED, N_("Extrapolated"), "extrapolated"} +}; + +static const Util::EnumDataConverter JoinTypeConverter(JoinType, sizeof (JoinType)/sizeof(*JoinType)); + +LPETaperStroke::LPETaperStroke(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + line_width(_("Stroke width"), _("The (non-tapered) width of the path"), "stroke_width", &wr, this, 1.), + attach_start(_("Start offset"), _("Taper distance from path start"), "attach_start", &wr, this, 0.2), + attach_end(_("End offset"), _("The ending position of the taper"), "end_offset", &wr, this, 0.2), + smoothing(_("Taper smoothing"), _("Amount of smoothing to apply to the tapers"), "smoothing", &wr, this, 0.5), + join_type(_("Join type"), _("Join type for non-smooth nodes"), "jointype", JoinTypeConverter, &wr, this, LINEJOIN_EXTRAPOLATED), + miter_limit(_("Miter limit"), _("Limit for miter joins"), "miter_limit", &wr, this, 100.) +{ + show_orig_path = true; + _provides_knotholder_entities = true; + + attach_start.param_set_digits(3); + attach_end.param_set_digits(3); + + registerParameter(&line_width); + registerParameter(&attach_start); + registerParameter(&attach_end); + registerParameter(&smoothing); + registerParameter(&join_type); + registerParameter(&miter_limit); +} + +// from LPEPowerStroke -- sets fill if stroke color because we will +// be converting to a fill to make the new join. + +void LPETaperStroke::doOnApply(SPLPEItem const* lpeitem) +{ + if (SP_IS_SHAPE(lpeitem)) { + SPLPEItem* item = const_cast(lpeitem); + double width = (lpeitem && lpeitem->style) ? lpeitem->style->stroke_width.computed : 1.; + + SPCSSAttr *css = sp_repr_css_attr_new (); + if (true) { + if (lpeitem->style->stroke.isPaintserver()) { + SPPaintServer * server = lpeitem->style->getStrokePaintServer(); + if (server) { + Glib::ustring str; + str += "url(#"; + str += server->getId(); + str += ")"; + sp_repr_css_set_property (css, "fill", str.c_str()); + } + } else if (lpeitem->style->stroke.isColor()) { + gchar c[64]; + sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); + sp_repr_css_set_property (css, "fill", c); + } else { + sp_repr_css_set_property (css, "fill", "none"); + } + } else { + sp_repr_css_unset_property (css, "fill"); + } + + sp_repr_css_set_property(css, "stroke", "none"); + + sp_desktop_apply_css_recursive(item, css, true); + sp_repr_css_attr_unref (css); + + line_width.param_set_value(width); + } else { + printf("WARNING: It only makes sense to apply Join Type to paths (not groups).\n"); + } +} + +// from LPEPowerStroke -- sets stroke color from existing fill color + +void LPETaperStroke::doOnRemove(SPLPEItem const* lpeitem) +{ + if (SP_IS_SHAPE(lpeitem)) { + SPLPEItem *item = const_cast(lpeitem); + + SPCSSAttr *css = sp_repr_css_attr_new (); + if (true) { + if (lpeitem->style->fill.isPaintserver()) { + SPPaintServer * server = lpeitem->style->getFillPaintServer(); + if (server) { + Glib::ustring str; + str += "url(#"; + str += server->getId(); + str += ")"; + sp_repr_css_set_property (css, "stroke", str.c_str()); + } + } else if (lpeitem->style->fill.isColor()) { + gchar c[64]; + sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); + sp_repr_css_set_property (css, "stroke", c); + } else { + sp_repr_css_set_property (css, "stroke", "none"); + } + } else { + sp_repr_css_unset_property (css, "stroke"); + } + + Inkscape::CSSOStringStream os; + os << fabs(line_width); + sp_repr_css_set_property (css, "stroke-width", os.str().c_str()); + + sp_repr_css_set_property(css, "fill", "none"); + + sp_desktop_apply_css_recursive(item, css, true); + sp_repr_css_attr_unref (css); + } +} + +using Geom::Piecewise; +using Geom::D2; +using Geom::SBasis; +// leave Geom::Path + +Geom::Path return_at_first_cusp(Geom::Path const & path_in, double /*smooth_tolerance*/ = 0.05) { + return Geom::split_at_cusps(path_in)[0]; +} + +Piecewise > stretch_along(Piecewise > pwd2_in, Geom::Path pattern, double width); + +// references to pointers +void subdivideCurve(Geom::Curve * curve_in, Geom::Coord t, Geom::Curve *& val_first, Geom::Curve *& val_second); + +// actual effect + +Geom::PathVector LPETaperStroke::doEffect_path(Geom::PathVector const& path_in) +{ + Geom::Path first_cusp = return_at_first_cusp(path_in[0]); + Geom::Path last_cusp = return_at_first_cusp(path_in[0].reverse()); + + bool zeroStart = false; // [distance from start taper knot -> start of path] == 0 + bool zeroEnd = false; // [distance from end taper knot -> end of path] == 0 + bool metInMiddle = false; // knots are touching + + // there is a pretty good chance that people will try to drag the knots + // on top of each other, so block it + + unsigned size = path_in[0].size(); + if (size == first_cusp.size()) { + // check to see if the knots were dragged over each other + // if so, reset the end offset, but still allow the start offset. + if ( attach_start >= (size - attach_end) ) { + attach_end.param_set_value( size - attach_start ); + metInMiddle = true; + } + } + + if (attach_start == size - attach_end) { + metInMiddle = true; + } + if (attach_end == size - attach_start) { + metInMiddle = true; + } + + // don't let it be integer (TODO this is stupid!) + { + if (double(unsigned(attach_start)) == attach_start) { + attach_start.param_set_value(attach_start - 0.00001); + } + if (double(unsigned(attach_end)) == attach_end) { + attach_end.param_set_value(attach_end - 0.00001); + } + } + + unsigned allowed_start = first_cusp.size(); + unsigned allowed_end = last_cusp.size(); + + // don't let the knots be farther than they are allowed to be + { + if ((unsigned)attach_start >= allowed_start) { + attach_start.param_set_value((double)allowed_start - 0.00001); + } + if ((unsigned)attach_end >= allowed_end) { + attach_end.param_set_value((double)allowed_end - 0.00001); + } + } + + // don't let it be zero (this is stupid too!) + if (attach_start < 0.0000001 || withinRange(double(attach_start), 0.00000001, 0.000001)) { + attach_start.param_set_value( 0.0000001 ); + zeroStart = true; + } + if (attach_end < 0.0000001 || withinRange(double(attach_end), 0.00000001, 0.000001)) { + attach_end.param_set_value( 0.0000001 ); + zeroEnd = true; + } + + // Path::operator () means get point at time t + start_attach_point = first_cusp(attach_start); + end_attach_point = last_cusp(attach_end); + Geom::PathVector pathv_out; + + // the following function just splits it up into three pieces. + pathv_out = doEffect_simplePath(path_in); + + // now for the actual tapering. the stretch_along method (stolen from PaP) is used to accomplish this + + Geom::PathVector real_pathv; + Geom::Path real_path; + Geom::PathVector pat_vec; + Piecewise > pwd2; + Geom::Path throwaway_path; + + if (!zeroStart) { + // Construct the pattern + std::stringstream pat_str; + pat_str.imbue(std::locale::classic()); + pat_str << "M 1,0 C " << 1 - (double)smoothing << ",0 0,0.5 0,0.5 0,0.5 " << 1 - (double)smoothing << ",1 1,1"; + + pat_vec = sp_svg_read_pathv(pat_str.str().c_str()); + pwd2.concat(stretch_along(pathv_out[0].toPwSb(), pat_vec[0], -fabs(line_width))); + throwaway_path = Geom::path_from_piecewise(pwd2, LPE_CONVERSION_TOLERANCE)[0]; + + real_path.append(throwaway_path); + } + + // if this condition happens to evaluate false, i.e. there was no space for a path to be drawn, it is simply skipped. + // although this seems obvious, it can probably lead to bugs. + if (!metInMiddle) { + // append the outside outline of the path (goes with the direction of the path) + throwaway_path = Outline::PathOutsideOutline(pathv_out[1], -fabs(line_width), static_cast(join_type.get_value()), miter_limit); + if (!zeroStart && real_path.size() >= 1 && throwaway_path.size() >= 1) { + if (!Geom::are_near(real_path.finalPoint(), throwaway_path.initialPoint())) { + real_path.appendNew(throwaway_path.initialPoint()); + } else { + real_path.setFinal(throwaway_path.initialPoint()); + } + } + real_path.append(throwaway_path); + } + + if (!zeroEnd) { + // append the ending taper + std::stringstream pat_str_1; + pat_str_1.imbue(std::locale::classic()); + pat_str_1 << "M 0,1 C " << (double)smoothing << ",1 1,0.5 1,0.5 1,0.5 " << double(smoothing) << ",0 0,0"; + pat_vec = sp_svg_read_pathv(pat_str_1.str().c_str()); + + pwd2 = Piecewise >(); + pwd2.concat(stretch_along(pathv_out[2].toPwSb(), pat_vec[0], -fabs(line_width))); + + throwaway_path = Geom::path_from_piecewise(pwd2, LPE_CONVERSION_TOLERANCE)[0]; + if (!Geom::are_near(real_path.finalPoint(), throwaway_path.initialPoint()) && real_path.size() >= 1) { + real_path.appendNew(throwaway_path.initialPoint()); + } else { + real_path.setFinal(throwaway_path.initialPoint()); + } + real_path.append(throwaway_path); + } + + if (!metInMiddle) { + // append the inside outline of the path (against direction) + throwaway_path = Outline::PathOutsideOutline(pathv_out[1].reverse(), -fabs(line_width), static_cast(join_type.get_value()), miter_limit); + + if (!Geom::are_near(real_path.finalPoint(), throwaway_path.initialPoint()) && real_path.size() >= 1) { + real_path.appendNew(throwaway_path.initialPoint()); + } else { + real_path.setFinal(throwaway_path.initialPoint()); + } + real_path.append(throwaway_path); + } + + if (!Geom::are_near(real_path.finalPoint(), real_path.initialPoint())) { + real_path.appendNew(real_path.initialPoint()); + } else { + real_path.setFinal(real_path.initialPoint()); + } + real_path.close(); + + real_pathv.push_back(real_path); + + return real_pathv; +} + +/** + * @return Always returns a PathVector with three elements. + * + * The positions of the effect knots are accessed to determine + * where exactly the input path should be split. + */ +Geom::PathVector LPETaperStroke::doEffect_simplePath(Geom::PathVector const & path_in) +{ + size_t size = path_in[0].size(); + + unsigned loc = (unsigned)attach_start; + Geom::Curve * curve_start = path_in[0] [loc].duplicate(); + + std::vector pathv_out; + Geom::Path path_out = Geom::Path(); + + Geom::Path trimmed_start = Geom::Path(); + Geom::Path trimmed_end = Geom::Path(); + + for (size_t i = 0; i < loc; ++i) { + trimmed_start.append(path_in[0] [i]); + } + + Geom::Curve * temp; + subdivideCurve(curve_start, attach_start - loc, temp, curve_start); + trimmed_start.append(*temp); + if (temp) delete temp; temp = 0; + + // special case: path is one segment long + // special case: what if the two knots occupy the same segment? + if ((size == 1) || ( size - unsigned(attach_end) - 1 == loc )) { + + // If you look into it, I don't actually think there is a working way to do this + // with only point math. So we use nearest_point instead. + Geom::Coord t = Geom::nearest_point(end_attach_point, *curve_start); + + // it is just a dumb segment + // we have to do some shifting here because the value changed when we reduced the length + // of the previous segment. + + subdivideCurve(curve_start, t, curve_start, temp); + trimmed_end.append(*temp); + if (temp) delete temp; temp = 0; + + for (size_t j = (size - attach_end) + 1; j < size; ++j) { + trimmed_end.append(path_in[0] [j]); + } + + path_out.append(*curve_start); + pathv_out.push_back(trimmed_start); + pathv_out.push_back(path_out); + pathv_out.push_back(trimmed_end); + return pathv_out; + } + + pathv_out.push_back(trimmed_start); + + // append almost all of the rest of the path, ignore the curves that the knot is past (we'll get to it in a minute) + path_out.append(*curve_start); + + for (size_t k = loc + 1; k < (size - unsigned(attach_end)) - 1; ++k) { + path_out.append(path_in[0] [k]); + } + + // deal with the last segment in a very similar fashion to the first + loc = size - attach_end; + + Geom::Curve * curve_end = path_in[0] [loc].duplicate(); + + Geom::Coord t = Geom::nearest_point(end_attach_point, *curve_end); + + subdivideCurve(curve_end, t, curve_end, temp); + trimmed_end.append(*temp); + if (temp) delete temp; temp = 0; + + for (size_t j = (size - attach_end) + 1; j < size; ++j) { + trimmed_end.append(path_in[0] [j]); + } + + path_out.append(*curve_end); + pathv_out.push_back(path_out); + + pathv_out.push_back(trimmed_end); + + if (curve_end) delete curve_end; + if (curve_start) delete curve_start; + return pathv_out; +} + + +/** + * Most of the below function is verbatim from Pattern Along Path. However, it needed a little + * tweaking to get it to work right in this case. Also, large portions of the effect have been + * stripped out as I deemed them unnecessary for the relative simplicity of this effect. + */ +Piecewise > stretch_along(Piecewise > pwd2_in, Geom::Path pattern, double prop_scale) +{ + using namespace Geom; + + // Don't allow empty path parameter: + if ( pattern.empty() ) { + return pwd2_in; + } + + /* Much credit should go to jfb and mgsloan of lib2geom development for the code below! */ + Piecewise > output; + std::vector > > pre_output; + + D2 > patternd2 = make_cuts_independent(pattern.toPwSb()); + Piecewise x0 = Piecewise(patternd2[0]); + Piecewise y0 = Piecewise(patternd2[1]); + OptInterval pattBndsX = bounds_exact(x0); + OptInterval pattBndsY = bounds_exact(y0); + if (pattBndsX && pattBndsY) { + x0 -= pattBndsX->min(); + y0 -= pattBndsY->middle(); + + double xspace = 0; + double noffset = 0; + double toffset = 0; + // Prevent more than 90% overlap... + if (xspace < -pattBndsX->extent()*.9) { + xspace = -pattBndsX->extent()*.9; + } + + y0+=noffset; + + std::vector > > paths_in; + paths_in = split_at_discontinuities(pwd2_in); + + for (unsigned idx = 0; idx < paths_in.size(); idx++) { + Piecewise > path_i = paths_in[idx]; + Piecewise x = x0; + Piecewise y = y0; + Piecewise > uskeleton = arc_length_parametrization(path_i,2,.1); + uskeleton = remove_short_cuts(uskeleton,.01); + Piecewise > n = rot90(derivative(uskeleton)); + n = force_continuity(remove_short_cuts(n,.1)); + + int nbCopies = 0; + double scaling = 1; + nbCopies = 1; + scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); + + double pattWidth = pattBndsX->extent() * scaling; + + if (scaling != 1.0) { + x*=scaling; + } + if ( false ) { + y*=(scaling*prop_scale); + } else { + if (prop_scale != 1.0) y *= prop_scale; + } + x += toffset; + + double offs = 0; + for (int i=0; i > output_piece = compose(uskeleton,x+offs)+y*compose(n,x+offs); + std::vector > > splited_output_piece = split_at_discontinuities(output_piece); + pre_output.insert(pre_output.end(), splited_output_piece.begin(), splited_output_piece.end() ); + } else { + output.concat(compose(uskeleton,x+offs)+y*compose(n,x+offs)); + } + offs+=pattWidth; + } + } + return output; + } else { + return pwd2_in; + } +} + +void subdivideCurve(Geom::Curve * curve_in, Geom::Coord t, Geom::Curve *& val_first, Geom::Curve *& val_second) +{ + if (Geom::LineSegment* linear = dynamic_cast(curve_in)) { + // special case for line segments + std::pair seg_pair = linear->subdivide(t); + val_first = seg_pair.first.duplicate(); + val_second = seg_pair.second.duplicate(); + } else { + // all other cases: + Geom::CubicBezier cubic = Geom::sbasis_to_cubicbezier(curve_in->toSBasis()); + std::pair cubic_pair = cubic.subdivide(t); + val_first = cubic_pair.first.duplicate(); + val_second = cubic_pair.second.duplicate(); + } +} + + +void LPETaperStroke::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +{ + KnotHolderEntity *e = new TpS::KnotHolderEntityAttachBegin(this); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Start point of the taper"), SP_KNOT_SHAPE_CIRCLE); + knotholder->add(e); + + KnotHolderEntity *f = new TpS::KnotHolderEntityAttachEnd(this); + f->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("End point of the taper"), SP_KNOT_SHAPE_CIRCLE); + knotholder->add(f); +} + +namespace TpS { + +void KnotHolderEntityAttachBegin::knot_set(Geom::Point const &p, Geom::Point const&/*origin*/, guint state) +{ + using namespace Geom; + + LPETaperStroke* lpe = dynamic_cast(_effect); + + Geom::Point const s = snap_knot_position(p, state); + + if (!SP_IS_SHAPE(lpe->sp_lpe_item)) { + printf("WARNING: LPEItem is not a path!\n"); + return; + } + + SPCurve* curve; + if (!(curve = SP_SHAPE(lpe->sp_lpe_item)->getCurve())) { + // oops + return; + } + // in case you are wondering, the above are simply sanity checks. we never want to actually + // use that object. + + Geom::PathVector pathv = lpe->pathvector_before_effect; + + Piecewise > pwd2; + Geom::Path p_in = return_at_first_cusp(pathv[0]); + pwd2.concat(p_in.toPwSb()); + + double t0 = nearest_point(s, pwd2); + lpe->attach_start.param_set_value(t0); + + // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, true); +} +void KnotHolderEntityAttachEnd::knot_set(Geom::Point const &p, Geom::Point const& /*origin*/, guint state) +{ + using namespace Geom; + + LPETaperStroke* lpe = dynamic_cast(_effect); + + Geom::Point const s = snap_knot_position(p, state); + + if (!SP_IS_SHAPE(lpe->sp_lpe_item) ) { + printf("WARNING: LPEItem is not a path!\n"); + return; + } + + SPCurve* curve; + if ( !(curve = SP_SHAPE(lpe->sp_lpe_item)->getCurve()) ) { + // oops + return; + } + Geom::PathVector pathv = lpe->pathvector_before_effect; + Geom::Path p_in = return_at_first_cusp(pathv[0].reverse()); + Piecewise > pwd2 = p_in.toPwSb(); + + double t0 = nearest_point(s, pwd2); + lpe->attach_end.param_set_value(t0); + + sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); +} + +Geom::Point KnotHolderEntityAttachBegin::knot_get() const +{ + LPETaperStroke const * lpe = dynamic_cast (_effect); + return lpe->start_attach_point; +} + +Geom::Point KnotHolderEntityAttachEnd::knot_get() const +{ + LPETaperStroke const * lpe = dynamic_cast (_effect); + return lpe->end_attach_point; +} + +} // namespace TpS +} // namespace LivePathEffect +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/live_effects/lpe-taperstroke.h b/src/live_effects/lpe-taperstroke.h new file mode 100644 index 000000000..88604486e --- /dev/null +++ b/src/live_effects/lpe-taperstroke.h @@ -0,0 +1,72 @@ +/** @file + * @brief Taper Stroke path effect (meant as a replacement for using Power Strokes for tapering) + */ +/* Authors: + * Liam P White + * Copyright (C) 2014 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_LPE_TAPERSTROKE_H +#define INKSCAPE_LPE_TAPERSTROKE_H + +#include "live_effects/parameter/enum.h" +#include "live_effects/effect.h" +#include "live_effects/parameter/parameter.h" +#include "live_effects/parameter/vector.h" + +namespace Inkscape { +namespace LivePathEffect { + +namespace TpS { +// we need a separate namespace to avoid clashes with other LPEs +class KnotHolderEntityAttachBegin; +class KnotHolderEntityAttachEnd; +} + +class LPETaperStroke : public Effect { +public: + LPETaperStroke(LivePathEffectObject *lpeobject); + virtual ~LPETaperStroke() {} + + virtual void doOnApply(SPLPEItem const* lpeitem); + virtual void doOnRemove(SPLPEItem const* lpeitem); + + virtual Geom::PathVector doEffect_path (Geom::PathVector const& path_in); + Geom::PathVector doEffect_simplePath(Geom::PathVector const& path_in); + + virtual void addKnotHolderEntities(KnotHolder * knotholder, SPDesktop * desktop, SPItem * item); + + friend class TpS::KnotHolderEntityAttachBegin; + friend class TpS::KnotHolderEntityAttachEnd; +private: + ScalarParam line_width; + ScalarParam attach_start; + ScalarParam attach_end; + ScalarParam smoothing; + EnumParam join_type; + ScalarParam miter_limit; + + Geom::Point start_attach_point; + Geom::Point end_attach_point; + + LPETaperStroke(const LPETaperStroke&); + LPETaperStroke& operator=(const LPETaperStroke&); +}; + +} //namespace LivePathEffect +} //namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h index b1ba1ee4e..374e715ec 100644 --- a/src/live_effects/lpeobject-reference.h +++ b/src/live_effects/lpeobject-reference.h @@ -9,10 +9,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include -#include #include +#include "uri-references.h" + namespace Inkscape { namespace XML { class Node; @@ -33,7 +33,7 @@ public: SPObject *owner; // concerning the LPEObject that is refered to: - gchar *lpeobject_href; + char *lpeobject_href; Inkscape::XML::Node *lpeobject_repr; LivePathEffectObject *lpeobject; diff --git a/src/live_effects/lpeobject.h b/src/live_effects/lpeobject.h index 9700024fe..2e62707e3 100644 --- a/src/live_effects/lpeobject.h +++ b/src/live_effects/lpeobject.h @@ -47,9 +47,9 @@ protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert index 1137ef34b..f990f41c7 100644 --- a/src/live_effects/parameter/Makefile_insert +++ b/src/live_effects/parameter/Makefile_insert @@ -20,12 +20,16 @@ ink_common_sources += \ live_effects/parameter/path.h \ live_effects/parameter/originalpath.cpp \ live_effects/parameter/originalpath.h \ + live_effects/parameter/originalpatharray.cpp \ + live_effects/parameter/originalpatharray.h \ live_effects/parameter/powerstrokepointarray.cpp \ live_effects/parameter/powerstrokepointarray.h \ live_effects/parameter/filletchamferpointarray.cpp \ live_effects/parameter/filletchamferpointarray.h \ live_effects/parameter/text.cpp \ live_effects/parameter/text.h \ + live_effects/parameter/transformedpoint.cpp \ + live_effects/parameter/transformedpoint.h \ live_effects/parameter/togglebutton.cpp \ live_effects/parameter/togglebutton.h \ live_effects/parameter/unit.cpp \ diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index a89a6279b..bb00ef045 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -8,12 +8,20 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include "ui/dialog/lpe-fillet-chamfer-properties.h" #include "live_effects/parameter/filletchamferpointarray.h" + #include <2geom/piecewise.h> #include <2geom/sbasis-to-bezier.h> #include <2geom/sbasis-geometric.h> +#include <2geom/svg-elliptical-arc.h> +#include <2geom/line.h> +#include <2geom/path-intersection.h> +#include "ui/dialog/lpe-fillet-chamfer-properties.h" +#include "live_effects/parameter/filletchamferpointarray.h" #include "live_effects/effect.h" #include "svg/svg.h" #include "svg/stringstream.h" @@ -32,6 +40,7 @@ // this has to be included last. #include + using namespace Geom; namespace Inkscape { @@ -165,11 +174,12 @@ void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2( } } if (last_pathv.size() > pathv.size() || - (last_pathv[counterPaths].size() > counter - offset && + (last_pathv.size() > counterPaths && + last_pathv[counterPaths].size() > counter - offset && !are_near(curve_it1->initialPoint(), last_pathv[counterPaths][counter - offset].initialPoint(), 0.1))) { - if (last_pathv.size() > counterPaths && curve_it2 == curve_endit) { + if ( curve_it2 == curve_endit) { if (last_pathv[counterPaths].size() < pathv[counterPaths].size()) { offset = abs(last_pathv[counterPaths].size() - pathv[counterPaths].size()); @@ -332,10 +342,10 @@ void FilletChamferPointArrayParam::recalculate_knots( result.push_back(Point(xPos, 0)); } ++curve_it1; + counter++; if (curve_it2 != curve_endit) { ++curve_it2; } - counter++; counterCurves++; } } @@ -359,6 +369,11 @@ void FilletChamferPointArrayParam::set_helper_size(int hs) helper_size = hs; } +void FilletChamferPointArrayParam::set_use_distance(bool use_knot_distance ) +{ + use_distance = use_knot_distance; +} + void FilletChamferPointArrayParam::set_unit(const gchar *abbr) { unit = abbr; @@ -398,6 +413,205 @@ void FilletChamferPointArrayParam::addCanvasIndicators( hp_vec.push_back(hp); } +double FilletChamferPointArrayParam::rad_to_len(int index, double rad) +{ + double len = 0; + std::vector subpaths = path_from_piecewise(last_pwd2, 0.1); + std::pair positions = get_positions(index, subpaths); + D2 A = last_pwd2[last_index(index, subpaths)]; + if(positions.second != 0){ + A = last_pwd2[index-1]; + }else{ + if(!subpaths[positions.first].closed()){ + return len; + } + } + D2 B = last_pwd2[index]; + Piecewise > offset_curve0 = Piecewise >(A)+rot90(unitVector(derivative(A)))*(rad); + Piecewise > offset_curve1 = Piecewise >(B)+rot90(unitVector(derivative(B)))*(rad); + Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0]; + Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0]; + Geom::Crossings cs = Geom::crossings(p0, p1); + if(cs.size() > 0){ + Point cp =p0(cs[0].ta); + double p0pt = nearest_point(cp, B); + len = time_to_len(index,p0pt); + } else { + if(rad < 0){ + len = rad_to_len(index, rad * -1); + } + } + return len; +} + +double FilletChamferPointArrayParam::len_to_rad(int index, double len) +{ + double rad = 0; + double tmp_len = _vector[index][X]; + _vector[index] = Geom::Point(len,_vector[index][Y]); + std::vector subpaths = path_from_piecewise(last_pwd2, 0.1); + std::pair positions = get_positions(index, subpaths); + Piecewise > u; + u.push_cut(0); + u.push(last_pwd2[last_index(index, subpaths)], 1); + Geom::Curve * A = path_from_piecewise(u, 0.1)[0][0].duplicate(); + Geom::Curve * B = subpaths[positions.first][positions.second].duplicate(); + std::vector times; + if(positions.second != 0){ + A = subpaths[positions.first][positions.second-1].duplicate(); + times = get_times(index-1, subpaths, false); + }else{ + if(!subpaths[positions.first].closed()){ + return rad; + } + times = get_times(last_index(index, subpaths), subpaths, true); + } + _vector[index] = Geom::Point(tmp_len,_vector[index][Y]); + Geom::Point startArcPoint = A->toSBasis().valueAt(times[1]); + Geom::Point endArcPoint = B->toSBasis().valueAt(times[2]); + Curve *knotCurve1 = A->portion(times[0], times[1]); + Curve *knotCurve2 = B->portion(times[2], 1); + Geom::CubicBezier const *cubic1 = dynamic_cast(&*knotCurve1); + Ray ray1(startArcPoint, A->finalPoint()); + if (cubic1) { + ray1.setPoints((*cubic1)[2], startArcPoint); + } + Geom::CubicBezier const *cubic2 = dynamic_cast(&*knotCurve2); + Ray ray2(B->initialPoint(), endArcPoint); + if (cubic2) { + ray2.setPoints(endArcPoint, (*cubic2)[1]); + } + bool ccwToggle = cross(A->finalPoint() - startArcPoint, endArcPoint - startArcPoint) < 0; + double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint)); + double angleBetween = angle_between(ray1, ray2, ccwToggle); + rad = distanceArc/sin(angleBetween/2.0); + return rad * -1; +} + +std::vector FilletChamferPointArrayParam::get_times(int index, std::vector subpaths, bool last) +{ + const double tolerance = 0.001; + const double gapHelper = 0.00001; + std::pair positions = get_positions(index, subpaths); + Curve *curve_it1; + curve_it1 = subpaths[positions.first][positions.second].duplicate(); + Coord it1_length = (*curve_it1).length(tolerance); + double time_it1, time_it2, time_it1_B, intpart; + time_it1 = modf(to_time(index, _vector[index][X]), &intpart); + if (_vector[index][Y] == 0) { + time_it1 = 0; + } + double resultLenght = 0; + time_it1_B = 1; + if (subpaths[positions.first].closed() && last) { + time_it2 = modf(to_time(index - positions.second , _vector[index - positions.second ][X]), &intpart); + resultLenght = it1_length + to_len(index - positions.second, _vector[index - positions.second ][X]); + } else if (!subpaths[positions.first].closed() && last){ + time_it2 = 0; + resultLenght = 0; + } else { + time_it2 = modf(to_time(index + 1, _vector[index + 1][X]), &intpart); + resultLenght = it1_length + to_len( index + 1, _vector[index + 1][X]); + } + if (resultLenght > 0 && time_it2 != 0) { + time_it1_B = modf(to_time(index, -resultLenght), &intpart); + } else { + if (time_it2 == 0) { + time_it1_B = 1; + } else { + time_it1_B = gapHelper; + } + } + + if ((subpaths[positions.first].closed() && last && _vector[index - positions.second][Y] == 0) || (subpaths[positions.first].size() > positions.second + 1 && _vector[index + 1][Y] == 0)) { + time_it1_B = 1; + time_it2 = 0; + } + if (time_it1_B < time_it1) { + time_it1_B = time_it1 + gapHelper; + } + std::vector out; + out.push_back(time_it1); + out.push_back(time_it1_B); + out.push_back(time_it2); + return out; +} + +std::pair FilletChamferPointArrayParam::get_positions(int index, std::vector subpaths) +{ + int counter = -1; + std::size_t first = 0; + std::size_t second = 0; + for (PathVector::const_iterator path_it = subpaths.begin(); path_it != subpaths.end(); ++path_it) { + if (path_it->empty()) + continue; + Geom::Path::const_iterator curve_it1 = path_it->begin(); + Geom::Path::const_iterator curve_endit = path_it->end_default(); + if (path_it->closed()) { + const Geom::Curve &closingline = path_it->back_closed(); + // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + first++; + second = 0; + while (curve_it1 != curve_endit) { + counter++; + second++; + if(counter == index){ + break; + } + ++curve_it1; + } + if(counter == index){ + break; + } + } + first--; + second--; + std::pair out(first, second); + return out; +} + +int FilletChamferPointArrayParam::last_index(int index, std::vector subpaths) +{ + int counter = -1; + bool inSubpath = false; + for (PathVector::const_iterator path_it = subpaths.begin(); path_it != subpaths.end(); ++path_it) { + if (path_it->empty()) + continue; + Geom::Path::const_iterator curve_it1 = path_it->begin(); + Geom::Path::const_iterator curve_endit = path_it->end_default(); + if (path_it->closed()) { + const Geom::Curve &closingline = path_it->back_closed(); + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + curve_endit = path_it->end_open(); + } + } + while (curve_it1 != curve_endit) { + counter++; + if(counter == index){ + inSubpath = true; + } + ++curve_it1; + } + if(inSubpath){ + break; + } + } + if(!inSubpath){ + counter = -1; + } + return counter; +} + + double FilletChamferPointArrayParam::len_to_time(int index, double len) { double t = 0; @@ -405,7 +619,7 @@ double FilletChamferPointArrayParam::len_to_time(int index, double len) if (len != 0) { if (last_pwd2[index][0].degreesOfFreedom() != 2) { Piecewise > u; - u.push_cut(0); + u.push_cut(0); u.push(last_pwd2[index], 1); std::vector t_roots = roots(arcLengthSb(u) - std::abs(len)); if (t_roots.size() > 0) { @@ -586,34 +800,34 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state) this->knot->tip = g_strdup(tip); this->knot->show(); } - } else if ((state & GDK_MOD1_MASK) || (state & GDK_SHIFT_MASK)) { - Geom::Point offset = Geom::Point(_pparam->_vector.at(_index).x(), - _pparam->_vector.at(_index).y()); + } else if (state & GDK_SHIFT_MASK) { + double xModified = _pparam->_vector.at(_index).x(); + if(xModified < 0 && !_pparam->use_distance){ + xModified = _pparam->len_to_rad(_index, _pparam->_vector.at(_index).x()); + } + std::vector subpaths = path_from_piecewise(_pparam->last_pwd2, 0.1); + std::pair positions = _pparam->get_positions(_index, subpaths); + D2 A = _pparam->last_pwd2[_pparam->last_index(_index, subpaths)]; + if(positions.second != 0){ + A = _pparam->last_pwd2[_index-1]; + } + D2 B = _pparam->last_pwd2[_index]; + bool aprox = (A[0].degreesOfFreedom() != 2 || B[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false; + Geom::Point offset = Geom::Point(xModified, _pparam->_vector.at(_index).y()); Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( - this->desktop, offset, this, _pparam->unit); + this->desktop, offset, this, _pparam->unit, _pparam->use_distance, aprox); } } -void -FilletChamferPointArrayParamKnotHolderEntity::knot_doubleclicked(guint state) -{ - //todo: fill the double click dialog whith this parameters in the added file - //src/ui/dialog/lpe-fillet-chamfer-properties.cpp(.h) - //My idea for when have enought time is: - //label whith radius in percent - //label whith radius in size -maybe handle units- - //entry whith actual radius -in flexible % mode or fixed -?px- - //2 radio options to switch entry from fixed or flexible, also update the - //entry - //Checkbox or two radios to swith fillet or chamfer - -} - void FilletChamferPointArrayParamKnotHolderEntity::knot_set_offset( Geom::Point offset) { - _pparam->_vector.at(_index) = Geom::Point(offset.x(), offset.y()); + double xModified = offset.x(); + if(xModified < 0 && !_pparam->use_distance){ + xModified = _pparam->rad_to_len(_index, offset.x()); + } + _pparam->_vector.at(_index) = Geom::Point(xModified, offset.y()); this->parent_holder->knot_ungrabbed_handler(this->knot, 0); } @@ -644,7 +858,6 @@ void FilletChamferPointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, "Shift+Click open dialog, " "Ctrl+Alt+Click reset"); } - FilletChamferPointArrayParamKnotHolderEntity *e = new FilletChamferPointArrayParamKnotHolderEntity(this, i); e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), diff --git a/src/live_effects/parameter/filletchamferpointarray.h b/src/live_effects/parameter/filletchamferpointarray.h index 93d6e9f4c..a1fa698ae 100644 --- a/src/live_effects/parameter/filletchamferpointarray.h +++ b/src/live_effects/parameter/filletchamferpointarray.h @@ -43,9 +43,15 @@ public: guint32 color); virtual double to_time(int index, double A); virtual double to_len(int index, double A); + virtual double rad_to_len(int index, double rad); + virtual double len_to_rad(int index, double len); virtual double len_to_time(int index, double len); virtual double time_to_len(int index, double time); + virtual std::pair get_positions(int index, std::vector subpaths); + virtual int last_index(int index, std::vector subpaths); + std::vector get_times(int index, std::vector subpaths, bool last); virtual void set_helper_size(int hs); + virtual void set_use_distance(bool use_knot_distance); virtual void set_unit(const gchar *abbr); virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); @@ -79,6 +85,7 @@ private: SPKnotModeType knot_mode; guint32 knot_color; int helper_size; + bool use_distance; const gchar *unit; Geom::PathVector hp; @@ -96,7 +103,6 @@ public: guint state); virtual Geom::Point knot_get() const; virtual void knot_click(guint state); - virtual void knot_doubleclicked(guint state); virtual void knot_set_offset(Geom::Point offset); /*Checks whether the index falls within the size of the parameter's vector*/ diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp new file mode 100644 index 000000000..7706dbdf8 --- /dev/null +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -0,0 +1,487 @@ +/* + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include +#endif + +#include "live_effects/parameter/originalpatharray.h" + +#include +#include +#include +#include +#include + +#include + +#include "inkscape.h" +#include "icon-size.h" +#include "widgets/icon.h" +#include "ui/clipboard.h" +#include "svg/svg.h" +#include "svg/stringstream.h" +#include "originalpath.h" +#include "uri.h" +#include "display/curve.h" + +#include <2geom/coord.h> +#include <2geom/point.h> +#include "sp-shape.h" +#include "sp-text.h" +#include "live_effects/effect.h" + +#include "verbs.h" +#include "document-undo.h" +#include "document.h" + +namespace Inkscape { + +namespace LivePathEffect { + +class OriginalPathArrayParam::ModelColumns : public Gtk::TreeModel::ColumnRecord +{ +public: + + ModelColumns() + { + add(_colObject); + add(_colLabel); + add(_colReverse); + } + virtual ~ModelColumns() {} + + Gtk::TreeModelColumn _colObject; + Gtk::TreeModelColumn _colLabel; + Gtk::TreeModelColumn _colReverse; +}; + +OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + Inkscape::UI::Widget::Registry* wr, + Effect* effect ) +: Parameter(label, tip, key, wr, effect), + _vector(), + _tree(), + _text_renderer(), + _toggle_renderer(), + _scroller() +{ + _model = new ModelColumns(); + _store = Gtk::TreeStore::create(*_model); + _tree.set_model(_store); + + _tree.set_reorderable(true); + _tree.enable_model_drag_dest (Gdk::ACTION_MOVE); + + _text_renderer = manage(new Gtk::CellRendererText()); + int nameColNum = _tree.append_column(_("Name"), *_text_renderer) - 1; + _name_column = _tree.get_column(nameColNum); + _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel); + + _tree.set_expander_column( *_tree.get_column(nameColNum) ); + _tree.set_search_column(_model->_colLabel); + + Gtk::CellRendererToggle * _toggle_renderer = manage(new Gtk::CellRendererToggle()); + int toggleColNum = _tree.append_column(_("Reverse"), *_toggle_renderer) - 1; + Gtk::TreeViewColumn* col = _tree.get_column(toggleColNum); + _toggle_renderer->set_activatable(true); + _toggle_renderer->signal_toggled().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_reverse_toggled)); + col->add_attribute(_toggle_renderer->property_active(), _model->_colReverse); + + //quick little hack -- newer versions of gtk gave the item zero space allotment + _scroller.set_size_request(-1, 120); + + _scroller.add(_tree); + _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); + //_scroller.set_shadow_type(Gtk::SHADOW_IN); + + oncanvas_editable = true; + +} + +OriginalPathArrayParam::~OriginalPathArrayParam() +{ + while (!_vector.empty()) { + PathAndDirection *w = _vector.back(); + _vector.pop_back(); + unlink(w); + delete w; + } + delete _model; +} + +void OriginalPathArrayParam::on_reverse_toggled(const Glib::ustring& path) +{ + Gtk::TreeModel::iterator iter = _store->get_iter(path); + Gtk::TreeModel::Row row = *iter; + PathAndDirection *w = row[_model->_colObject]; + row[_model->_colReverse] = !row[_model->_colReverse]; + w->reversed = row[_model->_colReverse]; + + gchar * full = param_getSVGValue(); + param_write_to_repr(full); + g_free(full); + DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Link path parameter to path")); +} + +void OriginalPathArrayParam::param_set_default() +{ + +} + +Gtk::Widget* OriginalPathArrayParam::param_newWidget() +{ + Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox()); + Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); + + vbox->pack_start(_scroller, Gtk::PACK_EXPAND_WIDGET); + + + { // Paste path to link button + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_link_button_click)); + hbox->pack_start(*pButton, Gtk::PACK_SHRINK); + pButton->set_tooltip_text(_("Link to path")); + } + + { // Remove linked path + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_REMOVE, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_remove_button_click)); + hbox->pack_start(*pButton, Gtk::PACK_SHRINK); + pButton->set_tooltip_text(_("Remove Path")); + } + + { // Move Down + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_GO_DOWN, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_down_button_click)); + hbox->pack_end(*pButton, Gtk::PACK_SHRINK); + pButton->set_tooltip_text(_("Move Down")); + } + + { // Move Down + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_GO_UP, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_up_button_click)); + hbox->pack_end(*pButton, Gtk::PACK_SHRINK); + pButton->set_tooltip_text(_("Move Up")); + } + + vbox->pack_end(*hbox, Gtk::PACK_SHRINK); + + vbox->show_all_children(true); + + return vbox; +} + +bool OriginalPathArrayParam::_selectIndex(const Gtk::TreeIter& iter, int* i) +{ + if ((*i)-- <= 0) { + _tree.get_selection()->select(iter); + return true; + } + return false; +} + +void OriginalPathArrayParam::on_up_button_click() +{ + Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected(); + if (iter) { + Gtk::TreeModel::Row row = *iter; + + int i = -1; + std::vector::iterator piter = _vector.begin(); + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); piter = iter, i++, iter++) { + if (*iter == row[_model->_colObject]) { + _vector.erase(iter); + _vector.insert(piter, row[_model->_colObject]); + break; + } + } + + gchar * full = param_getSVGValue(); + param_write_to_repr(full); + g_free(full); + + DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Move path up")); + + _store->foreach_iter(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::_selectIndex), &i)); + } +} + +void OriginalPathArrayParam::on_down_button_click() +{ + Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected(); + if (iter) { + Gtk::TreeModel::Row row = *iter; + + int i = 0; + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); i++, iter++) { + if (*iter == row[_model->_colObject]) { + std::vector::iterator niter = _vector.erase(iter); + if (niter != _vector.end()) { + niter++; + i++; + } + _vector.insert(niter, row[_model->_colObject]); + break; + } + } + + gchar * full = param_getSVGValue(); + param_write_to_repr(full); + g_free(full); + + DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Move path down")); + + _store->foreach_iter(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::_selectIndex), &i)); + } +} + +void OriginalPathArrayParam::on_remove_button_click() +{ + Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected(); + if (iter) { + Gtk::TreeModel::Row row = *iter; + remove_link(row[_model->_colObject]); + + gchar * full = param_getSVGValue(); + param_write_to_repr(full); + g_free(full); + + DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Remove path")); + } + +} + +void +OriginalPathArrayParam::on_link_button_click() +{ + Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); + Glib::ustring pathid = cm->getShapeOrTextObjectId(SP_ACTIVE_DESKTOP); + + if (pathid == "") { + return; + } + // add '#' at start to make it an uri. + pathid.insert(pathid.begin(), '#'); + + Inkscape::SVGOStringStream os; + bool foundOne = false; + for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); iter++) { + if (foundOne) { + os << "|"; + } else { + foundOne = true; + } + os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0"); + } + + if (foundOne) { + os << "|"; + } + + os << pathid.c_str() << ",0"; + + param_write_to_repr(os.str().c_str()); + DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Link path parameter to path")); +} + +void OriginalPathArrayParam::unlink(PathAndDirection* to) +{ + to->linked_modified_connection.disconnect(); + to->linked_delete_connection.disconnect(); + to->ref.detach(); + to->_pathvector = Geom::PathVector(); + if (to->href) { + g_free(to->href); + to->href = NULL; + } +} + +void OriginalPathArrayParam::remove_link(PathAndDirection* to) +{ + unlink(to); + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); iter++) { + if (*iter == to) { + PathAndDirection *w = *iter; + _vector.erase(iter); + delete w; + return; + } + } +} + +void OriginalPathArrayParam::linked_delete(SPObject */*deleted*/, PathAndDirection* /*to*/) +{ + //remove_link(to); + + gchar * full = param_getSVGValue(); + param_write_to_repr(full); + g_free(full); +} + +bool OriginalPathArrayParam::_updateLink(const Gtk::TreeIter& iter, PathAndDirection* pd) +{ + Gtk::TreeModel::Row row = *iter; + if (row[_model->_colObject] == pd) { + SPObject *obj = pd->ref.getObject(); + row[_model->_colLabel] = obj && obj->getId() ? ( obj->label() ? obj->label() : obj->getId() ) : pd->href; + return true; + } + return false; +} + +void OriginalPathArrayParam::linked_changed(SPObject */*old_obj*/, SPObject *new_obj, PathAndDirection* to) +{ + to->linked_delete_connection.disconnect(); + to->linked_modified_connection.disconnect(); + to->linked_transformed_connection.disconnect(); + + if (new_obj && SP_IS_ITEM(new_obj)) { + to->linked_delete_connection = new_obj->connectDelete(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_delete), to)); + to->linked_modified_connection = new_obj->connectModified(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_modified), to)); + to->linked_transformed_connection = SP_ITEM(new_obj)->connectTransformed(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_transformed), to)); + + linked_modified(new_obj, SP_OBJECT_MODIFIED_FLAG, to); + } else { + to->_pathvector = Geom::PathVector(); + SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); + _store->foreach_iter(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to)); + } +} + +void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/, PathAndDirection* to) +{ + if (!to) { + return; + } + SPCurve *curve = NULL; + if (SP_IS_SHAPE(linked_obj)) { + curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE(); + } + if (SP_IS_TEXT(linked_obj)) { + curve = SP_TEXT(linked_obj)->getNormalizedBpath(); + } + + if (curve == NULL) { + // curve invalid, set empty pathvector + to->_pathvector = Geom::PathVector(); + } else { + to->_pathvector = curve->get_pathvector(); + curve->unref(); + } +} + +void OriginalPathArrayParam::linked_modified(SPObject *linked_obj, guint flags, PathAndDirection* to) +{ + if (!to) { + return; + } + setPathVector(linked_obj, flags, to); + SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); + _store->foreach_iter(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to)); +} + +bool OriginalPathArrayParam::param_readSVGValue(const gchar* strvalue) +{ + if (strvalue) { + while (!_vector.empty()) { + PathAndDirection *w = _vector.back(); + unlink(w); + _vector.pop_back(); + delete w; + } + _store->clear(); + + gchar ** strarray = g_strsplit(strvalue, "|", 0); + for (gchar ** iter = strarray; *iter != NULL; iter++) { + if ((*iter)[0] == '#') { + gchar ** substrarray = g_strsplit(*iter, ",", 0); + PathAndDirection* w = new PathAndDirection((SPObject *)param_effect->getLPEObj()); + w->href = g_strdup(*substrarray); + w->reversed = *(substrarray+1) != NULL && (*(substrarray+1))[0] == '1'; + + w->linked_changed_connection = w->ref.changedSignal().connect(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_changed), w)); + w->ref.attach(URI(w->href)); + + _vector.push_back(w); + + Gtk::TreeModel::iterator iter = _store->append(); + Gtk::TreeModel::Row row = *iter; + SPObject *obj = w->ref.getObject(); + + row[_model->_colObject] = w; + row[_model->_colLabel] = obj ? ( obj->label() ? obj->label() : obj->getId() ) : w->href; + row[_model->_colReverse] = w->reversed; + g_strfreev (substrarray); + } + } + g_strfreev (strarray); + return true; + } + return false; +} + +gchar * OriginalPathArrayParam::param_getSVGValue() const +{ + Inkscape::SVGOStringStream os; + bool foundOne = false; + for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); iter++) { + if (foundOne) { + os << "|"; + } else { + foundOne = true; + } + os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0"); + } + gchar * str = g_strdup(os.str().c_str()); + return str; +} + +} /* namespace LivePathEffect */ + +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h new file mode 100644 index 000000000..6c792613f --- /dev/null +++ b/src/live_effects/parameter/originalpatharray.h @@ -0,0 +1,122 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALPATHARRAY_H +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALPATHARRAY_H + +/* + * Inkscape::LivePathEffectParameters + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include + +#include +#include +#include +#include + +#include "live_effects/parameter/parameter.h" +#include "live_effects/parameter/path-reference.h" + +#include "svg/svg.h" +#include "svg/stringstream.h" +#include "path-reference.h" +#include "sp-object.h" + +namespace Inkscape { + +namespace LivePathEffect { + +class PathAndDirection { +public: + PathAndDirection(SPObject *owner) + : href(NULL), + ref(owner), + _pathvector(Geom::PathVector()), + reversed(false) + { + + } + gchar *href; + URIReference ref; + std::vector _pathvector; + bool reversed; + + sigc::connection linked_changed_connection; + sigc::connection linked_delete_connection; + sigc::connection linked_modified_connection; + sigc::connection linked_transformed_connection; +}; + +class OriginalPathArrayParam : public Parameter { +public: + class ModelColumns; + + OriginalPathArrayParam( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + Inkscape::UI::Widget::Registry* wr, + Effect* effect); + + virtual ~OriginalPathArrayParam(); + + virtual Gtk::Widget * param_newWidget(); + virtual bool param_readSVGValue(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + virtual void param_set_default(); + + /** Disable the canvas indicators of parent class by overriding this method */ + virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; + /** Disable the canvas indicators of parent class by overriding this method */ + virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector & /*hp_vec*/) {}; + + std::vector _vector; + +protected: + bool _updateLink(const Gtk::TreeIter& iter, PathAndDirection* pd); + bool _selectIndex(const Gtk::TreeIter& iter, int* i); + void unlink(PathAndDirection* to); + void remove_link(PathAndDirection* to); + void setPathVector(SPObject *linked_obj, guint flags, PathAndDirection* to); + + void linked_changed(SPObject *old_obj, SPObject *new_obj, PathAndDirection* to); + void linked_modified(SPObject *linked_obj, guint flags, PathAndDirection* to); + void linked_transformed(Geom::Affine const *, SPItem *, PathAndDirection*) {} + void linked_delete(SPObject *deleted, PathAndDirection* to); + + ModelColumns *_model; + Glib::RefPtr _store; + Gtk::TreeView _tree; + Gtk::CellRendererText *_text_renderer; + Gtk::CellRendererToggle *_toggle_renderer; + Gtk::TreeView::Column *_name_column; + Gtk::ScrolledWindow _scroller; + + void on_link_button_click(); + void on_remove_button_click(); + void on_up_button_click(); + void on_down_button_click(); + void on_reverse_toggled(const Glib::ustring& path); + +private: + OriginalPathArrayParam(const OriginalPathArrayParam&); + OriginalPathArrayParam& operator=(const OriginalPathArrayParam&); +}; + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 647986da6..427be8065 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -4,8 +4,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include - +#include "ui/dialog/lpe-powerstroke-properties.h" #include "live_effects/parameter/powerstrokepointarray.h" #include "live_effects/effect.h" @@ -21,6 +20,8 @@ #include "desktop.h" #include "live_effects/lpeobject.h" +#include + namespace Inkscape { namespace LivePathEffect { @@ -102,6 +103,23 @@ PowerStrokePointArrayParam::recalculate_controlpoints_for_new_pwd2(Geom::Piecewi } } +float PowerStrokePointArrayParam::median_width() +{ + size_t size = _vector.size(); + if (size > 0) + { + if (size % 2 == 0) + { + return (_vector[size / 2 - 1].y() + _vector[size / 2].y()) / 2; + } + else + { + return _vector[size / 2].y(); + } + } + return 1; +} + void PowerStrokePointArrayParam::set_pwd2(Geom::Piecewise > const & pwd2_in, Geom::Piecewise > const & pwd2_normal_in) { @@ -117,7 +135,7 @@ PowerStrokePointArrayParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotMode knot_mode = mode; knot_color = color; } - +/* class PowerStrokePointArrayParamKnotHolderEntity : public KnotHolderEntity { public: PowerStrokePointArrayParamKnotHolderEntity(PowerStrokePointArrayParam *p, unsigned int index); @@ -127,7 +145,7 @@ public: virtual Geom::Point knot_get() const; virtual void knot_click(guint state); - /** Checks whether the index falls within the size of the parameter's vector */ + // Checks whether the index falls within the size of the parameter's vector bool valid_index(unsigned int index) const { return (_pparam->_vector.size() > index); }; @@ -135,7 +153,7 @@ public: private: PowerStrokePointArrayParam *_pparam; unsigned int _index; -}; +};*/ PowerStrokePointArrayParamKnotHolderEntity::PowerStrokePointArrayParamKnotHolderEntity(PowerStrokePointArrayParam *p, unsigned int index) : _pparam(p), @@ -184,6 +202,12 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_get() const return canvas_point; } +void PowerStrokePointArrayParamKnotHolderEntity::knot_set_offset(Geom::Point offset) +{ + _pparam->_vector.at(_index) = Geom::Point(offset.x(), offset.y() / 2); + this->parent_holder->knot_ungrabbed_handler(this->knot, 0); +} + void PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) { @@ -226,10 +250,15 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) // add knot to knotholder PowerStrokePointArrayParamKnotHolderEntity *e = new PowerStrokePointArrayParamKnotHolderEntity(_pparam, _index+1); e->create( this->desktop, this->item, parent_holder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Stroke width control point: drag to alter the stroke width. Ctrl+click adds a control point, Ctrl+Alt+click deletes it."), + _("Stroke width control point: drag to alter the stroke width. Ctrl+click adds a control point, Ctrl+Alt+click deletes it, Shift+click launches width dialog."), _pparam->knot_shape, _pparam->knot_mode, _pparam->knot_color); parent_holder->add(e); } + } + else if ((state & GDK_MOD1_MASK) || (state & GDK_SHIFT_MASK)) + { + Geom::Point offset = Geom::Point(_pparam->_vector.at(_index).x(), _pparam->_vector.at(_index).y() * 2); + Inkscape::UI::Dialogs::PowerstrokePropertiesDialog::showDialog(this->desktop, offset, this); } } @@ -238,7 +267,7 @@ void PowerStrokePointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, S for (unsigned int i = 0; i < _vector.size(); ++i) { PowerStrokePointArrayParamKnotHolderEntity *e = new PowerStrokePointArrayParamKnotHolderEntity(this, i); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Stroke width control point: drag to alter the stroke width. Ctrl+click adds a control point, Ctrl+Alt+click deletes it."), + _("Stroke width control point: drag to alter the stroke width. Ctrl+click adds a control point, Ctrl+Alt+click deletes it, Shift+click launches width dialog."), knot_shape, knot_mode, knot_color); knotholder->add(e); } diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index e1fa440f2..911bbc82d 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -20,8 +20,6 @@ namespace Inkscape { namespace LivePathEffect { -class PowerStrokePointArrayParamKnotHolderEntity; - class PowerStrokePointArrayParam : public ArrayParam { public: PowerStrokePointArrayParam( const Glib::ustring& label, @@ -37,6 +35,8 @@ public: void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); + float median_width(); + virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); @@ -60,6 +60,25 @@ private: Geom::Piecewise > last_pwd2_normal; }; +class PowerStrokePointArrayParamKnotHolderEntity : public KnotHolderEntity { +public: + PowerStrokePointArrayParamKnotHolderEntity(PowerStrokePointArrayParam *p, unsigned int index); + virtual ~PowerStrokePointArrayParamKnotHolderEntity() {} + + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; + virtual void knot_set_offset(Geom::Point offset); + virtual void knot_click(guint state); + + /** Checks whether the index falls within the size of the parameter's vector */ + bool valid_index(unsigned int index) const { + return (_pparam->_vector.size() > index); + }; + +private: + PowerStrokePointArrayParam *_pparam; + unsigned int _index; +}; } //namespace LivePathEffect diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp new file mode 100644 index 000000000..0d03432c3 --- /dev/null +++ b/src/live_effects/parameter/transformedpoint.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "ui/widget/registered-widget.h" +#include "live_effects/parameter/transformedpoint.h" +#include "sp-lpe-item.h" +#include "knotholder.h" +#include "svg/svg.h" +#include "svg/stringstream.h" + +#include "live_effects/effect.h" +#include "desktop.h" +#include "verbs.h" + +#include + +namespace Inkscape { + +namespace LivePathEffect { + +TransformedPointParam::TransformedPointParam( const Glib::ustring& label, const Glib::ustring& tip, + const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, + Effect* effect, Geom::Point default_vector, + bool dontTransform) + : Parameter(label, tip, key, wr, effect), + defvalue(default_vector), + origin(0.,0.), + vector(default_vector), + noTransform(dontTransform) +{ + vec_knot_shape = SP_KNOT_SHAPE_DIAMOND; + vec_knot_mode = SP_KNOT_MODE_XOR; + vec_knot_color = 0xffffb500; +} + +TransformedPointParam::~TransformedPointParam() +{ + +} + +void +TransformedPointParam::param_set_default() +{ + setOrigin(Geom::Point(0.,0.)); + setVector(defvalue); +} + +bool +TransformedPointParam::param_readSVGValue(const gchar * strvalue) +{ + gchar ** strarray = g_strsplit(strvalue, ",", 4); + if (!strarray) { + return false; + } + double val[4]; + unsigned int i = 0; + while (i < 4 && strarray[i]) { + if (sp_svg_number_read_d(strarray[i], &val[i]) != 0) { + i++; + } else { + break; + } + } + g_strfreev (strarray); + if (i == 4) { + setOrigin( Geom::Point(val[0], val[1]) ); + setVector( Geom::Point(val[2], val[3]) ); + return true; + } + return false; +} + +gchar * +TransformedPointParam::param_getSVGValue() const +{ + Inkscape::SVGOStringStream os; + os << origin << " , " << vector; + gchar * str = g_strdup(os.str().c_str()); + return str; +} + +Gtk::Widget * +TransformedPointParam::param_newWidget() +{ + Inkscape::UI::Widget::RegisteredVector * pointwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredVector( param_label, + param_tooltip, + param_key, + *param_wr, + param_effect->getRepr(), + param_effect->getSPDoc() ) ); + pointwdg->setPolarCoords(); + pointwdg->setValue( vector, origin ); + pointwdg->clearProgrammatically(); + pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change vector parameter")); + + Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() ); + static_cast(hbox)->pack_start(*pointwdg, true, true); + static_cast(hbox)->show_all_children(); + + return dynamic_cast (hbox); +} + +void +TransformedPointParam::set_and_write_new_values(Geom::Point const &new_origin, Geom::Point const &new_vector) +{ + setValues(new_origin, new_vector); + gchar * str = param_getSVGValue(); + param_write_to_repr(str); + g_free(str); +} + +void +TransformedPointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) +{ + if (!noTransform) { + set_and_write_new_values( origin * postmul, vector * postmul.withoutTranslation() ); + } +} + + +void +TransformedPointParam::set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) +{ + vec_knot_shape = shape; + vec_knot_mode = mode; + vec_knot_color = color; +} + +void +TransformedPointParam::set_oncanvas_color(guint32 color) +{ + vec_knot_color = color; +} + +class TransformedPointParamKnotHolderEntity_Vector : public KnotHolderEntity { +public: + TransformedPointParamKnotHolderEntity_Vector(TransformedPointParam *p) : param(p) { } + virtual ~TransformedPointParamKnotHolderEntity_Vector() {} + + virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { + Geom::Point const s = p - param->origin; + /// @todo implement angle snapping when holding CTRL + param->setVector(s); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + }; + virtual Geom::Point knot_get() const{ + return param->origin + param->vector; + }; + virtual void knot_click(guint /*state*/){ + g_print ("This is the vector handle associated to parameter '%s'\n", param->param_key.c_str()); + }; + +private: + TransformedPointParam *param; +}; + +void +TransformedPointParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +{ + TransformedPointParamKnotHolderEntity_Vector *vector_e = new TransformedPointParamKnotHolderEntity_Vector(this); + vector_e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), vec_knot_shape, vec_knot_mode, vec_knot_color); + knotholder->add(vector_e); +} + +} /* namespace LivePathEffect */ + +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/transformedpoint.h b/src/live_effects/parameter/transformedpoint.h new file mode 100644 index 000000000..c96bedb53 --- /dev/null +++ b/src/live_effects/parameter/transformedpoint.h @@ -0,0 +1,82 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_TRANSFORMED_POINT_H +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_TRANSFORMED_POINT_H + +/* + * Inkscape::LivePathEffectParameters + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include +#include <2geom/point.h> + +#include "live_effects/parameter/parameter.h" + +#include "knot-holder-entity.h" + +namespace Inkscape { + +namespace LivePathEffect { + + +class TransformedPointParam : public Parameter { +public: + TransformedPointParam( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + Inkscape::UI::Widget::Registry* wr, + Effect* effect, + Geom::Point default_vector = Geom::Point(1,0), + bool dontTransform = false); + virtual ~TransformedPointParam(); + + virtual Gtk::Widget * param_newWidget(); + inline const gchar *handleTip() const { return param_tooltip.c_str(); } + + virtual bool param_readSVGValue(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + + Geom::Point getVector() const { return vector; }; + Geom::Point getOrigin() const { return origin; }; + void setValues(Geom::Point const &new_origin, Geom::Point const &new_vector) { setVector(new_vector); setOrigin(new_origin); }; + void setVector(Geom::Point const &new_vector) { vector = new_vector; }; + void setOrigin(Geom::Point const &new_origin) { origin = new_origin; }; + virtual void param_set_default(); + + void set_and_write_new_values(Geom::Point const &new_origin, Geom::Point const &new_vector); + + virtual void param_transform_multiply(Geom::Affine const &postmul, bool set); + + void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); + void set_oncanvas_color(guint32 color); + + virtual bool providesKnotHolderEntities() const { return true; } + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + +private: + TransformedPointParam(const TransformedPointParam&); + TransformedPointParam& operator=(const TransformedPointParam&); + + Geom::Point defvalue; + + Geom::Point origin; + Geom::Point vector; + + bool noTransform; + + /// The looks of the vector and origin knots oncanvas + SPKnotShapeType vec_knot_shape; + SPKnotModeType vec_knot_mode; + guint32 vec_knot_color; + + friend class TransformedPointParamKnotHolderEntity_Vector; +}; + + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif diff --git a/src/live_effects/pathoutlineprovider.cpp b/src/live_effects/pathoutlineprovider.cpp new file mode 100644 index 000000000..21a0fb809 --- /dev/null +++ b/src/live_effects/pathoutlineprovider.cpp @@ -0,0 +1,803 @@ +/* Author: + * Liam P. White + * + * Copyright (C) 2014 Author + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <2geom/angle.h> +#include <2geom/path.h> +#include <2geom/circle.h> +#include <2geom/sbasis-to-bezier.h> +#include <2geom/shape.h> +#include <2geom/transforms.h> +#include <2geom/path-sink.h> +#include + +#include "pathoutlineprovider.h" +#include "livarot/path-description.h" +#include "helper/geom-nodetype.h" +#include "svg/svg.h" + +namespace Geom { +/** +* Refer to: Weisstein, Eric W. "Circle-Circle Intersection." + From MathWorld--A Wolfram Web Resource. + http://mathworld.wolfram.com/Circle-CircleIntersection.html +* +* @return 0 if no intersection +* @return 1 if one circle is contained in the other +* @return 2 if intersections are found (they are written to p0 and p1) +*/ +static int circle_circle_intersection(Circle const &circle0, Circle const &circle1, Point & p0, Point & p1) +{ + Point X0 = circle0.center(); + double r0 = circle0.ray(); + Point X1 = circle1.center(); + double r1 = circle1.ray(); + + /* dx and dy are the vertical and horizontal distances between + * the circle centers. + */ + Point D = X1 - X0; + + /* Determine the straight-line distance between the centers. */ + double d = L2(D); + + /* Check for solvability. */ + if (d > (r0 + r1)) { + /* no solution. circles do not intersect. */ + return 0; + } + if (d <= fabs(r0 - r1)) { + /* no solution. one circle is contained in the other */ + return 1; + } + + /* 'point 2' is the point where the line through the circle + * intersection points crosses the line between the circle + * centers. + */ + + /* Determine the distance from point 0 to point 2. */ + double a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ; + + /* Determine the coordinates of point 2. */ + Point p2 = X0 + D * (a/d); + + /* Determine the distance from point 2 to either of the + * intersection points. + */ + double h = std::sqrt((r0*r0) - (a*a)); + + /* Now determine the offsets of the intersection points from + * point 2. + */ + Point r = (h/d)*rot90(D); + + /* Determine the absolute intersection points. */ + p0 = p2 + r; + p1 = p2 - r; + + return 2; +} +/** +* Find circle that touches inside of the curve, with radius matching the curvature, at time value \c t. +* Because this method internally uses unitTangentAt, t should be smaller than 1.0 (see unitTangentAt). +*/ +static Circle touching_circle( D2 const &curve, double t, double tol=0.01 ) +{ + D2 dM=derivative(curve); + if ( are_near(L2sq(dM(t)),0.) ) { + dM=derivative(dM); + } + if ( are_near(L2sq(dM(t)),0.) ) { // try second time + dM=derivative(dM); + } + Piecewise > unitv = unitVector(dM,tol); + Piecewise dMlength = dot(Piecewise >(dM),unitv); + Piecewise k = cross(derivative(unitv),unitv); + k = divide(k,dMlength,tol,3); + double curv = k(t); // note that this value is signed + + Geom::Point normal = unitTangentAt(curve, t).cw(); + double radius = 1/curv; + Geom::Point center = curve(t) + radius*normal; + return Geom::Circle(center, fabs(radius)); +} + +std::vector split_at_cusps(const Geom::Path& in) +{ + PathVector out = PathVector(); + Path temp = Path(); + + for (unsigned i = 0; i < in.size(); i++) { + temp.append(in[i]); + if ( get_nodetype(in[i], in[i + 1]) != Geom::NODE_SMOOTH ) { + out.push_back(temp); + temp = Path(); + } + } + if (temp.size() > 0) { + out.push_back(temp); + } + return out; +} + +Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2 const & sbasis_in) +{ + std::vector temp; + sbasis_to_bezier(temp, sbasis_in, 4); + return Geom::CubicBezier( temp ); +} + +static boost::optional intersection_point(Geom::Point const & origin_a, Geom::Point const & vector_a, Geom::Point const & origin_b, Geom::Point const & vector_b) +{ + Geom::Coord denom = cross(vector_b, vector_a); + if (!Geom::are_near(denom,0.)) { + Geom::Coord t = (cross(origin_a,vector_b) + cross(vector_b,origin_b)) / denom; + return origin_a + t * vector_a; + } + return boost::none; +} + +} // namespace Geom + +namespace Outline { + +typedef Geom::D2 D2SB; +typedef Geom::Piecewise PWD2; + +// UTILITY + +unsigned bezierOrder (const Geom::Curve* curve_in) +{ + using namespace Geom; + if ( const BezierCurve* bz = dynamic_cast(curve_in) ) { + return bz->order(); + } + return 0; +} + +/** + * @return true if the angle formed by the curves and their handles is greater than 180 degrees clockwise, otherwise false. + */ +bool outside_angle (const Geom::Curve& cbc1, const Geom::Curve& cbc2) +{ + Geom::Point start_point; + Geom::Point cross_point = cbc1.finalPoint(); + Geom::Point end_point; + + if (cross_point != cbc2.initialPoint()) { + printf("WARNING: Non-contiguous path in Outline::outside_angle()"); + return false; + } + + Geom::CubicBezier cubicBezier = Geom::sbasis_to_cubicbezier(cbc1.toSBasis()); + start_point = cubicBezier [2]; + + /* + * Because the node editor does not yet support true quadratics, paths are converted to + * cubic beziers in the node tool with degenerate handles on one side. + */ + + if (are_near(start_point, cross_point, 0.0000001)) { + start_point = cubicBezier [1]; + } + cubicBezier = Geom::sbasis_to_cubicbezier(cbc2.toSBasis()); + end_point = cubicBezier [1]; + if (are_near(end_point, cross_point, 0.0000001)) { + end_point = cubicBezier [2]; + } + + // got our three points, now let's see what their clockwise angle is + + // Definition of a Graham scan + + /******************************************************************** + # Three points are a counter-clockwise turn if ccw > 0, clockwise if + # ccw < 0, and collinear if ccw = 0 because ccw is a determinant that + # gives the signed area of the triangle formed by p1, p2 and p3. + function ccw(p1, p2, p3): + return (p2.x - p1.x)*(p3.y - p1.y) - (p2.y - p1.y)*(p3.x - p1.x) + *********************************************************************/ + + double ccw = ( (cross_point.x() - start_point.x()) * (end_point.y() - start_point.y()) ) - + ( (cross_point.y() - start_point.y()) * (end_point.x() - start_point.x()) ); + return ccw > 0; +} + +// LINE JOINS + +typedef Geom::BezierCurveN<1u> BezierLine; + +/** + * Removes the crossings on an interior join. + * @param path_builder Contains the incoming segment; result is appended to this + * @param outgoing The outgoing segment + */ +void joinInside(Geom::Path& path_builder, Geom::Curve const& outgoing) +{ + Geom::Curve const& incoming = path_builder.back(); + + // Using Geom::crossings to find intersections between two curves + Geom::Crossings cross = Geom::crossings(incoming, outgoing); + if (!cross.empty()) { + // Crossings found, create the join + Geom::CubicBezier cubic = Geom::sbasis_to_cubicbezier(incoming.toSBasis()); + cubic = cubic.subdivide(cross[0].ta).first; + // erase the last segment, as we're going to overwrite it now + path_builder.erase_last(); + path_builder.append(cubic, Geom::Path::STITCH_DISCONTINUOUS); + + cubic = Geom::sbasis_to_cubicbezier(outgoing.toSBasis()); + cubic = cubic.subdivide(cross[0].tb).second; + path_builder.append(cubic, Geom::Path::STITCH_DISCONTINUOUS); + } else { + // No crossings occurred, or Geom::crossings() failed; default to bevel + if (Geom::are_near(incoming.finalPoint(), outgoing.initialPoint())) { + path_builder.appendNew(outgoing.initialPoint()); + } else { + path_builder.setFinal(outgoing.initialPoint()); + } + } +} + +/** + * Try to create a miter join. Falls back to bevel if no miter can be created. + * @param path_builder Path to append curves to; back() is the incoming curve + * @param outgoing Outgoing curve. + * @param miter_limit When mitering, don't exceed this length + * @param line_width The thickness of the line. + */ +void miter_curves(Geom::Path& path_builder, Geom::Curve const& outgoing, double miter_limit, double line_width) +{ + using namespace Geom; + Curve const& incoming = path_builder.back(); + Point tang1 = unitTangentAt(Geom::reverse(incoming.toSBasis()), 0.); + Point tang2 = unitTangentAt(outgoing.toSBasis(), 0); + + boost::optional p = intersection_point (incoming.finalPoint(), tang1, outgoing.initialPoint(), tang2); + if (p) { + // check size of miter + Point point_on_path = incoming.finalPoint() - rot90(tang1) * line_width; + Coord len = distance(*p, point_on_path); + if (len <= miter_limit) { + // miter OK + path_builder.appendNew(*p); + } + } + path_builder.appendNew(outgoing.initialPoint()); +} + +/** + * Smoothly extrapolate curves along a circular route. Falls back to miter if necessary. + * @param path_builder Path to append curves to; back() is the incoming curve + * @param outgoing Outgoing curve. + * @param miter_limit When mitering, don't exceed this length + * @param line_width The thickness of the line. Used for miter fallback. + */ +void extrapolate_curves(Geom::Path& path_builder, Geom::Curve const& outgoing, double miter_limit, double line_width) +{ + Geom::Curve const& incoming = path_builder.back(); + Geom::Point endPt = outgoing.initialPoint(); + + // The method used when extrapolating curves fails to work when either side of the join to be extrapolated + // is a line segment. When this situation is encountered, fall back to a regular miter join. + bool lineProblem = (dynamic_cast(&incoming)) || (dynamic_cast(&outgoing)); + if (lineProblem == false) { + // Geom::Point tang1 = Geom::unitTangentAt(Geom::reverse(incoming.toSBasis()), 0.); + Geom::Point tang2 = Geom::unitTangentAt(outgoing.toSBasis(), 0); + + Geom::Circle circle1 = Geom::touching_circle(Geom::reverse(incoming.toSBasis()), 0.); + Geom::Circle circle2 = Geom::touching_circle(outgoing.toSBasis(), 0); + + Geom::Point points[2]; + int solutions = Geom::circle_circle_intersection(circle1, circle2, points[0], points[1]); + if (solutions == 2) { + Geom::Point sol(0,0); + if ( dot(tang2,points[0]-endPt) > 0 ) { + // points[0] is bad, choose points[1] + sol = points[1]; + } else if ( dot(tang2,points[1]-endPt) > 0 ) { // points[0] could be good, now check points[1] + // points[1] is bad, choose points[0] + sol = points[0]; + } else { + // both points are good, choose nearest + sol = ( distanceSq(endPt, points[0]) < distanceSq(endPt, points[1]) ) ? points[0] : points[1]; + } + + Geom::EllipticalArc *arc0 = circle1.arc(incoming.finalPoint(), 0.5*(incoming.finalPoint()+sol), sol, true); + Geom::EllipticalArc *arc1 = circle2.arc(sol, 0.5*(sol+endPt), endPt, true); + try { + if (arc0) { + path_builder.append (arc0->toSBasis()); + delete arc0; + arc0 = NULL; + } else { + throw std::exception(); + } + + if (arc1) { + path_builder.append (arc1->toSBasis()); + delete arc1; + arc1 = NULL; + } else { + throw std::exception(); + } + + } catch (std::exception const & ex) { + printf("WARNING: Error extrapolating line join: %s\n", ex.what()); + path_builder.appendNew(endPt); + } + } else { + // 1 or no solutions found, default to miter + miter_curves(path_builder, outgoing, miter_limit, line_width); + } + } else { + // Line segments exist + miter_curves(path_builder, outgoing, miter_limit, line_width); + } +} + +/** + * Extrapolate curves by reflecting them along the line that would be given by beveling the join. + * @param path_builder Path to append curves to; back() is the incoming curve + * @param outgoing Outgoing curve. + * @param miter_limit When mitering, don't exceed this length + * @param line_width The thickness of the line. Used for miter fallback. + */ +void reflect_curves(Geom::Path& path_builder, Geom::Curve const& outgoing, double miter_limit, double line_width) +{ + using namespace Geom; + Curve const& incoming = path_builder.back(); + // On the outside, we'll take the incoming curve, the outgoing curve, and + // reflect them over the line formed by taking the unit tangent vector at times + // 0 and 1, respectively, rotated by 90 degrees. + Crossings cross; + + // reflect curves along the line that would be given by beveling the join + Point tang1 = unitTangentAt(reverse(incoming.toSBasis()), 0.); + D2SB newcurve1 = incoming.toSBasis() * reflection(-rot90(tang1), incoming.finalPoint()); + CubicBezier bzr1 = sbasis_to_cubicbezier(reverse(newcurve1)); + + Point tang2 = Geom::unitTangentAt(outgoing.toSBasis(), 0.); + D2SB newcurve2 = outgoing.toSBasis() * reflection(-rot90(tang2), outgoing.initialPoint()); + CubicBezier bzr2 = sbasis_to_cubicbezier(reverse(newcurve2)); + + cross = crossings(bzr1, bzr2); + if (cross.empty()) { + // paths don't cross, fall back to miter + miter_curves(path_builder, outgoing, miter_limit, line_width); + } else { + // reflected join + std::pair sub1 = bzr1.subdivide(cross[0].ta); + std::pair sub2 = bzr2.subdivide(cross[0].tb); + + // TODO it seems as if a bug in 2geom sometimes doesn't catch the first + // crossing of paths, but the second instead; but only sometimes. + path_builder.appendNew (sub1.first[1], sub1.first[2], sub2.second[0]); + path_builder.appendNew (sub2.second[1], sub2.second[2], outgoing.initialPoint()); + } +} + +// Ideal function pointer we want to pass +typedef void JoinFunc(Geom::Path& /*path_builder*/, Geom::Curve const& /*outgoing*/, double /*miter_limit*/, double /*line_width*/); + +/** + * Helper function for repeated logic in outlineHalf. + */ +static void outlineHelper(Geom::Path& path_builder, Geom::PathVector* path_vec, bool outside, double width, double miter, JoinFunc func) +{ + Geom::Curve * cbc2 = path_vec->front()[0].duplicate(); + + if (outside) { + func(path_builder, *cbc2, miter, width); + } else { + joinInside(path_builder, *cbc2); + } + + // store it + Geom::Path temp_path = path_vec->front(); + if (!outside) { + // erase the first segment since the inside join code already appended it + temp_path.erase(temp_path.begin()); + } + + if (temp_path.initialPoint() != path_builder.finalPoint()) { + temp_path.setInitial(path_builder.finalPoint()); + } + + path_builder.append(temp_path); + + delete cbc2; +} + +/** + * Offsets exactly one half of a bezier spline (path). + * @param path_in The input path to use. (To create the other side use path_in.reverse() ) + * @param line_width the line width to use (usually you want to divide this by 2) + * @param miter_limit the miter parameter + * @param func Join function to apply at each join. + */ + +Geom::Path outlineHalf(const Geom::Path& path_in, double line_width, double miter_limit, JoinFunc func) +{ + // NOTE: it is important to notice the distinction between a Geom::Path and a livarot ::Path here! + // if you do not see "Geom::" there is a different function set! + + Geom::PathVector pv = split_at_cusps(path_in); + + ::Path to_outline; + ::Path outlined_result; + + Geom::Path path_builder = Geom::Path(); // the path to store the result in + Geom::PathVector* path_vec; // needed because livarot returns a pointer (TODO make this not a pointer) + + // Do two curves at a time for efficiency, since the join function needs to know the outgoing curve as well + const size_t k = pv.size(); + for (size_t u = 0; u < k; u += 2) { + to_outline = Path(); + outlined_result = Path(); + + to_outline.LoadPath(pv[u], Geom::identity(), false, false); + to_outline.OutsideOutline(&outlined_result, line_width / 2, join_straight, butt_straight, 10); + // now a curve has been outside outlined and loaded into outlined_result + + // get the Geom::Path + path_vec = outlined_result.MakePathVector(); + + // on the first run through, there is no join + if (u == 0) { + path_builder.start(path_vec->front().initialPoint()); + path_builder.append(path_vec->front()); + } else { + outlineHelper(path_builder, path_vec, outside_angle(pv[u-1][pv[u-1].size()-1], pv[u][0]), line_width, miter_limit, func); + } + + // outline the next segment, but don't store it yet + if (path_vec) + delete path_vec; + path_vec = NULL; + + // odd number of paths + if (u < k - 1) { + outlined_result = Path(); + to_outline = Path(); + + to_outline.LoadPath(pv[u+1], Geom::Affine(), false, false); + to_outline.OutsideOutline(&outlined_result, line_width / 2, join_straight, butt_straight, 10); + + path_vec = outlined_result.MakePathVector(); + outlineHelper(path_builder, path_vec, outside_angle(pv[u][pv[u].size()-1], pv[u+1][0]), line_width, miter_limit, func); + + if (path_vec) + delete path_vec; + path_vec = NULL; + } + } + + if (path_in.closed()) { + Geom::Curve * cbc1; + Geom::Curve * cbc2; + + if ( path_in[path_in.size()].isDegenerate() ) { + // handle case for last segment curved + outlined_result = Path(); + to_outline = Path(); + + Geom::Path oneCurve; oneCurve.append(path_in[0]); + + to_outline.LoadPath(oneCurve, Geom::Affine(), false, false); + to_outline.OutsideOutline(&outlined_result, line_width / 2, join_straight, butt_straight, 10); + + path_vec = outlined_result.MakePathVector(); + + cbc1 = path_builder[path_builder.size() - 1].duplicate(); + cbc2 = path_vec->front()[0].duplicate(); + + delete path_vec; + } else { + // handle case for last segment straight + // since the path doesn't actually give us access to it, we'll do it ourselves + outlined_result = Path(); + to_outline = Path(); + + Geom::Path oneCurve; oneCurve.append(Geom::LineSegment(path_in.finalPoint(), path_in.initialPoint())); + + to_outline.LoadPath(oneCurve, Geom::Affine(), false, false); + to_outline.OutsideOutline(&outlined_result, line_width / 2, join_straight, butt_straight, 10); + + path_vec = outlined_result.MakePathVector(); + + cbc1 = path_builder[path_builder.size() - 1].duplicate(); + cbc2 = (*path_vec)[0] [0].duplicate(); + + outlineHelper(path_builder, path_vec, outside_angle(path_in[path_in.size()-1], oneCurve[0]), line_width, miter_limit, func); + + delete cbc1; + cbc1 = cbc2->duplicate(); + delete path_vec; + + oneCurve = Geom::Path(); oneCurve.append(path_in[0]); + + to_outline.LoadPath(oneCurve, Geom::Affine(), false, false); + to_outline.OutsideOutline(&outlined_result, line_width / 2, join_straight, butt_straight, 10); + + path_vec = outlined_result.MakePathVector(); + delete cbc2; cbc2 = (*path_vec)[0] [0].duplicate(); + delete path_vec; + } + + Geom::Path temporary; + temporary.append(*cbc1); + + Geom::Curve const & prev_curve = path_in[path_in.size()].isDegenerate() ? path_in[path_in.size() - 1] : path_in[path_in.size()]; + Geom::Path isStraight; + isStraight.append(prev_curve); + isStraight.append(path_in[0]); + // does closing path require a join? + if (Geom::split_at_cusps(isStraight).size() > 1) { + bool outside = outside_angle(prev_curve, path_in[0]); + if (outside) { + func(temporary, *cbc2, miter_limit, line_width); + } else { + joinInside(temporary, *cbc2); + path_builder.erase(path_builder.begin()); + } + + // extract the appended curves + path_builder.erase_last(); + if (Geom::are_near(path_builder.finalPoint(), temporary.initialPoint())) { + path_builder.setFinal(temporary.initialPoint()); + } else { + path_builder.appendNew(temporary.initialPoint()); + } + path_builder.append(temporary); + } else { + // closing path does not require a join + path_builder.setFinal(path_builder.initialPoint()); + } + path_builder.close(); + + if (cbc1) delete cbc1; + if (cbc2) delete cbc2; + } + + return path_builder; +} + +Geom::PathVector outlinePath(const Geom::PathVector& path_in, double line_width, LineJoinType join, ButtTypeMod butt, double miter_lim, bool extrapolate, double start_lean, double end_lean) +{ + Geom::PathVector path_out; + + unsigned pv_size = path_in.size(); + for (unsigned i = 0; i < pv_size; i++) { + + if (path_in[i].size() > 1) { + Geom::Path with_direction; + Geom::Path against_direction; + + with_direction = Outline::outlineHalf(path_in[i], -line_width, miter_lim, extrapolate ? extrapolate_curves : reflect_curves); + against_direction = Outline::outlineHalf(path_in[i].reverse(), -line_width, miter_lim, extrapolate ? extrapolate_curves : reflect_curves); + + Geom::PathBuilder pb; + + pb.moveTo(with_direction.initialPoint()); + pb.append(with_direction); + + //add in our line caps + if (!path_in[i].closed()) { + switch (butt) { + case BUTT_STRAIGHT: + pb.lineTo(against_direction.initialPoint()); + break; + case BUTT_ROUND: + pb.arcTo((-line_width) / 2, (-line_width) / 2, 0., true, true, against_direction.initialPoint() ); + break; + case BUTT_POINTY: { + Geom::Point end_deriv = -Geom::unitTangentAt(Geom::reverse(path_in[i].back().toSBasis()), 0.); + double radius = 0.5 * Geom::distance(with_direction.finalPoint(), against_direction.initialPoint()); + Geom::Point midpoint = 0.5 * (with_direction.finalPoint() + against_direction.initialPoint()) + radius*end_deriv; + pb.lineTo(midpoint); + pb.lineTo(against_direction.initialPoint()); + break; + } + case BUTT_SQUARE: { + Geom::Point end_deriv = -Geom::unitTangentAt(Geom::reverse(path_in[i].back().toSBasis()), 0.); + double radius = 0.5 * Geom::distance(with_direction.finalPoint(), against_direction.initialPoint()); + pb.lineTo(with_direction.finalPoint() + radius*end_deriv); + pb.lineTo(against_direction.initialPoint() + radius*end_deriv); + pb.lineTo(against_direction.initialPoint()); + break; + } + case BUTT_LEANED: { + Geom::Point end_deriv = -Geom::unitTangentAt(Geom::reverse(path_in[i].back().toSBasis()), 0.); + double maxRadius = (end_lean+0.5) * Geom::distance(with_direction.finalPoint(), against_direction.initialPoint()); + double minRadius = ((end_lean*-1)+0.5) * Geom::distance(with_direction.finalPoint(), against_direction.initialPoint()); + pb.lineTo(with_direction.finalPoint() + maxRadius*end_deriv); + pb.lineTo(against_direction.initialPoint() + minRadius*end_deriv); + pb.lineTo(against_direction.initialPoint()); + break; + } + } + } else { + pb.moveTo(against_direction.initialPoint()); + } + + pb.append(against_direction); + + //cap (if necessary) + if (!path_in[i].closed()) { + switch (butt) { + case BUTT_STRAIGHT: + pb.lineTo(with_direction.initialPoint()); + break; + case BUTT_ROUND: + pb.arcTo((-line_width) / 2, (-line_width) / 2, 0., true, true, with_direction.initialPoint() ); + break; + case BUTT_POINTY: { + Geom::Point end_deriv = -Geom::unitTangentAt(path_in[i].front().toSBasis(), 0.); + double radius = 0.5 * Geom::distance(against_direction.finalPoint(), with_direction.initialPoint()); + Geom::Point midpoint = 0.5 * (against_direction.finalPoint() + with_direction.initialPoint()) + radius*end_deriv; + pb.lineTo(midpoint); + pb.lineTo(with_direction.initialPoint()); + break; + } + case BUTT_SQUARE: { + Geom::Point end_deriv = -Geom::unitTangentAt(path_in[i].front().toSBasis(), 0.); + double radius = 0.5 * Geom::distance(against_direction.finalPoint(), with_direction.initialPoint()); + pb.lineTo(against_direction.finalPoint() + radius*end_deriv); + pb.lineTo(with_direction.initialPoint() + radius*end_deriv); + pb.lineTo(with_direction.initialPoint()); + break; + } + case BUTT_LEANED: { + Geom::Point end_deriv = -Geom::unitTangentAt(path_in[i].front().toSBasis(), 0.); + double maxRadius = (start_lean+0.5) * Geom::distance(against_direction.finalPoint(), with_direction.initialPoint()); + double minRadius = ((start_lean*-1)+0.5) * Geom::distance(against_direction.finalPoint(), with_direction.initialPoint()); + pb.lineTo(against_direction.finalPoint() + minRadius*end_deriv); + pb.lineTo(with_direction.initialPoint() + maxRadius*end_deriv); + pb.lineTo(with_direction.initialPoint()); + break; + } + } + } + pb.flush(); + path_out.push_back(pb.peek()[0]); + if (path_in[i].closed()) { + path_out.push_back(pb.peek()[1]); + } + } else { + Path p = Path(); + Path outlinepath = Path(); + ButtType original_butt; + switch (butt) { + case BUTT_STRAIGHT: + original_butt = butt_straight; + break; + case BUTT_ROUND: + original_butt = butt_round; + break; + case butt_pointy: { + original_butt = butt_pointy; + break; + } + case BUTT_SQUARE: { + original_butt = butt_square; + break; + } + case BUTT_LEANED: { + original_butt = butt_straight; + break; + } + } + p.LoadPath(path_in[i], Geom::Affine(), false, false); + p.Outline(&outlinepath, line_width / 2, static_cast(join), original_butt, miter_lim); + Geom::PathVector *pv_p = outlinepath.MakePathVector(); + //somewhat hack-ish + path_out.push_back( (*pv_p)[0].reverse() ); + if (pv_p) delete pv_p; + } + } + return path_out; +} + +#define miter_lim fabs(line_width * miter_limit) + +Geom::PathVector PathVectorOutline(Geom::PathVector const & path_in, double line_width, ButtTypeMod linecap_type, LineJoinType linejoin_type, double miter_limit, double start_lean, double end_lean) +{ + std::vector path_out = std::vector(); + if (path_in.empty()) { + return path_out; + } + Path p = Path(); + Path outlinepath = Path(); + for (unsigned i = 0; i < path_in.size(); i++) { + p.LoadPath(path_in[i], Geom::Affine(), false, ( (i==0) ? false : true)); + } + + // magic! + ButtType original_butt; + switch (linecap_type) { + case BUTT_STRAIGHT: + original_butt = butt_straight; + break; + case BUTT_ROUND: + original_butt = butt_round; + break; + case butt_pointy: { + original_butt = butt_pointy; + break; + } + case BUTT_SQUARE: { + original_butt = butt_square; + break; + } + case BUTT_LEANED: { + original_butt = butt_straight; + break; + } + } + if (linejoin_type <= LINEJOIN_POINTY) { + p.Outline(&outlinepath, line_width / 2, static_cast(linejoin_type), + original_butt, miter_lim); + // fix memory leak + std::vector *pv_p = outlinepath.MakePathVector(); + path_out = *pv_p; + delete pv_p; + + } else if (linejoin_type == LINEJOIN_REFLECTED) { + // reflected arc join + path_out = outlinePath(path_in, line_width, static_cast(linejoin_type), + linecap_type , miter_lim, false, start_lean, end_lean); + + } else if (linejoin_type == LINEJOIN_EXTRAPOLATED) { + // extrapolated arc join + path_out = outlinePath(path_in, line_width, LINEJOIN_STRAIGHT, linecap_type, miter_lim, true, start_lean, end_lean); + } + + return path_out; +} + +Geom::Path PathOutsideOutline(Geom::Path const & path_in, double line_width, LineJoinType linejoin_type, double miter_limit) +{ + + Geom::Path path_out; + + if (linejoin_type <= LINEJOIN_POINTY || path_in.size() <= 1) { + + Geom::PathVector * pathvec; + + Path path_tangent = Path(); + Path path_outline = Path(); + path_outline.LoadPath(path_in, Geom::Affine(), false, false); + path_outline.OutsideOutline(&path_tangent, line_width / 2, static_cast(linejoin_type), butt_straight, miter_lim); + + pathvec = path_tangent.MakePathVector(); + path_out = pathvec->front(); + delete pathvec; + return path_out; + } else if (linejoin_type == LINEJOIN_REFLECTED) { + path_out = outlineHalf(path_in, line_width, miter_lim, reflect_curves); + return path_out; + } else if (linejoin_type == LINEJOIN_EXTRAPOLATED) { + path_out = outlineHalf(path_in, line_width, miter_lim, extrapolate_curves); + return path_out; + } + return path_out; +} + +} // namespace Outline + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8 : diff --git a/src/live_effects/pathoutlineprovider.h b/src/live_effects/pathoutlineprovider.h new file mode 100644 index 000000000..c17584be2 --- /dev/null +++ b/src/live_effects/pathoutlineprovider.h @@ -0,0 +1,55 @@ +#ifndef SEEN_PATH_OUTLINE_H +#define SEEN_PATH_OUTLINE_H + +/* Author: + * Liam P. White + * + * Copyright (C) 2014 Author + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include +#include + +enum LineJoinType { + LINEJOIN_STRAIGHT, + LINEJOIN_ROUND, + LINEJOIN_POINTY, + LINEJOIN_REFLECTED, + LINEJOIN_EXTRAPOLATED +}; +enum ButtTypeMod { + BUTT_STRAIGHT, + BUTT_ROUND, + BUTT_SQUARE, + BUTT_POINTY, + BUTT_LEANED +}; + +namespace Geom +{ + Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2 const & sbasis_in); + std::vector split_at_cusps(const Geom::Path& in); +} + +namespace Outline +{ + unsigned bezierOrder (const Geom::Curve* curve_in); + std::vector PathVectorOutline(std::vector const & path_in, double line_width, ButtTypeMod linecap_type, + LineJoinType linejoin_type, double miter_limit, double start_lean = 0, double end_lean = 0); + Geom::Path PathOutsideOutline(Geom::Path const & path_in, double line_width, LineJoinType linejoin_type, double miter_limit); +} + +#endif // SEEN_PATH_OUTLINE_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/main-cmdlineact.h b/src/main-cmdlineact.h index fe11357fa..c8ef64f10 100644 --- a/src/main-cmdlineact.h +++ b/src/main-cmdlineact.h @@ -15,20 +15,18 @@ * Released under GNU GPL v2.x, read the file 'COPYING' for more information */ -#include - namespace Inkscape { class ActionContext; class CmdLineAction { bool _isVerb; - gchar * _arg; + char * _arg; static std::list _list; public: - CmdLineAction (bool isVerb, gchar const * arg); + CmdLineAction (bool isVerb, char const * arg); virtual ~CmdLineAction (); void doIt (ActionContext const & context); diff --git a/src/marker.h b/src/marker.h index 9eefcdf16..b58523251 100644 --- a/src/marker.h +++ b/src/marker.h @@ -1,5 +1,5 @@ -#ifndef __SP_MARKER_H__ -#define __SP_MARKER_H__ +#ifndef SEEN_SP_MARKER_H +#define SEEN_SP_MARKER_H /* * SVG implementation @@ -12,7 +12,6 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - /* * This is quite similar in logic to * Maybe we should merge them somehow (Lauris) @@ -26,8 +25,9 @@ struct SPMarkerView; #include <2geom/rect.h> #include <2geom/affine.h> -#include "svg/svg-length.h" + #include "enums.h" +#include "svg/svg-length.h" #include "sp-item-group.h" #include "uri-references.h" #include "viewbox.h" @@ -93,7 +93,7 @@ Inkscape::DrawingItem *sp_marker_show_instance (SPMarker *marker, Inkscape::Draw unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); -const gchar *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); +const char *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); SPObject *sp_marker_fork_if_necessary(SPObject *marker); #endif diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index f888555d2..18a26d82c 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -178,6 +178,9 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/message-context.h b/src/message-context.h index a92874d68..ea86c4ec0 100644 --- a/src/message-context.h +++ b/src/message-context.h @@ -14,8 +14,9 @@ #ifndef SEEN_INKSCAPE_MESSAGE_CONTEXT_H #define SEEN_INKSCAPE_MESSAGE_CONTEXT_H -#include +#include #include + #include "message.h" namespace Inkscape { @@ -48,7 +49,7 @@ public: * @param type the message type * @param message the message text */ - void set(MessageType type, gchar const *message); + void set(MessageType type, char const *message); /** @brief pushes a message on the stack using prinf-style formatting, * and replacing our old message @@ -56,7 +57,7 @@ public: * @param type the message type * @param format a printf-style formatting string */ - void setF(MessageType type, gchar const *format, ...) G_GNUC_PRINTF(3,4); + void setF(MessageType type, char const *format, ...) G_GNUC_PRINTF(3,4); /** @brief pushes a message on the stack using printf-style formatting, * and a stdarg argument list @@ -65,7 +66,7 @@ public: * @param format a printf-style formatting string * @param args printf-style arguments */ - void setVF(MessageType type, gchar const *format, va_list args); + void setVF(MessageType type, char const *format, va_list args); /** @brief pushes a message onto the stack for a brief period of time * without disturbing our "current" message @@ -73,7 +74,7 @@ public: * @param type the message type * @param message the message text */ - void flash(MessageType type, gchar const *message); + void flash(MessageType type, char const *message); /** @brief pushes a message onto the stack for a brief period of time * using printf-style formatting, without disturbing our current @@ -82,7 +83,7 @@ public: * @param type the message type * @param format a printf-style formatting string */ - void flashF(MessageType type, gchar const *format, ...) G_GNUC_PRINTF(3,4); + void flashF(MessageType type, char const *format, ...) G_GNUC_PRINTF(3,4); /** @brief pushes a message onto the stack for a brief period of time * using printf-style formatting and a stdarg argument list; @@ -92,7 +93,7 @@ public: * @param format a printf-style formatting string * @param args printf-style arguments */ - void flashVF(MessageType type, gchar const *format, va_list args); + void flashVF(MessageType type, char const *format, va_list args); /** @brief removes our current message from the stack */ void clear(); diff --git a/src/message-stack.h b/src/message-stack.h index 3b8307761..42bf4e8a7 100644 --- a/src/message-stack.h +++ b/src/message-stack.h @@ -16,11 +16,12 @@ #ifndef SEEN_INKSCAPE_MESSAGE_STACK_H #define SEEN_INKSCAPE_MESSAGE_STACK_H -#include -#include -#include -#include +#include +#include +#include // G_GNUC_PRINTF is the only thing worth having from here #include +#include + #include "gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" @@ -61,14 +62,14 @@ public: /** @brief returns the text of the message currently at the top of * the stack */ - gchar const *currentMessage() { + char const *currentMessage() { return _messages ? _messages->message : NULL; } /** @brief connects to the "changed" signal which is emitted whenever * the topmost message on the stack changes. */ - sigc::connection connectChanged(sigc::slot slot) + sigc::connection connectChanged(sigc::slot slot) { return _changed_signal.connect(slot); } @@ -80,7 +81,7 @@ public: * * @return the id of the pushed message */ - MessageId push(MessageType type, gchar const *message); + MessageId push(MessageType type, char const *message); /** @brief pushes a message onto the stack using printf-like formatting * @@ -89,7 +90,7 @@ public: * * @return the id of the pushed message */ - MessageId pushF(MessageType type, gchar const *format, ...) G_GNUC_PRINTF(3,4); + MessageId pushF(MessageType type, char const *format, ...) G_GNUC_PRINTF(3,4); /** @brief pushes a message onto the stack using printf-like formatting, * using a stdarg argument list @@ -100,7 +101,7 @@ public: * * @return the id of the pushed message */ - MessageId pushVF(MessageType type, gchar const *format, va_list args); + MessageId pushVF(MessageType type, char const *format, va_list args); /** @brief removes a message from the stack, given its id * @@ -119,7 +120,7 @@ public: * * @return the id of the pushed message */ - MessageId flash(MessageType type, gchar const *message); + MessageId flash(MessageType type, char const *message); /** * Temporarily pushes a message onto the stack. @@ -140,7 +141,7 @@ public: * * @return the id of the pushed message */ - MessageId flashF(MessageType type, gchar const *format, ...) G_GNUC_PRINTF(3,4); + MessageId flashF(MessageType type, char const *format, ...) G_GNUC_PRINTF(3,4); /** @brief temporarily pushes a message onto the stack using * printf-like formatting, using a stdarg argument list @@ -151,7 +152,7 @@ public: * * @return the id of the pushed message */ - MessageId flashVF(MessageType type, gchar const *format, va_list args); + MessageId flashVF(MessageType type, char const *format, va_list args); private: struct Message { @@ -167,13 +168,13 @@ private: void operator=(MessageStack const &); // no assign /// pushes a message onto the stack with an optional timeout - MessageId _push(MessageType type, guint lifetime, gchar const *message); + MessageId _push(MessageType type, unsigned int lifetime, char const *message); Message *_discard(Message *m); ///< frees a message struct and returns the next such struct in the list void _emitChanged(); ///< emits the "changed" signal - static gboolean _timeout(gpointer data); ///< callback to expire flashed messages + static int _timeout(void* data); ///< callback to expire flashed messages - sigc::signal _changed_signal; + sigc::signal _changed_signal; Message *_messages; ///< the stack of messages as a linked list MessageId _next_id; ///< the next message id to assign }; diff --git a/src/number-opt-number.h b/src/number-opt-number.h index d9ab56102..f6fe584f9 100644 --- a/src/number-opt-number.h +++ b/src/number-opt-number.h @@ -13,27 +13,23 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include -//todo: use glib instead of stdlib -#include +#include + #include "svg/stringstream.h" class NumberOptNumber { public: - gfloat number; + float number; - gfloat optNumber; + float optNumber; - guint _set : 1; + unsigned int _set : 1; - guint optNumber_set : 1; + unsigned int optNumber_set : 1; NumberOptNumber() { @@ -44,27 +40,27 @@ public: optNumber_set = FALSE; } - gfloat getNumber() + float getNumber() { if(_set) return number; return -1; } - gfloat getOptNumber() + float getOptNumber() { if(optNumber_set) return optNumber; return -1; } - void setOptNumber(gfloat num) + void setOptNumber(float num) { optNumber_set = true; optNumber = num; } - void setNumber(gfloat num) + void setNumber(float num) { _set = true; number = num; @@ -78,7 +74,7 @@ public: return _set; } - gchar *getValueString() + char *getValueString() { Inkscape::SVGOStringStream os; @@ -96,12 +92,12 @@ public: return g_strdup(os.str().c_str()); } - void set(gchar const *str) + void set(char const *str) { if(!str) return; - gchar **values = g_strsplit(str, " ", 2); + char **values = g_strsplit(str, " ", 2); if( values[0] != NULL ) { diff --git a/src/object-edit.cpp b/src/object-edit.cpp index fe22f6c1c..14a5bd3d5 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -96,33 +96,33 @@ KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) class RectKnotHolderEntityRX : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; /* handle for vertical rounding radius */ class RectKnotHolderEntityRY : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; /* handle for width/height adjustment */ class RectKnotHolderEntityWH : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); protected: - void set_internal(Geom::Point const &p, Geom::Point const &origin, guint state); + void set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; /* handle for x/y adjustment */ class RectKnotHolderEntityXY : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; Geom::Point @@ -134,7 +134,7 @@ RectKnotHolderEntityRX::knot_get() const } void -RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { SPRect *rect = SP_RECT(item); @@ -159,7 +159,7 @@ RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*orig } void -RectKnotHolderEntityRX::knot_click(guint state) +RectKnotHolderEntityRX::knot_click(unsigned int state) { SPRect *rect = SP_RECT(item); @@ -183,7 +183,7 @@ RectKnotHolderEntityRY::knot_get() const } void -RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { SPRect *rect = SP_RECT(item); @@ -217,7 +217,7 @@ RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*orig } void -RectKnotHolderEntityRY::knot_click(guint state) +RectKnotHolderEntityRY::knot_click(unsigned int state) { SPRect *rect = SP_RECT(item); @@ -255,7 +255,7 @@ RectKnotHolderEntityWH::knot_get() const } void -RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &origin, guint state) +RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state) { SPRect *rect = SP_RECT(item); @@ -327,7 +327,7 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or } void -RectKnotHolderEntityWH::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) +RectKnotHolderEntityWH::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) { set_internal(p, origin, state); update_knot(); @@ -342,7 +342,7 @@ RectKnotHolderEntityXY::knot_get() const } void -RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) +RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) { SPRect *rect = SP_RECT(item); @@ -468,10 +468,10 @@ RectKnotHolder::RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRel class Box3DKnotHolderEntity : public KnotHolderEntity { public: virtual Geom::Point knot_get() const = 0; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) = 0; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) = 0; Geom::Point knot_get_generic(SPItem *item, unsigned int knot_id) const; - void knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &p, guint state); + void knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &p, unsigned int state); }; Geom::Point @@ -481,7 +481,7 @@ Box3DKnotHolderEntity::knot_get_generic(SPItem *item, unsigned int knot_id) cons } void -Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, guint state) +Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, unsigned int state) { Geom::Point const s = snap_knot_position(new_pos, state); @@ -504,55 +504,55 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom class Box3DKnotHolderEntity0 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntity1 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntity2 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntity3 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntity4 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntity5 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntity6 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntity7 : public Box3DKnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; class Box3DKnotHolderEntityCenter : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; Geom::Point @@ -610,55 +610,55 @@ Box3DKnotHolderEntityCenter::knot_get() const } void -Box3DKnotHolderEntity0::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity0::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 0, new_pos, state); } void -Box3DKnotHolderEntity1::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity1::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 1, new_pos, state); } void -Box3DKnotHolderEntity2::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity2::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 2, new_pos, state); } void -Box3DKnotHolderEntity3::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity3::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 3, new_pos, state); } void -Box3DKnotHolderEntity4::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity4::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 4, new_pos, state); } void -Box3DKnotHolderEntity5::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity5::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 5, new_pos, state); } void -Box3DKnotHolderEntity6::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity6::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 6, new_pos, state); } void -Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state) +Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) { knot_set_generic(item, 7, new_pos, state); } void -Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, guint state) +Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, unsigned int state) { Geom::Point const s = snap_knot_position(new_pos, state); @@ -739,29 +739,29 @@ Box3DKnotHolder::Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderR class ArcKnotHolderEntityStart : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; class ArcKnotHolderEntityEnd : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; class ArcKnotHolderEntityRX : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; class ArcKnotHolderEntityRY : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; /* @@ -783,7 +783,7 @@ sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p) } void -ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); @@ -813,7 +813,7 @@ ArcKnotHolderEntityStart::knot_get() const } void -ArcKnotHolderEntityStart::knot_click(guint state) +ArcKnotHolderEntityStart::knot_click(unsigned int state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -824,7 +824,7 @@ ArcKnotHolderEntityStart::knot_click(guint state) } void -ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); @@ -855,7 +855,7 @@ ArcKnotHolderEntityEnd::knot_get() const void -ArcKnotHolderEntityEnd::knot_click(guint state) +ArcKnotHolderEntityEnd::knot_click(unsigned int state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -867,7 +867,7 @@ ArcKnotHolderEntityEnd::knot_click(guint state) void -ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -891,7 +891,7 @@ ArcKnotHolderEntityRX::knot_get() const } void -ArcKnotHolderEntityRX::knot_click(guint state) +ArcKnotHolderEntityRX::knot_click(unsigned int state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -902,7 +902,7 @@ ArcKnotHolderEntityRX::knot_click(guint state) } void -ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -926,7 +926,7 @@ ArcKnotHolderEntityRY::knot_get() const } void -ArcKnotHolderEntityRY::knot_click(guint state) +ArcKnotHolderEntityRY::knot_click(unsigned int state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -975,19 +975,19 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea class StarKnotHolderEntity1 : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; class StarKnotHolderEntity2 : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; void -StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { SPStar *star = SP_STAR(item); @@ -1013,7 +1013,7 @@ StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origi } void -StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { SPStar *star = SP_STAR(item); @@ -1063,7 +1063,7 @@ StarKnotHolderEntity2::knot_get() const } static void -sp_star_knot_click(SPItem *item, guint state) +sp_star_knot_click(SPItem *item, unsigned int state) { SPStar *star = SP_STAR(item); @@ -1080,13 +1080,13 @@ sp_star_knot_click(SPItem *item, guint state) } void -StarKnotHolderEntity1::knot_click(guint state) +StarKnotHolderEntity1::knot_click(unsigned int state) { sp_star_knot_click(item, state); } void -StarKnotHolderEntity2::knot_click(guint state) +StarKnotHolderEntity2::knot_click(unsigned int state) { sp_star_knot_click(item, state); } @@ -1119,14 +1119,14 @@ StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRel class SpiralKnotHolderEntityInner : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual void knot_click(guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); }; class SpiralKnotHolderEntityOuter : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; @@ -1137,7 +1137,7 @@ public: * [control] constrain inner arg to round per PI/4 */ void -SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) +SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); @@ -1186,7 +1186,7 @@ SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &o * [control] constrain inner arg to round per PI/4 */ void -SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); @@ -1276,7 +1276,7 @@ SpiralKnotHolderEntityOuter::knot_get() const } void -SpiralKnotHolderEntityInner::knot_click(guint state) +SpiralKnotHolderEntityInner::knot_click(unsigned int state) { SPSpiral *spiral = SP_SPIRAL(item); @@ -1314,11 +1314,11 @@ SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde class OffsetKnotHolderEntity : public KnotHolderEntity { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; void -OffsetKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +OffsetKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int /*state*/) { SPOffset *offset = SP_OFFSET(item); @@ -1357,7 +1357,7 @@ OffsetKnotHolder::OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde class FlowtextKnotHolderEntity : public RectKnotHolderEntityWH { public: virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); }; Geom::Point @@ -1369,7 +1369,7 @@ FlowtextKnotHolderEntity::knot_get() const } void -FlowtextKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) +FlowtextKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) { set_internal(p, origin, state); } diff --git a/src/object-hierarchy.cpp b/src/object-hierarchy.cpp index f2bf177dc..f241da83d 100644 --- a/src/object-hierarchy.cpp +++ b/src/object-hierarchy.cpp @@ -9,6 +9,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include +#include + #include "sp-object.h" #include "object-hierarchy.h" @@ -32,7 +35,7 @@ void ObjectHierarchy::clear() { } void ObjectHierarchy::setTop(SPObject *object) { - g_return_if_fail(object != NULL); + if (object == NULL) { printf("Assertion object != NULL failed\n"); return; } if ( top() == object ) { return; @@ -53,8 +56,8 @@ void ObjectHierarchy::setTop(SPObject *object) { } void ObjectHierarchy::_addTop(SPObject *senior, SPObject *junior) { - g_assert(junior != NULL); - g_assert(senior != NULL); + assert(junior != NULL); + assert(senior != NULL); SPObject *object = junior->parent; do { @@ -64,7 +67,7 @@ void ObjectHierarchy::_addTop(SPObject *senior, SPObject *junior) { } void ObjectHierarchy::_addTop(SPObject *object) { - g_assert(object != NULL); + assert(object != NULL); _hierarchy.push_back(_attach(object)); _added_signal.emit(object); } @@ -82,7 +85,7 @@ void ObjectHierarchy::_trimAbove(SPObject *limit) { } void ObjectHierarchy::setBottom(SPObject *object) { - g_return_if_fail(object != NULL); + if (object == NULL) { printf("assertion object != NULL failed\n"); return; } if ( bottom() == object ) { return; @@ -125,8 +128,8 @@ void ObjectHierarchy::_trimBelow(SPObject *limit) { } void ObjectHierarchy::_addBottom(SPObject *senior, SPObject *junior) { - g_assert(junior != NULL); - g_assert(senior != NULL); + assert(junior != NULL); + assert(senior != NULL); if ( junior != senior ) { _addBottom(senior, junior->parent); @@ -135,15 +138,15 @@ void ObjectHierarchy::_addBottom(SPObject *senior, SPObject *junior) { } void ObjectHierarchy::_addBottom(SPObject *object) { - g_assert(object != NULL); + assert(object != NULL); _hierarchy.push_front(_attach(object)); _added_signal.emit(object); } void ObjectHierarchy::_trim_for_release(SPObject *object) { this->_trimBelow(object); - g_assert(!this->_hierarchy.empty()); - g_assert(this->_hierarchy.front().object == object); + assert(!this->_hierarchy.empty()); + assert(this->_hierarchy.front().object == object); sp_object_ref(object, NULL); this->_detach(this->_hierarchy.front()); diff --git a/src/object-hierarchy.h b/src/object-hierarchy.h index 0343d850e..16004c81a 100644 --- a/src/object-hierarchy.h +++ b/src/object-hierarchy.h @@ -10,12 +10,11 @@ #ifndef SEEN_INKSCAPE_OBJECT_HIERARCHY_H #define SEEN_INKSCAPE_OBJECT_HIERARCHY_H +#include #include #include -#include #include #include -#include class SPObject; diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index d355b49fe..a72601276 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -22,6 +22,7 @@ #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" +#include "color.h" #include #include #include "sp-path.h" @@ -433,6 +434,10 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec gchar *title = item->title(); // remember description gchar *desc = item->desc(); + // remember highlight color + guint32 highlight_color = 0; + if (item->isHighlightSet()) + highlight_color = item->highlight_color(); // It's going to resurrect, so we delete without notifying listeners. item->deleteObject(false); @@ -450,6 +455,9 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec newObj->setDesc(desc); g_free(desc); } + if (highlight_color && newObj) { + SP_ITEM(newObj)->setHighlightColor( highlight_color ); + } // move to the saved position repr->setPosition(pos > 0 ? pos : 0); diff --git a/src/path-chemistry.h b/src/path-chemistry.h index efc687b44..a2150440c 100644 --- a/src/path-chemistry.h +++ b/src/path-chemistry.h @@ -13,8 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include - class SPDesktop; class SPItem; @@ -25,6 +23,9 @@ class Node; } // namespace XML } // namespace Inkscape +typedef unsigned int guint32; +typedef struct _GSList GSList; + void sp_selected_path_combine (SPDesktop *desktop); void sp_selected_path_break_apart (SPDesktop *desktop); // interactive=true only has an effect if desktop != NULL, i.e. if a GUI is available diff --git a/src/path-prefix.h b/src/path-prefix.h index be57ae354..6ef0ccbe9 100644 --- a/src/path-prefix.h +++ b/src/path-prefix.h @@ -10,15 +10,15 @@ * define'd directories, and instead should use only the paths defined here. * */ -#ifndef _PATH_PREFIX_H_ -#define _PATH_PREFIX_H_ +#ifndef SEEN_PATH_PREFIX_H +#define SEEN_PATH_PREFIX_H #include "require-config.h" // INKSCAPE_DATADIR #include "prefix.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +//#ifdef __cplusplus +//extern "C" { +//#endif /* __cplusplus */ #ifdef ENABLE_BINRELOC # define INKSCAPE_APPICONDIR BR_DATADIR( "/pixmaps" ) @@ -112,8 +112,8 @@ extern "C" { # endif #endif -#ifdef __cplusplus -} -#endif /* __cplusplus */ +//#ifdef __cplusplus +//} +//#endif /* __cplusplus */ #endif /* _PATH_PREFIX_H_ */ diff --git a/src/persp3d-reference.h b/src/persp3d-reference.h index fa9eca5c9..cce497d94 100644 --- a/src/persp3d-reference.h +++ b/src/persp3d-reference.h @@ -10,9 +10,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include "uri-references.h" -#include +#include #include + +#include "uri-references.h" #include "persp3d.h" class SPObject; @@ -35,7 +36,7 @@ public: SPObject *owner; // concerning the Persp3D (we only use SPBox3D) that is refered to: - gchar *persp_href; + char *persp_href; Inkscape::XML::Node *persp_repr; Persp3D *persp; diff --git a/src/persp3d.h b/src/persp3d.h index bd3777a19..be5680bcb 100644 --- a/src/persp3d.h +++ b/src/persp3d.h @@ -1,5 +1,5 @@ -#ifndef __PERSP3D_H__ -#define __PERSP3D_H__ +#ifndef SEEN_PERSP3D_H +#define SEEN_PERSP3D_H /* * Implementation of 3D perspectives as SPObjects @@ -16,8 +16,9 @@ #define SP_IS_PERSP3D(obj) (dynamic_cast((SPObject*)obj) != NULL) #include -#include #include +#include + #include "transf_mat_3x4.h" #include "document.h" #include "inkscape.h" // for SP_ACTIVE_DOCUMENT @@ -64,11 +65,11 @@ protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; @@ -100,7 +101,7 @@ void persp3d_update_z_orders (Persp3D *persp); inline unsigned int persp3d_num_boxes (Persp3D *persp) { return persp->perspective_impl->boxes.size(); } std::list persp3d_list_of_boxes(Persp3D *persp); -bool persp3d_perspectives_coincide(const Persp3D *lhs, const Persp3D *rhs); +bool persp3d_perspectives_coincide(Persp3D const *lhs, Persp3D const *rhs); void persp3d_absorb(Persp3D *persp1, Persp3D *persp2); Persp3D * persp3d_create_xml_element (SPDocument *document, Persp3DImpl *dup = NULL); @@ -112,7 +113,7 @@ void persp3d_print_debugging_info (Persp3D *persp); void persp3d_print_debugging_info_all(SPDocument *doc); void persp3d_print_all_selected(); -void print_current_persp3d(gchar *func_name, Persp3D *persp); +void print_current_persp3d(char *func_name, Persp3D *persp); #endif /* __PERSP3D_H__ */ diff --git a/src/perspective-line.h b/src/perspective-line.h index 57abaae9c..64f7d03bd 100644 --- a/src/perspective-line.h +++ b/src/perspective-line.h @@ -13,7 +13,6 @@ #define SEEN_PERSPECTIVE_LINE_H #include "line-geometry.h" -#include class SPDesktop; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 734e8a582..66a3e47d4 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -1,8 +1,9 @@ #ifndef SEEN_PREFERENCES_SKELETON_H #define SEEN_PREFERENCES_SKELETON_H -#include +#include "inkscape-version.h" +// FIXME why is this here? #ifdef N_ #undef N_ #endif diff --git a/src/preferences.h b/src/preferences.h index d5429815e..d5ae40e56 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -13,14 +13,16 @@ #ifndef INKSCAPE_PREFSTORE_H #define INKSCAPE_PREFSTORE_H -#include -#include #include #include #include +#include +#include + #include "xml/repr.h" class SPCSSAttr; +typedef unsigned int guint32; namespace Inkscape { diff --git a/src/prefix.cpp b/src/prefix.cpp index 630d6caa8..6bf5cb2cf 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -186,7 +186,7 @@ br_locate_prefix (void *symbol) * br_prepend_prefix (&argc, "/share/foo/data.png"); --> Returns "/usr/share/foo/data.png" */ char * -br_prepend_prefix (void *symbol, char *path) +br_prepend_prefix (void *symbol, char const *path) { char *tmp, *newpath; diff --git a/src/prefix.h b/src/prefix.h index af96fa746..7c5a1fd3c 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -80,7 +80,7 @@ extern "C" { const char *br_thread_local_store (char *str); char *br_locate (void *symbol); char *br_locate_prefix (void *symbol); -char *br_prepend_prefix (void *symbol, char *path); +char *br_prepend_prefix (void *symbol, char const *path); #endif /* ENABLE_BINRELOC */ diff --git a/src/print.h b/src/print.h index bbf95b833..ab2bcc0a7 100644 --- a/src/print.h +++ b/src/print.h @@ -41,18 +41,18 @@ unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, - guchar *px, unsigned int w, unsigned int h, unsigned int rs, + unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, Geom::Affine const &transform, SPStyle const *style); unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, SPStyle const *style); -void sp_print_get_param(SPPrintContext *ctx, gchar *name, bool *value); +void sp_print_get_param(SPPrintContext *ctx, char *name, bool *value); /* UI */ void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc); -void sp_print_document_to_file(SPDocument *doc, gchar const *filename); +void sp_print_document_to_file(SPDocument *doc, char const *filename); #endif /* !PRINT_H_INKSCAPE */ diff --git a/src/profile-manager.h b/src/profile-manager.h index be9446c17..54cd4a1da 100644 --- a/src/profile-manager.h +++ b/src/profile-manager.h @@ -9,9 +9,10 @@ #ifndef SEEN_INKSCAPE_PROFILE_MANAGER_H #define SEEN_INKSCAPE_PROFILE_MANAGER_H +#include + #include "document-subset.h" #include "gc-finalized.h" -#include class SPDocument; @@ -26,7 +27,7 @@ public: ProfileManager(SPDocument *document); ~ProfileManager(); - ColorProfile* find(gchar const* name); + ColorProfile* find(char const* name); private: ProfileManager(ProfileManager const &); // no copy diff --git a/src/proj_pt.cpp b/src/proj_pt.cpp index f5cca8fca..311b9a034 100644 --- a/src/proj_pt.cpp +++ b/src/proj_pt.cpp @@ -9,12 +9,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + #include "proj_pt.h" #include "svg/stringstream.h" namespace Proj { -Pt2::Pt2(const gchar *coord_str) { +Pt2::Pt2(const char *coord_str) { if (!coord_str) { pt[0] = 0.0; pt[1] = 0.0; @@ -22,7 +24,7 @@ Pt2::Pt2(const gchar *coord_str) { g_warning ("Coordinate string is empty. Creating default Pt2\n"); return; } - gchar **coords = g_strsplit(coord_str, ":", 0); + char **coords = g_strsplit(coord_str, ":", 0); if (coords[0] == NULL || coords[1] == NULL || coords[2] == NULL) { g_strfreev (coords); g_warning ("Malformed coordinate string.\n"); @@ -52,7 +54,7 @@ Pt2::affine() { return Geom::Point (pt[0]/pt[2], pt[1]/pt[2]); } -gchar * +char * Pt2::coord_string() { Inkscape::SVGOStringStream os; os << pt[0] << " : " @@ -61,7 +63,7 @@ Pt2::coord_string() { return g_strdup(os.str().c_str()); } -Pt3::Pt3(const gchar *coord_str) { +Pt3::Pt3(const char *coord_str) { if (!coord_str) { pt[0] = 0.0; pt[1] = 0.0; @@ -70,7 +72,7 @@ Pt3::Pt3(const gchar *coord_str) { g_warning ("Coordinate string is empty. Creating default Pt2\n"); return; } - gchar **coords = g_strsplit(coord_str, ":", 0); + char **coords = g_strsplit(coord_str, ":", 0); if (coords[0] == NULL || coords[1] == NULL || coords[2] == NULL || coords[3] == NULL) { g_strfreev (coords); @@ -94,7 +96,7 @@ Pt3::normalize() { pt[3] = 1.0; } -gchar * +char * Pt3::coord_string() { Inkscape::SVGOStringStream os; os << pt[0] << " : " diff --git a/src/proj_pt.h b/src/proj_pt.h index 28ec0aca3..1ee4b7f14 100644 --- a/src/proj_pt.h +++ b/src/proj_pt.h @@ -13,7 +13,7 @@ #define SEEN_PROJ_PT_H #include <2geom/point.h> -#include +#include namespace Proj { @@ -25,7 +25,7 @@ public: Pt2 () { pt[0] = 0; pt[1] = 0; pt[2] = 1.0; } // we default to (0 : 0 : 1) Pt2 (double x, double y, double w) { pt[0] = x; pt[1] = y; pt[2] = w; } Pt2 (Geom::Point const &point) { pt[0] = point[Geom::X]; pt[1] = point[Geom::Y]; pt[2] = 1; } - Pt2 (const gchar *coord_str); + Pt2 (const char *coord_str); inline double operator[] (unsigned int index) const { if (index > 2) { return Geom::infinity(); } @@ -81,8 +81,8 @@ public: void normalize(); Geom::Point affine(); inline bool is_finite() { return pt[2] != 0; } // FIXME: Should we allow for some tolerance? - gchar *coord_string(); - inline void print(gchar const *s) const { g_print ("%s(%8.2f : %8.2f : %8.2f)\n", s, pt[0], pt[1], pt[2]); } + char *coord_string(); + inline void print(char const *s) const { printf ("%s(%8.2f : %8.2f : %8.2f)\n", s, pt[0], pt[1], pt[2]); } private: double pt[3]; @@ -93,7 +93,7 @@ class Pt3 { public: Pt3 () { pt[0] = 0; pt[1] = 0; pt[2] = 0; pt[3] = 1.0; } // we default to (0 : 0 : 0 : 1) Pt3 (double x, double y, double z, double w) { pt[0] = x; pt[1] = y; pt[2] = z; pt[3] = w; } - Pt3 (const gchar *coord_str); + Pt3 (const char *coord_str); inline bool operator== (Pt3 &rhs) { normalize(); @@ -146,9 +146,9 @@ public: } void normalize(); inline bool is_finite() { return pt[3] != 0; } // FIXME: Should we allow for some tolerance? - gchar *coord_string(); - inline void print(gchar const *s) const { - g_print ("%s(%8.2f : %8.2f : %8.2f : %8.2f)\n", s, pt[0], pt[1], pt[2], pt[3]); + char *coord_string(); + inline void print(char const *s) const { + printf ("%s(%8.2f : %8.2f : %8.2f : %8.2f)\n", s, pt[0], pt[1], pt[2], pt[3]); } private: diff --git a/src/rdf.h b/src/rdf.h index 3dde1cb48..c3ced1583 100644 --- a/src/rdf.h +++ b/src/rdf.h @@ -11,7 +11,6 @@ #ifndef SEEN_RDF_H #define SEEN_RDF_H -#include #include #include "document.h" @@ -22,18 +21,18 @@ * \brief Holds license name/resource doubles for rdf_license_t entries */ struct rdf_double_t { - gchar const *name; - gchar const *resource; + char const *name; + char const *resource; }; /** * \brief Holds license name and RDF information */ struct rdf_license_t { - gchar const *name; /* localized name of this license */ - gchar const *uri; /* URL for the RDF/Work/license element */ + char const *name; /* localized name of this license */ + char const *uri; /* URL for the RDF/Work/license element */ struct rdf_double_t *details; /* the license details */ -// gchar const *fragment; /* XML contents for the RDF/License tag */ +// char const *fragment; /* XML contents for the RDF/License tag */ }; extern rdf_license_t rdf_licenses []; @@ -69,10 +68,10 @@ enum RDF_Editable { */ struct rdf_work_entity_t { char const *name; /* unique name of this entity for internal reference */ - gchar const *title; /* localized title of this entity for data entry */ - gchar const *tag; /* namespace tag for the RDF/Work element */ + char const *title; /* localized title of this entity for data entry */ + char const *tag; /* namespace tag for the RDF/Work element */ RDFType datatype; /* how to extract/inject the RDF information */ - gchar const *tip; /* tool tip to explain the meaning of the entity */ + char const *tip; /* tool tip to explain the meaning of the entity */ RDF_Format format; /* in what format is this data edited? */ RDF_Editable editable;/* in what way is the data editable? */ }; @@ -83,19 +82,19 @@ extern rdf_work_entity_t rdf_work_entities []; * \brief Generic collection of RDF information for the RDF debug function */ struct rdf_t { - gchar* work_title; - gchar* work_date; - gchar* work_creator; - gchar* work_owner; - gchar* work_publisher; - gchar* work_type; - gchar* work_source; - gchar* work_subject; - gchar* work_description; + char* work_title; + char* work_date; + char* work_creator; + char* work_owner; + char* work_publisher; + char* work_type; + char* work_source; + char* work_subject; + char* work_description; struct rdf_license_t* license; }; -struct rdf_work_entity_t * rdf_find_entity(gchar const * name); +struct rdf_work_entity_t * rdf_find_entity(char const * name); /** * \brief Retrieves a known RDF/Work entity's contents from the document XML by name @@ -114,7 +113,7 @@ const gchar * rdf_get_work_entity(SPDocument const * doc, */ unsigned int rdf_set_work_entity(SPDocument * doc, struct rdf_work_entity_t * entity, - const gchar * text); + const char * text); /** * \brief Attempts to match and retrieve a known RDF/License from the document XML diff --git a/src/removeoverlap.h b/src/removeoverlap.h index 1ba41572a..7109c9513 100644 --- a/src/removeoverlap.h +++ b/src/removeoverlap.h @@ -13,7 +13,7 @@ #ifndef SEEN_REMOVEOVERLAP_H #define SEEN_REMOVEOVERLAP_H -#include +typedef struct _GSList GSList; void removeoverlap(GSList const *items, double xGap, double yGap); diff --git a/src/rubberband.h b/src/rubberband.h index fbebe2b08..a7bc57145 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -10,17 +10,17 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include #include <2geom/point.h> #include <2geom/rect.h> +#include +#include /* fixme: do multidocument safe */ -class CtrlRect; +class CtrlRect; +class SPCurve; +class SPDesktop; struct SPCanvasItem; -class SPCurve; -class SPDesktop; enum { RUBBERBAND_MODE_RECT, diff --git a/src/satisfied-guide-cns.h b/src/satisfied-guide-cns.h index 73e1e7e7f..25e5919d0 100644 --- a/src/satisfied-guide-cns.h +++ b/src/satisfied-guide-cns.h @@ -3,7 +3,7 @@ #include <2geom/forward.h> #include -#include +#include "sp-item.h" class SPDesktop; class SPGuideConstraint; diff --git a/src/selcue.h b/src/selcue.h index bcac7315f..d9b16b0f5 100644 --- a/src/selcue.h +++ b/src/selcue.h @@ -1,5 +1,5 @@ -#ifndef __SP_SELCUE_H__ -#define __SP_SELCUE_H__ +#ifndef SEEN_SP_SELCUE_H +#define SEEN_SP_SELCUE_H /* * Helper object for showing selected items @@ -13,8 +13,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include -#include #include class SPDesktop; @@ -52,7 +52,7 @@ private: void _updateItemBboxes(); void _updateItemBboxes(Inkscape::Preferences *prefs); - void _updateItemBboxes(gint mode, int prefs_bbox); + void _updateItemBboxes(int mode, int prefs_bbox); void _newItemBboxes(); void _newTextBaselines(); void _boundingBoxPrefsChanged(int prefs_bbox); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index c1c315835..1ea142839 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2792,54 +2792,53 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) if (desktop == NULL) { return; } - - Inkscape::Selection *selection = sp_desktop_selection(desktop); - SPItem *item = selection->singleItem(); - if (g_slist_length(const_cast(selection->itemList())) != 1 || !item) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one path to clone.")); - return; - } - if ( !(SP_IS_SHAPE(item) || SP_IS_TEXT(item)) ) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one path to clone.")); - return; - } - - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - Inkscape::XML::Node *parent = item->getRepr()->parent(); - - // create the LPE - Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect"); - { - lpe_repr->setAttribute("effect", "clone_original"); - gchar *href = g_strdup_printf("#%s", item->getRepr()->attribute("id")); - lpe_repr->setAttribute("linkedpath", href); - g_free(href); - desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to and assigns the 'id' attribute - } - const gchar * lpe_id = lpe_repr->attribute("id"); - Inkscape::GC::release(lpe_repr); - - // create the new path - Inkscape::XML::Node *clone = xml_doc->createElement("svg:path"); - { - clone->setAttribute("d", "M 0 0", false); - // add the new clone to the top of the original's parent - parent->appendChild(clone); - SPObject *clone_obj = desktop->doc()->getObjectById(clone->attribute("id")); - if (SP_IS_LPE_ITEM(clone_obj)) { - gchar *href = g_strdup_printf("#%s", lpe_id); - SP_LPE_ITEM(clone_obj)->addPathEffect( href, false ); - g_free(href); + + Inkscape::SVGOStringStream os; + SPObject * firstItem = NULL; + for (const GSList * item = desktop->selection->itemList(); item != NULL; item = item->next) { + if (SP_IS_SHAPE(item->data) || SP_IS_TEXT(item->data)) { + if (firstItem) { + os << "|"; + } else { + firstItem = SP_ITEM(item->data); + } + os << "#" << SP_ITEM(item->data)->getId() << ",0"; } } + if (firstItem) { + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + SPObject *parent = firstItem->parent; - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, - _("Clone original path")); + // create the LPE + Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect"); + { + lpe_repr->setAttribute("effect", "fill_between_many"); + lpe_repr->setAttribute("linkedpaths", os.str().c_str()); + desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to and assigns the 'id' attribute + } + const gchar * lpe_id = lpe_repr->attribute("id"); + Inkscape::GC::release(lpe_repr); - // select the new object: - selection->set(clone); + // create the new path + Inkscape::XML::Node *clone = xml_doc->createElement("svg:path"); + { + clone->setAttribute("d", "M 0 0", false); + // add the new clone to the top of the original's parent + parent->appendChildRepr(clone); + SPObject *clone_obj = desktop->doc()->getObjectById(clone->attribute("id")); + if (SP_IS_LPE_ITEM(clone_obj)) { + gchar *href = g_strdup_printf("#%s", lpe_id); + //sp_lpe_item_add_path_effect( SP_LPE_ITEM(clone_obj), href, false ); + SP_LPE_ITEM(clone_obj)->addPathEffect(href, false); + g_free(href); + } + } - Inkscape::GC::release(clone); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, + _("Fill between strokes")); + } else { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to fill.")); + } } void sp_selection_to_marker(SPDesktop *desktop, bool apply) @@ -3663,6 +3662,118 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) g_free(filepath); } +/* Creates a mask or clipPath from selection. + * What is a clip group? + * A clip group is a tangled mess of XML that allows an object inside a group + * to clip the entire group using a few s and generally irritating me. + */ + +void sp_selection_set_clipgroup(SPDesktop *desktop) +{ + if (desktop == NULL) { + return; + } + SPDocument* doc = sp_desktop_document(desktop); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + + Inkscape::Selection *selection = sp_desktop_selection(desktop); + if (selection->isEmpty()) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to create clippath or mask from.")); + return; + } + + GSList const *l = const_cast(selection->reprList()); + + GSList *p = g_slist_copy(const_cast(l)); + + p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); + + selection->clear(); + + gint topmost = (static_cast(g_slist_last(p)->data))->position(); + Inkscape::XML::Node *topmost_parent = (static_cast(g_slist_last(p)->data))->parent(); + + Inkscape::XML::Node *inner = xml_doc->createElement("svg:g"); + inner->setAttribute("inkscape:label", "Clip"); + + while (p) { + Inkscape::XML::Node *current = static_cast(p->data); + + if (current->parent() == topmost_parent) { + Inkscape::XML::Node *spnew = current->duplicate(xml_doc); + sp_repr_unparent(current); + inner->appendChild(spnew); + Inkscape::GC::release(spnew); + topmost --; // only reduce count for those items deleted from topmost_parent + } else { // move it to topmost_parent first + GSList *temp_clip = NULL; + + // At this point, current may already have no item, due to its being a clone whose original is already moved away + // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform + gchar const *t_str = current->attribute("transform"); + Geom::Affine item_t(Geom::identity()); + if (t_str) + sp_svg_transform_read(t_str, &item_t); + item_t *= SP_ITEM(doc->getObjectByRepr(current->parent()))->i2doc_affine(); + // FIXME: when moving both clone and original from a transformed group (either by + // grouping into another parent, or by cut/paste) the transform from the original's + // parent becomes embedded into original itself, and this affects its clones. Fix + // this by remembering the transform diffs we write to each item into an array and + // then, if this is clone, looking up its original in that array and pre-multiplying + // it by the inverse of that original's transform diff. + + sp_selection_copy_one(current, item_t, &temp_clip, xml_doc); + sp_repr_unparent(current); + + // paste into topmost_parent (temporarily) + GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip); + if (temp_clip) g_slist_free(temp_clip); + if (copied) { // if success, + // take pasted object (now in topmost_parent) + Inkscape::XML::Node *in_topmost = static_cast(copied->data); + // make a copy + Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); + // remove pasted + sp_repr_unparent(in_topmost); + // put its copy into group + inner->appendChild(spnew); + Inkscape::GC::release(spnew); + g_slist_free(copied); + } + } + p = g_slist_remove(p, current); + } + + Inkscape::XML::Node *outer = xml_doc->createElement("svg:g"); + outer->appendChild(inner); + topmost_parent->appendChild(outer); + outer->setPosition(topmost + 1); + + Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); + clone->setAttribute("x", "0", false); + clone->setAttribute("y", "0", false); + clone->setAttribute("xlink:href", g_strdup_printf("#%s", inner->attribute("id")), false); + + clone->setAttribute("inkscape:transform-center-x", inner->attribute("inkscape:transform-center-x"), false); + clone->setAttribute("inkscape:transform-center-y", inner->attribute("inkscape:transform-center-y"), false); + + const Geom::Affine maskTransform(Geom::Affine::identity()); + GSList *templist = NULL; + + templist = g_slist_append(templist, clone); + // add the new clone to the top of the original's parent + gchar const *mask_id = SPClipPath::create(templist, doc, &maskTransform); + + g_slist_free(templist); + + outer->setAttribute("clip-path", g_strdup_printf("url(#%s)", mask_id)); + + Inkscape::GC::release(clone); + + selection->set(outer); + DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Create Clip Group")); +} + /** * Creates a mask or clipPath from selection. * Two different modes: diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 01c35d65a..d86906548 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -17,21 +17,21 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/forward.h> #include "sp-item.h" -#include "2geom/forward.h" -namespace Inkscape { class Selection; } +class SPCSSAttr; +class SPDesktop; +typedef struct _GSList GSList; namespace Inkscape { + +class Selection; + namespace LivePathEffect { class PathParam; } -} -class SPCSSAttr; -class SPDesktop; - -namespace Inkscape { class SelectionHelper { public: static void selectAll(SPDesktop *desktop); @@ -108,21 +108,21 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons void sp_selection_remove_transform (SPDesktop *desktop); void sp_selection_scale_absolute (Inkscape::Selection *selection, double x0, double x1, double y0, double y1); void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale); -void sp_selection_rotate_relative (Inkscape::Selection *selection, Geom::Point const ¢er, gdouble angle); +void sp_selection_rotate_relative (Inkscape::Selection *selection, Geom::Point const ¢er, double angle); void sp_selection_skew_relative (Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy); void sp_selection_move_relative (Inkscape::Selection *selection, Geom::Point const &move, bool compensate = true); void sp_selection_move_relative (Inkscape::Selection *selection, double dx, double dy); void sp_selection_rotate_90 (SPDesktop *desktop, bool ccw); -void sp_selection_rotate (Inkscape::Selection *selection, gdouble angle); -void sp_selection_rotate_screen (Inkscape::Selection *selection, gdouble angle); +void sp_selection_rotate (Inkscape::Selection *selection, double angle); +void sp_selection_rotate_screen (Inkscape::Selection *selection, double angle); -void sp_selection_scale (Inkscape::Selection *selection, gdouble grow); -void sp_selection_scale_screen (Inkscape::Selection *selection, gdouble grow_pixels); -void sp_selection_scale_times (Inkscape::Selection *selection, gdouble times); +void sp_selection_scale (Inkscape::Selection *selection, double grow); +void sp_selection_scale_screen (Inkscape::Selection *selection, double grow_pixels); +void sp_selection_scale_times (Inkscape::Selection *selection, double times); -void sp_selection_move (Inkscape::Selection *selection, gdouble dx, gdouble dy); -void sp_selection_move_screen (Inkscape::Selection *selection, gdouble dx, gdouble dy); +void sp_selection_move (Inkscape::Selection *selection, double dx, double dy); +void sp_selection_move_screen (Inkscape::Selection *selection, double dx, double dy); void sp_selection_item_next (SPDesktop *desktop); void sp_selection_item_prev (SPDesktop *desktop); @@ -156,6 +156,7 @@ void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, fl void sp_selection_create_bitmap_copy (SPDesktop *desktop); +void sp_selection_set_clipgroup(SPDesktop *desktop); void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer); void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path); diff --git a/src/selection-describer.h b/src/selection-describer.h index b4174edd8..5514ce4b1 100644 --- a/src/selection-describer.h +++ b/src/selection-describer.h @@ -16,11 +16,10 @@ #include #include "message-context.h" -namespace Inkscape { class Selection; } - namespace Inkscape { class MessageStack; +class Selection; class SelectionDescriber : public sigc::trackable { public: @@ -29,7 +28,7 @@ public: private: void _updateMessageFromSelection(Inkscape::Selection *selection); - void _selectionModified(Inkscape::Selection *selection, guint /*flags*/); + void _selectionModified(Inkscape::Selection *selection, unsigned int /*flags*/); sigc::connection *_selection_changed_connection; sigc::connection *_selection_modified_connection; @@ -43,6 +42,7 @@ private: } #endif + /* Local Variables: mode:c++ diff --git a/src/selection.h b/src/selection.h index ba38bec08..5964b20e8 100644 --- a/src/selection.h +++ b/src/selection.h @@ -30,6 +30,7 @@ class SPDesktop; class SPItem; class SPBox3D; class Persp3D; +typedef struct _GSList GSList; namespace Inkscape { class LayerModel; @@ -256,10 +257,10 @@ public: std::list const box3DList(Persp3D *persp = NULL); /** Returns the number of layers in which there are selected objects. */ - guint numberOfLayers(); + unsigned int numberOfLayers(); /** Returns the number of parents to which the selected objects belong. */ - guint numberOfParents(); + unsigned int numberOfParents(); /** Returns the bounding rectangle of the selection. */ Geom::OptRect bounds(SPItem::BBoxType type) const; @@ -317,11 +318,11 @@ public: * @return the resulting connection * */ - sigc::connection connectModified(sigc::slot const &slot) + sigc::connection connectModified(sigc::slot const &slot) { return _modified_signal.connect(slot); } - sigc::connection connectModifiedFirst(sigc::slot const &slot) + sigc::connection connectModifiedFirst(sigc::slot const &slot) { return _modified_signal.slots().insert(_modified_signal.slots().begin(), slot); } @@ -333,12 +334,12 @@ private: void operator=(Selection const &); /** Issues modification notification signals. */ - static gboolean _emit_modified(Selection *selection); + static int _emit_modified(Selection *selection); /** Schedules an item modification signal to be sent. */ - void _schedule_modified(SPObject *obj, guint flags); + void _schedule_modified(SPObject *obj, unsigned int flags); /** Issues modified selection signal. */ - void _emitModified(guint flags); + void _emitModified(unsigned int flags); /** Issues changed selection signal. */ void _emitChanged(bool persist_selection_context = false); @@ -374,15 +375,15 @@ private: LayerModel *_layers; GC::soft_ptr _desktop; SPObject* _selection_context; - guint _flags; - guint _idle; + unsigned int _flags; + unsigned int _idle; std::map _modified_connections; std::map _release_connections; sigc::connection _context_release_connection; sigc::signal _changed_signal; - sigc::signal _modified_signal; + sigc::signal _modified_signal; }; } diff --git a/src/seltrans-handles.h b/src/seltrans-handles.h index 740729a6e..ebd5758c8 100644 --- a/src/seltrans-handles.h +++ b/src/seltrans-handles.h @@ -14,11 +14,13 @@ #include <2geom/forward.h> #include + #include "enums.h" -namespace Inkscape -{ - class SelTrans; +typedef unsigned int guint32; + +namespace Inkscape { + class SelTrans; } guint32 const DEF_COLOR[] = { 0xff, 0xff6600, 0xff6600, 0xff, 0xff, 0xff }; @@ -34,7 +36,7 @@ enum SPSelTransType { struct SPSelTransTypeInfo { guint32 const *color; - gchar const *tip; + char const *tip; }; // One per handle type in order extern SPSelTransTypeInfo const handtypes[5]; @@ -45,7 +47,7 @@ struct SPSelTransHandle { SPSelTransType type; SPAnchorType anchor; GdkCursorType cursor; - guint control; + unsigned int control; gdouble x, y; }; // These are 4 * each handle type + 1 for center @@ -64,5 +66,3 @@ extern SPSelTransHandle const hands[17]; End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : - - diff --git a/src/seltrans.h b/src/seltrans.h index 44268ed69..d5db1542d 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -15,32 +15,33 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include #include <2geom/point.h> #include <2geom/affine.h> #include <2geom/rect.h> +#include +#include +#include + #include "knot.h" -#include "selcue.h" #include "message-context.h" -#include -#include "sp-item.h" #include "seltrans-handles.h" +#include "selcue.h" +#include "sp-item.h" + class SPKnot; class SPDesktop; struct SPCanvasItem; struct SPCtrlLine; struct SPSelTransHandle; +typedef struct _GSList GSList; -namespace Inkscape -{ +namespace Inkscape { Geom::Scale calcScaleFactors(Geom::Point const &initial_point, Geom::Point const &new_point, Geom::Point const &origin, bool const skew = false); -namespace XML -{ - class Node; +namespace XML { + class Node; } class SelTrans @@ -56,26 +57,26 @@ public: void increaseState(); void resetState(); void setCenter(Geom::Point const &p); - void grab(Geom::Point const &p, gdouble x, gdouble y, bool show_handles, bool translating); + void grab(Geom::Point const &p, double x, double y, bool show_handles, bool translating); void transform(Geom::Affine const &rel_affine, Geom::Point const &norm); void ungrab(); void stamp(); - void moveTo(Geom::Point const &xy, guint state); - void stretch(SPSelTransHandle const &handle, Geom::Point &pt, guint state); - void scale(Geom::Point &pt, guint state); - void skew(SPSelTransHandle const &handle, Geom::Point &pt, guint state); - void rotate(Geom::Point &pt, guint state); - gboolean request(SPSelTransHandle const &handle, Geom::Point &pt, guint state); - gboolean scaleRequest(Geom::Point &pt, guint state); - gboolean stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state); - gboolean skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state); - gboolean rotateRequest(Geom::Point &pt, guint state); - gboolean centerRequest(Geom::Point &pt, guint state); - - gboolean handleRequest(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle); - void handleGrab(SPKnot *knot, guint state, SPSelTransHandle const &handle); - void handleClick(SPKnot *knot, guint state, SPSelTransHandle const &handle); - void handleNewEvent(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle); + void moveTo(Geom::Point const &xy, unsigned int state); + void stretch(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state); + void scale(Geom::Point &pt, unsigned int state); + void skew(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state); + void rotate(Geom::Point &pt, unsigned int state); + int request(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state); + int scaleRequest(Geom::Point &pt, unsigned int state); + int stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state); + int skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state); + int rotateRequest(Geom::Point &pt, unsigned int state); + int centerRequest(Geom::Point &pt, unsigned int state); + + int handleRequest(SPKnot *knot, Geom::Point *position, unsigned int state, SPSelTransHandle const &handle); + void handleGrab(SPKnot *knot, unsigned int state, SPSelTransHandle const &handle); + void handleClick(SPKnot *knot, unsigned int state, SPSelTransHandle const &handle); + void handleNewEvent(SPKnot *knot, Geom::Point *position, unsigned int state, SPSelTransHandle const &handle); enum Show { @@ -115,7 +116,7 @@ private: void _updateHandles(); void _updateVolatileState(); void _selChanged(Inkscape::Selection *selection); - void _selModified(Inkscape::Selection *selection, guint flags); + void _selModified(Inkscape::Selection *selection, unsigned int flags); void _boundingBoxPrefsChanged(int prefs_bbox); void _makeHandles(); void _showHandles(SPSelTransType type); @@ -156,7 +157,7 @@ private: Geom::OptRect _bbox; Geom::OptRect _visual_bbox; Geom::OptRect _geometric_bbox; - gdouble _strokewidth; + double _strokewidth; Geom::Affine _current_relative_affine; Geom::Affine _absolute_affine; @@ -173,8 +174,8 @@ private: Geom::Point _origin_for_specpoints; Geom::Point _origin_for_bboxpoints; - gdouble _handle_x; - gdouble _handle_y; + double _handle_x; + double _handle_y; boost::optional _center; bool _center_is_set; ///< we've already set _center, no need to reread it from items @@ -184,8 +185,8 @@ private: SPCanvasItem *_norm; SPCanvasItem *_grip; SPCtrlLine *_l[4]; - guint _sel_changed_id; - guint _sel_modified_id; + unsigned int _sel_changed_id; + unsigned int _sel_modified_id; GSList *_stamp_cache; Geom::Point _origin; ///< position of origin for transforms diff --git a/src/shape-editor.h b/src/shape-editor.h index df0dbfa3a..d2611b111 100644 --- a/src/shape-editor.h +++ b/src/shape-editor.h @@ -12,8 +12,6 @@ * */ -#include - namespace Inkscape { namespace XML { class Node; } } class KnotHolder; @@ -37,10 +35,10 @@ public: bool knot_mouseover() const; - static void blockSetItem(bool b) { _blockSetItem = b; } // kludge? + static void blockSetItem(bool b) { _blockSetItem = b; } // kludge - static void event_attr_changed(Inkscape::XML::Node * /*repr*/, gchar const *name, gchar const * /*old_value*/, - gchar const * /*new_value*/, bool /*is_interactive*/, void *data); + static void event_attr_changed(Inkscape::XML::Node * /*repr*/, char const *name, char const * /*old_value*/, + char const * /*new_value*/, bool /*is_interactive*/, void *data); private: bool has_knotholder(); void reset_item (bool keep_knotholder = true); diff --git a/src/shortcuts.h b/src/shortcuts.h index 406768f97..f24a82603 100644 --- a/src/shortcuts.h +++ b/src/shortcuts.h @@ -1,5 +1,5 @@ -#ifndef __SP_SHORTCUTS_H__ -#define __SP_SHORTCUTS_H__ +#ifndef SEEN_SP_SHORTCUTS_H +#define SEEN_SP_SHORTCUTS_H /* * Keyboard shortcut processing @@ -16,9 +16,6 @@ typedef struct _GtkAccelGroup GtkAccelGroup; typedef struct _GtkWidget GtkWidget; -struct _GtkAccelGroup; -struct _GtkWidget; - namespace Inkscape { class Verb; namespace UI { @@ -42,14 +39,14 @@ bool sp_shortcut_invoke (unsigned int shortcut, Inkscape::UI::View::View *view); void sp_shortcut_init(); Inkscape::Verb * sp_shortcut_get_verb (unsigned int shortcut); unsigned int sp_shortcut_get_primary (Inkscape::Verb * verb); // Returns GDK_VoidSymbol if no shortcut is found. -gchar* sp_shortcut_get_label (unsigned int shortcut); // Returns the human readable form of the shortcut (or NULL), for example Shift+Ctrl+F. Free the returned string with g_free. +char* sp_shortcut_get_label (unsigned int shortcut); // Returns the human readable form of the shortcut (or NULL), for example Shift+Ctrl+F. Free the returned string with g_free. void sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary, bool const is_user_set=false); void sp_shortcut_unset(unsigned int const shortcut); void sp_shortcut_add_to_file(char const *action, unsigned int const shortcut); void sp_shortcut_delete_from_file(char const *action, unsigned int const shortcut); void sp_shortcuts_delete_all_from_file(); Glib::ustring sp_shortcut_to_label(unsigned int const shortcut); -unsigned int sp_gdkmodifier_to_shortcut(guint accel_key, Gdk::ModifierType gdkmodifier, guint hardware_keycode); +unsigned int sp_gdkmodifier_to_shortcut(unsigned int accel_key, Gdk::ModifierType gdkmodifier, unsigned int hardware_keycode); void sp_shortcut_get_file_names(std::vector *names, std::vector *paths); bool sp_shortcut_is_user_set(Inkscape::Verb *verb); void sp_shortcut_file_export(); diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 8bb7cb52f..54e33e1a8 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -14,7 +14,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -//#include "snapped-point.h" +#include <2geom/point.h> +#include <2geom/rect.h> +#include + #include "snap-enums.h" class SPItem; // forward declaration diff --git a/src/snap-preferences.h b/src/snap-preferences.h index a7a2e2926..7bdeea52e 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -49,13 +49,13 @@ public: void setSnapPerp(bool enabled) {_snap_perp = enabled;} void setSnapTang(bool enabled) {_snap_tang = enabled;} - gdouble getGridTolerance() const {return _grid_tolerance;} - gdouble getGuideTolerance() const {return _guide_tolerance;} - gdouble getObjectTolerance() const {return _object_tolerance;} + double getGridTolerance() const {return _grid_tolerance;} + double getGuideTolerance() const {return _guide_tolerance;} + double getObjectTolerance() const {return _object_tolerance;} - void setGridTolerance(gdouble val) {_grid_tolerance = val;} - void setGuideTolerance(gdouble val) {_guide_tolerance = val;} - void setObjectTolerance(gdouble val) {_object_tolerance = val;} + void setGridTolerance(double val) {_grid_tolerance = val;} + void setGuideTolerance(double val) {_guide_tolerance = val;} + void setObjectTolerance(double val) {_object_tolerance = val;} private: @@ -91,9 +91,9 @@ private: bool _snap_perp; bool _snap_tang; - gdouble _grid_tolerance; - gdouble _guide_tolerance; - gdouble _object_tolerance; + double _grid_tolerance; + double _guide_tolerance; + double _object_tolerance; }; } diff --git a/src/snap.cpp b/src/snap.cpp index 5b795b22f..fb87aae6b 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -116,7 +116,7 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p, Inkscape::SnapSourceType const source_type, Geom::OptRect const &bbox_to_snap) const { - Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type), bbox_to_snap); + Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type, Inkscape::SNAPTARGET_PATH), bbox_to_snap); s.getPointIfSnapped(p); } diff --git a/src/snap.h b/src/snap.h index 67af20063..20b2b246f 100644 --- a/src/snap.h +++ b/src/snap.h @@ -32,6 +32,7 @@ enum SPGuideDragType { // used both here and in desktop-events.cpp class SPGuide; class SPNamedView; +typedef struct _GSList GSList; /** * Class to coordinate snapping operations. diff --git a/src/snapped-curve.h b/src/snapped-curve.h index 6bb8bfeca..0e3a1c747 100644 --- a/src/snapped-curve.h +++ b/src/snapped-curve.h @@ -11,14 +11,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include <2geom/forward.h> #include #include + #include "snapped-point.h" #include "snapped-line.h" -#include <2geom/forward.h> -namespace Inkscape -{ +namespace Inkscape { /// Class describing the result of an attempt to snap to a curve. class SnappedCurve : public SnappedPoint diff --git a/src/snapped-point.h b/src/snapped-point.h index bf440c450..9d77ab162 100644 --- a/src/snapped-point.h +++ b/src/snapped-point.h @@ -12,10 +12,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include -#include #include <2geom/geom.h> -#include +#include +#include + +#include "snap-candidate.h" namespace Inkscape { diff --git a/src/snapper.h b/src/snapper.h index c609239cf..9616d0954 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -12,15 +12,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ -#include -#include #include -#include // for g_assert +#include +#include +#include "snap-candidate.h" #include "snapped-point.h" #include "snapped-line.h" #include "snapped-curve.h" -#include "snap-candidate.h" struct IntermSnapResults { std::list points; @@ -86,7 +85,7 @@ public: bool hasPoint() const {return _type != DIRECTION && _type != UNDEFINED;} Geom::Point getPoint() const { - g_assert(_type != DIRECTION && _type != UNDEFINED); + assert(_type != DIRECTION && _type != UNDEFINED); return _point; } @@ -95,7 +94,7 @@ public: } Geom::Coord getRadius() const { - g_assert(_type == CIRCLE); + assert(_type == CIRCLE); return _radius; } @@ -121,7 +120,7 @@ public: Geom::Point const p2_on_cl = p1_on_cl + _direction; return Geom::projection(p, Geom::Line(p1_on_cl, p2_on_cl)); } else { - g_warning("Bug: trying to find the projection onto an undefined constraint"); + printf("WARNING: Bug: trying to find the projection onto an undefined constraint"); return Geom::Point(); } } diff --git a/src/sp-anchor.h b/src/sp-anchor.h index 778640032..d17718344 100644 --- a/src/sp-anchor.h +++ b/src/sp-anchor.h @@ -1,5 +1,5 @@ -#ifndef __SP_ANCHOR_H__ -#define __SP_ANCHOR_H__ +#ifndef SEEN_SP_ANCHOR_H +#define SEEN_SP_ANCHOR_H /* * SVG element implementation @@ -23,16 +23,16 @@ public: SPAnchor(); virtual ~SPAnchor(); - gchar *href; + char *href; virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void set(unsigned int key, gchar const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char* displayName() const; - virtual gchar* description() const; - virtual gint event(SPEvent *event); + virtual char* description() const; + virtual int event(SPEvent *event); }; #endif diff --git a/src/sp-clippath.h b/src/sp-clippath.h index ba7a90a57..eb8b14174 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -19,6 +19,9 @@ #define SP_IS_CLIPPATH(obj) (dynamic_cast((SPObject*)obj) != NULL) struct SPClipPathView; +typedef struct _GSList GSList; + +#include #include "sp-object-group.h" #include "uri-references.h" @@ -42,8 +45,8 @@ public: unsigned int clipPathUnits : 1; SPClipPathView *display; - static const gchar *create(GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); - static GType sp_clippath_get_type(void); + static char const *create(GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); + //static GType sp_clippath_get_type(void); Inkscape::DrawingItem *show(Inkscape::Drawing &drawing, unsigned int key); void hide(unsigned int key); @@ -57,12 +60,12 @@ protected: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; @@ -90,10 +93,10 @@ protected: Inkscape::XML::Node * const owner_repr = owner->getRepr(); //XML Tree being used directly here while it shouldn't be... Inkscape::XML::Node * const obj_repr = obj->getRepr(); - gchar const * owner_name = NULL; - gchar const * owner_clippath = NULL; - gchar const * obj_name = NULL; - gchar const * obj_id = NULL; + char const * owner_name = NULL; + char const * owner_clippath = NULL; + char const * obj_name = NULL; + char const * obj_id = NULL; if (owner_repr != NULL) { owner_name = owner_repr->name(); owner_clippath = owner_repr->attribute("clippath"); @@ -102,7 +105,7 @@ protected: obj_name = obj_repr->name(); obj_id = obj_repr->attribute("id"); } - g_warning("Ignoring recursive clippath reference " + printf("WARNING: Ignoring recursive clippath reference " "<%s clippath=\"%s\"> in <%s id=\"%s\">", owner_name, owner_clippath, obj_name, obj_id); diff --git a/src/sp-conn-end-pair.h b/src/sp-conn-end-pair.h index 9f7f5a5d2..93f54378c 100644 --- a/src/sp-conn-end-pair.h +++ b/src/sp-conn-end-pair.h @@ -11,12 +11,10 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include -#include -#include -#include +#include +#include + #include "libavoid/connector.h" @@ -33,21 +31,21 @@ class Node; } } -extern void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, gdouble curvature); +extern void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, double curvature); class SPConnEndPair { public: SPConnEndPair(SPPath *); ~SPConnEndPair(); void release(); - void setAttr(unsigned const key, gchar const *const value); + void setAttr(unsigned const key, char const *const value); void writeRepr(Inkscape::XML::Node *const repr) const; void getAttachedItems(SPItem *[2]) const; void getEndpoints(Geom::Point endPts[]) const; - gdouble getCurvature(void) const; + double getCurvature(void) const; SPConnEnd** getConnEnds(void); bool isOrthogonal(void) const; - friend void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, gdouble curvature); + friend void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, double curvature); void tellLibavoidNewEndpoints(const bool processTransaction = false); bool reroutePathFromLibavoid(void); void makePathInvalid(void); @@ -64,7 +62,7 @@ private: Avoid::ConnRef *_connRef; int _connType; - gdouble _connCurvature; + double _connCurvature; // A sigc connection for transformed signal. sigc::connection _transformed_connection; diff --git a/src/sp-conn-end.h b/src/sp-conn-end.h index a0b1ba5df..2b89a159d 100644 --- a/src/sp-conn-end.h +++ b/src/sp-conn-end.h @@ -1,8 +1,7 @@ #ifndef SEEN_SP_CONN_END #define SEEN_SP_CONN_END -#include -#include +#include #include #include "sp-use-reference.h" @@ -15,7 +14,7 @@ public: SPConnEnd(SPObject *owner); SPUseReference ref; - gchar *href; + char *href; /** Change of href string (not a modification of the attributes of the referrent). */ sigc::connection _changed_connection; @@ -29,13 +28,13 @@ public: /** A sigc connection for owning group transformed, used to do move compensation. */ sigc::connection _group_connection; - void setAttacherHref(gchar const *, SPPath *); - void setAttacherEndpoint(gchar const *, SPPath *); + void setAttacherHref(char const * value, SPPath * unused); + //void setAttacherEndpoint(char const *, SPPath *); // not defined private: - SPConnEnd(SPConnEnd const &); - SPConnEnd &operator=(SPConnEnd const &); + SPConnEnd(SPConnEnd const &); // no copy + SPConnEnd &operator=(SPConnEnd const &); // no assign }; void sp_conn_end_href_changed(SPObject *old_ref, SPObject *ref, diff --git a/src/sp-cursor.cpp b/src/sp-cursor.cpp index ea73da00c..16659d1cf 100644 --- a/src/sp-cursor.cpp +++ b/src/sp-cursor.cpp @@ -17,13 +17,14 @@ */ #include +#include #include #include #include "color.h" #include "sp-cursor.h" -static void free_cursor_data(guchar *pixels, gpointer /*data*/) { +static void free_cursor_data(unsigned char *pixels, void* /*data*/) { delete [] reinterpret_cast(pixels); } @@ -53,7 +54,7 @@ struct RGBA { } }; -GdkPixbuf *sp_cursor_pixbuf_from_xpm(gchar const *const *xpm, GdkColor const& black, GdkColor const& white, guint32 fill, guint32 stroke) +GdkPixbuf *sp_cursor_pixbuf_from_xpm(char const *const *xpm, GdkColor const& black, GdkColor const& white, guint32 fill, guint32 stroke) { int height = 0; int width = 0; @@ -72,7 +73,7 @@ GdkPixbuf *sp_cursor_pixbuf_from_xpm(gchar const *const *xpm, GdkColor const& bl char const *p = xpm[1 + i]; g_assert(*p >=0); - guchar const ccode = (guchar) *p; + unsigned char const ccode = (guchar) *p; p++; while (isspace(*p)) { @@ -110,7 +111,7 @@ GdkPixbuf *sp_cursor_pixbuf_from_xpm(gchar const *const *xpm, GdkColor const& bl return gdk_pixbuf_new_from_data(reinterpret_cast(pixmap_buffer), GDK_COLORSPACE_RGB, TRUE, 8, width, height, width * sizeof(guint32), free_cursor_data, NULL); } -GdkCursor *sp_cursor_new_from_xpm(gchar const *const *xpm, gint hot_x, gint hot_y) +GdkCursor *sp_cursor_new_from_xpm(char const *const *xpm, int hot_x, int hot_y) { GdkCursor *cursor = 0; GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)xpm); diff --git a/src/sp-cursor.h b/src/sp-cursor.h index f445127ad..c0b8b46a3 100644 --- a/src/sp-cursor.h +++ b/src/sp-cursor.h @@ -1,10 +1,13 @@ #ifndef SP_CURSOR_H #define SP_CURSOR_H -#include +typedef unsigned int guint32; +typedef struct _GdkPixbuf GdkPixbuf; +typedef struct _GdkCursor GdkCursor; +typedef struct _GdkColor GdkColor; -GdkPixbuf* sp_cursor_pixbuf_from_xpm(gchar const *const *xpm, GdkColor const& black, GdkColor const& white, guint32 fill, guint32 stroke); -GdkCursor *sp_cursor_new_from_xpm(gchar const *const *xpm, gint hot_x, gint hot_y); +GdkPixbuf* sp_cursor_pixbuf_from_xpm(char const *const *xpm, GdkColor const& black, GdkColor const& white, guint32 fill, guint32 stroke); +GdkCursor *sp_cursor_new_from_xpm(char const *const *xpm, int hot_x, int hot_y); #endif diff --git a/src/sp-defs.h b/src/sp-defs.h index 6efdea1f3..c122cb2a9 100644 --- a/src/sp-defs.h +++ b/src/sp-defs.h @@ -27,7 +27,7 @@ protected: virtual void release(); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; #endif // !SEEN_SP_DEFS_H diff --git a/src/sp-desc.h b/src/sp-desc.h index 2bb42b333..40888bee4 100644 --- a/src/sp-desc.h +++ b/src/sp-desc.h @@ -1,5 +1,5 @@ -#ifndef __SP_DESC_H__ -#define __SP_DESC_H__ +#ifndef SEEN_SP_DESC_H +#define SEEN_SP_DESC_H /* * SVG implementation @@ -23,7 +23,7 @@ public: virtual ~SPDesc(); protected: - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index e575b8761..09768fd6d 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -24,7 +24,7 @@ #define SP_IS_GENERICELLIPSE(obj) (dynamic_cast((obj)) != NULL) enum GenericEllipseType { - SP_GENERIC_ELLIPSE_UNDEFINED, + SP_GENERIC_ELLIPSE_UNDEFINED, // FIXME shouldn't exist SP_GENERIC_ELLIPSE_ARC, SP_GENERIC_ELLIPSE_CIRCLE, SP_GENERIC_ELLIPSE_ELLIPSE @@ -53,10 +53,10 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual void set(unsigned int key, gchar const *value); + virtual void set(unsigned int key, char const *value); virtual void update(SPCtx *ctx, unsigned int flags); - virtual Inkscape::XML::Node *write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node *write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char *displayName() const; virtual void set_shape(); @@ -76,7 +76,7 @@ public: Geom::Point getPointAtAngle(double arg) const; bool set_elliptical_path_attribute(Inkscape::XML::Node *repr); - void position_set(gdouble x, gdouble y, gdouble rx, gdouble ry); + void position_set(double x, double y, double rx, double ry); protected: /** diff --git a/src/sp-filter-primitive.h b/src/sp-filter-primitive.h index 040e2f31f..d81adbd10 100644 --- a/src/sp-filter-primitive.h +++ b/src/sp-filter-primitive.h @@ -1,5 +1,5 @@ -#ifndef __SP_FILTER_PRIMITIVE_H__ -#define __SP_FILTER_PRIMITIVE_H__ +#ifndef SEEN_SP_FILTER_PRIMITIVE_H +#define SEEN_SP_FILTER_PRIMITIVE_H /** \file * Document level base class for all SVG filter primitives. @@ -40,11 +40,11 @@ protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); public: virtual void build_renderer(Inkscape::Filters::Filter* filter) = 0; @@ -54,8 +54,8 @@ public: void sp_filter_primitive_renderer_common(SPFilterPrimitive *sp_prim, Inkscape::Filters::FilterPrimitive *nr_prim); int sp_filter_primitive_name_previous_out(SPFilterPrimitive *prim); -int sp_filter_primitive_read_in(SPFilterPrimitive *prim, gchar const *name); -int sp_filter_primitive_read_result(SPFilterPrimitive *prim, gchar const *name); +int sp_filter_primitive_read_in(SPFilterPrimitive *prim, char const *name); +int sp_filter_primitive_read_result(SPFilterPrimitive *prim, char const *name); #endif /* diff --git a/src/sp-filter.h b/src/sp-filter.h index 0d087c5bf..e6318c569 100644 --- a/src/sp-filter.h +++ b/src/sp-filter.h @@ -12,6 +12,7 @@ #ifndef SP_FILTER_H_SEEN #define SP_FILTER_H_SEEN +#include #include #include "number-opt-number.h" @@ -19,8 +20,6 @@ #include "sp-filter-units.h" #include "svg/svg-length.h" -#include - #define SP_FILTER(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_FILTER(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -45,9 +44,9 @@ public: virtual ~SPFilter(); SPFilterUnits filterUnits; - guint filterUnits_set : 1; + unsigned int filterUnits_set : 1; SPFilterUnits primitiveUnits; - guint primitiveUnits_set : 1; + unsigned int primitiveUnits_set : 1; SVGLength x; SVGLength y; SVGLength width; @@ -68,11 +67,11 @@ protected: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node* child); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; void sp_filter_set_filter_units(SPFilter *filter, SPFilterUnits filterUnits); @@ -88,14 +87,14 @@ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr int sp_filter_primitive_count(SPFilter *filter); /// Returns a slot number for given image name, or -1 for unknown name. -int sp_filter_get_image_name(SPFilter *filter, gchar const *name); +int sp_filter_get_image_name(SPFilter *filter, char const *name); /// Returns slot number for given image name, even if it's unknown. -int sp_filter_set_image_name(SPFilter *filter, gchar const *name); +int sp_filter_set_image_name(SPFilter *filter, char const *name); /** Finds image name based on it's slot number. Returns 0 for unknown slot * numbers. */ -gchar const *sp_filter_name_for_image(SPFilter const *filter, int const image); +char const *sp_filter_name_for_image(SPFilter const *filter, int const image); /// Returns a result image name that is not in use inside this filter. Glib::ustring sp_filter_get_new_result_name(SPFilter *filter); diff --git a/src/sp-flowdiv.h b/src/sp-flowdiv.h index d00cfc51b..4a3690726 100644 --- a/src/sp-flowdiv.h +++ b/src/sp-flowdiv.h @@ -1,5 +1,5 @@ -#ifndef __SP_ITEM_FLOWDIV_H__ -#define __SP_ITEM_FLOWDIV_H__ +#ifndef SEEN_SP_ITEM_FLOWDIV_H +#define SEEN_SP_ITEM_FLOWDIV_H /* */ @@ -31,11 +31,11 @@ public: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void update(SPCtx* ctx, guint flags); + virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual void set(unsigned int key, gchar const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; class SPFlowtspan : public SPItem { @@ -46,11 +46,11 @@ public: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void update(SPCtx* ctx, guint flags); + virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual void set(unsigned int key, gchar const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; class SPFlowpara : public SPItem { @@ -61,11 +61,11 @@ public: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void update(SPCtx* ctx, guint flags); + virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual void set(unsigned int key, gchar const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; // these do not need any style @@ -78,7 +78,7 @@ protected: virtual void release(); virtual void modified(unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; class SPFlowregionbreak : public SPObject { @@ -90,7 +90,7 @@ protected: virtual void release(); virtual void modified(unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; #endif diff --git a/src/sp-flowregion.h b/src/sp-flowregion.h index 721eb0432..024a298b8 100644 --- a/src/sp-flowregion.h +++ b/src/sp-flowregion.h @@ -1,5 +1,5 @@ -#ifndef __SP_ITEM_FLOWREGION_H__ -#define __SP_ITEM_FLOWREGION_H__ +#ifndef SEEN_SP_ITEM_FLOWREGION_H +#define SEEN_SP_ITEM_FLOWREGION_H /* */ @@ -30,7 +30,7 @@ public: virtual void remove_child(Inkscape::XML::Node *child); virtual void update(SPCtx *ctx, unsigned int flags); virtual void modified(guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char* displayName() const; }; @@ -47,7 +47,7 @@ public: virtual void remove_child(Inkscape::XML::Node *child); virtual void update(SPCtx *ctx, unsigned int flags); virtual void modified(guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char* displayName() const; }; diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index a5b7db22e..743d55030 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -4,10 +4,10 @@ /* */ -#include "sp-item.h" - #include <2geom/forward.h> + #include "libnrtype/Layout-TNG.h" +#include "sp-item.h" #define SP_FLOWTEXT(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_FLOWTEXT(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -63,18 +63,18 @@ public: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node* child); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); virtual Geom::Affine set_transform(Geom::Affine const& xform); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); virtual const char* displayName() const; - virtual gchar* description() const; + virtual char* description() const; virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; diff --git a/src/sp-font-face.h b/src/sp-font-face.h index 531dd5843..669b93197 100644 --- a/src/sp-font-face.h +++ b/src/sp-font-face.h @@ -1,9 +1,5 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef __SP_FONTFACE_H__ -#define __SP_FONTFACE_H__ +#ifndef SEEN_SP_FONTFACE_H +#define SEEN_SP_FONTFACE_H #include @@ -117,11 +113,11 @@ protected: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node* child); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif //#ifndef __SP_FONTFACE_H__ diff --git a/src/sp-font.h b/src/sp-font.h index 6e6f4eec2..6e26a02b2 100644 --- a/src/sp-font.h +++ b/src/sp-font.h @@ -1,7 +1,3 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - #ifndef SP_FONT_H_SEEN #define SP_FONT_H_SEEN @@ -40,11 +36,11 @@ protected: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node* child); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif //#ifndef SP_FONT_H_SEEN diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h index 52413f8a7..c96c0b6e4 100644 --- a/src/sp-glyph-kerning.h +++ b/src/sp-glyph-kerning.h @@ -25,11 +25,11 @@ class GlyphNames { public: - GlyphNames(const gchar* value); + GlyphNames(char const* value); ~GlyphNames(); - bool contains(const char* name); + bool contains(char const* name); private: - gchar* names; + char* names; }; class SPGlyphKerning : public SPObject { @@ -47,9 +47,9 @@ public: protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; class SPHkern : public SPGlyphKerning { diff --git a/src/sp-glyph.h b/src/sp-glyph.h index e92357c94..297ac930e 100644 --- a/src/sp-glyph.h +++ b/src/sp-glyph.h @@ -52,9 +52,9 @@ public: protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; diff --git a/src/sp-gradient-vector.h b/src/sp-gradient-vector.h index 8e860c169..e57820b56 100644 --- a/src/sp-gradient-vector.h +++ b/src/sp-gradient-vector.h @@ -1,7 +1,6 @@ #ifndef SEEN_SP_GRADIENT_VECTOR_H #define SEEN_SP_GRADIENT_VECTOR_H -#include #include #include "color.h" @@ -14,9 +13,9 @@ * copying from SPStop to SPGradientStop. */ struct SPGradientStop { - gdouble offset; + double offset; SPColor color; - gfloat opacity; + float opacity; }; /** diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 70c54451a..b3e885560 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -54,9 +54,6 @@ #include "style.h" #include "display/grayscale.h" -#define SP_MACROS_SILENT -#include "macros.h" - /// Has to be power of 2 Seems to be unused. //#define NCOLORS NR_GRADIENT_VECTOR_LENGTH @@ -107,11 +104,11 @@ void SPGradient::setSwatch( bool swatch ) * Equivalent meaning they have the same stop count, same stop colors and same stop opacity * @param that - A gradient to compare this to */ -gboolean SPGradient::isEquivalent(SPGradient *that) +bool SPGradient::isEquivalent(SPGradient *that) { //TODO Make this work for mesh gradients - bool status = FALSE; + bool status = false; while(1){ // not really a loop, used to avoid deep nesting or multiple exit points from function if (this->getStopCount() != that->getStopCount()) { break; } @@ -132,11 +129,11 @@ gboolean SPGradient::isEquivalent(SPGradient *that) SPStop *as = this->getVector()->getFirstStop(); SPStop *bs = that->getVector()->getFirstStop(); - bool effective = TRUE; + bool effective = true; while (effective && (as && bs)) { if (!as->getEffectiveColor().isClose(bs->getEffectiveColor(), 0.001) || as->offset != bs->offset) { - effective = FALSE; + effective = false; break; } else { @@ -144,9 +141,9 @@ gboolean SPGradient::isEquivalent(SPGradient *that) bs = bs->getNextStop(); } } - if(!effective)break; + if (!effective) break; - status = TRUE; + status = true; break; } return status; @@ -157,9 +154,9 @@ gboolean SPGradient::isEquivalent(SPGradient *that) * Aligned means that they have exactly the same coordinates and transform. * @param that - A gradient to compare this to */ -gboolean SPGradient::isAligned(SPGradient *that) +bool SPGradient::isAligned(SPGradient *that) { - bool status = FALSE; + bool status = false; /* Some gradients have coordinates/other values specified, some don't. yes/yes check the coordinates/other values @@ -223,7 +220,7 @@ gboolean SPGradient::isAligned(SPGradient *that) } else { break; } - status = TRUE; + status = true; break; } return status; diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 1dfff22ee..fbb48df62 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -14,30 +14,18 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include -#include -#include #include <2geom/affine.h> +#include +#include +#include +#include + #include "sp-paint-server.h" #include "sp-gradient-spread.h" #include "sp-gradient-units.h" #include "sp-gradient-vector.h" #include "sp-mesh-array.h" -#include -#include - - - -//#include -//#include -//#include <2geom/forward.h> -//#include "sp-gradient-spread.h" -//#include "sp-gradient-units.h" -// -//class SPGradient; -//struct SPMeshGradient; - class SPGradientReference; class SPStop; @@ -109,30 +97,30 @@ public: private: /** gradientUnits attribute */ SPGradientUnits units; - guint units_set : 1; + unsigned int units_set : 1; public: /** gradientTransform attribute */ Geom::Affine gradientTransform; - guint gradientTransform_set : 1; + unsigned int gradientTransform_set : 1; private: /** spreadMethod attribute */ SPGradientSpread spread; - guint spread_set : 1; + unsigned int spread_set : 1; /** Gradient stops */ - guint has_stops : 1; + unsigned int has_stops : 1; /** Gradient patches */ - guint has_patches : 1; + unsigned int has_patches : 1; public: /** Reference (href) */ SPGradientReference *ref; /** State in Inkscape gradient system */ - guint state; + unsigned int state; /** Linear and Radial Gradients */ @@ -146,8 +134,8 @@ public: SPStop* getFirstStop(); int getStopCount() const; - gboolean isEquivalent(SPGradient *b); - gboolean isAligned(SPGradient *b); + bool isEquivalent(SPGradient *b); + bool isAligned(SPGradient *b); /** Mesh Gradients **************/ @@ -175,7 +163,7 @@ public: */ SPGradient *getVector(bool force_private = false); - static GType getType(); + //static GType getType(); /** Forces vector to be built, if not present (i.e. changed) */ void ensureVector(); @@ -196,7 +184,7 @@ public: void setSwatch(bool swatch = true); - static void gradientRefModified(SPObject *href, guint flags, SPGradient *gradient); + static void gradientRefModified(SPObject *href, unsigned int flags, SPGradient *gradient); static void gradientRefChanged(SPObject *old_ref, SPObject *ref, SPGradient *gr); private: @@ -208,13 +196,13 @@ private: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void modified(guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void modified(unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref); virtual void remove_child(Inkscape::XML::Node *child); - virtual void set(unsigned key, gchar const *value); + virtual void set(unsigned key, char const *value); }; void diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 60f15a79d..0e83c2acf 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -341,7 +341,7 @@ void SPGuide::hideSPGuide(SPCanvas *canvas) g_assert_not_reached(); } -void SPGuide::sensitize(SPCanvas *canvas, gboolean sensitive) +void SPGuide::sensitize(SPCanvas *canvas, bool sensitive) { g_assert(canvas != NULL); g_assert(SP_IS_CANVAS(canvas)); diff --git a/src/sp-guide.h b/src/sp-guide.h index fa4f0033b..cd67df222 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -13,12 +13,15 @@ * */ +#include <2geom/point.h> #include -#include <2geom/point.h> #include "sp-object.h" #include "sp-guide-attachment.h" +typedef unsigned int guint32; +typedef void (*GCallback) (void); + struct SPCanvas; struct SPCanvasGroup; class SPDesktop; @@ -52,14 +55,14 @@ public: static SPGuide *createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2); void showSPGuide(SPCanvasGroup *group, GCallback handler); void hideSPGuide(SPCanvas *canvas); - void sensitize(SPCanvas *canvas, gboolean sensitive); + void sensitize(SPCanvas *canvas, bool sensitive); Geom::Point getPositionFrom(Geom::Point const &pt) const; double getDistanceFrom(Geom::Point const &pt) const; protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); }; void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > &pts); diff --git a/src/sp-image.h b/src/sp-image.h index 17262d74f..9fa33b5de 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -14,7 +14,6 @@ #ifndef SEEN_INKSCAPE_SP_IMAGE_H #define SEEN_INKSCAPE_SP_IMAGE_H -#include #include #include "svg/svg-length.h" #include "display/curve.h" @@ -43,24 +42,24 @@ public: SPCurve *curve; // This curve is at the image's boundary for snapping - gchar *href; + char *href; #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gchar *color_profile; + char *color_profile; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) Inkscape::Pixbuf *pixbuf; virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void set(unsigned int key, gchar const* value); - virtual void update(SPCtx *ctx, guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual void update(SPCtx *ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual void modified(unsigned int flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); virtual const char* displayName() const; - virtual gchar* description() const; + virtual char* description() const; virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; virtual Geom::Affine set_transform(Geom::Affine const &transform); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index bb52b0c55..79604446a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -614,6 +614,18 @@ SPGroup::LayerMode SPGroup::layerDisplayMode(unsigned int dkey) const { } } +void SPGroup::setExpanded(bool isexpanded) { + if ( _expanded != isexpanded ){ + _expanded = isexpanded; + } +} + +void SPGroup::setInsertBottom(bool insertbottom) { + if ( _insertBottom != insertbottom) { + _insertBottom = insertbottom; + } +} + void SPGroup::setLayerDisplayMode(unsigned int dkey, SPGroup::LayerMode mode) { if ( layerDisplayMode(dkey) != mode ) { _display_modes[dkey] = mode; diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 2004a72b8..97423630d 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -1,5 +1,5 @@ -#ifndef __SP_ITEM_GROUP_H__ -#define __SP_ITEM_GROUP_H__ +#ifndef SEEN_SP_ITEM_GROUP_H +#define SEEN_SP_ITEM_GROUP_H /* * SVG implementation @@ -25,6 +25,7 @@ namespace Inkscape { class Drawing; class DrawingItem; +typedef struct _GSList GSList; } // namespace Inkscape @@ -35,12 +36,20 @@ public: enum LayerMode { GROUP, LAYER, MASK_HELPER }; + bool _expanded; + bool _insertBottom; LayerMode _layer_mode; std::map _display_modes; LayerMode layerMode() const { return _layer_mode; } void setLayerMode(LayerMode mode); + bool expanded() const { return _expanded; } + void setExpanded(bool isexpanded); + + bool insertBottom() const { return _insertBottom; } + void setInsertBottom(bool insertbottom); + LayerMode effectiveLayerMode(unsigned int display_key) const { if ( _layer_mode == LAYER ) { return LAYER; @@ -54,7 +63,7 @@ public: void translateChildItems(Geom::Translate const &tr); void scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p); - gint getItemCount() const; + int getItemCount() const; virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); private: @@ -69,15 +78,15 @@ public: virtual void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); virtual void update(SPCtx *ctx, unsigned int flags); - virtual void modified(guint flags); - virtual void set(unsigned int key, gchar const* value); + virtual void modified(unsigned int flags); + virtual void set(unsigned int key, char const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const; virtual void print(SPPrintContext *ctx); virtual const char* displayName() const; - virtual gchar *description() const; + virtual char *description() const; virtual Inkscape::DrawingItem *show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide (unsigned int key); @@ -90,7 +99,7 @@ void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = tr GSList *sp_item_group_item_list (SPGroup *group); -SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name); +SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name); #endif diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index 0f5117289..90fd676ee 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -9,6 +9,7 @@ #include using std::vector; +#define return_if_fail(test) if (!(test)) { printf("WARNING: assertion '%s' failed", #test); return; } /** * Called by sp_guide_moveto to indicate that the guide line corresponding to g has been moved, and @@ -19,15 +20,15 @@ using std::vector; void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoint_ix, double const position, bool const commit) { - g_return_if_fail(SP_IS_ITEM(&item)); - g_return_if_fail( unsigned(snappoint_ix) < 8 ); + return_if_fail(SP_IS_ITEM(&item)); + return_if_fail( unsigned(snappoint_ix) < 8 ); Geom::Point const dir( mv_g.normal_to_line ); double const dir_lensq(dot(dir, dir)); - g_return_if_fail( dir_lensq != 0 ); + return_if_fail( dir_lensq != 0 ); std::vector snappoints; item.getSnappoints(snappoints, NULL); - g_return_if_fail( snappoint_ix < int(snappoints.size()) ); + return_if_fail( snappoint_ix < int(snappoints.size()) ); double const pos0 = dot(dir, snappoints[snappoint_ix].getPoint()); /// \todo effic: skip if mv_g is already satisfied. diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 086da56ff..86beee907 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -18,6 +18,8 @@ #include "sp-item.h" #include "sp-item-transform.h" +#include + void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) { Geom::Point center = item->getCenter(); diff --git a/src/sp-item-transform.h b/src/sp-item-transform.h index 230d5a3dd..d563c9768 100644 --- a/src/sp-item-transform.h +++ b/src/sp-item-transform.h @@ -1,9 +1,8 @@ #ifndef SEEN_SP_ITEM_TRANSFORM_H #define SEEN_SP_ITEM_TRANSFORM_H -#include - #include <2geom/forward.h> + class SPItem; void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation); @@ -11,9 +10,9 @@ void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); void sp_item_skew_rel (SPItem *item, double skewX, double skewY); void sp_item_move_rel(SPItem *item, Geom::Translate const &tr); -Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, gdouble stroke_x, gdouble stroke_y, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1); -Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, bool preserve, gdouble x0, gdouble y0, gdouble x1, gdouble y1); -Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke); +Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, double stroke_x, double stroke_y, bool transform_stroke, bool preserve, double x0, double y0, double x1, double y1); +Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, bool preserve, double x0, double y0, double x1, double y1); +Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, double const initial_strokewidth, bool const transform_stroke); #endif // SEEN_SP_ITEM_TRANSFORM_H diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ecaea1586..4785dc588 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -99,6 +99,8 @@ SPItem::SPItem() : SPObject() { sensitive = TRUE; bbox_valid = FALSE; + _highlightColor = NULL; + transform_center_x = 0; transform_center_y = 0; @@ -179,6 +181,26 @@ bool SPItem::isHidden(unsigned display_key) const { return true; } +bool SPItem::isHighlightSet() const { + return _highlightColor != NULL; +} + +guint32 SPItem::highlight_color() const { + if (_highlightColor) + { + return atoi(_highlightColor) | 0x00000000; + } + else if (parent && parent != this && SP_IS_ITEM(parent)) + { + return SP_ITEM(parent)->highlight_color(); + } + else + { + static Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + return prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) | 0x00000000; + } +} + void SPItem::setEvaluated(bool evaluated) { _is_evaluated = evaluated; _evaluated_status = StatusSet; @@ -234,9 +256,13 @@ void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); // Copied from DocumentProperties::onDocUnitChange() - gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); - gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); - gdouble viewscale = std::min(viewscale_h, viewscale_w); + gdouble viewscale = 1.0; + Geom::Rect vb = this->document->getRoot()->viewBox; + if ( !vb.hasZeroArea() ) { + gdouble viewscale_w = this->document->getWidth().value("px") / vb.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ vb.height(); + viewscale = std::min(viewscale_h, viewscale_w); + } // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); @@ -267,9 +293,13 @@ Geom::Point SPItem::getCenter() const { document->ensureUpToDate(); // Copied from DocumentProperties::onDocUnitChange() - gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); - gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); - gdouble viewscale = std::min(viewscale_h, viewscale_w); + gdouble viewscale = 1.0; + Geom::Rect vb = this->document->getRoot()->viewBox; + if ( !vb.hasZeroArea() ) { + gdouble viewscale_w = this->document->getWidth().value("px") / vb.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ vb.height(); + viewscale = std::min(viewscale_h, viewscale_w); + } // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); @@ -360,7 +390,7 @@ void SPItem::lowerToBottom() { * \param target - the SPItem to move into or after * \param intoafter - move to after the target (false), move inside (sublayer) of the target (true) */ -void SPItem::moveTo(SPItem *target, gboolean intoafter) { +void SPItem::moveTo(SPItem *target, bool intoafter) { Inkscape::XML::Node *target_ref = ( target ? target->getRepr() : NULL ); Inkscape::XML::Node *our_ref = getRepr(); @@ -413,6 +443,7 @@ void SPItem::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "inkscape:transform-center-y" ); object->readAttr( "inkscape:connector-avoid" ); object->readAttr( "inkscape:connection-points" ); + object->readAttr( "inkscape:highlight-color" ); SPObject::build(document, repr); } @@ -487,11 +518,23 @@ void SPItem::set(unsigned int key, gchar const* value) { break; } case SP_ATTR_SODIPODI_INSENSITIVE: + { item->sensitive = !value; for (SPItemView *v = item->display; v != NULL; v = v->next) { v->arenaitem->setSensitive(item->sensitive); } break; + } + case SP_ATTR_INKSCAPE_HIGHLIGHT_COLOR: + { + g_free(item->_highlightColor); + if (value) { + item->_highlightColor = g_strdup(value); + } else { + item->_highlightColor = NULL; + } + break; + } case SP_ATTR_CONNECTOR_AVOID: item->avoidRef->setAvoid(value); break; @@ -701,6 +744,11 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X g_free ((void *) uri); } } + if (item->_highlightColor){ + repr->setAttribute("inkscape:highlight-color", item->_highlightColor); + } else { + repr->setAttribute("inkscape:highlight-color", NULL); + } SPObject::write(xml_doc, repr, flags); diff --git a/src/sp-item.h b/src/sp-item.h index 15784d041..1e4f5f4c6 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -18,10 +18,11 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include + #include <2geom/forward.h> #include <2geom/affine.h> #include <2geom/rect.h> +#include #include "sp-object.h" #include "snap-preferences.h" @@ -34,6 +35,7 @@ class SPClipPathReference; class SPMaskReference; class SPAvoidRef; struct SPPrintContext; +typedef unsigned int guint32; namespace Inkscape { @@ -72,7 +74,7 @@ enum PatternTransform { class SPEvent { public: unsigned int type; - gpointer data; + void* data; }; /// SPItemView @@ -153,6 +155,19 @@ public: bool isHidden() const; void setHidden(bool hidden); + /* Objects dialogue */ + bool isSensitive() const { + return sensitive; + }; + + bool isHighlightSet() const; + guint32 highlight_color() const; + + void setHighlightColor(guint32 color); + + void unsetHighlightColor(); + /********************/ + bool isEvaluated() const; void setEvaluated(bool visible); void resetEvaluated(); @@ -179,7 +194,7 @@ public: void lowerOne(); void raiseToTop(); void lowerToBottom(); - void moveTo(SPItem *target, gboolean intoafter); + void moveTo(SPItem *target, bool intoafter); sigc::connection connectTransformed(sigc::slot slot) { return _transformed_signal.connect(slot); @@ -198,7 +213,7 @@ public: unsigned int pos_in_parent() const; - gchar *detailedDescription() const; + char *detailedDescription() const; bool isFiltered() const; @@ -209,14 +224,14 @@ public: void getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs=0) const; void adjust_pattern(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false, PatternTransform = TRANSFORM_BOTH); void adjust_gradient(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false); - void adjust_stroke(gdouble ex); - void adjust_stroke_width_recursive(gdouble ex); + void adjust_stroke(double ex); + void adjust_stroke_width_recursive(double ex); void freeze_stroke_width_recursive(bool freeze); void adjust_paint_recursive(Geom::Affine advertized_transform, Geom::Affine t_ancestors, bool is_pattern); void adjust_livepatheffect(Geom::Affine const &postmul, bool set = false); void doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &transform, Geom::Affine const *adv = NULL, bool compensate = true); void set_item_transform(Geom::Affine const &transform_matrix); - gint emitEvent (SPEvent &event); + int emitEvent (SPEvent &event); Inkscape::DrawingItem *get_arenaitem(unsigned int key); Geom::Affine i2doc_affine() const; @@ -224,6 +239,7 @@ public: void set_i2d_affine(Geom::Affine const &transform); Geom::Affine dt2i_affine() const; + char *_highlightColor; private: enum EvaluatedStatus { @@ -240,14 +256,14 @@ private: public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void set(unsigned int key, gchar const* value); - virtual void update(SPCtx *ctx, guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual void update(SPCtx *ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; virtual void print(SPPrintContext *ctx); virtual const char* displayName() const; - virtual gchar* description() const; + virtual char* description() const; virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; @@ -255,7 +271,7 @@ public: virtual void convert_to_guides() const; - virtual gint event(SPEvent *event); + virtual int event(SPEvent *event); }; diff --git a/src/sp-line.h b/src/sp-line.h index c1932d3ee..d6a075659 100644 --- a/src/sp-line.h +++ b/src/sp-line.h @@ -31,13 +31,13 @@ public: SVGLength y2; virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual void set(unsigned int key, gchar const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); + virtual void set(unsigned int key, char const* value); virtual const char* displayName() const; virtual Geom::Affine set_transform(Geom::Affine const &transform); virtual void convert_to_guides() const; - virtual void update(SPCtx* ctx, guint flags); + virtual void update(SPCtx* ctx, unsigned int flags); virtual void set_shape(); }; diff --git a/src/sp-linear-gradient.cpp b/src/sp-linear-gradient.cpp index 959e8d733..6e9f5e6dd 100644 --- a/src/sp-linear-gradient.cpp +++ b/src/sp-linear-gradient.cpp @@ -1,3 +1,5 @@ +#include + #include "sp-linear-gradient.h" #include "attributes.h" diff --git a/src/sp-linear-gradient.h b/src/sp-linear-gradient.h index ac3fdb04a..a152e7fe2 100644 --- a/src/sp-linear-gradient.h +++ b/src/sp-linear-gradient.h @@ -26,8 +26,8 @@ public: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual void set(unsigned key, gchar const *value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned key, char const *value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; #endif /* !SP_LINEAR_GRADIENT_H */ diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index bb7d9f273..8ca6e6490 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -249,7 +249,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve) { // Groups have their doBeforeEffect called elsewhere if (!SP_IS_GROUP(this)) { - lpe->doBeforeEffect(this); + lpe->doBeforeEffect_impl(this); } try { @@ -263,6 +263,9 @@ bool SPLPEItem::performPathEffect(SPCurve *curve) { } return false; } + if (!SP_IS_GROUP(this)) { + lpe->doAfterEffect(this); + } } } } @@ -462,10 +465,13 @@ void SPLPEItem::removeCurrentPathEffect(bool keep_paths) if (!lperef) return; + if (Inkscape::LivePathEffect::Effect* effect_ = this->getCurrentLPE()) { + effect_->doOnRemove(this); + } PathEffectList new_list = *this->path_effect_list; new_list.remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list std::string r = patheffectlist_write_svg(new_list); - + if (!r.empty()) { this->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); } else { diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 3e858748d..fbac467fd 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -14,14 +14,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-item.h" - #include +#include "sp-item.h" #define SP_LPE_ITEM(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_LPE_ITEM(obj) (dynamic_cast((SPObject*)obj) != NULL) -class CLPEItem; class LivePathEffectObject; class SPCurve; class SPDesktop; @@ -58,7 +56,7 @@ public: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, gchar const* value); + virtual void set(unsigned int key, char const* value); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); @@ -66,7 +64,7 @@ public: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node* child); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual void update_patheffect(bool write); @@ -90,7 +88,7 @@ public: bool setCurrentPathEffect(Inkscape::LivePathEffect::LPEObjectReference* lperef); void removeCurrentPathEffect(bool keep_paths); void removeAllPathEffects(bool keep_paths); - void addPathEffect(gchar *value, bool reset); + void addPathEffect(char *value, bool reset); void addPathEffect(LivePathEffectObject * new_lpeobj); bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1); diff --git a/src/sp-mask.h b/src/sp-mask.h index e08d1e81e..e991fedb6 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -55,12 +55,12 @@ protected: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; class SPMaskReference : public Inkscape::URIReference { @@ -86,10 +86,10 @@ protected: Inkscape::XML::Node * const owner_repr = owner->getRepr(); //XML Tree being used directly here while it shouldn't be... Inkscape::XML::Node * const obj_repr = obj->getRepr(); - gchar const * owner_name = NULL; - gchar const * owner_mask = NULL; - gchar const * obj_name = NULL; - gchar const * obj_id = NULL; + char const * owner_name = NULL; + char const * owner_mask = NULL; + char const * obj_name = NULL; + char const * obj_id = NULL; if (owner_repr != NULL) { owner_name = owner_repr->name(); owner_mask = owner_repr->attribute("mask"); @@ -98,7 +98,7 @@ protected: obj_name = obj_repr->name(); obj_id = obj_repr->attribute("id"); } - g_warning("Ignoring recursive mask reference " + printf("WARNING: Ignoring recursive mask reference " "<%s mask=\"%s\"> in <%s id=\"%s\">", owner_name, owner_mask, obj_name, obj_id); @@ -108,6 +108,6 @@ protected: } }; -const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); +const char *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); #endif // SEEN_SP_MASK_H diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index 300f2ad19..8bfe23656 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -37,6 +37,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include + // For color picking #include "display/drawing.h" #include "display/drawing-context.h" diff --git a/src/sp-mesh-array.h b/src/sp-mesh-array.h index b10974e7e..330f6d87b 100644 --- a/src/sp-mesh-array.h +++ b/src/sp-mesh-array.h @@ -39,8 +39,6 @@ an array which simplifies things like inserting new rows or columns. */ -#include -#include #include <2geom/point.h> #include "color.h" @@ -89,13 +87,13 @@ public: opacity = 0.0; } NodeType node_type; - guint node_edge; + unsigned int node_edge; bool set; Geom::Point p; - guint draggable; // index of on-screen node - gchar path_type; + unsigned int draggable; // index of on-screen node + char path_type; SPColor color; - gdouble opacity; + double opacity; }; @@ -110,21 +108,21 @@ private: public: SPMeshPatchI( std::vector > *n, int r, int c ); - Geom::Point getPoint( guint side, guint point ); - std::vector< Geom::Point > getPointsForSide( guint i ); - void setPoint( guint side, guint point, Geom::Point p, bool set = true ); - gchar getPathType( guint i ); - void setPathType( guint, gchar t ); - Geom::Point getTensorPoint( guint i ); - void setTensorPoint( guint i, Geom::Point p ); + Geom::Point getPoint( unsigned int side, unsigned int point ); + std::vector< Geom::Point > getPointsForSide( unsigned int i ); + void setPoint( unsigned int side, unsigned int point, Geom::Point p, bool set = true ); + char getPathType( unsigned int i ); + void setPathType( unsigned int, char t ); + Geom::Point getTensorPoint( unsigned int i ); + void setTensorPoint( unsigned int i, Geom::Point p ); bool tensorIsSet(); - bool tensorIsSet( guint i ); - Geom::Point coonsTensorPoint( guint i ); + bool tensorIsSet( unsigned int i ); + Geom::Point coonsTensorPoint( unsigned int i ); void updateNodes(); - SPColor getColor( guint i ); - void setColor( guint i, SPColor c ); - gdouble getOpacity( guint i ); - void setOpacity( guint i, gdouble o ); + SPColor getColor( unsigned int i ); + void setColor( unsigned int i, SPColor c ); + double getOpacity( unsigned int i ); + void setOpacity( unsigned int i, double o ); }; class SPMeshGradient; @@ -160,26 +158,26 @@ public: void print(); // Get size of patch - guint patch_rows(); - guint patch_columns(); + unsigned int patch_rows(); + unsigned int patch_columns(); - SPMeshNode * node( guint i, guint j ) { return nodes[i][j]; } + SPMeshNode * node( unsigned int i, unsigned int j ) { return nodes[i][j]; } // Operations on corners - bool adjacent_corners( guint i, guint j, SPMeshNode* n[4] ); - guint side_toggle( std::vector< guint > ); - guint side_arc( std::vector< guint > ); - guint tensor_toggle( std::vector< guint > ); - guint color_smooth( std::vector< guint > ); - guint color_pick( std::vector< guint >, SPItem* ); + bool adjacent_corners( unsigned int i, unsigned int j, SPMeshNode* n[4] ); + unsigned int side_toggle( std::vector< unsigned int > ); + unsigned int side_arc( std::vector< unsigned int > ); + unsigned int tensor_toggle( std::vector< unsigned int > ); + unsigned int color_smooth( std::vector< unsigned int > ); + unsigned int color_pick( std::vector< unsigned int >, SPItem* ); // Update other nodes in response to a node move. - void update_handles( guint corner, std::vector< guint > selected_corners, Geom::Point old_p, MeshNodeOperation op ); + void update_handles( unsigned int corner, std::vector< unsigned int > selected_corners, Geom::Point old_p, MeshNodeOperation op ); - void split_row( guint i, guint n ); - void split_column( guint j, guint n ); - void split_row( guint i, double coord ); - void split_column( guint j, double coord ); + void split_row( unsigned int i, unsigned int n ); + void split_column( unsigned int j, unsigned int n ); + void split_row( unsigned int i, double coord ); + void split_column( unsigned int j, double coord ); }; #endif /* !SEEN_SP_MESH_ARRAY_H */ diff --git a/src/sp-mesh-gradient.cpp b/src/sp-mesh-gradient.cpp index 1b04a6f8e..bf28164a9 100644 --- a/src/sp-mesh-gradient.cpp +++ b/src/sp-mesh-gradient.cpp @@ -1,3 +1,5 @@ +#include + #include "attributes.h" #include "display/cairo-utils.h" #include "xml/repr.h" diff --git a/src/sp-mesh-gradient.h b/src/sp-mesh-gradient.h index 0b570c4dd..4df753f62 100644 --- a/src/sp-mesh-gradient.h +++ b/src/sp-mesh-gradient.h @@ -24,8 +24,8 @@ public: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual void set(unsigned key, gchar const *value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned key, char const *value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; #endif /* !SP_MESH_GRADIENT_H */ diff --git a/src/sp-mesh-patch.h b/src/sp-mesh-patch.h index ddade6503..e57ad1699 100644 --- a/src/sp-mesh-patch.h +++ b/src/sp-mesh-patch.h @@ -12,9 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include -//#include "svg/svg-length.h" #include "sp-object.h" #define SP_MESHPATCH(obj) (dynamic_cast((SPObject*)obj)) @@ -34,8 +32,8 @@ public: protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void set(unsigned int key, const gchar* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual void set(unsigned int key, const char* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif /* !SEEN_SP_MESHPATCH_H */ diff --git a/src/sp-mesh-row.h b/src/sp-mesh-row.h index e39bdc631..793b5a645 100644 --- a/src/sp-mesh-row.h +++ b/src/sp-mesh-row.h @@ -11,7 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "sp-object.h" #define SP_MESHROW(obj) (dynamic_cast((SPObject*)obj)) @@ -28,8 +27,8 @@ public: protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void set(unsigned int key, const gchar* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual void set(unsigned int key, const char* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif /* !SEEN_SP_MESHROW_H */ diff --git a/src/sp-metadata.h b/src/sp-metadata.h index 2a9d58e11..a89020390 100644 --- a/src/sp-metadata.h +++ b/src/sp-metadata.h @@ -1,5 +1,5 @@ -#ifndef __SP_METADATA_H__ -#define __SP_METADATA_H__ +#ifndef SEEN_SP_METADATA_H +#define SEEN_SP_METADATA_H /* * SVG implementation @@ -14,7 +14,6 @@ #include "sp-object.h" - /* Metadata base class */ #define SP_METADATA(obj) (dynamic_cast((SPObject*)obj)) @@ -29,9 +28,9 @@ protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; SPMetadata * sp_document_metadata (SPDocument *document); diff --git a/src/sp-missing-glyph.h b/src/sp-missing-glyph.h index a72ed0e99..06bc92231 100644 --- a/src/sp-missing-glyph.h +++ b/src/sp-missing-glyph.h @@ -1,9 +1,5 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef __SP_MISSING_GLYPH_H__ -#define __SP_MISSING_GLYPH_H__ +#ifndef SEEN_SP_MISSING_GLYPH_H +#define SEEN_SP_MISSING_GLYPH_H /* * SVG element implementation @@ -31,8 +27,8 @@ public: protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); - virtual void set(unsigned int key, const gchar* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); private: double horiz_adv_x; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index a01ba891e..1d9fa06a3 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -935,7 +935,7 @@ void SPNamedView::hide(SPDesktop const *desktop) views = g_slist_remove(views, desktop); } -void SPNamedView::activateGuides(gpointer desktop, gboolean active) +void SPNamedView::activateGuides(void* desktop, bool active) { g_assert(desktop != NULL); g_assert(g_slist_find(views, desktop)); diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 05cbcc398..37310dc76 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -29,6 +29,9 @@ namespace Inkscape { } } +typedef unsigned int guint32; +typedef guint32 GQuark; + enum { SP_BORDER_LAYER_BOTTOM, SP_BORDER_LAYER_TOP @@ -48,11 +51,11 @@ public: double zoom; double cx; double cy; - gint window_width; - gint window_height; - gint window_x; - gint window_y; - gint window_maximized; + int window_width; + int window_height; + int window_x; + int window_y; + int window_maximized; SnapManager snap_manager; GSList * grids; @@ -74,13 +77,13 @@ public: GSList *guides; GSList *views; - gint viewcount; + int viewcount; void show(SPDesktop *desktop); void hide(SPDesktop const *desktop); - void activateGuides(gpointer desktop, gboolean active); - gchar const *getName() const; - guint getViewCount(); + void activateGuides(void* desktop, bool active); + char const *getName() const; + unsigned int getViewCount(); GSList const *getViewList() const; Inkscape::Util::Unit const * getDefaultUnit() const; @@ -100,17 +103,17 @@ private: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void set(unsigned int key, gchar const* value); + virtual void set(unsigned int key, char const* value); virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node* child); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; -SPNamedView *sp_document_namedview(SPDocument *document, gchar const *name); -SPNamedView const *sp_document_namedview(SPDocument const *document, gchar const *name); +SPNamedView *sp_document_namedview(SPDocument *document, char const *name); +SPNamedView const *sp_document_namedview(SPDocument const *document, char const *name); void sp_namedview_window_from_document(SPDesktop *desktop); void sp_namedview_document_from_window(SPDesktop *desktop); diff --git a/src/sp-object-group.h b/src/sp-object-group.h index 4df346228..dcaa8a1d0 100644 --- a/src/sp-object-group.h +++ b/src/sp-object-group.h @@ -30,7 +30,7 @@ protected: virtual void order_changed(Inkscape::XML::Node* child, Inkscape::XML::Node* old, Inkscape::XML::Node* new_repr); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; #endif // SEEN_SP_OBJECTGROUP_H diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 65228ec0a..fcff43aa5 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1406,12 +1406,12 @@ bool SPObject::setDesc(gchar const *desc, bool verbatim) return setTitleOrDesc(desc, "svg:desc", verbatim); } -gchar * SPObject::getTitleOrDesc(gchar const *svg_tagname) const +char * SPObject::getTitleOrDesc(gchar const *svg_tagname) const { - gchar *result = 0; + char *result = NULL; SPObject *elem = findFirstChild(svg_tagname); if ( elem ) { - result = g_string_free(elem->textualContent(), FALSE); + result = elem->textualContent(); } return result; } @@ -1493,7 +1493,7 @@ SPObject * SPObject::findFirstChild(gchar const *tagname) const return NULL; } -GString * SPObject::textualContent() const +char* SPObject::textualContent() const { GString* text = g_string_new(""); @@ -1502,15 +1502,15 @@ GString * SPObject::textualContent() const Inkscape::XML::NodeType child_type = child->repr->type(); if (child_type == Inkscape::XML::ELEMENT_NODE) { - GString * new_text = child->textualContent(); - g_string_append(text, new_text->str); - g_string_free(new_text, TRUE); + char* new_string = child->textualContent(); + g_string_append(text, new_string); + g_free(new_string); } else if (child_type == Inkscape::XML::TEXT_NODE) { g_string_append(text, child->repr->content()); } } - return text; + return g_string_free(text, FALSE); } /* diff --git a/src/sp-object.h b/src/sp-object.h index e58f161d6..575198f36 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -45,8 +45,9 @@ class SPObject; #define SP_OBJECT_WRITE_BUILD (1 << 0) #define SP_OBJECT_WRITE_EXT (1 << 1) #define SP_OBJECT_WRITE_ALL (1 << 2) +#define SP_OBJECT_WRITE_NO_CHILDREN (1 << 3) -#include +#include #include #include #include @@ -57,6 +58,7 @@ class SPObject; class SPCSSAttr; class SPStyle; +typedef struct _GSList GSList; namespace Inkscape { namespace XML { @@ -109,8 +111,8 @@ class SPDocument; class SPIXmlSpace { public: SPIXmlSpace(): set(0), value(SP_XML_SPACE_DEFAULT) {}; - guint set : 1; - guint value : 1; + unsigned int set : 1; + unsigned int value : 1; }; /* @@ -152,7 +154,7 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner=NULL); * \pre object points to real object * @todo need to move this to be a member of SPObject. */ -SPObject *sp_object_href(SPObject *object, gpointer owner); +SPObject *sp_object_href(SPObject *object, void* owner); /** * Decrease weak refcount. @@ -164,7 +166,7 @@ SPObject *sp_object_href(SPObject *object, gpointer owner); * \pre object points to real object and hrefcount>0 * @todo need to move this to be a member of SPObject. */ -SPObject *sp_object_hunref(SPObject *object, gpointer owner); +SPObject *sp_object_hunref(SPObject *object, void* owner); /** * SPObject is an abstract base class of all of the document nodes at the @@ -183,7 +185,7 @@ SPObject *sp_object_hunref(SPObject *object, gpointer owner); * provides document level functionality such as the undo stack, * dictionary and so on. Source: doc/architecture.txt */ -class SPObject { // : public GObject { +class SPObject { public: enum CollectionPolicy { COLLECT_WITH_PARENT, @@ -209,7 +211,7 @@ private: SPObject(const SPObject&); SPObject& operator=(const SPObject&); - gchar *id; /* Our very own unique id */ + char *id; /* Our very own unique id */ Inkscape::XML::Node *repr; /* Our xml representation */ public: int refCount; @@ -217,7 +219,7 @@ public: /** * Returns the objects current ID string. */ - gchar const* getId() const; + char const* getId() const; /** * Returns the XML representation of tree @@ -281,7 +283,7 @@ public: typedef Inkscape::Util::ForwardPointerIterator ConstSiblingIterator; bool isSiblingOf(SPObject const *object) const { - g_return_val_if_fail(object != NULL, false); + if (object == NULL) return false; return this->parent && this->parent == object->parent; } @@ -332,26 +334,26 @@ public: * Gets the author-visible label property for the object or a default if * no label is defined. */ - gchar const *label() const; + char const *label() const; /** * Returns a default label property for this object. */ - gchar const *defaultLabel() const; + char const *defaultLabel() const; /** * Sets the author-visible label for this object. * * @param label the new label. */ - void setLabel(gchar const *label); + void setLabel(char const *label); /** * Returns the title of this object, or NULL if there is none. * The caller must free the returned string using g_free() - see comment * for getTitleOrDesc() below. */ - gchar *title() const; + char *title() const; /** * Sets the title of this object. @@ -359,14 +361,14 @@ public: * (if any) should be deleted. * The second argument is optional - @see setTitleOrDesc() below for details. */ - bool setTitle(gchar const *title, bool verbatim = false); + bool setTitle(char const *title, bool verbatim = false); /** * Returns the description of this object, or NULL if there is none. * The caller must free the returned string using g_free() - see comment * for getTitleOrDesc() below. */ - gchar *desc() const; + char *desc() const; /** * Sets the description of this object. @@ -374,7 +376,7 @@ public: * description (if any) should be deleted. * The second argument is optional - @see setTitleOrDesc() below for details. */ - bool setDesc(gchar const *desc, bool verbatim=false); + bool setDesc(char const *desc, bool verbatim=false); /** * Set the policy under which this object will be orphan-collected. @@ -501,9 +503,9 @@ public: * Indicates that another object supercedes this one. */ void setSuccessor(SPObject *successor) { - g_assert(successor != NULL); - g_assert(_successor == NULL); - g_assert(successor->_successor == NULL); + assert(successor != NULL); + assert(_successor == NULL); + assert(successor->_successor == NULL); sp_object_ref(successor, NULL); _successor = successor; } @@ -655,8 +657,8 @@ public: sigc::signal _modified_signal; SPObject *_successor; CollectionPolicy _collection_policy; - gchar *_label; - mutable gchar *_default_label; + char *_label; + mutable char *_default_label; // WARNING: // Methods below should not be used outside of the SP tree, @@ -690,7 +692,7 @@ public: unsigned getPosition(); - gchar const * getAttribute(gchar const *name,SPException *ex=NULL) const; + char const * getAttribute(char const *name,SPException *ex=NULL) const; void appendChild(Inkscape::XML::Node *child); @@ -699,18 +701,18 @@ public: /** * Call virtual set() function of object. */ - void setKeyValue(unsigned int key, gchar const *value); + void setKeyValue(unsigned int key, char const *value); - void setAttribute(gchar const *key, gchar const *value, SPException *ex=NULL); + void setAttribute(char const *key, char const *value, SPException *ex=NULL); /** * Read value of key attribute from XML node into object. */ - void readAttr(gchar const *key); + void readAttr(char const *key); - gchar const *getTagName(SPException *ex) const; + char const *getTagName(SPException *ex) const; - void removeAttribute(gchar const *key, SPException *ex=NULL); + void removeAttribute(char const *key, SPException *ex=NULL); /** * Returns an object style property. @@ -740,13 +742,13 @@ public: * element instead), we should probably make the caller * responsible for ascending the repr tree as necessary. */ - gchar const *getStyleProperty(gchar const *key, gchar const *def) const; + char const *getStyleProperty(char const *key, char const *def) const; - void setCSS(SPCSSAttr *css, gchar const *attr); + void setCSS(SPCSSAttr *css, char const *attr); - void changeCSS(SPCSSAttr *css, gchar const *attr); + void changeCSS(SPCSSAttr *css, char const *attr); - bool storeAsDouble( gchar const *key, double *val ) const; + bool storeAsDouble( char const *key, double *val ) const; private: // Private member functions used in the definitions of setTitle(), @@ -769,7 +771,7 @@ private: * The return value is true if a change was made to the title/description, * and usually false otherwise. */ - bool setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim); + bool setTitleOrDesc(char const *value, char const *svg_tagname, bool verbatim); /** * Returns the title or description of this object, or NULL if there is none. @@ -781,20 +783,20 @@ private: * Consequently, the return value is a newly allocated string (or NULL), and * must be freed (using g_free()) by the caller. */ - gchar * getTitleOrDesc(gchar const *svg_tagname) const; + char * getTitleOrDesc(char const *svg_tagname) const; /** * Find the first child of this object with a given tag name, * and return it. Returns NULL if there is no matching child. */ - SPObject * findFirstChild(gchar const *tagname) const; + SPObject * findFirstChild(char const *tagname) const; /** * Return the full textual content of an element (typically all the * content except the tags). * Must not be used on anything except elements. */ - GString * textualContent() const; + char * textualContent() const; /* Real handlers of repr signals */ @@ -802,17 +804,17 @@ public: /** * Callback for attr_changed node event. */ - static void repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); + static void repr_attr_changed(Inkscape::XML::Node *repr, char const *key, char const *oldval, char const *newval, bool is_interactive, void* data); /** * Callback for content_changed node event. */ - static void repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); + static void repr_content_changed(Inkscape::XML::Node *repr, char const *oldcontent, char const *newcontent, void* data); /** * Callback for child_added node event. */ - static void repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); + static void repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void* data); /** * Callback for remove_child node event. @@ -824,7 +826,7 @@ public: * * \todo fixme: */ - static void repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); + static void repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, void* data); friend class SPObjectImpl; @@ -838,12 +840,12 @@ protected: virtual void order_changed(Inkscape::XML::Node* child, Inkscape::XML::Node* old_repr, Inkscape::XML::Node* new_repr); - virtual void set(unsigned int key, const gchar* value); + virtual void set(unsigned int key, const char* value); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); public: virtual void read_content(); diff --git a/src/sp-offset.h b/src/sp-offset.h index 259a69b78..eb3fe227c 100644 --- a/src/sp-offset.h +++ b/src/sp-offset.h @@ -11,11 +11,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-shape.h" - -#include +#include #include +#include "sp-shape.h" + #define SP_OFFSET(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_OFFSET(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -54,7 +54,7 @@ public: SPOffset(); virtual ~SPOffset(); - void *originalPath; ///< will be a livarot Path, just don't declare it here to please the gcc linker + void *originalPath; ///< will be a livarot Path, just don't declare it here to please the gcc linker FIXME what? char *original; ///< SVG description of the source path float rad; ///< offset radius @@ -65,7 +65,7 @@ public: bool sourceDirty; bool isUpdating; - gchar *sourceHref; + char *sourceHref; SPUseReference *sourceRef; Inkscape::XML::Node *sourceRepr; ///< the repr associated with that id SPObject *sourceObject; @@ -76,14 +76,14 @@ public: sigc::connection _transformed_connection; virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual void set(unsigned int key, gchar const* value); - virtual void update(SPCtx *ctx, guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual void update(SPCtx *ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned flags); virtual void release(); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; virtual const char* displayName() const; - virtual gchar* description() const; + virtual char* description() const; virtual void set_shape(); }; diff --git a/src/sp-paint-server-reference.h b/src/sp-paint-server-reference.h index e08694c2f..bbd9c25fa 100644 --- a/src/sp-paint-server-reference.h +++ b/src/sp-paint-server-reference.h @@ -15,9 +15,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-object.h" #include "uri-references.h" +class SPDocument; +class SPObject; class SPPaintServer; class SPPaintServerReference : public Inkscape::URIReference { diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index c1c8d651e..beac72af5 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -15,10 +15,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include <2geom/rect.h> #include "sp-object.h" +typedef struct _cairo cairo_t; +typedef struct _cairo_pattern cairo_pattern_t; + #define SP_PAINT_SERVER(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_PAINT_SERVER(obj) (dynamic_cast((SPObject*)obj) != NULL) diff --git a/src/sp-path.h b/src/sp-path.h index 5f8a91d98..572fd648d 100644 --- a/src/sp-path.h +++ b/src/sp-path.h @@ -32,7 +32,7 @@ public: SPPath(); virtual ~SPPath(); - gint nodesInPath() const; + int nodesInPath() const; // still in lowercase because the names should be clearer on whether curve, curve->copy or curve-ref is returned. void set_original_curve (SPCurve *curve, unsigned int owner, bool write); @@ -49,13 +49,13 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void update(SPCtx* ctx, guint flags); + virtual void update(SPCtx* ctx, unsigned int flags); - virtual void set(unsigned int key, gchar const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char* displayName() const; - virtual gchar* description() const; + virtual char* description() const; virtual Geom::Affine set_transform(Geom::Affine const &transform); virtual void convert_to_guides() const; diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 8f7dbbadd..f021101e2 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -18,6 +18,7 @@ class SPPatternReference; class SPItem; +typedef struct _GSList GSList; #include "svg/svg-length.h" #include "sp-paint-server.h" @@ -33,17 +34,17 @@ public: virtual ~SPPattern(); /* Reference (href) */ - gchar *href; + char *href; SPPatternReference *ref; /* patternUnits and patternContentUnits attribute */ - guint patternUnits : 1; - guint patternUnits_set : 1; - guint patternContentUnits : 1; - guint patternContentUnits_set : 1; + unsigned int patternUnits : 1; + unsigned int patternUnits_set : 1; + unsigned int patternContentUnits : 1; + unsigned int patternContentUnits_set : 1; /* patternTransform attribute */ Geom::Affine patternTransform; - guint patternTransform_set : 1; + unsigned int patternTransform_set : 1; /* Tile rectangle */ SVGLength x; SVGLength y; @@ -83,22 +84,22 @@ enum { SP_PATTERN_UNITS_OBJECTBOUNDINGBOX }; -guint pattern_users (SPPattern *pattern); +unsigned int pattern_users (SPPattern *pattern); SPPattern *pattern_chain (SPPattern *pattern); -SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property); +SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); -const gchar *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); +const char *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); SPPattern *pattern_getroot (SPPattern *pat); -guint pattern_patternUnits (SPPattern const *pat); -guint pattern_patternContentUnits (SPPattern const *pat); +unsigned int pattern_patternUnits (SPPattern const *pat); +unsigned int pattern_patternContentUnits (SPPattern const *pat); Geom::Affine const &pattern_patternTransform(SPPattern const *pat); -gdouble pattern_x (SPPattern const *pat); -gdouble pattern_y (SPPattern const *pat); -gdouble pattern_width (SPPattern const *pat); -gdouble pattern_height (SPPattern const *pat); +double pattern_x (SPPattern const *pat); +double pattern_y (SPPattern const *pat); +double pattern_width (SPPattern const *pat); +double pattern_height (SPPattern const *pat); Geom::OptRect pattern_viewBox (SPPattern const *pat); #endif // SEEN_SP_PATTERN_H diff --git a/src/sp-polygon.h b/src/sp-polygon.h index 41ab245bd..438fdf794 100644 --- a/src/sp-polygon.h +++ b/src/sp-polygon.h @@ -1,5 +1,5 @@ -#ifndef __SP_POLYGON_H__ -#define __SP_POLYGON_H__ +#ifndef SEEN_SP_POLYGON_H +#define SEEN_SP_POLYGON_H /* * SVG implementation @@ -15,7 +15,6 @@ #include "sp-shape.h" - #define SP_POLYGON(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_POLYGON(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -25,12 +24,12 @@ public: virtual ~SPPolygon(); virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual void set(unsigned int key, gchar const* value); - virtual gchar* description() const; + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); + virtual void set(unsigned int key, char const* value); + virtual char* description() const; }; // made 'public' so that SPCurve can set it as friend: -void sp_polygon_set(SPObject *object, unsigned int key, const gchar *value); +void sp_polygon_set(SPObject *object, unsigned int key, char const*value); #endif diff --git a/src/sp-polyline.h b/src/sp-polyline.h index e24ea95c7..1ca102a9e 100644 --- a/src/sp-polyline.h +++ b/src/sp-polyline.h @@ -12,10 +12,10 @@ public: virtual ~SPPolyLine(); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void set(unsigned int key, gchar const* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); - virtual gchar* description() const; + virtual char* description() const; }; #endif // SEEN_SP_POLYLINE_H diff --git a/src/sp-radial-gradient.cpp b/src/sp-radial-gradient.cpp index 7c481fead..2c2b17b7d 100644 --- a/src/sp-radial-gradient.cpp +++ b/src/sp-radial-gradient.cpp @@ -1,3 +1,5 @@ +#include + #include "sp-radial-gradient.h" #include "attributes.h" diff --git a/src/sp-radial-gradient.h b/src/sp-radial-gradient.h index 42ff109aa..f753623b7 100644 --- a/src/sp-radial-gradient.h +++ b/src/sp-radial-gradient.h @@ -5,10 +5,12 @@ * SPRadialGradient: SVG implementtion. */ -#include #include "sp-gradient.h" #include "svg/svg-length.h" +typedef struct _cairo cairo_t; +typedef struct _cairo_pattern cairo_pattern_t; + #define SP_RADIALGRADIENT(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_RADIALGRADIENT(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -28,8 +30,8 @@ public: protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual void set(unsigned key, gchar const *value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned key, char const *value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); }; #endif /* !SP_RADIAL_GRADIENT_H */ diff --git a/src/sp-rect.h b/src/sp-rect.h index aa3f88e42..757229724 100644 --- a/src/sp-rect.h +++ b/src/sp-rect.h @@ -14,10 +14,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "svg/svg-length.h" -#include "sp-shape.h" #include <2geom/forward.h> +#include "svg/svg-length.h" +#include "sp-shape.h" #define SP_RECT(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_RECT(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -27,34 +27,34 @@ public: SPRect(); virtual ~SPRect(); - void setPosition(gdouble x, gdouble y, gdouble width, gdouble height); + void setPosition(double x, double y, double width, double height); /* If SET if FALSE, VALUE is just ignored */ - void setRx(bool set, gdouble value); - void setRy(bool set, gdouble value); + void setRx(bool set, double value); + void setRy(bool set, double value); - gdouble getVisibleRx() const; - void setVisibleRx(gdouble rx); + double getVisibleRx() const; + void setVisibleRx(double rx); - gdouble getVisibleRy() const; - void setVisibleRy(gdouble ry); + double getVisibleRy() const; + void setVisibleRy(double ry); Geom::Rect getRect() const; - gdouble getVisibleWidth() const; - void setVisibleWidth(gdouble rx); + double getVisibleWidth() const; + void setVisibleWidth(double rx); - gdouble getVisibleHeight() const; - void setVisibleHeight(gdouble ry); + double getVisibleHeight() const; + void setVisibleHeight(double ry); void compensateRxRy(Geom::Affine xform); virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void set(unsigned key, gchar const *value); + virtual void set(unsigned key, char const *value); virtual void update(SPCtx* ctx, unsigned int flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char* displayName() const; virtual void set_shape(); @@ -71,7 +71,7 @@ public: SVGLength ry; private: - static gdouble vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform); + static double vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform); }; #endif // SEEN_SP_RECT_H diff --git a/src/sp-root.h b/src/sp-root.h index a25e8030c..2776ae887 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -40,7 +40,7 @@ public: SVGLength width; SVGLength height; - gchar *onload; + char *onload; /** * Primary \ element where we put new defs (patterns, gradients etc.). @@ -52,9 +52,9 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); - virtual void set(unsigned int key, gchar const* value); - virtual void update(SPCtx *ctx, guint flags); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual void set(unsigned int key, char const* value); + virtual void update(SPCtx *ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual void modified(unsigned int flags); virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); diff --git a/src/sp-script.h b/src/sp-script.h index 36072a0ca..b71f86720 100644 --- a/src/sp-script.h +++ b/src/sp-script.h @@ -1,5 +1,5 @@ -#ifndef __SP_SCRIPT_H__ -#define __SP_SCRIPT_H__ +#ifndef SEEN_SP_SCRIPT_H +#define SEEN_SP_SCRIPT_H /* * SVG