summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-05-10 11:40:31 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-05-10 11:40:31 +0000
commit870dbb0348163f55263eb9dca601d525d53a8d79 (patch)
tree63ad837d271d8134f393aa587516e45cf4e6550b /src/live_effects
parentupdate to trunk (diff)
downloadinkscape-870dbb0348163f55263eb9dca601d525d53a8d79.tar.gz
inkscape-870dbb0348163f55263eb9dca601d525d53a8d79.zip
Working on Krzysztof review. Seems to be all fixed.
TODO: double check review and comment (bzr r13645.1.89)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/CMakeLists.txt4
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp154
-rw-r--r--src/live_effects/lpe-fillet-chamfer.h6
-rw-r--r--src/live_effects/parameter/array.cpp9
-rw-r--r--src/live_effects/parameter/satellitearray.cpp90
5 files changed, 129 insertions, 134 deletions
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt
index e06afef2f..a5bb1741c 100644
--- a/src/live_effects/CMakeLists.txt
+++ b/src/live_effects/CMakeLists.txt
@@ -58,11 +58,11 @@ set(live_effects_SRC
parameter/array.cpp
parameter/bool.cpp
- parameter/parameter.cpp
- parameter/path.cpp
parameter/originalpath.cpp
parameter/originalpatharray.cpp
+ parameter/parameter.cpp
parameter/path-reference.cpp
+ parameter/path.cpp
parameter/point.cpp
parameter/powerstrokepointarray.cpp
parameter/satellitearray.cpp
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 8d457c90b..16bef6a99 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -4,13 +4,6 @@
*
* Copyright (C) 2014 Author(s)
*
- * Special thanks to Johan Engelen for the base of the effect -powerstroke-
- * Also to ScislaC for point me to the idea
- * Also su_v for his construvtive feedback and time
- * Also to Mc- (IRC nick) for his important contribution to find real time
- * values based on
- * and finaly to Liam P. White for his big help on coding, that save me a lot of
- * hours
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -27,7 +20,6 @@
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
-using namespace Geom;
namespace Inkscape {
namespace LivePathEffect {
@@ -45,7 +37,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject)
method(_("Method:"), _("Methods to calculate the fillet or chamfer"),
"method", FMConverter, &wr, this, FM_AUTO),
radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &wr,
- this, 0.),
+ this, 0.0),
chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "chamfer_steps",
&wr, this, 1),
flexible(_("Flexible radius size (%)"), _("Flexible radius size (%)"),
@@ -78,7 +70,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject)
registerParameter(&only_selected);
registerParameter(&hide_knots);
- radius.param_set_range(0., infinity());
+ radius.param_set_range(0.0, Geom::infinity());
radius.param_set_increments(1, 1);
radius.param_set_digits(4);
chamfer_steps.param_set_range(1, 999);
@@ -96,13 +88,13 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem);
SPShape *shape = dynamic_cast<SPShape *>(splpeitem);
if (shape) {
- PathVector const original_pathv =
+ Geom::PathVector const original_pathv =
pathv_to_linear_and_cubic_beziers(shape->getCurve()->get_pathvector());
- Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv);
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in = paths_to_pw(original_pathv);
pwd2_in = remove_short_cuts(pwd2_in, 0.01);
int global_counter = 0;
std::vector<Satellite> satellites;
- for (PathVector::const_iterator path_it = original_pathv.begin();
+ for (Geom::PathVector::const_iterator path_it = original_pathv.begin();
path_it != original_pathv.end(); ++path_it) {
if (path_it->empty()) {
continue;
@@ -110,7 +102,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
Geom::Path::const_iterator curve_it1 = path_it->begin();
Geom::Path::const_iterator curve_endit = path_it->end_default();
if (path_it->closed()) {
- Curve const &closingline = path_it->back_closed();
+ Geom::Curve const &closingline = path_it->back_closed();
// the closing line segment is always of type
// LineSegment.
if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
@@ -133,11 +125,11 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
active = false;
}
}
- Satellite satellite(F);
+ Satellite satellite(FILLET);
satellite.setIsTime(flexible);
- satellite.setActive(active)
- satellite.setMirror(mirror_knots)
- satellite.setHidden(hidden)
+ satellite.setActive(active);
+ satellite.setHasMirror(mirror_knots);
+ satellite.setHidden(hidden);
satellite.setAmount(0.0);
satellite.setAngle(0.0);
satellite.setSteps(steps);
@@ -148,6 +140,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
}
}
pointwise = new Pointwise(pwd2_in, satellites);
+ pointwise->setPathInfo(original_pathv);
satellites_param.setPointwise(pointwise);
} else {
g_warning("LPE Fillet/Chamfer can only be applied to shapes (not groups).");
@@ -250,22 +243,22 @@ Gtk::Widget *LPEFilletChamfer::newWidget()
void LPEFilletChamfer::fillet()
{
- updateSatelliteType(F);
+ updateSatelliteType(FILLET);
}
void LPEFilletChamfer::inverseFillet()
{
- updateSatelliteType(IF);
+ updateSatelliteType(INVERSE_FILLET);
}
void LPEFilletChamfer::chamfer()
{
- updateSatelliteType(C);
+ updateSatelliteType(CHAMFER);
}
void LPEFilletChamfer::inverseChamfer()
{
- updateSatelliteType(IC);
+ updateSatelliteType(INVERSE_CHAMFER);
}
void LPEFilletChamfer::refreshKnots()
@@ -284,7 +277,7 @@ void LPEFilletChamfer::updateAmount()
power = radius / 100;
}
std::vector<Satellite> satellites = pointwise->getSatellites();
- Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
Pathinfo path_info(pwd2);
for (std::vector<Satellite>::iterator it = satellites.begin();
it != satellites.end(); ++it)
@@ -335,7 +328,7 @@ void LPEFilletChamfer::updateAmount()
void LPEFilletChamfer::updateChamferSteps()
{
std::vector<Satellite> satellites = pointwise->getSatellites();
- Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
for (std::vector<Satellite>::iterator it = satellites.begin();
it != satellites.end(); ++it) {
if (ignore_radius_0 && it->amount == 0) {
@@ -357,7 +350,7 @@ void LPEFilletChamfer::updateChamferSteps()
void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype)
{
std::vector<Satellite> satellites = pointwise->getSatellites();
- Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
for (std::vector<Satellite>::iterator it = satellites.begin();
it != satellites.end(); ++it) {
if (ignore_radius_0 && it->amount == 0) {
@@ -366,10 +359,10 @@ void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype)
if (only_selected) {
Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin());
if (isNodePointSelected(satellite_point)) {
- it->satelliteType = satellitetype;
+ it->satellite_type = satellitetype;
}
} else {
- it->satelliteType = satellitetype;
+ it->satellite_type = satellitetype;
}
}
pointwise->setSatellites(satellites);
@@ -394,9 +387,9 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
//mandatory call
satellites_param.setEffectType(effectType());
- PathVector const &original_pathv =
+ Geom::PathVector const original_pathv =
pathv_to_linear_and_cubic_beziers(c->get_pathvector());
- Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv);
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in = paths_to_pw(original_pathv);
pwd2_in = remove_short_cuts(pwd2_in, 0.01);
std::vector<Satellite> sats = satellites_param.data();
if(sats.empty()){
@@ -410,20 +403,20 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
}
for (std::vector<Satellite>::iterator it = sats.begin();
it != sats.end();) {
- if (it->isTime != flexible) {
- it->isTime = flexible;
+ if (it->is_time != flexible) {
+ it->is_time = flexible;
double amount = it->amount;
- D2<SBasis> d2_in = pwd2_in[it - sats.begin()];
- if (it->isTime) {
- double time = it->timeAtArcLength(amount, d2_in);
+ Geom::D2<Geom::SBasis> d2_in = pwd2_in[it - sats.begin()];
+ if (it->is_time) {
+ double time = timeAtArcLength(amount, d2_in);
it->amount = time;
} else {
- double size = it->arcLengthAt(amount, d2_in);
+ double size = arcLengthAt(amount, d2_in);
it->amount = size;
}
}
- if (it->hasMirror != mirror_knots) {
- it->hasMirror = mirror_knots;
+ if (it->has_mirror != mirror_knots) {
+ it->has_mirror = mirror_knots;
}
it->hidden = hide_knots;
++it;
@@ -431,19 +424,19 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
Pathinfo path_info(original_pathv);
size_t number_curves = path_info.size();
if (pointwise && number_curves != sats.size()) {
- bool active = true;
- bool hidden = false;
- bool is_time = sats[0].isTime;
- bool mirror_knots = sats[0].hasMirror;
- double amount = 0.0;
- double degrees = 0.0;
- int steps = 0;
- Satellite sat(sats[0].satelliteType, is_time, active, mirror_knots,
- hidden, amount, degrees, steps);
+ Satellite sat(sats[0].satellite_type);
+ sat.setIsTime(sats[0].is_time);
+ sat.setActive(true);
+ sat.setHasMirror( sats[0].has_mirror);
+ sat.setHidden(false);
+ sat.setAmount(0.0);
+ sat.setAngle(0.0);
+ sat.setSteps(0);
pointwise->recalculateForNewPwd2(pwd2_in, original_pathv, sat);
} else {
pointwise = new Pointwise(pwd2_in, sats);
}
+ pointwise->setPathInfo(original_pathv);
satellites_param.setPointwise(pointwise);
refreshKnots();
} else {
@@ -466,7 +459,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
const double K = (4.0 / 3.0) * (sqrt(2.0) - 1.0);
std::vector<Geom::Path> path_in_processed =
pathv_to_linear_and_cubic_beziers(path_in);
- for (PathVector::const_iterator path_it = path_in_processed.begin();
+ for (Geom::PathVector::const_iterator path_it = path_in_processed.begin();
path_it != path_in_processed.end(); ++path_it) {
if (path_it->empty()) {
continue;
@@ -511,7 +504,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
continue;
}
Satellite satellite;
- Curve *curve_it2_fixed = path_it->begin()->duplicate();
+ Geom::Curve *curve_it2_fixed = path_it->begin()->duplicate();
if (!path_it->closed()) {
if (curve_it2 != curve_endit) {
curve_it2_fixed = (*curve_it2).duplicate();
@@ -520,7 +513,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}
} else {
if (time0 != 1) {
- Curve *last_curve = curve_it1->portion(time0, 1);
+ Geom::Curve *last_curve = curve_it1->portion(time0, 1);
last_curve->setInitial(tmp_path.finalPoint());
tmp_path.append(*last_curve);
}
@@ -552,7 +545,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}
bool last = curve_it2 == curve_endit;
- double s = satellite.size(curve_it2_fixed->toSBasis());
+ double s = satellite.arcDistance(curve_it2_fixed->toSBasis());
double time1 = satellite.time(s, true, (*curve_it1).toSBasis());
double time2 = satellite.time(curve_it2_fixed->toSBasis());
if (!satellite.active) {
@@ -567,15 +560,15 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
times.push_back(time0);
times.push_back(time1);
times.push_back(time2);
- Curve *knot_curve_1 = curve_it1->portion(times[0], times[1]);
+ Geom::Curve *knot_curve_1 = curve_it1->portion(times[0], times[1]);
if (counter_curves > 0) {
knot_curve_1->setInitial(tmp_path.finalPoint());
} else {
tmp_path.start((*curve_it1).pointAt(times[0]));
}
- Point start_arc_point = knot_curve_1->finalPoint();
- Point end_arc_point = curve_it2_fixed->pointAt(times[2]);
+ Geom::Point start_arc_point = knot_curve_1->finalPoint();
+ Geom::Point end_arc_point = curve_it2_fixed->pointAt(times[2]);
if (times[2] == 1) {
end_arc_point = curve_it2_fixed->pointAt(times[2] - GAP_HELPER);
}
@@ -586,22 +579,22 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
double k2 = distance(end_arc_point, curve_it2_fixed->initialPoint()) * K;
Geom::CubicBezier const *cubic_1 =
dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_1);
- Ray ray_1(start_arc_point, curve_it1->finalPoint());
+ Geom::Ray ray_1(start_arc_point, curve_it1->finalPoint());
if (cubic_1) {
ray_1.setPoints((*cubic_1)[2], start_arc_point);
}
- Point handle_1 = Point::polar(ray_1.angle(), k1) + start_arc_point;
+ Geom::Point handle_1 = Geom::Point::polar(ray_1.angle(), k1) + start_arc_point;
if (time0 == 1) {
handle_1 = start_arc_point;
}
- Curve *knot_curve_2 = curve_it2_fixed->portion(times[2], 1);
+ Geom::Curve *knot_curve_2 = curve_it2_fixed->portion(times[2], 1);
Geom::CubicBezier const *cubic_2 =
dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_2);
- Ray ray_2(curve_it2_fixed->initialPoint(), end_arc_point);
+ Geom::Ray ray_2(curve_it2_fixed->initialPoint(), end_arc_point);
if (cubic_2) {
ray_2.setPoints(end_arc_point, (*cubic_2)[1]);
}
- Point handle_2 = end_arc_point - Point::polar(ray_2.angle(), k2);
+ Geom::Point handle_2 = end_arc_point - Geom::Point::polar(ray_2.angle(), k2);
bool ccw_toggle = cross(curve_it1->finalPoint() - start_arc_point,
end_arc_point - start_arc_point) < 0;
@@ -610,7 +603,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
if (ccw_toggle) {
handleAngle = ray_1.angle() + angle;
}
- Point inverse_handle_1 = Point::polar(handleAngle, k1) + start_arc_point;
+ Geom::Point inverse_handle_1 = Geom::Point::polar(handleAngle, k1) + start_arc_point;
if (time0 == 1) {
inverse_handle_1 = start_arc_point;
}
@@ -618,39 +611,40 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
if (ccw_toggle) {
handleAngle = ray_2.angle() - angle;
}
- Point inverse_handle_2 = end_arc_point - Point::polar(handleAngle, k2);
+ Geom::Point inverse_handle_2 = end_arc_point - Geom::Point::polar(handleAngle, k2);
if (times[2] == 1) {
end_arc_point = curve_it2_fixed->pointAt(times[2]);
}
if (times[1] == times[0]) {
start_arc_point = curve_it1->pointAt(times[0]);
}
- Line const x_line(Geom::Point(0, 0), Geom::Point(1, 0));
- Line const angled_line(start_arc_point, end_arc_point);
+ Geom::Line const x_line(Geom::Point(0, 0), Geom::Point(1, 0));
+ Geom::Line const angled_line(start_arc_point, end_arc_point);
double arc_angle = Geom::angle_between(x_line, angled_line);
double radius = Geom::distance(start_arc_point,
middle_point(start_arc_point, end_arc_point)) /
sin(angle / 2.0);
- Coord rx = radius;
- Coord ry = rx;
+ Geom::Coord rx = radius;
+ Geom::Coord ry = rx;
if (times[1] != 1) {
if (times[1] != times[0] || times[1] == times[0] == 1) {
if (!knot_curve_1->isDegenerate()) {
tmp_path.append(*knot_curve_1);
}
}
- SatelliteType type = satellite.satelliteType;
+ SatelliteType type = satellite.satellite_type;
size_t steps = satellite.steps;
if (steps < 1) {
steps = 1;
}
- if (type == C) {
+ if (type == CHAMFER) {
Geom::Path path_chamfer;
path_chamfer.start(tmp_path.finalPoint());
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) ||
- method == FM_ARC) {
- path_chamfer.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0,
+ method == FM_ARC)
+ {
+ path_chamfer.appendNew<Geom::SVGEllipticalArc>(rx, ry, arc_angle, 0,
ccw_toggle, end_arc_point);
} else {
path_chamfer.appendNew<Geom::CubicBezier>(handle_1, handle_2,
@@ -658,19 +652,19 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}
double chamfer_stepsTime = 1.0 / steps;
for (size_t i = 1; i < steps; i++) {
- Geom::Point chamfer_step =
- path_chamfer.pointAt(chamfer_stepsTime * i);
+ Geom::Point chamfer_step = path_chamfer.pointAt(chamfer_stepsTime * i);
tmp_path.appendNew<Geom::LineSegment>(chamfer_step);
}
tmp_path.appendNew<Geom::LineSegment>(end_arc_point);
- } else if (type == IC) {
+ } else if (type == INVERSE_CHAMFER) {
Geom::Path path_chamfer;
path_chamfer.start(tmp_path.finalPoint());
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) ||
- method == FM_ARC) {
+ method == FM_ARC)
+ {
ccw_toggle = ccw_toggle ? 0 : 1;
- path_chamfer.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0,
+ path_chamfer.appendNew<Geom::SVGEllipticalArc>(rx, ry, arc_angle, 0,
ccw_toggle, end_arc_point);
} else {
path_chamfer.appendNew<Geom::CubicBezier>(
@@ -683,22 +677,24 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
tmp_path.appendNew<Geom::LineSegment>(chamfer_step);
}
tmp_path.appendNew<Geom::LineSegment>(end_arc_point);
- } else if (type == IF) {
+ } else if (type == INVERSE_FILLET) {
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) ||
- method == FM_ARC) {
+ method == FM_ARC)
+ {
ccw_toggle = ccw_toggle ? 0 : 1;
- tmp_path.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
+ tmp_path.appendNew<Geom::SVGEllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
end_arc_point);
} else {
tmp_path.appendNew<Geom::CubicBezier>(inverse_handle_1,
inverse_handle_2, end_arc_point);
}
- } else if (type == F) {
+ } else if (type == FILLET) {
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) ||
- method == FM_ARC) {
- tmp_path.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
+ method == FM_ARC)
+ {
+ tmp_path.appendNew<Geom::SVGEllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
end_arc_point);
} else {
tmp_path.appendNew<Geom::CubicBezier>(handle_1, handle_2,
diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h
index 48056924a..bab278cf5 100644
--- a/src/live_effects/lpe-fillet-chamfer.h
+++ b/src/live_effects/lpe-fillet-chamfer.h
@@ -7,11 +7,7 @@
*
* Copyright (C) 2014 Author(s)
*
- * Special thanks to Johan Engelen for the base of the effect -powerstroke-
- * Also to ScislaC for point me to the idea
- * Also su_v for his construvtive feedback and time
- * and finaly to Liam P. White for his big help on coding, that save me a lot of
- * hours
+ * Jabiertxof:Thanks to all people help me
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index c71b8ed55..9b326fe32 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -83,7 +83,14 @@ ArrayParam<Satellite >::readsvg(const gchar * str)
if (sp_svg_satellite_read_d(str, &sat)) {
return sat;
}
- Satellite satellite(Geom::F, true, false, false, true, 0.0, 0.0, 0);
+ Satellite satellite(FILLET);
+ satellite.setIsTime(true);
+ satellite.setActive(false);
+ satellite.setHasMirror(false);
+ satellite.setHidden(true);
+ satellite.setAmount(0.0);
+ satellite.setAngle(0.0);
+ satellite.setSteps(0);
return satellite;
}
diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp
index 5a90d1930..7df849c24 100644
--- a/src/live_effects/parameter/satellitearray.cpp
+++ b/src/live_effects/parameter/satellitearray.cpp
@@ -1,10 +1,8 @@
/*
- * Copyright (C) Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
- * Special thanks to Johan Engelen for the base of the effect -powerstroke-
- * Also to ScislaC for point me to the idea
- * Also su_v for his construvtive feedback and time
- * and finaly to Liam P. White for his big help on coding, that save me a lot of
- * hours
+ * Author(s):
+ * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
+ *
+ * Copyright (C) 2014 Author(s)
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -19,8 +17,6 @@
// this has to be included last.
#include <glibmm/i18n.h>
-using namespace Geom;
-
namespace Inkscape {
namespace LivePathEffect {
@@ -88,7 +84,7 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
if (!_vector[i].active || _vector[i].hidden) {
continue;
}
- if ((!_vector[i].hasMirror && mirror == true) || _vector[i].amount == 0) {
+ if ((!_vector[i].has_mirror && mirror == true) || _vector[i].amount == 0) {
continue;
}
double pos = 0;
@@ -97,7 +93,7 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
}
Geom::D2<Geom::SBasis> d2 = pwd2[i];
bool overflow = false;
- double size_out = _vector[i].size(pwd2[i]);
+ double size_out = _vector[i].arcDistance(pwd2[i]);
double lenght_out = Geom::length(pwd2[i], Geom::EPSILON);
double lenght_in = 0;
boost::optional<size_t> d2_prev_index = path_info.previous(i);
@@ -133,9 +129,9 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
Geom::Affine aff = Geom::Affine();
aff *= Geom::Scale(_helper_size);
if (mirror == true) {
- aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(90));
+ aff *= Geom::Rotate(ray_1.angle() - Geom::deg_to_rad(90));
} else {
- aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(270));
+ aff *= Geom::Rotate(ray_1.angle() - Geom::deg_to_rad(270));
}
pathv *= aff;
pathv += d2.valueAt(pos);
@@ -161,9 +157,9 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
aff = Geom::Affine();
aff *= Geom::Scale(_helper_size / 2.0);
if (mirror == true) {
- aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(90));
+ aff *= Geom::Rotate(ray_1.angle() - Geom::deg_to_rad(90));
} else {
- aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(270));
+ aff *= Geom::Rotate(ray_1.angle() - Geom::deg_to_rad(270));
}
pathv *= aff;
pathv += d2.valueAt(pos);
@@ -193,7 +189,7 @@ void SatelliteArrayParam::param_transform_multiply(Geom::Affine const &postmul,
if (prefs->getBool("/options/transform/rectcorners", true)) {
for (size_t i = 0; i < _vector.size(); ++i) {
- if (!_vector[i].isTime && _vector[i].amount > 0) {
+ if (!_vector[i].is_time && _vector[i].amount > 0) {
_vector[i].amount = _vector[i].amount *
((postmul.expansionX() + postmul.expansionY()) / 2);
}
@@ -214,23 +210,23 @@ void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
if (!_vector[i].active) {
continue;
}
- if (!_vector[i].hasMirror && mirror == true) {
+ if (!_vector[i].has_mirror && mirror == true) {
continue;
}
using namespace Geom;
- SatelliteType type = _vector[i].satelliteType;
+ SatelliteType type = _vector[i].satellite_type;
//IF is for filletChamfer effect...
if (_effectType == FILLET_CHAMFER) {
const gchar *tip;
- if (type == C) {
+ if (type == CHAMFER) {
tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
"<b>Shift+Click</b> open dialog, "
"<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IC) {
+ } else if (type == INVERSE_CHAMFER) {
tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
"<b>Shift+Click</b> open dialog, "
"<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IF) {
+ } else if (type == INVERSE_FILLET) {
tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, "
"<b>Shift+Click</b> open dialog, "
"<b>Ctrl+Alt+Click</b> reset");
@@ -263,8 +259,8 @@ FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(
SatelliteArrayParam *p, size_t index)
: _pparam(p), _index(index) {}
-void FilletChamferKnotHolderEntity::knot_set(Point const &p,
- Point const &/*origin*/,
+void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p,
+ Geom::Point const &/*origin*/,
guint state)
{
Geom::Point s = snap_knot_position(p, state);
@@ -298,10 +294,10 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p,
if (time_start > mirror_time) {
mirror_time = time_start;
}
- double size = satellite.arcLengthAt(mirror_time, d2_in);
+ double size = arcLengthAt(mirror_time, d2_in);
double amount = Geom::length(d2_in, Geom::EPSILON) - size;
- if (satellite.isTime) {
- amount = satellite.timeAtArcLength(amount, pwd2[index]);
+ if (satellite.is_time) {
+ amount = timeAtArcLength(amount, pwd2[index]);
}
satellite.amount = amount;
}
@@ -323,20 +319,20 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const
index = _index - _pparam->_vector.size();
}
if (!valid_index(index)) {
- return Point(infinity(), infinity());
+ return Geom::Point(Geom::infinity(), Geom::infinity());
}
Satellite satellite = _pparam->_vector.at(index);
if (!_pparam->_last_pointwise) {
- return Point(infinity(), infinity());
+ return Geom::Point(Geom::infinity(), Geom::infinity());
}
if (!satellite.active || satellite.hidden) {
- return Point(infinity(), infinity());
+ return Geom::Point(Geom::infinity(), Geom::infinity());
}
Pointwise *pointwise = _pparam->_last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
Pathinfo path_info(pwd2);
if (pwd2.size() <= index) {
- return Point(infinity(), infinity());
+ return Geom::Point(Geom::infinity(), Geom::infinity());
}
this->knot->show();
if (_index >= _pparam->_vector.size()) {
@@ -344,7 +340,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const
boost::optional<size_t> d2_prev_index = path_info.previous(index);
if (d2_prev_index) {
Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
- double s = satellite.size(pwd2[index]);
+ double s = satellite.arcDistance(pwd2[index]);
double t = satellite.time(s, true, d2_in);
if (t > 1) {
t = 1;
@@ -383,34 +379,34 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
} else {
using namespace Geom;
- SatelliteType type = _pparam->_vector.at(index).satelliteType;
+ SatelliteType type = _pparam->_vector.at(index).satellite_type;
switch (type) {
- case F:
- type = IF;
+ case FILLET:
+ type = INVERSE_FILLET;
break;
- case IF:
- type = C;
+ case INVERSE_FILLET:
+ type = CHAMFER;
break;
- case C:
- type = IC;
+ case CHAMFER:
+ type = INVERSE_CHAMFER;
break;
default:
- type = F;
+ type = FILLET;
break;
}
- _pparam->_vector.at(index).satelliteType = type;
+ _pparam->_vector.at(index).satellite_type = type;
_pparam->param_set_and_write_new_value(_pparam->_vector);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
const gchar *tip;
- if (type == C) {
+ if (type == CHAMFER) {
tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
"<b>Shift+Click</b> open dialog, "
"<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IC) {
+ } else if (type == INVERSE_CHAMFER) {
tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
"<b>Shift+Click</b> open dialog, "
"<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IF) {
+ } else if (type == INVERSE_FILLET) {
tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, "
"<b>Shift+Click</b> open dialog, "
"<b>Ctrl+Alt+Click</b> reset");
@@ -423,10 +419,10 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
this->knot->show();
}
} else if (state & GDK_SHIFT_MASK) {
- Piecewise<D2<SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
Pathinfo path_info(pwd2);
double amount = _pparam->_vector.at(index).amount;
- if (!_pparam->_use_distance && !_pparam->_vector.at(index).isTime) {
+ if (!_pparam->_use_distance && !_pparam->_vector.at(index).is_time) {
boost::optional<size_t> prev = path_info.previous(index);
if (prev) {
amount = _pparam->_vector.at(index).lenToRad(amount, pwd2[*prev], pwd2[index],_pparam->_vector.at(*prev));
@@ -435,7 +431,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
}
}
bool aprox = false;
- D2<SBasis> d2_out = _pparam->_last_pointwise->getPwd2()[index];
+ Geom::D2<Geom::SBasis> d2_out = _pparam->_last_pointwise->getPwd2()[index];
boost::optional<size_t> d2_prev_index = path_info.previous(index);
if (d2_prev_index) {
Geom::D2<Geom::SBasis> d2_in =
@@ -464,8 +460,8 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite)
}
double amount = satellite.amount;
double max_amount = amount;
- if (!_pparam->_use_distance && !satellite.isTime) {
- Piecewise<D2<SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
+ if (!_pparam->_use_distance && !satellite.is_time) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
Pathinfo path_info(pwd2);
boost::optional<size_t> prev = path_info.previous(index);
if (prev) {