summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter/filletchamferpointarray.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-24 23:26:11 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-24 23:26:11 +0000
commit7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5 (patch)
tree48cae26bf789b11d79f72efc16a6676f960eaaa6 /src/live_effects/parameter/filletchamferpointarray.cpp
parentupdate to trunk (diff)
parent3D box tool: the shift key must not prevent snapping of the vanishing point. ... (diff)
downloadinkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.tar.gz
inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.zip
update to trunk
(bzr r12588.1.45)
Diffstat (limited to 'src/live_effects/parameter/filletchamferpointarray.cpp')
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.cpp52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp
index e9d375b93..b089213fd 100644
--- a/src/live_effects/parameter/filletchamferpointarray.cpp
+++ b/src/live_effects/parameter/filletchamferpointarray.cpp
@@ -11,7 +11,6 @@
#include <2geom/piecewise.h>
#include <2geom/sbasis-to-bezier.h>
#include <2geom/sbasis-geometric.h>
-#include <2geom/svg-elliptical-arc.h>
#include <2geom/line.h>
#include <2geom/path-intersection.h>
@@ -205,7 +204,7 @@ void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2(
//delete temp vector
std::vector<Point>().swap(tmp);
if (last_pathv.size() > counterPaths) {
- last_pathv[counterPaths] = last_pathv[counterPaths].reverse();
+ last_pathv[counterPaths] = last_pathv[counterPaths].reversed();
}
} else {
if (last_pathv.size() > counterPaths) {
@@ -223,7 +222,7 @@ void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2(
}
double xPos = 0;
if (_vector[1][X] > 0) {
- xPos = nearest_point(curve_it1->initialPoint(), pwd2_in);
+ xPos = nearest_time(curve_it1->initialPoint(), pwd2_in);
}
if (nodetype == NODE_CUSP) {
result.push_back(Point(xPos, 1));
@@ -234,7 +233,7 @@ void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2(
double xPos = _vector[counter - offset][X];
if (_vector.size() <= (unsigned)(counter - offset)) {
if (_vector[1][X] > 0) {
- xPos = nearest_point(curve_it1->initialPoint(), pwd2_in);
+ xPos = nearest_time(curve_it1->initialPoint(), pwd2_in);
} else {
xPos = 0;
}
@@ -270,6 +269,9 @@ void FilletChamferPointArrayParam::recalculate_knots(
Piecewise<D2<SBasis> > const &pwd2_in)
{
bool change = false;
+ if(_vector.size() == 0){
+ return;
+ }
PathVector pathv = path_from_piecewise(pwd2_in, 0.001);
if (!pathv.empty()) {
std::vector<Point> result;
@@ -354,11 +356,6 @@ void FilletChamferPointArrayParam::set_pwd2(
last_pwd2_normal = pwd2_normal_in;
}
-void FilletChamferPointArrayParam::set_document_unit(Glib::ustring value_document_unit)
-{
- documentUnit = value_document_unit;
-}
-
void FilletChamferPointArrayParam::set_helper_size(int hs)
{
helper_size = hs;
@@ -374,11 +371,6 @@ void FilletChamferPointArrayParam::set_use_distance(bool use_knot_distance )
use_distance = use_knot_distance;
}
-void FilletChamferPointArrayParam::set_unit(const gchar *abbr)
-{
- unit = abbr;
-}
-
void FilletChamferPointArrayParam::updateCanvasIndicators()
{
std::vector<Point> ts = data();
@@ -403,8 +395,8 @@ void FilletChamferPointArrayParam::updateCanvasIndicators()
Geom::Affine aff = Geom::Affine();
aff *= Geom::Scale(helper_size);
aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270));
+ aff *= Geom::Translate(last_pwd2[i].valueAt(Xvalue));
pathv *= aff;
- pathv += last_pwd2[i].valueAt(Xvalue);
hp.push_back(pathv[0]);
hp.push_back(pathv[1]);
i++;
@@ -420,7 +412,7 @@ void FilletChamferPointArrayParam::addCanvasIndicators(
double FilletChamferPointArrayParam::rad_to_len(int index, double rad)
{
double len = 0;
- std::vector<Geom::Path> subpaths = path_from_piecewise(last_pwd2, 0.1);
+ Geom::PathVector subpaths = path_from_piecewise(last_pwd2, 0.1);
std::pair<std::size_t, std::size_t> positions = get_positions(index, subpaths);
D2<SBasis> A = last_pwd2[last_index(index, subpaths)];
if(positions.second != 0){
@@ -438,7 +430,7 @@ double FilletChamferPointArrayParam::rad_to_len(int index, double rad)
Geom::Crossings cs = Geom::crossings(p0, p1);
if(cs.size() > 0){
Point cp =p0(cs[0].ta);
- double p0pt = nearest_point(cp, B);
+ double p0pt = nearest_time(cp, B);
len = time_to_len(index,p0pt);
} else {
if(rad < 0){
@@ -453,7 +445,7 @@ double FilletChamferPointArrayParam::len_to_rad(int index, double len)
double rad = 0;
double tmp_len = _vector[index][X];
_vector[index] = Geom::Point(len,_vector[index][Y]);
- std::vector<Geom::Path> subpaths = path_from_piecewise(last_pwd2, 0.1);
+ Geom::PathVector subpaths = path_from_piecewise(last_pwd2, 0.1);
std::pair<std::size_t, std::size_t> positions = get_positions(index, subpaths);
Piecewise<D2<SBasis> > u;
u.push_cut(0);
@@ -485,14 +477,14 @@ double FilletChamferPointArrayParam::len_to_rad(int index, double len)
if (cubic2) {
ray2.setPoints(endArcPoint, (*cubic2)[1]);
}
- bool ccwToggle = cross(A->finalPoint() - startArcPoint, endArcPoint - startArcPoint) < 0;
+ bool ccwToggle = cross(A->finalPoint() - startArcPoint, endArcPoint - startArcPoint) > 0;
double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint));
double angleBetween = angle_between(ray1, ray2, ccwToggle);
rad = distanceArc/sin(angleBetween/2.0);
return rad * -1;
}
-std::vector<double> FilletChamferPointArrayParam::get_times(int index, std::vector<Geom::Path> subpaths, bool last)
+std::vector<double> FilletChamferPointArrayParam::get_times(int index, Geom::PathVector subpaths, bool last)
{
const double tolerance = 0.001;
const double gapHelper = 0.00001;
@@ -501,12 +493,18 @@ std::vector<double> FilletChamferPointArrayParam::get_times(int index, std::vect
curve_it1 = subpaths[positions.first][positions.second].duplicate();
Coord it1_length = (*curve_it1).length(tolerance);
double time_it1, time_it2, time_it1_B, intpart;
+ if(_vector.size() <= index){
+ std::vector<double> out;
+ out.push_back(0);
+ out.push_back(1);
+ out.push_back(0);
+ return out;
+ }
time_it1 = modf(to_time(index, _vector[index][X]), &intpart);
if (_vector[index][Y] == 0) {
time_it1 = 0;
}
double resultLenght = 0;
- time_it1_B = 1;
if (subpaths[positions.first].closed() && last) {
time_it2 = modf(to_time(index - positions.second , _vector[index - positions.second ][X]), &intpart);
resultLenght = it1_length + to_len(index - positions.second, _vector[index - positions.second ][X]);
@@ -541,7 +539,7 @@ std::vector<double> FilletChamferPointArrayParam::get_times(int index, std::vect
return out;
}
-std::pair<std::size_t, std::size_t> FilletChamferPointArrayParam::get_positions(int index, std::vector<Geom::Path> subpaths)
+std::pair<std::size_t, std::size_t> FilletChamferPointArrayParam::get_positions(int index, Geom::PathVector subpaths)
{
int counter = -1;
std::size_t first = 0;
@@ -583,7 +581,7 @@ std::pair<std::size_t, std::size_t> FilletChamferPointArrayParam::get_positions(
return out;
}
-int FilletChamferPointArrayParam::last_index(int index, std::vector<Geom::Path> subpaths)
+int FilletChamferPointArrayParam::last_index(int index, Geom::PathVector subpaths)
{
int counter = -1;
bool inSubpath = false;
@@ -709,9 +707,9 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_set(Point const &p,
return;
}
Piecewise<D2<SBasis> > const &pwd2 = _pparam->get_pwd2();
- double t = nearest_point(p, pwd2[_index]);
+ double t = nearest_time(p, pwd2[_index]);
Geom::Point const s = snap_knot_position(pwd2[_index].valueAt(t), state);
- t = nearest_point(s, pwd2[_index]);
+ t = nearest_time(s, pwd2[_index]);
if (t == 1) {
t = 0.9999;
}
@@ -803,7 +801,7 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state)
if(xModified < 0 && !_pparam->use_distance){
xModified = _pparam->len_to_rad(_index, _pparam->_vector.at(_index).x());
}
- std::vector<Geom::Path> subpaths = path_from_piecewise(_pparam->last_pwd2, 0.1);
+ Geom::PathVector subpaths = path_from_piecewise(_pparam->last_pwd2, 0.1);
std::pair<std::size_t, std::size_t> positions = _pparam->get_positions(_index, subpaths);
D2<SBasis> A = _pparam->last_pwd2[_pparam->last_index(_index, subpaths)];
if(positions.second != 0){
@@ -813,7 +811,7 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state)
bool aprox = (A[0].degreesOfFreedom() != 2 || B[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false;
Geom::Point offset = Geom::Point(xModified, _pparam->_vector.at(_index).y());
Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog(
- this->desktop, offset, this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit);
+ this->desktop, offset, this, _pparam->use_distance, aprox);
}
}