diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-03-04 22:42:59 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-03-04 22:42:59 +0000 |
| commit | 1db09cce6114c1b2d95ac77b00672caad0447b29 (patch) | |
| tree | 8aa92d59737bc340b63bd73c368f856da0a46a51 /src/live_effects/parameter | |
| parent | update to trunk (diff) | |
| download | inkscape-1db09cce6114c1b2d95ac77b00672caad0447b29.tar.gz inkscape-1db09cce6114c1b2d95ac77b00672caad0447b29.zip | |
All features done, only need piecewise update function
(bzr r13645.1.33)
Diffstat (limited to 'src/live_effects/parameter')
| -rw-r--r-- | src/live_effects/parameter/array.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/parameter/array.h | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitepairarray.cpp | 161 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitepairarray.h | 12 |
4 files changed, 168 insertions, 21 deletions
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp index c00cdd8da..e4c480d93 100644 --- a/src/live_effects/parameter/array.cpp +++ b/src/live_effects/parameter/array.cpp @@ -54,7 +54,7 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){ return 0; } gchar ** strarray = g_strsplit(str, "*", 0); - if(strarray[8] && !strarray[9]){ + if(strarray[9] && !strarray[10]){ sat->setSatelliteType(strarray[0]); sat->setIsTime(strncmp(strarray[1],"1",1) == 0); sat->setIsClosing(strncmp(strarray[2],"1",1) == 0); @@ -63,10 +63,14 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){ sat->setHasMirror(strncmp(strarray[5],"1",1) == 0); sat->setHidden(strncmp(strarray[6],"1",1) == 0); double ammount,angle; + float stepsTmp; sp_svg_number_read_d(strarray[7], &ammount); sp_svg_number_read_d(strarray[8], &angle); + sp_svg_number_read_f(strarray[9], &stepsTmp); + unsigned int steps = (unsigned int)stepsTmp; sat->setAmmount(ammount); sat->setAngle(angle); + sat->setSteps(steps); g_strfreev (strarray); return 1; } @@ -75,12 +79,12 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){ } template <> -std::pair<int, Geom::Satellite> -ArrayParam<std::pair<int, Geom::Satellite> >::readsvg(const gchar * str) +std::pair<unsigned int, Geom::Satellite> +ArrayParam<std::pair<unsigned int, Geom::Satellite> >::readsvg(const gchar * str) { gchar ** strarray = g_strsplit(str, ",", 2); double index; - std::pair<int, Geom::Satellite> result; + std::pair<unsigned int, Geom::Satellite> result; unsigned int success = (int)sp_svg_number_read_d(strarray[0], &index); Geom::Satellite sat; success += sp_svg_satellite_read_d(strarray[1], &sat); diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index 0be155f50..d28576fce 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -112,7 +112,7 @@ protected: str << nVector; } - void writesvgData(SVGOStringStream &str, std::pair<int, Geom::Satellite> const &nVector) const { + void writesvgData(SVGOStringStream &str, std::pair<unsigned int, Geom::Satellite> const &nVector) const { str << nVector.first; str << ","; str << nVector.second.getSatelliteTypeGchar(); @@ -132,6 +132,8 @@ protected: str << nVector.second.getAmmount(); str << "*"; str << nVector.second.getAngle(); + str << "*"; + str << nVector.second.getSteps(); } StorageType readsvg(const gchar * str); diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp index 72a666dc2..ffd04e14c 100644 --- a/src/live_effects/parameter/satellitepairarray.cpp +++ b/src/live_effects/parameter/satellitepairarray.cpp @@ -9,6 +9,7 @@ */ #include "knotholder.h" +#include "ui/dialog/lpe-fillet-chamfer-properties.h" #include "live_effects/parameter/satellitepairarray.h" #include "sp-lpe-item.h" // TODO due to internal breakage in glibmm headers, @@ -26,18 +27,14 @@ SatellitePairArrayParam::SatellitePairArrayParam( const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, Effect *effect) - : ArrayParam<std::pair<int,Geom::Satellite> >(label, tip, key, wr, effect, 0) + : ArrayParam<std::pair<unsigned int,Geom::Satellite> >(label, tip, key, wr, effect, 0) { knot_shape = SP_KNOT_SHAPE_DIAMOND; knot_mode = SP_KNOT_MODE_XOR; knot_color = 0x00ff0000; - /* - std::vector<std::pair<int,Geom::Satellite> > satellites; - Geom::Path path; - path.start(Geom::Point(0,0)); - path.appendNew<Geom::LineSegment>(Geom::Point(0,1)); - last_pointwise = new Pointwise(path.toPwSb(),satellites); - */ + helper_size = 0; + use_distance = false; + last_pointwise = NULL; } @@ -57,6 +54,21 @@ void SatellitePairArrayParam::set_pointwise(Geom::Pointwise *pointwise) last_pointwise = pointwise; } +void SatellitePairArrayParam::set_document_unit(Glib::ustring const * value_document_unit) +{ + documentUnit = value_document_unit; +} + +void SatellitePairArrayParam::set_use_distance(bool use_knot_distance ) +{ + use_distance = use_knot_distance; +} + +void SatellitePairArrayParam::set_unit(const gchar *abbr) +{ + unit = abbr; +} + void SatellitePairArrayParam::set_helper_size(int hs) { helper_size = hs; @@ -73,7 +85,7 @@ void SatellitePairArrayParam::updateCanvasIndicators() continue; } double pos = 0; - if(pwd2.size() <= _vector[i].first){ + if(pwd2.size() <= (unsigned)_vector[i].first){ break; } Geom::D2<Geom::SBasis> d2 = pwd2[_vector[i].first]; @@ -136,10 +148,26 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder, if(_vector[i].second.getHasMirror()){ addKnotHolderEntitieMirrored(knotholder, desktop, item, i); } + using namespace Geom; + SatelliteType type = _vector[i].second.getSatelliteType(); const gchar *tip; - tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, " - "<b>Shift+Click</b> open dialog, " - "<b>Ctrl+Alt+Click</b> reset"); + if (type == C){ + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == IC) { + tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == IF) { + tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else { + tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } SatellitePairArrayParamKnotHolderEntity *e = new SatellitePairArrayParamKnotHolderEntity(this, i); e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), @@ -152,8 +180,26 @@ void SatellitePairArrayParam::addKnotHolderEntitieMirrored(KnotHolder *knotholde SPDesktop *desktop, SPItem *item, int i) { + using namespace Geom; + SatelliteType type = _vector[i].second.getSatelliteType(); const gchar *tip; - tip = _("<b>Mirror</b> ppp"); + if (type == C){ + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == IC) { + tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == IF) { + tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else { + tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } SatellitePairArrayParamKnotHolderEntity *e = new SatellitePairArrayParamKnotHolderEntity(this, i + _vector.size()); e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), @@ -257,6 +303,95 @@ SatellitePairArrayParamKnotHolderEntity::knot_get() const } +void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state) +{ + int index = _index; + if( _index >= _pparam->_vector.size()){ + index = _index-_pparam->_vector.size(); + } + if (state & GDK_CONTROL_MASK) { + if (state & GDK_MOD1_MASK) { + _pparam->_vector.at(index).second.setAmmount(0.0); + _pparam->param_set_and_write_new_value(_pparam->_vector); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + }else{ + using namespace Geom; + SatelliteType type = _pparam->_vector.at(index).second.getSatelliteType(); + switch(type){ + case F: + type = IF; + break; + case IF: + type = C; + break; + case C: + type = IC; + break; + default: + type = F; + break; + } + _pparam->_vector.at(index).second.setSatelliteType(type); + _pparam->param_set_and_write_new_value(_pparam->_vector); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + const gchar *tip; + if (type == C){ + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == IC) { + tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == IF) { + tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else { + tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } + this->knot->tip = g_strdup(tip); + this->knot->show(); + } + } else if (state & GDK_SHIFT_MASK) { + double ammount = _pparam->_vector.at(index).second.getAmmount(); + if(!_pparam->use_distance && !_pparam->_vector.at(index).second.getIsTime()){ + ammount = _pparam->last_pointwise->len_to_rad(ammount, _pparam->_vector.at(index)); + } + boost::optional<Geom::D2<Geom::SBasis> > d2_in = _pparam->last_pointwise->getCurveIn(_pparam->_vector.at(index)); + bool aprox = false; + D2<SBasis> d2_out = _pparam->last_pointwise->getPwd2()[index]; + if(d2_in){ + aprox = ((*d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false; + } + Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( + this->desktop, ammount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index).second); + + } +} + +void SatellitePairArrayParamKnotHolderEntity::knot_set_offset(Geom::Satellite satellite) +{ + int index = _index; + if( _index >= _pparam->_vector.size()){ + index = _index-_pparam->_vector.size(); + } + double ammount = satellite.getAmmount(); + if(!_pparam->use_distance && !satellite.getIsTime()){ + ammount = _pparam->last_pointwise->rad_to_len(ammount, _pparam->_vector.at(index)); + } + satellite.setAmmount(ammount); + _pparam->_vector.at(index).second = satellite; + this->parent_holder->knot_ungrabbed_handler(this->knot, 0); + _pparam->param_set_and_write_new_value(_pparam->_vector); + SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item); + if(splpeitem){ + sp_lpe_item_update_patheffect(splpeitem, false, false); + } +} + } /* namespace LivePathEffect */ } /* namespace Inkscape */ diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h index 1ecc1fee6..21fb0fbd8 100644 --- a/src/live_effects/parameter/satellitepairarray.h +++ b/src/live_effects/parameter/satellitepairarray.h @@ -29,7 +29,7 @@ namespace LivePathEffect { class SatellitePairArrayParamKnotHolderEntity; -class SatellitePairArrayParam : public ArrayParam<std::pair<int, Geom::Satellite> > { +class SatellitePairArrayParam : public ArrayParam<std::pair<unsigned int, Geom::Satellite> > { public: SatellitePairArrayParam(const Glib::ustring &label, const Glib::ustring &tip, @@ -51,6 +51,9 @@ public: virtual bool providesKnotHolderEntities() const { return true; } + void set_document_unit(Glib::ustring const * value_document_unit); + void set_use_distance(bool use_knot_distance ); + void set_unit(const gchar *abbr); virtual void updateCanvasIndicators(); void set_pointwise(Geom::Pointwise *pointwise); friend class SatellitePairArrayParamKnotHolderEntity; @@ -64,7 +67,9 @@ private: guint32 knot_color; Geom::PathVector hp; int helper_size; - + bool use_distance; + const gchar *unit; + Glib::ustring const * documentUnit; Geom::Pointwise *last_pointwise; }; @@ -76,7 +81,8 @@ public: virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); virtual Geom::Point knot_get() const; - + virtual void knot_click(guint state); + void knot_set_offset(Geom::Satellite); /** Checks whether the index falls within the size of the parameter's vector */ bool valid_index(unsigned int index) const { return (_pparam->_vector.size() > index); |
