diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-26 14:25:00 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-26 14:25:00 +0000 |
| commit | 3cc709dc31fbb335cd2cf34cae67415eb1313830 (patch) | |
| tree | 6d6dafca970804b7db2f30f752e12d12ad128be3 | |
| parent | Commented out tidy_operator_styled_whitespace (fixes bug 1477723). (diff) | |
| parent | update to trunk (diff) | |
| download | inkscape-3cc709dc31fbb335cd2cf34cae67415eb1313830.tar.gz inkscape-3cc709dc31fbb335cd2cf34cae67415eb1313830.zip | |
merge lp:~inkscape.dev/inkscape/simplify-lpe-pencil-toolbar into lp:inkscape
(bzr r14259)
| -rw-r--r-- | share/icons/icons.svg | 4 | ||||
| -rw-r--r-- | share/icons/symbolic_icons.svg | 4 | ||||
| -rw-r--r-- | share/icons/tango_icons.svg | 4 | ||||
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 24 | ||||
| -rw-r--r-- | src/ui/tools/pencil-tool.cpp | 14 | ||||
| -rw-r--r-- | src/widgets/pencil-toolbar.cpp | 43 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 1 |
7 files changed, 90 insertions, 4 deletions
diff --git a/share/icons/icons.svg b/share/icons/icons.svg index 35ef6ab8c..7c2a479ba 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -3954,4 +3954,8 @@ http://www.inkscape.org/</dc:description> <path style="fill:none;stroke:#c8c8c8;stroke-width:1px;stroke-linecap:square" d="m 12.5,14.5 0,-9" id="path5602-7" /> <path style="fill:#ffffff;fill-rule:evenodd;stroke:url(#linearGradient5799-9);stroke-width:1px;stroke-linecap:round;stroke-linejoin:round" d="m 9.5,0.5 4,4 -4,0 0,-4 z" id="path4681-4" /> </g> +<g inkscape:label="#interactive_simplify" id="interactive_simplify-8" transform="translate(2.8103663,-3.4622352)"> +<rect style="color:#000000;display:inline;fill:none;stroke:none;stroke-width:1;marker:none" id="rect17937-7" width="15.721" height="15.721" x="284.96881" y="535.60986"/> +<path style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#1a1a1a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.29999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="m 290.17927,536.29791 c -0.73508,-0.0198 -1.39622,0.2336 -1.84159,0.74177 -0.44531,0.50792 -0.64525,1.18194 -0.72765,1.87328 -0.16506,1.38275 0.0895,2.98886 0.35184,4.5721 0.26249,1.58323 0.54397,3.14418 0.5465,4.16017 0.002,0.50783 -0.0816,0.85395 -0.14524,0.96912 -0.0636,0.11498 -0.0413,0.13606 -0.31741,0.12818 -0.62469,-0.018 -0.83827,-0.25596 -1.06003,-0.78451 -0.2217,-0.52866 -0.31969,-1.38583 -0.29946,-2.27495 0.0406,-1.77813 0.11807,-2.13825 0.11807,-2.13825 l -1.38194,-0.0121 c 0,0 -0.0337,0.44001 -0.0806,2.49766 -0.0235,1.02877 -0.0407,1.70852 0.34882,2.63692 0.38958,0.92839 1.22621,1.68264 2.3192,1.71432 0.63526,0.0182 1.2607,-0.33475 1.56909,-0.89219 0.30839,-0.55754 0.36843,-1.18568 0.36682,-1.84935 -0.004,-1.32684 -0.31391,-2.90454 -0.57194,-4.461 -0.25796,-1.55655 -0.45229,-3.08947 -0.33837,-4.04395 0.057,-0.47747 0.17846,-0.77307 0.3189,-0.93322 0.14036,-0.16024 0.32929,-0.27384 0.79054,-0.2615 0.45488,0.0122 0.69097,0.12483 0.82198,0.23928 0.13101,0.11437 0.20751,0.2532 0.26202,0.53156 0.109,0.55665 -0.0124,1.58674 -0.21261,2.6612 -0.20016,1.07473 -0.46142,2.18434 -0.43719,3.21672 0.0121,0.5163 0.098,1.05271 0.41323,1.5075 0.31537,0.45497 0.8398,0.71265 1.39541,0.74522 0.46064,0.0271 0.88102,-0.0505 1.23672,-0.27349 0.35569,-0.22306 0.61213,-0.59016 0.7531,-0.95885 0.28203,-0.73745 0.23775,-1.48168 0.21261,-2.157 -0.025,-0.67532 -0.0407,-1.30092 0.021,-1.57246 0.0307,-0.13582 0.0562,-0.15501 0.0568,-0.15554 6.1e-4,-5.1e-4 0.0216,-0.0342 0.20063,-0.029 0.21794,0.005 0.23819,0.0425 0.27101,0.0736 0.0328,0.031 0.0923,0.12248 0.19463,0.32304 0.10226,0.20058 0.24827,0.50789 0.53749,0.77427 0.28932,0.26646 0.7035,0.43865 1.17233,0.46148 1.60943,-0.27583 2.28398,-1.00425 3.4062,-0.0836 l 0,-1.66134 c -1.4875,-0.73615 -2.29389,-0.16099 -3.3448,0.10586 -0.24009,-0.0116 -0.2878,-0.0595 -0.33089,-0.0991 -0.0432,-0.0397 -0.1003,-0.12938 -0.19913,-0.32304 -0.0988,-0.19383 -0.23563,-0.49298 -0.51805,-0.76059 -0.28248,-0.26761 -0.69591,-0.43622 -1.15285,-0.44952 -0.41365,-0.0119 -0.82202,0.10779 -1.13042,0.388 -0.30846,0.28046 -0.47152,0.6683 -0.55246,1.0255 -0.16199,0.71419 -0.0912,1.41292 -0.0674,2.05446 0.0239,0.6418 -0.008,1.20669 -0.0929,1.42888 -0.0426,0.11125 -0.0664,0.13781 -0.12726,0.17604 -0.061,0.0384 -0.19635,0.0897 -0.47163,0.0736 -0.27557,-0.0162 -0.30637,-0.0703 -0.34286,-0.12306 -0.0366,-0.0526 -0.0975,-0.21662 -0.10481,-0.53499 -0.015,-0.63672 0.20013,-1.72004 0.40726,-2.83212 0.20712,-1.11192 0.4237,-2.26505 0.2096,-3.35858 -0.10709,-0.54685 -0.35815,-1.09774 -0.79203,-1.47675 -0.43396,-0.37901 -1.00009,-0.56172 -1.66043,-0.57941 z" id="path14318-5" inkscape:connector-curvature="0" sodipodi:nodetypes="cccccccccccccccccccccsccccccccccccsccccccccccccccccccccc"/> +</g> </svg> diff --git a/share/icons/symbolic_icons.svg b/share/icons/symbolic_icons.svg index bc385f460..64c8dc7b0 100644 --- a/share/icons/symbolic_icons.svg +++ b/share/icons/symbolic_icons.svg @@ -3464,6 +3464,10 @@ <path inkscape:connector-curvature="0" style="fill:url(#linearGradient19282)" d="m 13.969,3 0,1 3,0 a 1,1 0 0 1 1,1 l 0,1 -2,0 2.5,3 2.5,-3 -2,0 0,-1 a 2,2 0 0 0 -2,-2 l -3,0 z" id="path40863-1" /> <path id="path40889-9" d="m 12.969,16 0,-1 -3,0 a 1,1 0 0 1 -1,-1 l 0,-1 2,0 -2.5,-3 -2.5,3 2,0 0,1 a 2,2 0 0 0 2,2 l 3,0 z" style="fill:url(#linearGradient19282)" inkscape:connector-curvature="0" /> </g> +<g inkscape:label="#interactive_simplify" id="interactive_simplify-8" transform="translate(2.8103663,-3.4622352)"> +<rect style="color:#000000;display:inline;fill:none;stroke:none;stroke-width:1;marker:none" id="rect17937-7" width="15.721" height="15.721" x="284.96881" y="535.60986"/> +<path style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#666666;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.29999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="m 290.17927,536.29791 c -0.73508,-0.0198 -1.39622,0.2336 -1.84159,0.74177 -0.44531,0.50792 -0.64525,1.18194 -0.72765,1.87328 -0.16506,1.38275 0.0895,2.98886 0.35184,4.5721 0.26249,1.58323 0.54397,3.14418 0.5465,4.16017 0.002,0.50783 -0.0816,0.85395 -0.14524,0.96912 -0.0636,0.11498 -0.0413,0.13606 -0.31741,0.12818 -0.62469,-0.018 -0.83827,-0.25596 -1.06003,-0.78451 -0.2217,-0.52866 -0.31969,-1.38583 -0.29946,-2.27495 0.0406,-1.77813 0.11807,-2.13825 0.11807,-2.13825 l -1.38194,-0.0121 c 0,0 -0.0337,0.44001 -0.0806,2.49766 -0.0235,1.02877 -0.0407,1.70852 0.34882,2.63692 0.38958,0.92839 1.22621,1.68264 2.3192,1.71432 0.63526,0.0182 1.2607,-0.33475 1.56909,-0.89219 0.30839,-0.55754 0.36843,-1.18568 0.36682,-1.84935 -0.004,-1.32684 -0.31391,-2.90454 -0.57194,-4.461 -0.25796,-1.55655 -0.45229,-3.08947 -0.33837,-4.04395 0.057,-0.47747 0.17846,-0.77307 0.3189,-0.93322 0.14036,-0.16024 0.32929,-0.27384 0.79054,-0.2615 0.45488,0.0122 0.69097,0.12483 0.82198,0.23928 0.13101,0.11437 0.20751,0.2532 0.26202,0.53156 0.109,0.55665 -0.0124,1.58674 -0.21261,2.6612 -0.20016,1.07473 -0.46142,2.18434 -0.43719,3.21672 0.0121,0.5163 0.098,1.05271 0.41323,1.5075 0.31537,0.45497 0.8398,0.71265 1.39541,0.74522 0.46064,0.0271 0.88102,-0.0505 1.23672,-0.27349 0.35569,-0.22306 0.61213,-0.59016 0.7531,-0.95885 0.28203,-0.73745 0.23775,-1.48168 0.21261,-2.157 -0.025,-0.67532 -0.0407,-1.30092 0.021,-1.57246 0.0307,-0.13582 0.0562,-0.15501 0.0568,-0.15554 6.1e-4,-5.1e-4 0.0216,-0.0342 0.20063,-0.029 0.21794,0.005 0.23819,0.0425 0.27101,0.0736 0.0328,0.031 0.0923,0.12248 0.19463,0.32304 0.10226,0.20058 0.24827,0.50789 0.53749,0.77427 0.28932,0.26646 0.7035,0.43865 1.17233,0.46148 1.60943,-0.27583 2.28398,-1.00425 3.4062,-0.0836 l 0,-1.66134 c -1.4875,-0.73615 -2.29389,-0.16099 -3.3448,0.10586 -0.24009,-0.0116 -0.2878,-0.0595 -0.33089,-0.0991 -0.0432,-0.0397 -0.1003,-0.12938 -0.19913,-0.32304 -0.0988,-0.19383 -0.23563,-0.49298 -0.51805,-0.76059 -0.28248,-0.26761 -0.69591,-0.43622 -1.15285,-0.44952 -0.41365,-0.0119 -0.82202,0.10779 -1.13042,0.388 -0.30846,0.28046 -0.47152,0.6683 -0.55246,1.0255 -0.16199,0.71419 -0.0912,1.41292 -0.0674,2.05446 0.0239,0.6418 -0.008,1.20669 -0.0929,1.42888 -0.0426,0.11125 -0.0664,0.13781 -0.12726,0.17604 -0.061,0.0384 -0.19635,0.0897 -0.47163,0.0736 -0.27557,-0.0162 -0.30637,-0.0703 -0.34286,-0.12306 -0.0366,-0.0526 -0.0975,-0.21662 -0.10481,-0.53499 -0.015,-0.63672 0.20013,-1.72004 0.40726,-2.83212 0.20712,-1.11192 0.4237,-2.26505 0.2096,-3.35858 -0.10709,-0.54685 -0.35815,-1.09774 -0.79203,-1.47675 -0.43396,-0.37901 -1.00009,-0.56172 -1.66043,-0.57941 z" id="path14318-5-3" inkscape:connector-curvature="0" sodipodi:nodetypes="cccccccccccccccccccccsccccccccccccsccccccccccccccccccccc"/> +</g> <g id="stock_icons"> <g transform="translate(-270,23)" id="object-rotate-90-CW"> <g transform="translate(223.9998,725.3622)" id="g15895" inkscape:label="stock-rotate-270"> diff --git a/share/icons/tango_icons.svg b/share/icons/tango_icons.svg index c1da77e79..ae22f5370 100644 --- a/share/icons/tango_icons.svg +++ b/share/icons/tango_icons.svg @@ -5277,6 +5277,10 @@ http://www.inkscape.org/</dc:description> <ellipse style="color:#000000;text-decoration:none;text-decoration-line:none;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" id="ellipse47662" cx="18.48884" cy="207.5353" rx="6.611154" ry="6.515604" transform="matrix(0.8723531,0,0,0.8723531,2.360043,26.49119)" /> <rect y="199.5352" x="10.48884" height="15.99999" width="15.99999" id="rect47664" style="color:#000000;display:inline;fill:none;stroke:none;stroke-width:0.531496;marker:none" /> </g> +<g inkscape:label="#interactive_simplify" id="interactive_simplify-8" transform="translate(2.8103663,-3.4622352)"> +<rect style="color:#000000;display:inline;fill:none;stroke:none;stroke-width:1;marker:none" id="rect17937-7" width="15.721" height="15.721" x="284.96881" y="535.60986"/> +<path style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#555753;fill-opacity:0.98823529;fill-rule:nonzero;stroke:none;stroke-width:1.29999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="m 290.17927,536.29791 c -0.73508,-0.0198 -1.39622,0.2336 -1.84159,0.74177 -0.44531,0.50792 -0.64525,1.18194 -0.72765,1.87328 -0.16506,1.38275 0.0895,2.98886 0.35184,4.5721 0.26249,1.58323 0.54397,3.14418 0.5465,4.16017 0.002,0.50783 -0.0816,0.85395 -0.14524,0.96912 -0.0636,0.11498 -0.0413,0.13606 -0.31741,0.12818 -0.62469,-0.018 -0.83827,-0.25596 -1.06003,-0.78451 -0.2217,-0.52866 -0.31969,-1.38583 -0.29946,-2.27495 0.0406,-1.77813 0.11807,-2.13825 0.11807,-2.13825 l -1.38194,-0.0121 c 0,0 -0.0337,0.44001 -0.0806,2.49766 -0.0235,1.02877 -0.0407,1.70852 0.34882,2.63692 0.38958,0.92839 1.22621,1.68264 2.3192,1.71432 0.63526,0.0182 1.2607,-0.33475 1.56909,-0.89219 0.30839,-0.55754 0.36843,-1.18568 0.36682,-1.84935 -0.004,-1.32684 -0.31391,-2.90454 -0.57194,-4.461 -0.25796,-1.55655 -0.45229,-3.08947 -0.33837,-4.04395 0.057,-0.47747 0.17846,-0.77307 0.3189,-0.93322 0.14036,-0.16024 0.32929,-0.27384 0.79054,-0.2615 0.45488,0.0122 0.69097,0.12483 0.82198,0.23928 0.13101,0.11437 0.20751,0.2532 0.26202,0.53156 0.109,0.55665 -0.0124,1.58674 -0.21261,2.6612 -0.20016,1.07473 -0.46142,2.18434 -0.43719,3.21672 0.0121,0.5163 0.098,1.05271 0.41323,1.5075 0.31537,0.45497 0.8398,0.71265 1.39541,0.74522 0.46064,0.0271 0.88102,-0.0505 1.23672,-0.27349 0.35569,-0.22306 0.61213,-0.59016 0.7531,-0.95885 0.28203,-0.73745 0.23775,-1.48168 0.21261,-2.157 -0.025,-0.67532 -0.0407,-1.30092 0.021,-1.57246 0.0307,-0.13582 0.0562,-0.15501 0.0568,-0.15554 6.1e-4,-5.1e-4 0.0216,-0.0342 0.20063,-0.029 0.21794,0.005 0.23819,0.0425 0.27101,0.0736 0.0328,0.031 0.0923,0.12248 0.19463,0.32304 0.10226,0.20058 0.24827,0.50789 0.53749,0.77427 0.28932,0.26646 0.7035,0.43865 1.17233,0.46148 1.60943,-0.27583 2.28398,-1.00425 3.4062,-0.0836 l 0,-1.66134 c -1.4875,-0.73615 -2.29389,-0.16099 -3.3448,0.10586 -0.24009,-0.0116 -0.2878,-0.0595 -0.33089,-0.0991 -0.0432,-0.0397 -0.1003,-0.12938 -0.19913,-0.32304 -0.0988,-0.19383 -0.23563,-0.49298 -0.51805,-0.76059 -0.28248,-0.26761 -0.69591,-0.43622 -1.15285,-0.44952 -0.41365,-0.0119 -0.82202,0.10779 -1.13042,0.388 -0.30846,0.28046 -0.47152,0.6683 -0.55246,1.0255 -0.16199,0.71419 -0.0912,1.41292 -0.0674,2.05446 0.0239,0.6418 -0.008,1.20669 -0.0929,1.42888 -0.0426,0.11125 -0.0664,0.13781 -0.12726,0.17604 -0.061,0.0384 -0.19635,0.0897 -0.47163,0.0736 -0.27557,-0.0162 -0.30637,-0.0703 -0.34286,-0.12306 -0.0366,-0.0526 -0.0975,-0.21662 -0.10481,-0.53499 -0.015,-0.63672 0.20013,-1.72004 0.40726,-2.83212 0.20712,-1.11192 0.4237,-2.26505 0.2096,-3.35858 -0.10709,-0.54685 -0.35815,-1.09774 -0.79203,-1.47675 -0.43396,-0.37901 -1.00009,-0.56172 -1.66043,-0.57941 z" id="path14318-5-3" inkscape:connector-curvature="0" sodipodi:nodetypes="cccccccccccccccccccccsccccccccccccsccccccccccccccccccccc"/> +</g> <g style="display:inline" transform="translate(13.51115,137.9503)" id="off"> <ellipse style="color:#000000;text-decoration:none;text-decoration-line:none;display:inline;overflow:visible;visibility:visible;fill:#a40000;fill-opacity:1;fill-rule:evenodd;stroke:#8d8d8d;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" id="ellipse47668" cx="18.48884" cy="190.0497" rx="6.611154" ry="6.515604" /> <path style="color:#000000;text-decoration:none;text-decoration-line:none;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" d="M 15.90515,187.466 21.07254,192.6334" id="path47670" inkscape:connector-curvature="0" sodipodi:nodetypes="cc" inkscape:transform-center-x="-5.253213" inkscape:transform-center-y="3.571599" /> diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index e8cbfcdbf..865ee760e 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -21,6 +21,7 @@ #endif #include "live_effects/lpe-patternalongpath.h" +#include "live_effects/lpe-simplify.h" #include "display/canvas-bpath.h" #include "xml/repr.h" #include "svg/svg.h" @@ -266,6 +267,21 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points lpe->getRepr()->setAttribute("offset_points", s.str().c_str()); } +static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem *item) +{ + using namespace Inkscape::LivePathEffect; + + Effect::createAndApply(SIMPLIFY, dc->desktop->doc(), item); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); + // write powerstroke parameters: + lpe->getRepr()->setAttribute("steps", "1"); + lpe->getRepr()->setAttribute("threshold", threshold); + lpe->getRepr()->setAttribute("smooth_angles", "360"); + lpe->getRepr()->setAttribute("helper_size", "0"); + lpe->getRepr()->setAttribute("simplifyindividualpaths", "false"); + lpe->getRepr()->setAttribute("simplifyJustCoalesce", "false"); +} + static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve) { using namespace Inkscape::LivePathEffect; @@ -287,6 +303,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); + bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0); + if(simplify){ + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); + tol = tol/(100.0*(101.0-tol)); + std::ostringstream ss; + ss << tol; + spdc_apply_simplify(ss.str(), dc, item); + } bool shape_applied = false; SPCSSAttr *css_item = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS); const char *cstroke = sp_repr_css_property(css_item, "stroke", "none"); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 16c26546f..bfb1c67f0 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -635,8 +635,11 @@ void PencilTool::_interpolate() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double const tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); - + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); + if(simplify){ + tolerance_sq = 0; + } g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); this->green_curve->reset(); @@ -703,8 +706,11 @@ void PencilTool::_sketchInterpolate() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double const tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); - + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); + if(simplify){ + tolerance_sq = 0; + } bool average_all_sketches = prefs->getBool("/tools/freehand/pencil/average_all_sketches", true); g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 1214a378a..4b177d3ad 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -28,6 +28,7 @@ # include "config.h" #endif +#include <gtkmm.h> #include <glibmm/i18n.h> #include "pencil-toolbar.h" @@ -43,6 +44,12 @@ #include "ui/tools/pen-tool.h" #include "ui/uxmanager.h" #include "widgets/spinbutton-events.h" +#include <selection.h> +#include "live_effects/lpe-simplify.h" +#include "live_effects/effect-enum.h" +#include "live_effects/lpeobject.h" +#include "sp-lpe-item.h" +#include "util/glib-list-iterators.h" using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; @@ -151,6 +158,12 @@ static void freehand_change_shape(EgeSelectOneAction* act, GObject *dataKludge) prefs->setInt(freehand_tool_name(dataKludge) + "/shape", shape); } +static void freehand_simplify_lpe(InkToggleAction* itact, GObject *dataKludge) { + gint simplify = gtk_toggle_action_get_active( GTK_TOGGLE_ACTION(itact) ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt(freehand_tool_name(dataKludge) + "/simplify", simplify); +} + /** * Generate the list of freehand advanced shape option entries. */ @@ -232,6 +245,24 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb prefs->setDouble("/tools/freehand/pencil/tolerance", gtk_adjustment_get_value(adj)); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); + SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop")); + std::vector<SPItem *> selected = desktop->getSelection()->itemList(); + for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){ + SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it); + if (lpeitem && lpeitem->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); + if(thisEffect){ + Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(thisEffect->getLPEObj()->get_lpe()); + if (lpe) { + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); + tol = tol/(100.0*(101.0-tol)); + std::ostringstream ss; + ss << tol; + lpe->getRepr()->setAttribute("threshold", ss.str()); + } + } + } + } } /* @@ -303,6 +334,18 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_pencil_tb_defaults), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); } + /* LPE simplify based tolerance */ + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + InkToggleAction* itact = ink_toggle_action_new( "PencilLpeSimplify", + _("LPE based interactive simplify"), + _("LPE based interactive simplify"), + INKSCAPE_ICON("interactive_simplify"), + Inkscape::ICON_SIZE_SMALL_TOOLBAR ); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(itact), prefs->getInt("/tools/freehand/pencil/simplify", 0) ); + g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(freehand_simplify_lpe), holder) ; + gtk_action_group_add_action( mainActions, GTK_ACTION(itact) ); + } g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index d56b91f5e..62e4bcb8b 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -398,6 +398,7 @@ static gchar const * ui_descr = " <toolitem action='FreehandModeActionPencil' />" " <separator />" " <toolitem action='PencilToleranceAction' />" + " <toolitem action='PencilLpeSimplify' />" " <separator />" " <toolitem action='PencilResetAction' />" " <separator />" |
