summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-05-09 22:37:31 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-05-09 22:37:31 +0000
commit6195a5fd157ff2681534aa90a279627e0048d4e1 (patch)
tree2f3d936f145cc1b641a79dc12246bc87286672c9 /src
parentfixing review (diff)
downloadinkscape-6195a5fd157ff2681534aa90a279627e0048d4e1.tar.gz
inkscape-6195a5fd157ff2681534aa90a279627e0048d4e1.zip
fixing review
(bzr r13645.1.87)
Diffstat (limited to 'src')
-rw-r--r--src/helper/geom-satellite.cpp50
-rw-r--r--src/helper/geom-satellite.h54
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp43
-rw-r--r--src/live_effects/parameter/satellitearray.cpp22
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.cpp4
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h6
6 files changed, 92 insertions, 87 deletions
diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp
index 397a556a9..51cff7d79 100644
--- a/src/helper/geom-satellite.cpp
+++ b/src/helper/geom-satellite.cpp
@@ -11,7 +11,6 @@
#include <helper/geom-satellite.h>
#include <2geom/curve.h>
#include <2geom/nearest-point.h>
-#include <2geom/sbasis-geometric.h>
#include <2geom/path-intersection.h>
#include <2geom/sbasis-to-bezier.h>
#include <2geom/ray.h>
@@ -29,56 +28,7 @@ Satellite::Satellite(SatelliteType satellite_type)
Satellite::~Satellite() {}
-/**
- * Calculate the time in d2_in with a size of A
- * TODO: find a better place to it
- */
-double timeAtArcLength(double A, Geom::D2<Geom::SBasis> const d2_in)
-{
- if (!d2_in.isFinite() || d2_in.isZero() || A == 0) {
- return 0;
- }
- double t = 0;
- double length_part = Geom::length(d2_in, Geom::EPSILON);
- if (A > length_part || d2_in[0].degreesOfFreedom() == 2) {
- if (length_part != 0) {
- t = A / length_part;
- }
- } else if (d2_in[0].degreesOfFreedom() != 2) {
- Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
- u.push_cut(0);
- u.push(d2_in, 1);
- std::vector<double> t_roots = roots(arcLengthSb(u) - A);
- if (t_roots.size() > 0) {
- t = t_roots[0];
- }
- }
- return t;
-}
-
-/**
- * Calculate the size in d2_in with a point at A
- * TODO: find a better place to it
- */
-double arcLengthAt(double A, Geom::D2<Geom::SBasis> const d2_in)
-{
- if (!d2_in.isFinite() || d2_in.isZero() || A == 0) {
- return 0;
- }
- double s = 0;
- double length_part = Geom::length(d2_in, Geom::EPSILON);
- if (A > length_part || d2_in[0].degreesOfFreedom() == 2) {
- s = (A * length_part);
- } else if (d2_in[0].degreesOfFreedom() != 2) {
- Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
- u.push_cut(0);
- u.push(d2_in, 1);
- u = Geom::portion(u, 0.0, A);
- s = Geom::length(u, 0.001);
- }
- return s;
-}
/**
* Calculate the length of a satellite from a radious A input.
diff --git a/src/helper/geom-satellite.h b/src/helper/geom-satellite.h
index 263cefa68..a4b1b23b9 100644
--- a/src/helper/geom-satellite.h
+++ b/src/helper/geom-satellite.h
@@ -14,6 +14,7 @@
#include <2geom/d2.h>
#include <map>
#include <boost/assign.hpp>
+#include <2geom/sbasis-geometric.h>
#include "util/enums.h"
@@ -22,7 +23,7 @@ enum SatelliteType {
INVERSE_FILLET, //Inverse Fillet
CHAMFER, //Chamfer
INVERSE_CHAMFER, //Inverse Chamfer
- INVALID_SATELLITE // Invalid Satellite)
+ INVALID_SATELLITE // Invalid Satellite
};
/**
* @brief Satellite a per ?node/curve holder of data.
@@ -68,6 +69,57 @@ public:
size_t steps;
};
+/**
+ * Calculate the time in d2_in with a size of A
+ * TODO: find a better place to it
+ */
+double timeAtArcLength(double A, Geom::D2<Geom::SBasis> const d2_in)
+{
+ if (!d2_in.isFinite() || d2_in.isZero() || A == 0) {
+ return 0;
+ }
+ double t = 0;
+ double length_part = Geom::length(d2_in, Geom::EPSILON);
+ if (A > length_part || d2_in[0].degreesOfFreedom() == 2) {
+ if (length_part != 0) {
+ t = A / length_part;
+ }
+ } else if (d2_in[0].degreesOfFreedom() != 2) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
+ u.push_cut(0);
+ u.push(d2_in, 1);
+ std::vector<double> t_roots = roots(arcLengthSb(u) - A);
+ if (t_roots.size() > 0) {
+ t = t_roots[0];
+ }
+ }
+
+ return t;
+}
+
+/**
+ * Calculate the size in d2_in with a point at A
+ * TODO: find a better place to it
+ */
+double arcLengthAt(double A, Geom::D2<Geom::SBasis> const d2_in)
+{
+ if (!d2_in.isFinite() || d2_in.isZero() || A == 0) {
+ return 0;
+ }
+ double s = 0;
+ double length_part = Geom::length(d2_in, Geom::EPSILON);
+ if (A > length_part || d2_in[0].degreesOfFreedom() == 2) {
+ s = (A * length_part);
+ } else if (d2_in[0].degreesOfFreedom() != 2) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
+ u.push_cut(0);
+ u.push(d2_in, 1);
+ u = Geom::portion(u, 0.0, A);
+ s = Geom::length(u, 0.001);
+ }
+ return s;
+}
+
#endif // SEEN_SATELLITE_H
/*
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index d26f47541..8d457c90b 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -20,7 +20,6 @@
#include "display/curve.h"
#include "helper/geom-curves.h"
#include "helper/geom-satellite.h"
-#include "helper/geom-satellite-enum.h"
#include "helper/geom-pathinfo.h"
#include <2geom/svg-elliptical-arc.h>
#include "knotholder.h"
@@ -134,8 +133,14 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
active = false;
}
}
- Satellite satellite(F, flexible, active, mirror_knots, hidden, 0.0, 0.0,
- steps);
+ Satellite satellite(F);
+ satellite.setIsTime(flexible);
+ satellite.setActive(active)
+ satellite.setMirror(mirror_knots)
+ satellite.setHidden(hidden)
+ satellite.setAmount(0.0);
+ satellite.setAngle(0.0);
+ satellite.setSteps(steps);
satellites.push_back(satellite);
++curve_it1;
counter++;
@@ -282,10 +287,12 @@ void LPEFilletChamfer::updateAmount()
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
Pathinfo path_info(pwd2);
for (std::vector<Satellite>::iterator it = satellites.begin();
- it != satellites.end(); ++it) {
+ it != satellites.end(); ++it)
+ {
if (!path_info.closed(it - satellites.begin()) &&
path_info.first(it - satellites.begin()) ==
- (unsigned)(it - satellites.begin())) {
+ (unsigned)(it - satellites.begin()))
+ {
it->amount = 0;
continue;
}
@@ -294,26 +301,28 @@ void LPEFilletChamfer::updateAmount()
}
boost::optional<size_t> previous =
path_info.previous(it - satellites.begin());
- boost::optional<Geom::D2<Geom::SBasis> > previous_d2 = boost::none;
- boost::optional<Satellite> previous_satellite = boost::none;
- if (previous) {
- previous_d2 = pwd2[*previous];
- previous_satellite = satellites[*previous];
- }
if (only_selected) {
Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin());
if (isNodePointSelected(satellite_point)) {
if (!use_knot_distance && !flexible) {
- it->amount = it->radToLen(power, previous_d2,
- pwd2[it - satellites.begin()], previous_satellite);
+ if(previous){
+ it->amount = it->radToLen(power, pwd2[*previous],
+ pwd2[it - satellites.begin()], satellites[*previous]);
+ } else {
+ it->amount = 0.0;
+ }
} else {
it->amount = power;
}
}
} else {
if (!use_knot_distance && !flexible) {
- it->amount = it->radToLen(power, previous_d2,
- pwd2[it - satellites.begin()], previous_satellite);
+ if(previous){
+ it->amount = it->radToLen(power, pwd2[*previous],
+ pwd2[it - satellites.begin()], satellites[*previous]);
+ } else {
+ it->amount = 0.0;
+ }
} else {
it->amount = power;
}
@@ -406,10 +415,10 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
double amount = it->amount;
D2<SBasis> d2_in = pwd2_in[it - sats.begin()];
if (it->isTime) {
- double time = it->toTime(amount, d2_in);
+ double time = it->timeAtArcLength(amount, d2_in);
it->amount = time;
} else {
- double size = it->toSize(amount, d2_in);
+ double size = it->arcLengthAt(amount, d2_in);
it->amount = size;
}
}
diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp
index 5a3b64dd3..5a90d1930 100644
--- a/src/live_effects/parameter/satellitearray.cpp
+++ b/src/live_effects/parameter/satellitearray.cpp
@@ -298,10 +298,10 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p,
if (time_start > mirror_time) {
mirror_time = time_start;
}
- double size = satellite.toSize(mirror_time, d2_in);
+ double size = satellite.arcLengthAt(mirror_time, d2_in);
double amount = Geom::length(d2_in, Geom::EPSILON) - size;
if (satellite.isTime) {
- amount = satellite.toTime(amount, pwd2[index]);
+ amount = satellite.timeAtArcLength(amount, pwd2[index]);
}
satellite.amount = amount;
}
@@ -428,14 +428,11 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
double amount = _pparam->_vector.at(index).amount;
if (!_pparam->_use_distance && !_pparam->_vector.at(index).isTime) {
boost::optional<size_t> prev = path_info.previous(index);
- boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none;
- boost::optional<Satellite> prevSat = boost::none;
if (prev) {
- prevPwd2 = pwd2[*prev];
- prevSat = _pparam->_vector.at(*prev);
+ amount = _pparam->_vector.at(index).lenToRad(amount, pwd2[*prev], pwd2[index],_pparam->_vector.at(*prev));
+ } else {
+ amount = 0.0;
}
- amount = _pparam->_vector.at(index)
- .lenToRad(amount, prevPwd2, pwd2[index], prevSat);
}
bool aprox = false;
D2<SBasis> d2_out = _pparam->_last_pointwise->getPwd2()[index];
@@ -471,14 +468,11 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite)
Piecewise<D2<SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
Pathinfo path_info(pwd2);
boost::optional<size_t> prev = path_info.previous(index);
- boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none;
- boost::optional<Satellite> prevSat = boost::none;
if (prev) {
- prevPwd2 = pwd2[*prev];
- prevSat = _pparam->_vector.at(*prev);
+ amount = _pparam->_vector.at(index).radToLen(amount, pwd2[*prev], pwd2[index], _pparam->_vector.at(*prev));
+ } else {
+ amount = 0.0;
}
- amount = _pparam->_vector.at(index)
- .radToLen(amount, prevPwd2, pwd2[index], prevSat);
if (max_amount > 0 && amount == 0) {
amount = _pparam->_vector.at(index).amount;
}
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
index bc6557b19..2b49d1952 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
@@ -123,7 +123,7 @@ void FilletChamferPropertiesDialog::showDialog(
FilletChamferKnotHolderEntity *pt,
bool _use_distance,
bool _aprox_radius,
- Geom::Satellite _satellite)
+ Satellite _satellite)
{
FilletChamferPropertiesDialog *dialog = new FilletChamferPropertiesDialog();
@@ -200,7 +200,7 @@ void FilletChamferPropertiesDialog::_handleButtonEvent(GdkEventButton *event)
}
}
-void FilletChamferPropertiesDialog::_setSatellite(Geom::Satellite satellite)
+void FilletChamferPropertiesDialog::_setSatellite(Satellite satellite)
{
double position;
std::string distance_or_radius = std::string(_("Radius"));
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index 53bb90b80..f982db286 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -33,7 +33,7 @@ public:
FilletChamferKnotHolderEntity *pt,
bool _use_distance,
bool _aprox_radius,
- Geom::Satellite _satellite);
+ Satellite _satellite);
protected:
@@ -71,7 +71,7 @@ protected:
void _setUseDistance(bool use_knot_distance);
void _setAprox(bool aprox_radius);
void _setAmount(double amount);
- void _setSatellite(Geom::Satellite satellite);
+ void _setSatellite(Satellite satellite);
void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row);
bool _handleKeyEvent(GdkEventKey *event);
@@ -80,7 +80,7 @@ protected:
void _apply();
void _close();
bool _flexible;
- Geom::Satellite _satellite;
+ Satellite _satellite;
bool _use_distance;
double _amount;
bool _aprox;