mesh-tool.cpp revision 769a6887551cf7ff7bce4b48d3ac303cbea69507
1N/A#ifdef HAVE_CONFIG_H
1N/A#include "desktop-handles.h"
1N/A#include "document.h"
1N/A#include "document-undo.h"
1N/A#include "message-context.h"
1N/A#include "message-stack.h"
1N/A#include "preferences.h"
1N/A#include "rubberband.h"
1N/A#include "selection.h"
1N/A#include "sp-namedview.h"
1N/A#include "gradient-drag.h"
1N/A#include "gradient-chemistry.h"
1N/A#include "pixmaps/cursor-gradient.xpm"
1N/A#include "pixmaps/cursor-gradient-add.xpm"
1N/A#include "ui/tools/mesh-tool.h"
1N/A#include "sp-mesh-gradient.h"
1N/A#include "display/sp-ctrlcurve.h"
1N/A#include "ui/tool-factory.h"
1N/A bool meshContextRegistered = ToolFactory::instance().registerObject("/tools/mesh", createMeshContext);
1N/A , cursor_addnode(false)
1N/A , node_added(false)
1N/A this->enableGrDrag(false);
1N/A //The use of ngettext in the following code is intentional even if the English singular form would never be used
1N/A //TRANSLATORS: %s will be substituted with the point name (see previous messages); This is part of a compound message
1N/A //TRANSLATORS: This is a part of a compound message (out of two more indicating: grandint handle count & object count)
1N/A this->message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj);
1N/A //TRANSLATORS: The plural refers to number of selected mesh handles. This is part of a compound message (part two indicates selected object count)
1N/A g_strconcat(ngettext("<b>%d</b> mesh handle selected out of %d","<b>%d</b> mesh handles selected out of %d",n_sel),
1N/A //TRANSLATORS: Mind the space in front. (Refers to gradient handles selected). This is part of a compound message
1N/A // guint rows = 0;//mg->array.patches.size();
1N/A // guint columns = 0;//mg->array.patches[0].size();
1N/A this->enableSelectionCue();
1N/A this->enableGrDrag();
1N/Astatic void sp_mesh_context_split_near_point(MeshTool *rc, SPItem *item, Geom::Point mouse_p, guint32 /*etime*/)
1N/A#ifdef DEBUG_MESH
1N/A#ifdef DEBUG_MESH
1N/A for( std::map<SPMeshGradient*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
1N/A case MG_CORNER_SIDE_TOGGLE:
1N/A case MG_CORNER_SIDE_ARC:
1N/A case MG_CORNER_TENSOR_TOGGLE:
1N/A case MG_CORNER_COLOR_SMOOTH:
1N/A case MG_CORNER_COLOR_PICK:
1N/A if( noperation > 0 ) {
1N/A case MG_CORNER_SIDE_TOGGLE:
1N/A case MG_CORNER_SIDE_ARC:
1N/A case MG_CORNER_TENSOR_TOGGLE:
1N/A case MG_CORNER_COLOR_SMOOTH:
1N/A case MG_CORNER_COLOR_PICK:
1N/A double const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); // in px
1N/A case GDK_2BUTTON_PRESS:
1N/A#ifdef DEBUG_MESH
1N/A over_line |= sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y));
1N/A sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList()->data), this->mousepoint_doc, event->button.time);
1N/A Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
1N/A#ifdef DEBUG_MESH
1N/A std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl;
1N/A SPGradient *vector = sp_gradient_vector_for_object(sp_desktop_document(desktop), desktop, item, fsmode);
1N/A case GDK_BUTTON_PRESS:
1N/A#ifdef DEBUG_MESH
1N/A this->within_tolerance = true;
1N/A this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE);
1N/A case GDK_MOTION_NOTIFY:
1N/A#ifdef DEBUG_MESH
1N/A if ( this->within_tolerance
1N/A this->within_tolerance = false;
1N/A this->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Draw around</b> handles to select them"));
1N/A // See "pathflash" in ui/tools/node-tool.cpp for ideas.
1N/A over_line |= sp_mesh_context_is_over_line (this, (SPItem*) l->data, Geom::Point(event->motion.x, event->motion.y));
1N/A this->sp_event_context_update_cursor();
1N/A this->cursor_addnode = false;
1N/A this->sp_event_context_update_cursor();
1N/A this->cursor_addnode = true;
1N/A case GDK_BUTTON_RELEASE:
1N/A#ifdef DEBUG_MESH
1N/A over_line = sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y));
1N/A if (!this->within_tolerance) {
1N/A } else if (this->item_to_select) {
1N/A case GDK_KEY_PRESS:
1N/A#ifdef DEBUG_MESH
1N/A case GDK_KEY_Alt_L:
1N/A case GDK_KEY_Alt_R:
1N/A case GDK_KEY_Control_L:
1N/A case GDK_KEY_Control_R:
1N/A case GDK_KEY_Shift_L:
1N/A case GDK_KEY_Shift_R:
1N/A case GDK_KEY_Meta_R:
1N/A case GDK_KEY_Escape:
1N/A case GDK_KEY_KP_Left:
1N/A case GDK_KEY_KP_4:
1N/A case GDK_KEY_KP_Up:
1N/A case GDK_KEY_KP_8:
1N/A case GDK_KEY_KP_Right:
1N/A case GDK_KEY_KP_6:
1N/A case GDK_KEY_KP_Down:
1N/A case GDK_KEY_KP_2:
1N/A case GDK_KEY_Insert:
1N/A case GDK_KEY_KP_Insert:
1N/A case GDK_KEY_Delete:
1N/A case GDK_KEY_KP_Delete:
1N/A case GDK_KEY_BackSpace:
1N/A case GDK_KEY_RELEASE:
1N/A#ifdef DEBUG_MESH
1N/A case GDK_KEY_Alt_L:
1N/A case GDK_KEY_Alt_R:
1N/A case GDK_KEY_Control_L:
1N/A case GDK_KEY_Control_R:
1N/A case GDK_KEY_Shift_L:
1N/A case GDK_KEY_Shift_R:
1N/A case GDK_KEY_Meta_R:
1N/Astatic void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) {
1N/A Inkscape::PaintTarget fill_or_stroke = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
1N/A vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke);
1N/A // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
1N/A // We did an undoable action, but SPDocumentUndo::done will be called by the knot when released
1N/A sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> on which to create gradient."));