Code

Filter effects dialog:
[inkscape.git] / src / shape-editor.cpp
index 19b9ea64dc18239d2fc12969bbed9f29a5050ae9..f865d6a4db648dd2d4a8006a855a9f15604f0119 100644 (file)
@@ -229,7 +229,11 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) {
     sp_nodepath_ensure_livarot_path(this->nodepath);
 
     NR::Maybe<Path::cut_position> position = get_nearest_position_on_Path(this->nodepath->livarot_path, this->curvepoint_doc);
-    NR::Point nearest = get_point_on_Path(this->nodepath->livarot_path, position.assume().piece, position.assume().t);
+    if (!position) {
+        return false;
+    }
+
+    NR::Point nearest = get_point_on_Path(this->nodepath->livarot_path, position->piece, position->t);
     NR::Point delta = nearest - this->curvepoint_doc;
 
     delta = desktop->d2w(delta);
@@ -248,8 +252,8 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) {
         this->curvepoint_event[NR::X] = (gint) event_p [NR::X];
         this->curvepoint_event[NR::Y] = (gint) event_p [NR::Y];
         this->hit = true;
-        this->grab_t = position.assume().t;
-        this->grab_node = position.assume().piece;
+        this->grab_t = position->t;
+        this->grab_node = position->piece;
     }
 
     return close;
@@ -339,11 +343,11 @@ void ShapeEditor::deselect() {
 }
 
 void ShapeEditor::add_node () {
-    sp_node_selected_add_node(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_add_node(this->nodepath);
 }
 
 void ShapeEditor::delete_nodes () {
-    sp_node_selected_delete(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_delete(this->nodepath);
 }
 
 void ShapeEditor::delete_nodes_preserving_shape () {
@@ -352,31 +356,39 @@ void ShapeEditor::delete_nodes_preserving_shape () {
     }
 }
 
-void ShapeEditor::set_node_type(Inkscape::NodePath::NodeType type) {
-    sp_node_selected_set_type(type); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+void ShapeEditor::delete_segment () {
+    sp_node_selected_delete_segment(this->nodepath);
+}
+
+void ShapeEditor::set_node_type(int type) {
+    sp_node_selected_set_type(this->nodepath, (Inkscape::NodePath::NodeType) type);
 }
 
 void ShapeEditor::break_at_nodes() {
-    sp_node_selected_break(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_break(this->nodepath);
 }
 
 void ShapeEditor::join_nodes() {
-    sp_node_selected_join(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_join(this->nodepath);
+}
+
+void ShapeEditor::join_segments() {
+    sp_node_selected_join_segment(this->nodepath);
 }
 
 void ShapeEditor::duplicate_nodes() {
-    sp_node_selected_duplicate(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_duplicate(this->nodepath);
 }
 
 void ShapeEditor::set_type_of_segments(NRPathcode code) {
-    sp_node_selected_set_line_type(code); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_set_line_type(this->nodepath, code);
 }
 
 void ShapeEditor::move_nodes_screen(gdouble dx, gdouble dy) {
-    sp_node_selected_move_screen(dx, dy); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_move_screen(this->nodepath, dx, dy);
 }
 void ShapeEditor::move_nodes(gdouble dx, gdouble dy) {
-    sp_node_selected_move(dx, dy); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+    sp_node_selected_move(this->nodepath, dx, dy);
 }
 
 void ShapeEditor::rotate_nodes(gdouble angle, int which, bool screen) {
@@ -408,9 +420,15 @@ void ShapeEditor::select_prev () {
         sp_nodepath_select_prev (this->nodepath);
 }
 
-void ShapeEditor::flip (NR::Dim2 axis) {
+void ShapeEditor::show_handles (bool show) {
+    if (this->nodepath) 
+        sp_nodepath_show_handles (this->nodepath, show);
+}
+
+
+void ShapeEditor::flip (NR::Dim2 axis, NR::Maybe<NR::Point> center) {
     if (this->nodepath) 
-        sp_nodepath_flip (this->nodepath, axis);
+        sp_nodepath_flip (this->nodepath, axis, center);
 }
 
 void ShapeEditor::distribute (NR::Dim2 axis) {