diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-10-10 19:18:02 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-10-10 19:18:02 +0000 |
| commit | 0c2a0e9585f33fb6b78083b396ef53fc2d6b41c1 (patch) | |
| tree | 89f45cae1547e2acaa5281ac12f73b96539969ee /src | |
| parent | Added new button to get global measure as a dimension (diff) | |
| parent | Add buttons for some side/corner mesh opeartions. (diff) | |
| download | inkscape-0c2a0e9585f33fb6b78083b396ef53fc2d6b41c1.tar.gz inkscape-0c2a0e9585f33fb6b78083b396ef53fc2d6b41c1.zip | |
update to trunk
(bzr r14393.1.16)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-mesh-array.cpp | 18 | ||||
| -rw-r--r-- | src/ui/tools/mesh-tool.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tools/mesh-tool.h | 2 | ||||
| -rw-r--r-- | src/widgets/mesh-toolbar.cpp | 78 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 5 |
5 files changed, 94 insertions, 11 deletions
diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index 445c9a8f6..d76b884ae 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -313,7 +313,7 @@ bool SPMeshPatchI::tensorIsSet( unsigned int i ) { /** Return tensor control point for "corner" i. - If not sest, returns calculated (Coons) point. + If not set, returns calculated (Coons) point. */ Geom::Point SPMeshPatchI::getTensorPoint( guint k ) { @@ -1058,11 +1058,11 @@ void SPMeshNodeArray::create( SPMesh *mg, SPItem *item, Geom::OptRect bbox ) { Geom::Point center = bbox->midpoint(); // Must keep repr and array in sync. We have two choices: - // Build the repr first and the "read" it. - // Construct the array and the "write" it. + // Build the repr first and then "read" it. + // Construct the array and then "write" it. // We'll do the second. - // Remove any existing mesh. We could chose to simply scale an existing mesh... + // Remove any existing mesh. We could choose to simply scale an existing mesh... //clear(); // We get called twice when a new mesh is created...WHY? @@ -2265,10 +2265,12 @@ guint SPMeshNodeArray::color_pick( std::vector<guint> icorners, SPItem* item ) { // Region to average over Geom::Point p = n->p; - // std::cout << " p: " << p << std::endl; + // std::cout << " before transform: p: " << p << std::endl; p *= gr->gradientTransform; - // std::cout << " p: " << p << std::endl; - + // std::cout << " after transform: p: " << p << std::endl; + p *= item->i2doc_affine(); + // std::cout << " after transform: p: " << p << std::endl; + // If on edge, move inward guint cols = patch_columns()+1; guint rows = patch_rows()+1; @@ -2277,7 +2279,7 @@ guint SPMeshNodeArray::color_pick( std::vector<guint> icorners, SPItem* item ) { guint ncol = col * 3; guint nrow = row * 3; - double size = 3.0; + const double size = 3.0; // Top edge if( row == 0 ) { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 813d6ae5b..303757493 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -316,7 +316,7 @@ static void sp_mesh_context_split_near_point(MeshTool *rc, SPItem *item, Geom:: /** Wrapper for various mesh operations that require a list of selected corner nodes. */ -static void +void sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) { diff --git a/src/ui/tools/mesh-tool.h b/src/ui/tools/mesh-tool.h index d952c9010..91b35b3af 100644 --- a/src/ui/tools/mesh-tool.h +++ b/src/ui/tools/mesh-tool.h @@ -20,6 +20,7 @@ #include <stddef.h> #include <sigc++/sigc++.h> #include "ui/tools/tool-base.h" +#include "sp-mesh-array.h" #define SP_MESH_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::MeshTool*>((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_MESH_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::MeshTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) @@ -57,6 +58,7 @@ private: void sp_mesh_context_select_next(ToolBase *event_context); void sp_mesh_context_select_prev(ToolBase *event_context); +void sp_mesh_context_corner_operation(MeshTool *event_context, MeshCornerOperation operation ); } } diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 1af55d9cd..bef9129b9 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -34,6 +34,7 @@ #include "widgets/gradient-image.h" #include "style.h" +#include "inkscape.h" #include "preferences.h" #include "document-private.h" #include "document-undo.h" @@ -66,6 +67,7 @@ using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; +using Inkscape::UI::Tools::MeshTool; static bool blocked = false; @@ -314,10 +316,49 @@ static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget) } } +/** Temporary hack: Returns the mesh tool in the active desktop. + * Will go away during tool refactoring. */ +static MeshTool *get_mesh_tool() +{ + MeshTool *tool = 0; + if (SP_ACTIVE_DESKTOP ) { + Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; + if (SP_IS_MESH_CONTEXT(ec)) { + tool = static_cast<MeshTool*>(ec); + } + } + return tool; +} + +static void ms_toggle_sides(void) +{ + MeshTool *mt = get_mesh_tool(); + if (mt) { + sp_mesh_context_corner_operation( mt, MG_CORNER_SIDE_TOGGLE ); + } +} + +static void ms_make_elliptical(void) +{ + MeshTool *mt = get_mesh_tool(); + if (mt) { + sp_mesh_context_corner_operation( mt, MG_CORNER_SIDE_ARC ); + } +} + +static void ms_pick_colors(void) +{ + MeshTool *mt = get_mesh_tool(); + if (mt) { + sp_mesh_context_corner_operation( mt, MG_CORNER_COLOR_PICK ); + } +} + static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); /** * Mesh auxiliary toolbar construction and setup. + * Don't forget to add to XML in widgets/toolbox.cpp! * */ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder) @@ -466,7 +507,7 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); } - /* Typeing method */ + /* Type */ { GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT ); @@ -487,6 +528,41 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); g_object_set_data( holder, "mesh_select_type_action", act ); } + + { + InkAction* act = ink_action_new( "MeshToggleSidesAction", + _("Toggle Sides"), + _("Toggle selected sides between Beziers and lines."), + INKSCAPE_ICON("node-segment-line"), + secondarySize ); + g_object_set( act, "short_label", _("Toggle side:"), NULL ); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_sides), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + } + + { + InkAction* act = ink_action_new( "MeshMakeEllipticalAction", + _("Make elliptical"), + _("Make selected sides elliptical by changing length of handles. Works best if handles already approximate ellipse."), + INKSCAPE_ICON("node-segment-curve"), + secondarySize ); + g_object_set( act, "short_label", _("Make elliptical:"), NULL ); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_make_elliptical), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + } + + { + InkAction* act = ink_action_new( "MeshPickColorsAction", + _("Pick colors:"), + _("Pick colors for selected corner nodes from underneath mesh."), + INKSCAPE_ICON("color-picker"), + secondarySize ); + g_object_set( act, "short_label", _("Pick Color"), NULL ); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_pick_colors), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + } + + } static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 65a0cd9cb..3daa3c467 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -526,9 +526,12 @@ static gchar const * ui_descr = // " <toolitem action='MeshEditFillAction' />" // " <toolitem action='MeshEditStrokeAction' />" // " <toolitem action='MeshShowHandlesAction' />" + " <toolitem action='MeshToggleSidesAction' />" + " <toolitem action='MeshMakeEllipticalAction' />" + " <toolitem action='MeshPickColorsAction' />" + " <separator />" " <toolitem action='MeshWarningAction' />" " <toolitem action='MeshSmoothAction' />" - " <separator />" " </toolbar>" " <toolbar name='DropperToolbar'>" |
