diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-06 10:22:52 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-06 10:22:52 +0000 |
| commit | 2207d9110e54540a7408642099c9217d8037a6b0 (patch) | |
| tree | ae6cf241ada350845ea86df1507aa23f2e71382c /src | |
| parent | pointwise tweak (diff) | |
| download | inkscape-2207d9110e54540a7408642099c9217d8037a6b0.tar.gz inkscape-2207d9110e54540a7408642099c9217d8037a6b0.zip | |
astyle
(bzr r13645.1.105)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-pointwise.cpp | 30 | ||||
| -rw-r--r-- | src/helper/geom-satellite.cpp | 5 | ||||
| -rw-r--r-- | src/helper/geom-satellite.h | 35 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 50 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitearray.cpp | 24 |
5 files changed, 77 insertions, 67 deletions
diff --git a/src/helper/geom-pointwise.cpp b/src/helper/geom-pointwise.cpp index db66162ca..91281ed7d 100644 --- a/src/helper/geom-pointwise.cpp +++ b/src/helper/geom-pointwise.cpp @@ -57,7 +57,7 @@ void Pointwise::setStart() Geom::PathVector pointwise_pv = path_from_piecewise(Geom::remove_short_cuts(_pwd2,0.01),0.01); int counter = 0; for (Geom::PathVector::const_iterator path_it = pointwise_pv.begin(); - path_it != pointwise_pv.end(); ++path_it) { + path_it != pointwise_pv.end(); ++path_it) { if (path_it->empty()) { continue; } @@ -65,7 +65,7 @@ void Pointwise::setStart() Geom::Path::const_iterator curve_endit = path_it->end_default(); int index = 0; while (curve_it != curve_endit) { - if(index == 0){ + if(index == 0) { if (!path_it->closed()) { _satellites[counter].hidden = true; _satellites[counter].active = false; @@ -108,8 +108,7 @@ void Pointwise::pwd2Subtract(pwd2sb const &A) Geom::PathTime sat_curve_time = sat_path.nearestTime(pointwise_pv.curveAt(i - counter).initialPoint()); Geom::PathTime sat_curve_time_start = sat_path.nearestTime(sat_path.initialPoint()); if (sat_curve_time_start.curve_index < sat_curve_time.curve_index|| - !are_near(pwd2[i].at0(), A[i - counter].at0())) - { + !are_near(pwd2[i].at0(), A[i - counter].at0())) { counter++; } else { sats.push_back(_satellites[i - counter]); @@ -130,14 +129,14 @@ void Pointwise::pwd2Append(pwd2sb const &A, Satellite const &S) Geom::Path sat_path = pointwise_pv.pathAt(i - counter); boost::optional< Geom::PathVectorTime > sat_curve_time_optional = pointwise_pv.nearestTime(pointwise_pv.curveAt(i-counter).initialPoint()); Geom::PathVectorTime sat_curve_time; - if(sat_curve_time_optional){ + if(sat_curve_time_optional) { sat_curve_time = *sat_curve_time_optional; } sat_curve_time.normalizeForward(sat_path.size()); size_t first = Geom::nearest_time(sat_path.initialPoint(),_pwd2); size_t last = first + sat_path.size() - 1; bool is_start = false; - if(sat_curve_time.curve_index == 0){ + if(sat_curve_time.curve_index == 0) { is_start = true; } //Check for subpath closed. If a subpath is closed, is not reversed or moved @@ -146,7 +145,7 @@ void Pointwise::pwd2Append(pwd2sb const &A, Satellite const &S) pointwise_pv = path_from_piecewise(Geom::remove_short_cuts(A,0.01),0.01); sat_path = pointwise_pv.pathAt(i); sat_curve_time_optional = pointwise_pv.nearestTime(pointwise_pv.curveAt(i).initialPoint()); - if(sat_curve_time_optional){ + if(sat_curve_time_optional) { sat_curve_time = *sat_curve_time_optional; } sat_curve_time.normalizeForward(sat_path.size()); @@ -168,7 +167,7 @@ void Pointwise::pwd2Append(pwd2sb const &A, Satellite const &S) subpathReverse(first, last); } - if (_pwd2.size() <= i - counter || !are_near(_pwd2[i - counter].at0(), A[i].at0())){ + if (_pwd2.size() <= i - counter || !are_near(_pwd2[i - counter].at0(), A[i].at0())) { counter++; sats.push_back(S); } else { @@ -188,8 +187,7 @@ void Pointwise::subpathToBack(size_t subpath) Geom::PathVector tmp_path; Geom::Path to_back; for (Geom::PathVector::const_iterator path_it = path_in.begin(); - path_it != path_in.end(); ++path_it) - { + path_it != path_in.end(); ++path_it) { if (path_it->empty()) { continue; } @@ -233,7 +231,7 @@ void Pointwise::subpathReverse(size_t start, size_t end) Geom::Path sat_path = path_in.pathAt(start); boost::optional< Geom::PathVectorTime > sat_curve_time_optional = path_in.nearestTime(path_in.curveAt(start).initialPoint()); Geom::PathVectorTime sat_curve_time; - if(sat_curve_time_optional){ + if(sat_curve_time_optional) { sat_curve_time = *sat_curve_time_optional; } sat_curve_time.normalizeForward(sat_path.size()); @@ -241,8 +239,7 @@ void Pointwise::subpathReverse(size_t start, size_t end) Geom::PathVector tmp_path; Geom::Path rev; for (Geom::PathVector::const_iterator path_it = path_in.begin(); - path_it != path_in.end(); ++path_it) - { + path_it != path_in.end(); ++path_it) { if (path_it->empty()) { continue; } @@ -264,14 +261,13 @@ void Pointwise::insertDegenerateSatellites(pwd2sb const &A, Geom::PathVector con size_t size_A = A.size(); size_t size_B = B.curveCount(); size_t satellite_gap = size_B - size_A; - if (satellite_gap == 0){ + if (satellite_gap == 0) { return; } size_t counter = 0; size_t counter_added = 0; for (Geom::PathVector::const_iterator path_it = B.begin(); - path_it != B.end(); ++path_it) - { + path_it != B.end(); ++path_it) { if (path_it->empty()) { continue; } @@ -284,7 +280,7 @@ void Pointwise::insertDegenerateSatellites(pwd2sb const &A, Geom::PathVector con } } while (curve_it1 != curve_endit) { - if ((*curve_it1).isDegenerate() && counter_added < satellite_gap){ + if ((*curve_it1).isDegenerate() && counter_added < satellite_gap) { counter_added++; _satellites.insert(_satellites.begin() + counter + 1 ,S); } diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp index f5f28544d..ddef7685a 100644 --- a/src/helper/geom-satellite.cpp +++ b/src/helper/geom-satellite.cpp @@ -230,9 +230,8 @@ 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()) - { - satellite_type = it->second; + if(it != gchar_map_to_satellite_type.end()) { + satellite_type = it->second; } } diff --git a/src/helper/geom-satellite.h b/src/helper/geom-satellite.h index 42c5687bd..ef76060c4 100644 --- a/src/helper/geom-satellite.h +++ b/src/helper/geom-satellite.h @@ -36,13 +36,34 @@ public: Satellite(SatelliteType satellite_type); virtual ~Satellite(); - void setIsTime(bool set_is_time){is_time = set_is_time;} - void setActive(bool set_active){active = set_active;} - void setHasMirror(bool set_has_mirror){has_mirror = set_has_mirror;} - void setHidden(bool set_hidden){hidden = set_hidden;} - void setAmount(bool set_amount){amount = set_amount;} - void setAngle(bool set_angle){angle = set_angle;} - void setSteps(bool set_steps){steps = set_steps;} + void setIsTime(bool set_is_time) + { + is_time = set_is_time; + } + void setActive(bool set_active) + { + active = set_active; + } + void setHasMirror(bool set_has_mirror) + { + has_mirror = set_has_mirror; + } + void setHidden(bool set_hidden) + { + hidden = set_hidden; + } + void setAmount(bool set_amount) + { + amount = set_amount; + } + void setAngle(bool set_angle) + { + angle = set_angle; + } + void setSteps(bool set_steps) + { + steps = set_steps; + } double lenToRad(double A, Geom::D2<Geom::SBasis> d2_in, Geom::D2<Geom::SBasis> d2_out, Satellite previousSatellite) const; diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 7871ccc1e..8998279a6 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -32,7 +32,7 @@ static const Util::EnumDataConverter<FilletMethod> FMConverter(FilletMethodData, LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : Effect(lpeobject), satellites_param(_("pair_array_param"), _("pair_array_param"), - "satellites_param", &wr, this), + "satellites_param", &wr, this), 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, @@ -264,13 +264,11 @@ void LPEFilletChamfer::updateAmount() std::vector<Satellite> satellites = pointwise->getSatellites(); Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); for (std::vector<Satellite>::iterator it = satellites.begin(); - it != satellites.end(); ++it) - { + it != satellites.end(); ++it) { Geom::Path sat_path = pathvector_before_effect.pathAt(it - satellites.begin()); size_t sat_curve_time = Geom::nearest_time(pathvector_before_effect.curveAt(it - satellites.begin()).initialPoint() , pwd2); size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2); - if (!sat_path.closed() && sat_curve_time == first) - { + if (!sat_path.closed() && sat_curve_time == first) { it->amount = 0; continue; } @@ -278,19 +276,19 @@ void LPEFilletChamfer::updateAmount() continue; } boost::optional<size_t> previous = boost::none; - if (sat_path.closed() && sat_curve_time == first){ + if (sat_path.closed() && sat_curve_time == first) { sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2); previous = sat_curve_time + sat_path.size() - 1; - } else if(!sat_path.closed() || sat_curve_time != first){ + } else if(!sat_path.closed() || sat_curve_time != first) { previous = sat_curve_time - 1; } if (only_selected) { Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin()); if (isNodePointSelected(satellite_point)) { if (!use_knot_distance && !flexible) { - if(previous){ + if(previous) { it->amount = it->radToLen(power, pwd2[*previous], - pwd2[it - satellites.begin()]); + pwd2[it - satellites.begin()]); } else { it->amount = 0.0; } @@ -300,12 +298,12 @@ void LPEFilletChamfer::updateAmount() } } else { if (!use_knot_distance && !flexible) { - if(previous){ + if(previous) { it->amount = it->radToLen(power, pwd2[*previous], - pwd2[it - satellites.begin()]); - } else { - it->amount = 0.0; - } + pwd2[it - satellites.begin()]); + } else { + it->amount = 0.0; + } } else { it->amount = power; } @@ -361,7 +359,7 @@ void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype) void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) { - if(!_hp.empty()){ + if(!_hp.empty()) { _hp.clear(); } SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem); @@ -382,7 +380,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) 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()){ + if(sats.empty()) { doOnApply(lpeItem); sats = satellites_param.data(); } @@ -413,7 +411,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) } size_t number_curves = original_pathv.curveCount(); //if are diferent sizes call to poinwise recalculate - //todo: fire a reverse satellites on reverse path. Maybe a new method + //todo: fire a reverse satellites on reverse path. Maybe a new method //like "are_similar" to avoid precission issues on reverse a pointwise //and after convert to Pathvector if (pointwise && number_curves != sats.size()) { @@ -609,7 +607,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) 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; if (times[1] != 1) { @@ -628,8 +626,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) 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<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, end_arc_point); @@ -648,8 +645,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) 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) { path_chamfer.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, end_arc_point); } else { @@ -666,10 +662,9 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) } 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) { tmp_path.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, - end_arc_point); + end_arc_point); } else { tmp_path.appendNew<Geom::CubicBezier>(inverse_handle_1, inverse_handle_2, end_arc_point); @@ -677,11 +672,10 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) } else if (type == 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<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, - end_arc_point); + end_arc_point); } else { tmp_path.appendNew<Geom::CubicBezier>(handle_1, handle_2, end_arc_point); diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp index b7d403a91..5e45ddf0d 100644 --- a/src/live_effects/parameter/satellitearray.cpp +++ b/src/live_effects/parameter/satellitearray.cpp @@ -94,15 +94,15 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror) double size_out = _vector[i].arcDistance(pwd2[i]); double lenght_out = Geom::length(pwd2[i], Geom::EPSILON); double lenght_in = 0; - + Geom::Path sat_path = pointwise_pv.pathAt(i); boost::optional<size_t> d2_prev_index = boost::none; size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(i).initialPoint() , pwd2); size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2); - if (sat_path.closed() && sat_curve_time == first){ + if (sat_path.closed() && sat_curve_time == first) { sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2); d2_prev_index = sat_curve_time + sat_path.size() - 1; - } else if(!sat_path.closed() || sat_curve_time != first){ + } else if(!sat_path.closed() || sat_curve_time != first) { d2_prev_index = sat_curve_time - 1; } if (d2_prev_index) { @@ -298,10 +298,10 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, boost::optional<size_t> d2_prev_index = boost::none; size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2); size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2); - if (sat_path.closed() && sat_curve_time == first){ + if (sat_path.closed() && sat_curve_time == first) { sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2); d2_prev_index = sat_curve_time + sat_path.size() - 1; - } else if(!sat_path.closed() || sat_curve_time != first){ + } else if(!sat_path.closed() || sat_curve_time != first) { d2_prev_index = sat_curve_time - 1; } if (d2_prev_index) { @@ -360,10 +360,10 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const boost::optional<size_t> d2_prev_index = boost::none; size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2); size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2); - if (sat_path.closed() && sat_curve_time == first){ + if (sat_path.closed() && sat_curve_time == first) { sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2); d2_prev_index = sat_curve_time + sat_path.size() - 1; - } else if(!sat_path.closed() || sat_curve_time != first){ + } else if(!sat_path.closed() || sat_curve_time != first) { d2_prev_index = sat_curve_time - 1; } if (d2_prev_index) { @@ -454,13 +454,13 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) boost::optional<size_t> d2_prev_index = boost::none; size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2); size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2); - if (sat_path.closed() && sat_curve_time == first){ + if (sat_path.closed() && sat_curve_time == first) { sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2); d2_prev_index = sat_curve_time + sat_path.size() - 1; - } else if(!sat_path.closed() || sat_curve_time != first){ + } else if(!sat_path.closed() || sat_curve_time != first) { d2_prev_index = sat_curve_time - 1; } - + if (!_pparam->_use_distance && !_pparam->_vector.at(index).is_time) { if (d2_prev_index) { amount = _pparam->_vector.at(index).lenToRad(amount, pwd2[*d2_prev_index], pwd2[index],_pparam->_vector.at(*d2_prev_index)); @@ -504,10 +504,10 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) boost::optional<size_t> prev = boost::none; size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2); size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2); - if (sat_path.closed() && sat_curve_time == first){ + if (sat_path.closed() && sat_curve_time == first) { sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2); prev = sat_curve_time + sat_path.size() - 1; - } else if(!sat_path.closed() || sat_curve_time != first){ + } else if(!sat_path.closed() || sat_curve_time != first) { prev = sat_curve_time - 1; } if (prev) { |
