diff options
| author | Martin Owens <doctormo@gmail.com> | 2019-11-12 14:55:16 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2019-11-12 14:55:16 +0000 |
| commit | f51f2e31eabb0e89a5c01c4f64a4a96f068ca172 (patch) | |
| tree | 8d78ee466d8e4ebcdb81c988a39b6d09a01a31ca | |
| parent | Update greek translation (diff) | |
| download | inkscape-f51f2e31eabb0e89a5c01c4f64a4a96f068ca172.tar.gz inkscape-f51f2e31eabb0e89a5c01c4f64a4a96f068ca172.zip | |
Make paraxial have a free starting angle.
5 files changed, 238 insertions, 90 deletions
diff --git a/share/icons/Tango/scalable/actions/path-mode-polyline-paraxial.svg b/share/icons/Tango/scalable/actions/path-mode-polyline-paraxial.svg index cba635666..4247c8210 100644 --- a/share/icons/Tango/scalable/actions/path-mode-polyline-paraxial.svg +++ b/share/icons/Tango/scalable/actions/path-mode-polyline-paraxial.svg @@ -9,11 +9,12 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" id="svg1" - width="15.997396" - height="17.002623" + width="18.996401" + height="19.771414" version="1.1" sodipodi:docname="path-mode-polyline-paraxial.svg" - viewBox="0 0 15.997395 17.002623"> + viewBox="0 0 18.996399 19.771414" + inkscape:version="0.92.4 (unknown)"> <metadata id="metadata52"> <rdf:RDF> @@ -35,10 +36,17 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="640" - inkscape:window-height="480" + inkscape:window-width="3066" + inkscape:window-height="1703" id="namedview50" - showgrid="false" /> + showgrid="false" + inkscape:zoom="13.880212" + inkscape:cx="9.4981997" + inkscape:cy="9.8857088" + inkscape:window-x="134" + inkscape:window-y="41" + inkscape:window-maximized="1" + inkscape:current-layer="paraxial_lines_mode" /> <defs id="defs3"> <linearGradient @@ -148,21 +156,21 @@ </defs> <g id="paraxial_lines_mode" - transform="translate(-1774.0011,-191.99862)"> + transform="translate(-1772.5016,-190.61423)"> <path - d="m 1776.875,195 h 10.25 v 11 h -10.25 v -0.125" + d="m 1778.1305,194.05468 10.026,2.1311 -2.287,10.75962 -10.026,-2.1311 0.026,-0.12226" id="path15500" inkscape:connector-curvature="0" style="fill:none;fill-rule:evenodd;stroke:#555753;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> <path - d="m 1776.875,195 h 10.25 v 11 h -10.25 v -0.125" + d="m 1778.1305,194.05468 10.026,2.1311 -2.287,10.75962 -10.026,-2.1311 0.026,-0.12226" id="path15498" inkscape:connector-curvature="0" style="fill:none;fill-rule:evenodd;stroke:#babdb6;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> <g id="use15453" inkscape:label="#g14630" - transform="translate(329,-5)"> + transform="rotate(12,1641.2857,1768.1129)"> <g id="g6643" transform="matrix(0.7272727,0,0,0.7310807,1453.818,-102.0049)"> @@ -181,7 +189,7 @@ <g id="use15455" inkscape:label="#g14630" - transform="translate(339,-5)"> + transform="rotate(12,1636.2857,1815.6847)"> <g id="g31" transform="matrix(0.7272727,0,0,0.7310807,1453.818,-102.0049)"> @@ -200,7 +208,7 @@ <g id="use15494" inkscape:label="#g14630" - transform="translate(339,6)"> + transform="rotate(12,1583.9567,1810.1847)"> <g id="g38" transform="matrix(0.7272727,0,0,0.7310807,1453.818,-102.0049)"> @@ -219,7 +227,7 @@ <g id="use15496" inkscape:label="#g14630" - transform="translate(329,6)"> + transform="rotate(12,1588.9567,1762.6129)"> <g id="g45" transform="matrix(0.7272727,0,0,0.7310807,1453.818,-102.0049)"> diff --git a/share/icons/hicolor/scalable/actions/path-mode-polyline-paraxial.svg b/share/icons/hicolor/scalable/actions/path-mode-polyline-paraxial.svg index 1a1ac52a9..0d3b8ae3f 100644 --- a/share/icons/hicolor/scalable/actions/path-mode-polyline-paraxial.svg +++ b/share/icons/hicolor/scalable/actions/path-mode-polyline-paraxial.svg @@ -1,38 +1,122 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" + xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" id="svg1" - width="19.257412" - height="16.760713" - > + width="20" + height="20" + version="1.1" + sodipodi:docname="path-mode-polyline-paraxial.svg" + inkscape:version="0.92.4 (unknown)"> + <metadata + id="metadata15"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> <sodipodi:namedview id="base" showgrid="true" - gridspacingy="1pt" - gridspacingx="1pt" - gridoriginy="0pt" - gridoriginx="0pt" - /> - <defs id="defs3"> - - </defs> -<g id="path-mode-polyline-paraxial" inkscape:label="paraxial_lines_mode" transform="matrix(0.6666666,0,0,0.6666666,73.3333299999999,-119.999988)"> - <rect height="24" id="rect4983-8-8" style="color:#000000;fill:none" width="24" x="-110" y="180"/> - <path d="M -83.37415,197.5433 C -83.37415,197.5433 -104.0525,197.5433 -104.0525,197.5433 -104.0525,197.5433 -104.0525,189.6892 -104.0525,189.6892 -104.0525,189.6892 -95.20504,189.6892 -95.20504,189.6892 -95.20504,189.6892 -95.20504,203.3698 -95.20504,203.3698 -95.20504,203.3698 -89.29061,203.3698 -89.29061,203.3698 -89.29061,203.3698 -89.29061,184.0466 -89.29061,184.0466" id="path4985-5-5" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccccc" style="fill:none;stroke:#646464;stroke-width:2.2500002;stroke-linecap:round;stroke-linejoin:round"/> - <rect height="2.996397" id="rect4989-9-0" style="color:#000000;fill:#6464ff;fill-opacity:0.3921569;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.7491586;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" width="2.995161" x="-84.48362" y="196.0672"/> - <rect height="2.996397" id="rect8372-9" style="color:#000000;fill:#6464ff;fill-opacity:0.3921569;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.7491586;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" width="2.995161" x="-90.81646" y="182.1676"/> - <rect height="2.996397" id="rect8374-6" style="color:#000000;fill:#6464ff;fill-opacity:0.3921569;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.7491586;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" width="2.995161" x="-96.73253" y="188.1577"/> - <rect height="2.996397" id="rect8376-3" style="color:#000000;fill:#6464ff;fill-opacity:0.3921569;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.7491586;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" width="2.995161" x="-105.581" y="188.1577"/> - <rect height="2.996397" id="rect8378-8" style="color:#000000;fill:#6464ff;fill-opacity:0.3921569;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.7491586;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" width="2.995161" x="-105.581" y="196.0672"/> - <rect height="2.996397" id="rect5087" style="color:#000000;fill:#6464ff;fill-opacity:0.3921569;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.7491586;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" width="2.995161" x="-96.73253" y="201.7701"/> - <rect height="2.996397" id="rect5089" style="color:#000000;fill:#6464ff;fill-opacity:0.3921569;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.7491586;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" width="2.995161" x="-90.81646" y="201.7701"/> -</g> - + inkscape:zoom="14.080546" + inkscape:cx="-6.7769077" + inkscape:cy="8.3803568" + inkscape:window-width="3066" + inkscape:window-height="1703" + inkscape:window-x="134" + inkscape:window-y="41" + inkscape:window-maximized="1" + inkscape:current-layer="path-mode-polyline-paraxial"> + <inkscape:grid + id="GridFromPre046Settings" + type="xygrid" + originx="0pt" + originy="0pt" + spacingx="1pt" + spacingy="1pt" + color="#3f3fff" + empcolor="#3f3fff" + opacity="0.15" + empopacity="0.38" + empspacing="5" /> + </sodipodi:namedview> + <defs + id="defs3" /> + <g + id="path-mode-polyline-paraxial" + inkscape:label="paraxial_lines_mode" + transform="matrix(0.65209834,0.13860778,-0.13860778,0.65209834,100.03601,-100.71034)"> + <rect + height="24" + id="rect4983-8-8" + style="color:#000000;fill:none" + width="24" + x="-109.57581" + y="178.5159" /> + <path + d="m -86.76399,193.55765 c 0,0 -20.67835,0 -20.67835,0 0,0 0,-7.8541 0,-7.8541 0,0 8.84746,0 8.84746,0 0,0 0,13.6806 0,13.6806 0,0 5.91443,0 5.91443,0 0,0 0,-19.3232 0,-19.3232" + id="path4985-5-5" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" + style="fill:none;stroke:#646464;stroke-width:2.25000024;stroke-linecap:round;stroke-linejoin:round" /> + <rect + height="2.996397" + id="rect4989-9-0" + style="color:#000000;fill:#6464ff;fill-opacity:0.39215692;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.74915862;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" + width="2.9951611" + x="-87.873459" + y="192.08153" /> + <rect + height="2.996397" + id="rect8372-9" + style="color:#000000;fill:#6464ff;fill-opacity:0.39215692;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.74915862;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" + width="2.9951611" + x="-94.206299" + y="178.18193" /> + <rect + height="2.996397" + id="rect8374-6" + style="color:#000000;fill:#6464ff;fill-opacity:0.39215692;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.74915862;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" + width="2.9951611" + x="-100.12238" + y="184.17203" /> + <rect + height="2.996397" + id="rect8376-3" + style="color:#000000;fill:#6464ff;fill-opacity:0.39215692;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.74915862;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" + width="2.9951611" + x="-108.97086" + y="184.17203" /> + <rect + height="2.996397" + id="rect8378-8" + style="color:#000000;fill:#6464ff;fill-opacity:0.39215692;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.74915862;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" + width="2.9951611" + x="-108.97086" + y="192.08153" /> + <rect + height="2.996397" + id="rect5087" + style="color:#000000;fill:#6464ff;fill-opacity:0.39215692;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.74915862;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" + width="2.9951611" + x="-100.12238" + y="197.78442" /> + <rect + height="2.996397" + id="rect5089" + style="color:#000000;fill:#6464ff;fill-opacity:0.39215692;fill-rule:evenodd;stroke:#6464ff;stroke-width:0.74915862;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0" + width="2.9951611" + x="-94.206299" + y="197.78442" /> + </g> </svg> diff --git a/share/icons/hicolor/symbolic/actions/path-mode-polyline-paraxial-symbolic.svg b/share/icons/hicolor/symbolic/actions/path-mode-polyline-paraxial-symbolic.svg index b37f5c754..e897ac519 100644 --- a/share/icons/hicolor/symbolic/actions/path-mode-polyline-paraxial-symbolic.svg +++ b/share/icons/hicolor/symbolic/actions/path-mode-polyline-paraxial-symbolic.svg @@ -1,11 +1,66 @@ -<?xml version='1.0' encoding='UTF-8'?> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) and export_objects.py --> -<svg xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg1" width="16" height="16" viewBox="0 0 16 16" sodipodi:docname="path-mode-polyline-paraxial-symbolic.svg"> -<sodipodi:namedview objecttolerance="10" gridtolerance="10" guidetolerance="10" id="namedview" showgrid="true" inkscape:zoom="0.6002936" inkscape:cx="732.67439" inkscape:cy="-567.94603" inkscape:window-width="1920" inkscape:window-height="1016" inkscape:window-x="0" inkscape:window-y="27" inkscape:window-maximized="1" inkscape:current-layer="layer1"> - <inkscape:grid type="xygrid" id="grid"/> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + id="svg1" + width="16" + height="16" + viewBox="0 0 16 16" + sodipodi:docname="path-mode-polyline-paraxial-symbolic.svg" + inkscape:version="0.92.4 (unknown)"> + <metadata + id="metadata10"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs8" /> + <sodipodi:namedview + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + id="namedview" + showgrid="true" + inkscape:zoom="11.313708" + inkscape:cx="31.076513" + inkscape:cy="-4.6355167" + inkscape:window-width="3066" + inkscape:window-height="1703" + inkscape:window-x="134" + inkscape:window-y="41" + inkscape:window-maximized="1" + inkscape:current-layer="path-mode-polyline-paraxial"> + <inkscape:grid + type="xygrid" + id="grid" /> </sodipodi:namedview> - <g transform="matrix(0.986419,0,0,0.991161,-965.60969,-552.38829)" inkscape:label="00215" id="path-mode-polyline-paraxial"> - <path inkscape:connector-curvature="0" id="rect4983-8-8" d="m 979,557.36218 h 16 v 16 h -16 z" style="opacity:0;fill:none"/> - <path inkscape:connector-curvature="0" id="path21371" d="m 990.08594,557.31445 a 0.85008502,0.85008502 0 0 0 -0.83594,0.86133 v 9.23047 h -2.44531 v -5.01563 a 0.85008502,0.85008502 0 0 0 -0.84961,-0.8496 h -6.20117 a 0.85008502,0.85008502 0 0 0 -0.84961,0.8496 v 5.86524 a 0.85008502,0.85008502 0 0 0 0.84961,0.84961 h 5.35156 v 3.50195 a 0.85008502,0.85008502 0 0 0 0.84961,0.84961 h 4.14453 a 0.85008502,0.85008502 0 0 0 0.84961,-0.84961 v -3.50195 h 3.29687 a 0.85008502,0.85008502 0 1 0 0,-1.69922 h -3.29687 v -9.23047 a 0.85008502,0.85008502 0 0 0 -0.86328,-0.86133 z m -9.48242,5.92578 h 4.50195 v 4.16602 h -4.50195 z m 6.20117,5.86524 H 989.25 v 2.65234 h -2.44531 z" style="opacity:1;stroke-linecap:round"/> - </g> - </svg> + <g + transform="matrix(0.96486338,0.20508804,-0.20607396,0.96950175,-827.82271,-742.56732)" + inkscape:label="00215" + id="path-mode-polyline-paraxial"> + <path + inkscape:connector-curvature="0" + id="rect4983-8-8" + d="m 980.20345,558.57487 h 13.62178 v 13.62178 h -13.62178 z" + style="opacity:0;fill:none;stroke-width:0.85136104" /> + <path + inkscape:connector-curvature="0" + id="path21371" + d="m 990.53893,556.56605 a 0.85008502,0.85008502 0 0 0 -0.83594,0.86133 v 9.23047 h -2.44531 v -5.01563 a 0.85008502,0.85008502 0 0 0 -0.84961,-0.8496 h -6.20117 a 0.85008502,0.85008502 0 0 0 -0.84961,0.8496 v 5.86524 a 0.85008502,0.85008502 0 0 0 0.84961,0.84961 h 5.35156 v 3.50195 a 0.85008502,0.85008502 0 0 0 0.84961,0.84961 h 4.14453 a 0.85008502,0.85008502 0 0 0 0.84961,-0.84961 v -3.50195 h 3.29687 a 0.85008502,0.85008502 0 1 0 0,-1.69922 h -3.29687 v -9.23047 a 0.85008502,0.85008502 0 0 0 -0.86328,-0.86133 z m -9.48242,5.92578 h 4.50195 v 4.16602 h -4.50195 z m 6.20117,5.86524 h 2.44531 v 2.65234 h -2.44531 z" + style="opacity:1;stroke-linecap:round" /> + </g> +</svg> diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 9b25335d6..253ced25c 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -77,7 +77,6 @@ namespace Tools { static Geom::Point pen_drag_origin_w(0, 0); static bool pen_within_tolerance = false; -static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical const double HANDLE_CUBIC_GAP = 0.001; const std::string& PenTool::getPrefsPath() { @@ -95,6 +94,7 @@ PenTool::PenTool() , state(POINT) , polylines_only(false) , polylines_paraxial(false) + , paraxial_angle(Geom::Point(0,0)) , num_clicks(0) , expecting_clicks_for_LPE(0) , waiting_LPE(nullptr) @@ -254,7 +254,10 @@ bool PenTool::hasWaitingLPE() { * Snaps new node relative to the previous node. */ void PenTool::_endpointSnap(Geom::Point &p, guint const state) const { - if ((state & GDK_CONTROL_MASK) && !this->polylines_paraxial) { //CTRL enables angular snapping + // Paraxial kicks in after first line has set the angle (before then it's a free line) + bool poly = this->polylines_paraxial && !this->green_curve->is_unset(); + + if ((state & GDK_CONTROL_MASK) && !poly) { //CTRL enables angular snapping if (this->npoints > 0) { spdc_endpoint_snap_rotation(this, p, this->p[0], state); } else { @@ -265,9 +268,9 @@ void PenTool::_endpointSnap(Geom::Point &p, guint const state) const { // We cannot use shift here to disable snapping because the shift-key is already used // to toggle the paraxial direction; if the user wants to disable snapping (s)he will // have to use the %-key, the menu, or the snap toolbar - if ((this->npoints > 0) && this->polylines_paraxial) { + if ((this->npoints > 0) && poly) { // snap constrained - this->_setToNearestHorizVert(p, state, true); + this->_setToNearestHorizVert(p, state); } else { // snap freely boost::optional<Geom::Point> origin = this->npoints > 0 ? this->p[0] : boost::optional<Geom::Point>(); @@ -1770,7 +1773,7 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta if ((std::abs(p[Geom::X] - origin[Geom::X]) > 1e-9) && (std::abs(p[Geom::Y] - origin[Geom::Y]) > 1e-9)) { // ...then we should draw an L-shaped path, consisting of two paraxial segments Geom::Point intermed = p; - this->_setToNearestHorizVert(intermed, status, false); + this->_setToNearestHorizVert(intermed, status); this->red_curve->lineto(intermed); } this->red_curve->lineto(p); @@ -1850,7 +1853,7 @@ void PenTool::_setCtrl(Geom::Point const p, guint const state) { void PenTool::_finishSegment(Geom::Point const p, guint const state) { if (this->polylines_paraxial) { - pen_last_paraxial_dir = this->nextParaxialDirection(p, this->p[0], state); + this->nextParaxialDirection(p, this->p[0], state); } ++num_clicks; @@ -1960,8 +1963,18 @@ bool PenTool::_undoLastPoint() { sp_canvas_item_hide(this->cl0); sp_canvas_item_hide(this->cl1); this->state = PenTool::POINT; + + if(this->polylines_paraxial) { + // We compare the point we're removing with the nearest horiz/vert to + // see if the line was added with SHIFT or not. + Geom::Point compare(pt); + this->_setToNearestHorizVert(compare, 0); + if ((std::abs(compare[Geom::X] - pt[Geom::X]) > 1e-9) + || (std::abs(compare[Geom::Y] - pt[Geom::Y]) > 1e-9)) { + this->paraxial_angle = this->paraxial_angle.cw(); + } + } this->_setSubsequentPoint(pt, true); - pen_last_paraxial_dir = !pen_last_paraxial_dir; //redraw this->_bsplineSpiroBuild(); @@ -2029,7 +2042,7 @@ void PenTool::waitForLPEMouseClicks(Inkscape::LivePathEffect::EffectType effect_ this->polylines_paraxial = false; // TODO: think if this is correct for all cases } -int PenTool::nextParaxialDirection(Geom::Point const &pt, Geom::Point const &origin, guint state) const { +void PenTool::nextParaxialDirection(Geom::Point const &pt, Geom::Point const &origin, guint state) { // // after the first mouse click we determine whether the mouse pointer is closest to a // horizontal or vertical segment; for all subsequent mouse clicks, we use the direction @@ -2041,45 +2054,32 @@ int PenTool::nextParaxialDirection(Geom::Point const &pt, Geom::Point const &ori if (this->green_curve->is_unset()) { // first mouse click - double dist_h = fabs(pt[Geom::X] - origin[Geom::X]); - double dist_v = fabs(pt[Geom::Y] - origin[Geom::Y]); - int ret = (dist_h < dist_v) ? 1 : 0; // 0 = horizontal, 1 = vertical - pen_last_paraxial_dir = (state & GDK_SHIFT_MASK) ? 1 - ret : ret; - return pen_last_paraxial_dir; - } else { - // subsequent mouse click - return (state & GDK_SHIFT_MASK) ? pen_last_paraxial_dir : 1 - pen_last_paraxial_dir; + double h = pt[Geom::X] - origin[Geom::X]; + double v = pt[Geom::Y] - origin[Geom::Y]; + this->paraxial_angle = Geom::Point(h, v).ccw(); + } + if(!(state & GDK_SHIFT_MASK)) { + this->paraxial_angle = this->paraxial_angle.ccw(); } } -void PenTool::_setToNearestHorizVert(Geom::Point &pt, guint const state, bool snap) const { +void PenTool::_setToNearestHorizVert(Geom::Point &pt, guint const state) const { Geom::Point const origin = this->p[0]; + Geom::Point const target = (state & GDK_SHIFT_MASK) ? this->paraxial_angle : this->paraxial_angle.ccw(); - int next_dir = this->nextParaxialDirection(pt, origin, state); + // Create a horizontal or vertical constraint line + Inkscape::Snapper::SnapConstraint cl(origin, target); - if (!snap) { - if (next_dir == 0) { - // line is forced to be horizontal - pt[Geom::Y] = origin[Geom::Y]; - } else { - // line is forced to be vertical - pt[Geom::X] = origin[Geom::X]; - } - } else { - // Create a horizontal or vertical constraint line - Inkscape::Snapper::SnapConstraint cl(origin, next_dir ? Geom::Point(0, 1) : Geom::Point(1, 0)); + // Snap along the constraint line; if we didn't snap then still the constraint will be applied + SnapManager &m = this->desktop->namedview->snap_manager; - // Snap along the constraint line; if we didn't snap then still the constraint will be applied - SnapManager &m = this->desktop->namedview->snap_manager; + Inkscape::Selection *selection = this->desktop->getSelection(); + // selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping) + // TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment - Inkscape::Selection *selection = this->desktop->getSelection(); - // selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping) - // TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment - - m.setup(this->desktop, true, selection->singleItem()); - m.constrainedSnapReturnByRef(pt, Inkscape::SNAPSOURCE_NODE_HANDLE, cl); - m.unSetup(); - } + m.setup(this->desktop, true, selection->singleItem()); + m.constrainedSnapReturnByRef(pt, Inkscape::SNAPSOURCE_NODE_HANDLE, cl); + m.unSetup(); } } diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 0a7be5796..388bb3d43 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -53,9 +53,10 @@ public: Mode mode; State state; - bool polylines_only; bool polylines_paraxial; + Geom::Point paraxial_angle; + // propiety which saves if Spiro mode is active or not bool spiro; bool bspline; @@ -77,7 +78,7 @@ public: const std::string& getPrefsPath() override; - int nextParaxialDirection(Geom::Point const &pt, Geom::Point const &origin, guint state) const; + void nextParaxialDirection(Geom::Point const &pt, Geom::Point const &origin, guint state); void setPolylineMode(); bool hasWaitingLPE(); void waitForLPEMouseClicks(Inkscape::LivePathEffect::EffectType effect_type, unsigned int num_clicks, bool use_polylines = true); @@ -131,7 +132,7 @@ private: void _disableEvents(); void _enableEvents(); - void _setToNearestHorizVert(Geom::Point &pt, guint const state, bool snap) const; + void _setToNearestHorizVert(Geom::Point &pt, guint const state) const; void _setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_to_compare, gchar const *message); |
