diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-06-19 01:30:10 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-06-19 01:30:10 +0000 |
| commit | 417ba16c9f42a5476045ca4f1825fff2fed518ba (patch) | |
| tree | 3d3c9620ebb4b6dc6998550b353cf1825cf2f973 /src | |
| parent | Fixes when moves a path (diff) | |
| download | inkscape-417ba16c9f42a5476045ca4f1825fff2fed518ba.tar.gz inkscape-417ba16c9f42a5476045ca4f1825fff2fed518ba.zip | |
Organize doeffect function
(bzr r13645.1.164)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-pathvectorsatellites.cpp | 8 | ||||
| -rw-r--r-- | src/helper/geom-satellite.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 87 | ||||
| -rw-r--r-- | src/live_effects/parameter/array.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitesarray.cpp | 26 | ||||
| -rw-r--r-- | src/ui/dialog/lpe-fillet-chamfer-properties.cpp | 6 |
6 files changed, 61 insertions, 70 deletions
diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp index f72841b30..eca866978 100644 --- a/src/helper/geom-pathvectorsatellites.cpp +++ b/src/helper/geom-pathvectorsatellites.cpp @@ -65,7 +65,7 @@ void PathVectorSatellites::setSelected(std::vector<size_t> selected) size_t counter = 0; for (size_t i = 0; i < _satellites.size(); ++i) { for (size_t j = 0; j < _satellites[i].size(); ++j) { - if(find (selected.begin(), selected.end(), counter) != selected.end()){ + if (find (selected.begin(), selected.end(), counter) != selected.end()) { _satellites[i][j].setSelected(true); } else { _satellites[i][j].setSelected(false); @@ -107,9 +107,9 @@ void PathVectorSatellites::updateAmount(double radius, bool apply_no_radius, boo for (size_t i = 0; i < _satellites.size(); ++i) { for (size_t j = 0; j < _satellites[i].size(); ++j) { boost::optional<size_t> previous_index = boost::none; - if(j == 0 && _pathvector[i].closed()){ + if (j == 0 && _pathvector[i].closed()) { previous_index = _pathvector[i].size() - 1; - } else if(!_pathvector[i].closed() || j != 0) { + } else if (!_pathvector[i].closed() || j != 0) { previous_index = j - 1; } if (!_pathvector[i].closed() && j == 0) { @@ -128,7 +128,7 @@ void PathVectorSatellites::updateAmount(double radius, bool apply_no_radius, boo Geom::Point satellite_point = _pathvector[i].pointAt(j); if (_satellites[i][j].selected || !only_selected) { if (!use_knot_distance && !flexible) { - if(previous_index) { + if (previous_index) { _satellites[i][j].amount = _satellites[i][j].radToLen(power, _pathvector[i][*previous_index], _pathvector[i][j]); } else { _satellites[i][j].amount = 0.0; diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp index 1242c9aaf..8a92273d0 100644 --- a/src/helper/geom-satellite.cpp +++ b/src/helper/geom-satellite.cpp @@ -218,7 +218,7 @@ void Satellite::setSatelliteType(gchar const *A) std::map<std::string, SatelliteType> gchar_map_to_satellite_type = boost::assign::map_list_of("F", FILLET)("IF", INVERSE_FILLET)("C", CHAMFER)("IC", INVERSE_CHAMFER)("KO", INVALID_SATELLITE); std::map<std::string, SatelliteType>::iterator it = gchar_map_to_satellite_type.find(std::string(A)); - if(it != gchar_map_to_satellite_type.end()) { + if (it != gchar_map_to_satellite_type.end()) { satellite_type = it->second; } } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 47b91bf03..268e08921 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -259,7 +259,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) //if are diferent sizes call to poinwise recalculate //TODO: Update the satellite data in paths modified, Goal 0.93 Satellites satellites = _satellites_param.data(); - if(satellites.empty()) { + if (satellites.empty()) { doOnApply(lpeItem); satellites = _satellites_param.data(); } @@ -290,7 +290,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) if (satellites[i][j].is_time != _flexible) { satellites[i][j].is_time = _flexible; double amount = satellites[i][j].amount; - if (pathv[i].size() == j){ + if (pathv[i].size() == j) { continue; } Geom::Curve const &curve_in = pathv[i][j]; @@ -367,6 +367,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) if (curve == pathv[path].size() - 1 && pathv[path].closed()) { next_index = 0; } + //append last extreme of paths on open paths if (curve == pathv[path].size() -1 && !pathv[path].closed()) { //the path is open and we are at end of path if (time0 != 1) { //Previous satellite not at 100% amount Geom::Curve *last_curve = curve_it1->portion(time0, 1); @@ -389,7 +390,6 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) time0 = satellites[path][0].time(*curve_it1); } } - bool last = pathv[path].size() - 1 == curve; double s = satellite.arcDistance(curve_it2); double time1 = satellite.time(s, true, (*curve_it1)); double time2 = satellite.time(curve_it2); @@ -399,70 +399,61 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) if (time2 > 1) { time2 = 1; } - std::vector<double> times; - times.push_back(time0); - times.push_back(time1); - times.push_back(time2); - Geom::Curve *knot_curve_1 = curve_it1->portion(times[0], times[1]); - Geom::Curve *knot_curve_2 = curve_it2.portion(times[2], 1); + Geom::Curve *knot_curve_1 = curve_it1->portion(time0, time1); + Geom::Curve *knot_curve_2 = curve_it2.portion(time2, 1); if (curve > 0) { knot_curve_1->setInitial(tmp_path.finalPoint()); } else { - tmp_path.start((*curve_it1).pointAt(times[0])); + tmp_path.start((*curve_it1).pointAt(time0)); } Geom::Point start_arc_point = knot_curve_1->finalPoint(); - Geom::Point end_arc_point = curve_it2.pointAt(times[2]); - if (times[2] == 1) { - end_arc_point = curve_it2.pointAt(times[2] - GAP_HELPER); + Geom::Point end_arc_point = curve_it2.pointAt(time2); + //add a gap helper + if (time2 == 1) { + end_arc_point = curve_it2.pointAt(time2 - GAP_HELPER); } - if (times[1] == times[0]) { - start_arc_point = curve_it1->pointAt(times[0] + GAP_HELPER); + if (time1 == time0) { + start_arc_point = curve_it1->pointAt(time1 + GAP_HELPER); } + double k1 = distance(start_arc_point, curve_it1->finalPoint()) * K; - double k2 = distance(end_arc_point, curve_it2.initialPoint()) * K; - Geom::CubicBezier const *cubic_1 = - dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_1); + double k2 = distance(curve_it2.initialPoint(), end_arc_point) * K; + Geom::CubicBezier const *cubic_1 = dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_1); + Geom::CubicBezier const *cubic_2 = dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_2); Geom::Ray ray_1(start_arc_point, curve_it1->finalPoint()); + Geom::Ray ray_2(curve_it2.initialPoint(), end_arc_point); if (cubic_1) { ray_1.setPoints((*cubic_1)[2], 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; - } - Geom::CubicBezier const *cubic_2 = - dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_2); - Geom::Ray ray_2(curve_it2.initialPoint(), end_arc_point); if (cubic_2) { ray_2.setPoints(end_arc_point, (*cubic_2)[1]); } - 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; + bool ccw_toggle = cross(curve_it1->finalPoint() - start_arc_point, end_arc_point - start_arc_point) < 0; double angle = angle_between(ray_1, ray_2, ccw_toggle); - double handleAngle = ray_1.angle() - angle; + double handle_angle_1 = ray_1.angle() - angle; + double handle_angle_2 = ray_2.angle() + angle; if (ccw_toggle) { - handleAngle = ray_1.angle() + angle; + handle_angle_1 = ray_1.angle() + angle; + handle_angle_2 = ray_2.angle() - angle; } - Geom::Point inverse_handle_1 = Geom::Point::polar(handleAngle, k1) + start_arc_point; + Geom::Point handle_1 = Geom::Point::polar(ray_1.angle(), k1) + start_arc_point; + Geom::Point handle_2 = end_arc_point - Geom::Point::polar(ray_2.angle(), k2); + Geom::Point inverse_handle_1 = Geom::Point::polar(handle_angle_1, k1) + start_arc_point; + Geom::Point inverse_handle_2 = end_arc_point - Geom::Point::polar(handle_angle_2, k2); if (time0 == 1) { + handle_1 = start_arc_point; inverse_handle_1 = start_arc_point; } - handleAngle = ray_2.angle() + angle; - if (ccw_toggle) { - handleAngle = ray_2.angle() - angle; - } - Geom::Point inverse_handle_2 = end_arc_point - Geom::Point::polar(handleAngle, k2); - if (times[2] == 1) { - end_arc_point = curve_it2.pointAt(times[2]); + //remove gap helper + if (time2 == 1) { + end_arc_point = curve_it2.pointAt(time2); } - if (times[1] == times[0]) { - start_arc_point = curve_it1->pointAt(times[0]); + if (time1 == time0) { + start_arc_point = curve_it1->pointAt(time0); } - if (times[1] != 1) { - if (times[1] != times[0] || (times[1] == 1 && times[0] == 1)) { + if (time1 != 1) { + if (time1 != time0 || (time1 == 1 && time0 == 1)) { if (!knot_curve_1->isDegenerate()) { tmp_path.append(*knot_curve_1); } @@ -474,7 +465,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) 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); + sin(angle / 2.0); Geom::Coord rx = radius; Geom::Coord ry = rx; bool eliptical = (is_straight_curve(*curve_it1) && @@ -531,11 +522,11 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) tmp_path.append(*knot_curve_1); } } - if (path_it->closed() && last) { - tmp_path.close(); - } curve++; - time0 = times[2]; + time0 = time2; + } + if (path_it->closed()) { + tmp_path.close(); } path++; path_out.push_back(tmp_path); diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp index 28867def2..7470f54cd 100644 --- a/src/live_effects/parameter/array.cpp +++ b/src/live_effects/parameter/array.cpp @@ -59,7 +59,7 @@ ArrayParam<std::vector<Satellite > >::readsvg(const gchar * str) gchar ** iter = strarray; while (*iter != NULL) { gchar ** strsubarray = g_strsplit(*iter, ",", 8); - if(*strsubarray[7]){//steps always > 0 + if (*strsubarray[7]) {//steps always > 0 Satellite *satellite = new Satellite(); satellite->setSatelliteType(g_strstrip(strsubarray[0])); satellite->is_time = strncmp(strsubarray[1],"1",1) == 0; diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index d4182d459..4705fd821 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -85,7 +85,7 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) return; } - if(!_hp.empty()) { + if (!_hp.empty()) { _hp.clear(); } Geom::PathVector pathv = _last_pathvector_satellites->getPathVector(); @@ -112,10 +112,10 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) double size_out = _vector[i][j].arcDistance(*curve_in); double lenght_out = curve_in->length(); gint previous_index = j - 1; //Always are previous index because we skip first satellite on open paths - if(j == 0 && pathv[i].closed()){ + if (j == 0 && pathv[i].closed()) { previous_index = pathv[i].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } double lenght_in = pathv.curveAt(previous_index).length(); @@ -188,7 +188,7 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) } } } - if(!_knot_reset_helper.empty()){ + if (!_knot_reset_helper.empty()) { _hp.insert(_hp.end(), _knot_reset_helper.begin(), _knot_reset_helper.end() ); } if (mirror) { @@ -314,10 +314,10 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, return; } gint previous_index = curve_index - 1; - if(curve_index == 0 && pathv[path_index].closed()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } Geom::Curve const &curve_in = pathv[path_index][previous_index]; @@ -346,7 +346,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, satellite.setPosition(s, pathv[path_index][curve_index]); } _pparam->_knot_reset_helper.clear(); - if (satellite.amount == 0){ + if (satellite.amount == 0) { char const *svgd; svgd = "M -5.39,8.78 -9.13,5.29 -10.38,10.28 Z M -7.22,7.07 -3.43,3.37 m -1.95,-12.16 -3.74,3.5 -1.26,-5 z " "m -1.83,1.71 3.78,3.7 M 5.24,8.78 8.98,5.29 10.24,10.28 Z " @@ -388,10 +388,10 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const this->knot->show(); if (is_mirror) { gint previous_index = curve_index - 1; - if(curve_index == 0 && pathv[path_index].closed()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return Geom::Point(Geom::infinity(), Geom::infinity()); } Geom::Curve const &curve_in = pathv[path_index][previous_index]; @@ -490,10 +490,10 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } else if (state & GDK_SHIFT_MASK) { double amount = _pparam->_vector[path_index][curve_index].amount; gint previous_index = curve_index - 1; - if(curve_index == 0 && pathv[path_index].closed()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } if (!_pparam->_use_distance && !_pparam->_vector[path_index][curve_index].is_time) { @@ -543,10 +543,10 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) double max_amount = amount; if (!_pparam->_use_distance && !satellite.is_time) { gint previous_index = curve_index - 1; - if(curve_index == 0 && pathv[path_index].closed()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } amount = _pparam->_vector[path_index][curve_index].radToLen(amount, pathv[path_index][previous_index], pathv[path_index][curve_index]); diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index 098a84edf..98b654640 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -167,7 +167,7 @@ void FilletChamferPropertiesDialog::_apply() } _satellite.amount = d_pos; size_t steps = (size_t)_fillet_chamfer_chamfer_subdivisions.get_value(); - if(steps < 1) { + if (steps < 1) { steps = 1; } _satellite.steps = steps; @@ -204,10 +204,10 @@ void FilletChamferPropertiesDialog::_setSatellite(Satellite satellite) { double position; std::string distance_or_radius = std::string(_("Radius")); - if(_aprox) { + if (_aprox) { distance_or_radius = std::string(_("Radius approximated")); } - if(_use_distance) { + if (_use_distance) { distance_or_radius = std::string(_("Knot distance")); } if (satellite.is_time) { |
