summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-14 21:06:08 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-14 21:06:08 +0000
commit14b24b5d5cc3a8c72d496bea35e16e8ca47ae458 (patch)
treed44dca5ee6c215a03c81c1c1430a95a60f2d21ec /src/live_effects
parentupdate to trunk (diff)
downloadinkscape-14b24b5d5cc3a8c72d496bea35e16e8ca47ae458.tar.gz
inkscape-14b24b5d5cc3a8c72d496bea35e16e8ca47ae458.zip
commit for refactoring
(bzr r13645.1.42)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp27
-rw-r--r--src/live_effects/lpe-fillet-chamfer.h2
-rw-r--r--src/live_effects/parameter/satellitepairarray.cpp46
-rw-r--r--src/live_effects/parameter/satellitepairarray.h1
4 files changed, 53 insertions, 23 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 36dd599d4..b94e3c429 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -58,7 +58,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
hide_knots(_("Hide knots"), _("Hide knots"), "hide_knots", &wr, this, false),
ignore_radius_0(_("Ignore 0 radius knots"), _("Ignore 0 radius knots"), "ignore_radius_0", &wr, this, false),
helper_size(_("Helper size with direction:"), _("Helper size with direction"), "helper_size", &wr, this, 0),
- pointwise()
+ pointwise(NULL)
{
registerParameter(&satellitepairarrayparam_values);
registerParameter(&unit);
@@ -400,9 +400,8 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
changed = true;
refresh = true;
}
- bool hide = !hide_knots;
- if(it->second.getHidden() != hide){
- it->second.setHidden(hide);
+ if(it->second.getHidden() != hide_knots){
+ it->second.setHidden(hide_knots);
changed = true;
refresh = true;
}
@@ -419,6 +418,17 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
}
}
+void
+LPEFilletChamfer::adjustForNewPath(std::vector<Geom::Path> const &path_in)
+{
+ if (!path_in.empty() && pointwise) {
+ std::cout << pointwise->getSatellites().size() << "sizefirst\n";
+ pointwise->recalculate_for_new_pwd2(pathv_to_linear_and_cubic_beziers(path_in)[0].toPwSb());
+ std::cout << pointwise->getSatellites().size() << "sizesecond\n";
+ satellitepairarrayparam_values.set_pointwise(pointwise);
+ satellitepairarrayparam_values.param_set_and_write_new_value(pointwise->getSatellites());
+ }
+}
std::vector<Geom::Path>
LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
@@ -634,15 +644,6 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
return pathvector_out;
}
-void
-LPEFilletChamfer::adjustForNewPath(std::vector<Geom::Path> const &path_in)
-{
- if (!path_in.empty()) {
- //satellitepairarrayparam_values.recalculate_controlpoints_for_new_pwd2(pathv_to_linear_and_cubic_beziers(path_in)[0].toPwSb());
- }
-}
-
-
}; //namespace LivePathEffect
}; /* namespace Inkscape */
diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h
index 3d22216d4..1bedbefa4 100644
--- a/src/live_effects/lpe-fillet-chamfer.h
+++ b/src/live_effects/lpe-fillet-chamfer.h
@@ -39,7 +39,7 @@ public:
virtual void doOnApply(SPLPEItem const *lpeItem);
virtual void adjustForNewPath(std::vector<Geom::Path> const &path_in);
virtual Gtk::Widget* newWidget();
- /*double len_to_rad(double A, std::pair<int,Geom::Satellite> sat);*/
+ /*double len_to_rad(double A, std::pair<int,Geom::Satellite> sat);*/
void updateSatelliteType(Geom::SatelliteType satellitetype);
void updateChamferSteps();
void updateAmount();
diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp
index 0fc27153f..45f522693 100644
--- a/src/live_effects/parameter/satellitepairarray.cpp
+++ b/src/live_effects/parameter/satellitepairarray.cpp
@@ -52,6 +52,7 @@ void SatellitePairArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
void SatellitePairArrayParam::set_pointwise(Geom::Pointwise *pointwise)
{
last_pointwise = pointwise;
+ std::cout << pointwise->getSatellites().size() << "setted\n";
}
void SatellitePairArrayParam::set_document_unit(Glib::ustring value_document_unit)
@@ -82,7 +83,7 @@ void SatellitePairArrayParam::set_helper_size(int hs)
void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
{
- if( last_pointwise == NULL){
+ if(!last_pointwise){
return;
}
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = last_pointwise->getPwd2();
@@ -90,7 +91,7 @@ void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
hp.clear();
}
for (unsigned int i = 0; i < _vector.size(); ++i) {
- if(!_vector[i].second.getActive() || !_vector[i].second.getHidden()){
+ if(!_vector[i].second.getActive() || _vector[i].second.getHidden()){
continue;
}
if((!_vector[i].second.getHasMirror() && mirror == true) || _vector[i].second.getAmount() == 0){
@@ -188,13 +189,24 @@ void SatellitePairArrayParam::addCanvasIndicators(
hp_vec.push_back(hp);
}
+void SatellitePairArrayParam::recalculate_knots()
+{
+ if(last_pointwise){
+ _vector = last_pointwise->getSatellites();
+ write_to_SVG();
+ }
+}
+
void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
SPItem *item,
bool mirror)
{
+ std::cout << _vector.size() << "recalculated\n";
+ recalculate_knots();
+ std::cout << _vector.size() << "recalculated\n";
for (unsigned int i = 0; i < _vector.size(); ++i) {
- if(!_vector[i].second.getActive() || !_vector[i].second.getHidden()){
+ if(!_vector[i].second.getActive() || _vector[i].second.getHidden()){
continue;
}
if(!_vector[i].second.getHasMirror() && mirror == true){
@@ -262,10 +274,18 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p,
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
- if( _pparam->last_pointwise == NULL){
+ if (!valid_index(index)) {
+ return;
+ }
+
+ if( !_pparam->last_pointwise ){
return;
}
+
std::pair<int,Geom::Satellite> satellite = _pparam->_vector.at(index);
+ if(!satellite.second.getActive() || satellite.second.getHidden()){
+ return;
+ }
Geom::Pointwise* pointwise = _pparam->last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
if(_pparam->_vector.size() <= _index){
@@ -305,12 +325,21 @@ FilletChamferKnotHolderEntity::knot_get() const
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
+ if (!valid_index(index)) {
+ return Point(infinity(), infinity());
+ }
std::pair<int,Geom::Satellite> satellite = _pparam->_vector.at(index);
- if( _pparam->last_pointwise == NULL){
- return Geom::Point(0,0);
+ if(!_pparam->last_pointwise){
+ return Point(infinity(), infinity());
+ }
+ if(!satellite.second.getActive() || satellite.second.getHidden()){
+ return Point(infinity(), infinity());
}
Geom::Pointwise* pointwise = _pparam->last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
+ std::cout << pointwise->getSatellites().size() << "knotGet\n";
+ std::cout << satellite.first << "sindex\n";
+ std::cout << _index << "index\n";
if( _index >= _pparam->_vector.size()){
tmpPoint = satellite.second.getPosition(pwd2[satellite.first]);
boost::optional<Geom::D2<Geom::SBasis> > d2_in = pointwise->getCurveIn(satellite);
@@ -340,10 +369,9 @@ FilletChamferKnotHolderEntity::knot_get() const
return canvas_point;
}
-
void FilletChamferKnotHolderEntity::knot_click(guint state)
{
- if( _pparam->last_pointwise == NULL){
+ if( !_pparam->last_pointwise){
return;
}
@@ -416,7 +444,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
{
- if( _pparam->last_pointwise == NULL){
+ if( !_pparam->last_pointwise){
return;
}
int index = _index;
diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h
index d20339ccb..9b22a386b 100644
--- a/src/live_effects/parameter/satellitepairarray.h
+++ b/src/live_effects/parameter/satellitepairarray.h
@@ -56,6 +56,7 @@ public:
void set_use_distance(bool use_knot_distance );
void set_unit(const gchar *abbr);
void set_effect_type(EffectType et);
+ void recalculate_knots();
virtual void updateCanvasIndicators();
virtual void updateCanvasIndicators(bool mirror);
void set_pointwise(Geom::Pointwise *pointwise);