diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-08-28 22:19:09 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-08-28 22:19:09 +0000 |
| commit | 1cece014ec24ec8447917fa31029fc70fab69a77 (patch) | |
| tree | 0410f1d6dbf8f18434309301df4d1827a8faa476 /src/ui/tools | |
| parent | Allow pressure in pencil in the tree modes, bezier, bspline and spiro (diff) | |
| download | inkscape-1cece014ec24ec8447917fa31029fc70fab69a77.tar.gz inkscape-1cece014ec24ec8447917fa31029fc70fab69a77.zip | |
Parametrice into preferences magic numbers and other staff
Diffstat (limited to 'src/ui/tools')
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 16 | ||||
| -rw-r--r-- | src/ui/tools/pencil-tool.cpp | 12 | ||||
| -rw-r--r-- | src/ui/tools/pencil-tool.h | 1 |
3 files changed, 17 insertions, 12 deletions
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 072500144..2fdc8fade 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -262,13 +262,15 @@ static void spdc_apply_powerstroke_shape(std::vector<Geom::Point> points, Freeha } Effect::createAndApply(POWERSTROKE, dc->desktop->doc(), item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - lpe->getRepr()->setAttribute("start_linecap_type", "round"); - lpe->getRepr()->setAttribute("end_linecap_type", "round"); - lpe->getRepr()->setAttribute("sort_points", "true"); - lpe->getRepr()->setAttribute("interpolator_type", "CentripetalCatmullRom"); - lpe->getRepr()->setAttribute("interpolator_beta", "0.2"); - lpe->getRepr()->setAttribute("miter_limit", "4"); - lpe->getRepr()->setAttribute("linejoin_type", "round"); + if(prefs->getBool("/tools/freehand/pencil/optimus-powerstroke",true)) { + lpe->getRepr()->setAttribute("start_linecap_type", "round"); + lpe->getRepr()->setAttribute("end_linecap_type", "round"); + lpe->getRepr()->setAttribute("sort_points", "true"); + lpe->getRepr()->setAttribute("interpolator_type", "CentripetalCatmullRom"); + lpe->getRepr()->setAttribute("interpolator_beta", "0.2"); + lpe->getRepr()->setAttribute("miter_limit", "4"); + lpe->getRepr()->setAttribute("linejoin_type", "round"); + } static_cast<LPEPowerStroke*>(lpe)->offset_points.param_set_and_write_new_value(pt->points); pt->points.clear(); return; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 7fcbaa31e..3705d0f43 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -70,7 +70,6 @@ PencilTool::PencilTool() , req_tangent(0, 0) , is_drawing(false) , sketch_n(0) - , _gap_pressure(1.0) , _powerpreview(NULL) { } @@ -759,7 +758,13 @@ PencilTool::addPowerStrokePencil(SPCurve * c) if (min > max){ min = max; } + double gap_pressure = prefs->getDoubleLimited("/tools/freehand/pencil/gap-pressure",1.0, 0.1, 9999.0); + double knots_distance = prefs->getDoubleLimited("/tools/freehand/pencil/knots-distance",1.0, 0.1, 9999.0); + gint pressure_sensibility = prefs->getIntLimited("/tools/freehand/pencil/pressure-sensibility",12, 1, 100); + + double previous_pressure = 0.0; + double tol = knots_distance / zoom; Geom::Point previous_point = Geom::Point(0,0); bool start = true; auto pressure = this->wps.begin(); @@ -767,7 +772,7 @@ PencilTool::addPowerStrokePencil(SPCurve * c) //Maybe the 12 POW can be moved to a preferences 12 give a good results of sensibility on my tablet //But maybe is a tweakable value. less number = less sensibility //8 give an aceptable max witht to powerstoke - double pressure_base = pow(*pressure, 12); + double pressure_base = pow(*pressure, pressure_sensibility); double pressure_shirnked = (pressure_base * (max - min)) + min; double pressure_factor = pressure_base/pressure_shirnked; double pressure_computed = (pressure_shirnked * 8.0 * scale) / zoom; @@ -776,8 +781,7 @@ PencilTool::addPowerStrokePencil(SPCurve * c) pressure_computed = previous_pressure; buttonrelease = true; } - double tol = 135.0 / zoom; - if (start || std::abs(previous_pressure - pressure_computed) > _gap_pressure / (zoom * pressure_factor)) { + if (start || std::abs(previous_pressure - pressure_computed) > gap_pressure / (zoom * pressure_factor)) { Geom::Point position = *point; if (!live) { position *= transformCoordinate.inverse(); diff --git a/src/ui/tools/pencil-tool.h b/src/ui/tools/pencil-tool.h index 32eac2272..8f57cf4d0 100644 --- a/src/ui/tools/pencil-tool.h +++ b/src/ui/tools/pencil-tool.h @@ -69,7 +69,6 @@ private: bool _handleKeyPress(GdkEventKey const &event); bool _handleKeyRelease(GdkEventKey const &event); void _setStartpoint(Geom::Point const &p); - double _gap_pressure; SPItem *_powerpreview; void _setEndpoint(Geom::Point const &p); |
