From dff3aa428ff050c2cce501f646977ddad921feca Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 1 Apr 2015 04:13:16 +0200 Subject: Move 2Geom work to a intermediate positon -helper- Removed dependency to helper/geom.h Now use a simple vector, not a vector of pairs of size_t and Satellite Getters and setters on Satellite removed Update store parameter to a more friendly string, like powerstroke Todo: Documentation and Fix coding style. (bzr r13645.1.63) --- src/live_effects/parameter/Makefile_insert | 4 +- src/live_effects/parameter/array.cpp | 77 ++-- src/live_effects/parameter/array.h | 38 +- src/live_effects/parameter/satellitearray.cpp | 524 ++++++++++++++++++++++ src/live_effects/parameter/satellitearray.h | 108 +++++ src/live_effects/parameter/satellitepairarray.cpp | 507 --------------------- src/live_effects/parameter/satellitepairarray.h | 108 ----- 7 files changed, 686 insertions(+), 680 deletions(-) create mode 100644 src/live_effects/parameter/satellitearray.cpp create mode 100644 src/live_effects/parameter/satellitearray.h delete mode 100644 src/live_effects/parameter/satellitepairarray.cpp delete mode 100644 src/live_effects/parameter/satellitepairarray.h (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert index 74b499fa2..9a0ebe235 100644 --- a/src/live_effects/parameter/Makefile_insert +++ b/src/live_effects/parameter/Makefile_insert @@ -22,8 +22,8 @@ ink_common_sources += \ live_effects/parameter/originalpatharray.h \ live_effects/parameter/powerstrokepointarray.cpp \ live_effects/parameter/powerstrokepointarray.h \ - live_effects/parameter/satellitepairarray.cpp \ - live_effects/parameter/satellitepairarray.h \ + live_effects/parameter/satellitearray.cpp \ + live_effects/parameter/satellitearray.h \ live_effects/parameter/text.cpp \ live_effects/parameter/text.h \ live_effects/parameter/transformedpoint.cpp \ diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp index 33cb53f4e..c8ee63fec 100644 --- a/src/live_effects/parameter/array.cpp +++ b/src/live_effects/parameter/array.cpp @@ -5,9 +5,7 @@ */ #include "live_effects/parameter/array.h" - #include "helper-fns.h" - #include <2geom/coord.h> #include <2geom/point.h> @@ -15,6 +13,35 @@ namespace Inkscape { namespace LivePathEffect { +//TODO: move maybe to svg-lenght.cpp +unsigned int +sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){ + if (!str) { + return 0; + } + gchar ** strarray = g_strsplit(str, ",", 8); + if(strarray[7] && !strarray[8]){ + sat->setSatelliteType(g_strstrip(strarray[0])); + sat->isTime = strncmp(strarray[1],"1",1) == 0; + sat->active = strncmp(strarray[2],"1",1) == 0; + sat->hasMirror = strncmp(strarray[3],"1",1) == 0; + sat->hidden = strncmp(strarray[4],"1",1) == 0; + double amount,angle; + float stepsTmp; + sp_svg_number_read_d(strarray[5], &amount); + sp_svg_number_read_d(strarray[6], &angle); + sp_svg_number_read_f(strarray[7], &stepsTmp); + unsigned int steps = (unsigned int)stepsTmp; + sat->amount = amount; + sat->angle = angle; + sat->steps = steps; + g_strfreev (strarray); + return 1; + } + g_strfreev (strarray); + return 0; +} + template <> double ArrayParam::readsvg(const gchar * str) @@ -47,51 +74,17 @@ ArrayParam::readsvg(const gchar * str) } return Geom::Point(Geom::infinity(),Geom::infinity()); } -//TODO: move maybe to svg-lenght.cpp -unsigned int -sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){ - if (!str) { - return 0; - } - gchar ** strarray = g_strsplit(str, "*", 0); - if(strarray[8] && !strarray[9]){ - sat->setSatelliteType(strarray[0]); - sat->setIsTime(strncmp(strarray[1],"1",1) == 0); - sat->setIsEndOpen(strncmp(strarray[2],"1",1) == 0); - sat->setActive(strncmp(strarray[3],"1",1) == 0); - sat->setHasMirror(strncmp(strarray[4],"1",1) == 0); - sat->setHidden(strncmp(strarray[5],"1",1) == 0); - double amount,angle; - float stepsTmp; - sp_svg_number_read_d(strarray[6], &amount); - sp_svg_number_read_d(strarray[7], &angle); - sp_svg_number_read_f(strarray[8], &stepsTmp); - unsigned int steps = (unsigned int)stepsTmp; - sat->setAmount(amount); - sat->setAngle(angle); - sat->setSteps(steps); - g_strfreev (strarray); - return 1; - } - g_strfreev (strarray); - return 0; -} template <> -std::pair -ArrayParam >::readsvg(const gchar * str) +Geom::Satellite +ArrayParam::readsvg(const gchar * str) { - gchar ** strarray = g_strsplit(str, ",", 2); - double index; - std::pair 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); - g_strfreev (strarray); - if (success == 2) { - return std::make_pair((size_t)index, sat); + if (sp_svg_satellite_read_d(str, &sat)) { + return sat; } - return std::make_pair((size_t)0,sat); + Geom::Satellite satellite(Geom::F, true, false, false, true, 0.0, 0.0, 0); + return satellite; } } /* namespace LivePathEffect */ diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index 4fb053dbb..25e479304 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -15,8 +15,8 @@ #include "live_effects/parameter/parameter.h" -#include <2geom/satellite.h> -#include <2geom/satellite-enum.h> +#include "helper/geom-satellite.h" +#include "helper/geom-satellite-enum.h" #include "svg/svg.h" #include "svg/stringstream.h" @@ -111,26 +111,22 @@ protected: str << nVector; } - void writesvgData(SVGOStringStream &str, std::pair const &nVector) const { - str << nVector.first; + void writesvgData(SVGOStringStream &str, Geom::Satellite const &nVector) const { + str << nVector.getSatelliteTypeGchar(); str << ","; - str << nVector.second.getSatelliteTypeGchar(); - str << "*"; - str << nVector.second.getIsTime(); - str << "*"; - str << nVector.second.getIsEndOpen(); - str << "*"; - str << nVector.second.getActive(); - str << "*"; - str << nVector.second.getHasMirror(); - str << "*"; - str << nVector.second.getHidden(); - str << "*"; - str << nVector.second.getAmount(); - str << "*"; - str << nVector.second.getAngle(); - str << "*"; - str << nVector.second.getSteps(); + str << nVector.isTime; + str << ","; + str << nVector.active; + str << ","; + str << nVector.hasMirror; + str << ","; + str << nVector.hidden; + str << ","; + str << nVector.amount; + str << ","; + str << nVector.angle; + str << ","; + str << nVector.steps; } StorageType readsvg(const gchar * str); diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp new file mode 100644 index 000000000..24a491b4b --- /dev/null +++ b/src/live_effects/parameter/satellitearray.cpp @@ -0,0 +1,524 @@ +/* + * Copyright (C) Jabiertxo Arraiza Cenoz + * Special thanks to Johan Engelen for the base of the effect -powerstroke- + * Also to ScislaC for point me to the idea + * Also su_v for his construvtive feedback and time + * and finaly to Liam P. White for his big help on coding, that save me a lot of + * hours + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "knotholder.h" +#include "ui/dialog/lpe-fillet-chamfer-properties.h" +#include "live_effects/parameter/satellitearray.h" +#include "live_effects/effect.h" +#include "sp-lpe-item.h" +#include +#include +// TODO due to internal breakage in glibmm headers, +// this has to be included last. +#include + + +using namespace Geom; + +namespace Inkscape { + +namespace LivePathEffect { + +SatelliteArrayParam::SatelliteArrayParam( + const Glib::ustring &label, const Glib::ustring &tip, + const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, + Effect *effect) + : ArrayParam(label, tip, key, wr, effect, 0), + knoth(NULL) +{ + knot_shape = SP_KNOT_SHAPE_DIAMOND; + knot_mode = SP_KNOT_MODE_XOR; + knot_color = 0x00ff0000; + helper_size = 0; + use_distance = false; + _effectType = FILLET_CHAMFER; + last_pointwise = NULL; +} + +SatelliteArrayParam::~SatelliteArrayParam() {} + +void SatelliteArrayParam::set_oncanvas_looks(SPKnotShapeType shape, + SPKnotModeType mode, + guint32 color) +{ + knot_shape = shape; + knot_mode = mode; + knot_color = color; +} + +void SatelliteArrayParam::set_pointwise(Geom::Pointwise *pointwise) +{ + last_pointwise = pointwise; + param_set_and_write_new_value(last_pointwise->getSatellites()); +} + +void SatelliteArrayParam::set_document_unit(Glib::ustring value_document_unit) +{ + documentUnit = value_document_unit; +} + +void SatelliteArrayParam::set_use_distance(bool use_knot_distance ) +{ + use_distance = use_knot_distance; +} + +void SatelliteArrayParam::set_unit(const gchar *abbr) +{ + unit = abbr; +} + +void SatelliteArrayParam::set_effect_type(EffectType et) +{ + _effectType = et; +} + +void SatelliteArrayParam::set_helper_size(int hs) +{ + helper_size = hs; + updateCanvasIndicators(); +} + +void SatelliteArrayParam::updateCanvasIndicators(bool mirror) +{ + if(!last_pointwise){ + return; + } + Geom::Piecewise > pwd2 = last_pointwise->getPwd2(); + Pathinfo pathInfo(pwd2); + if( mirror == true){ + hp.clear(); + } + for (size_t i = 0; i < _vector.size(); ++i) { + if(!_vector[i].active || _vector[i].hidden){ + continue; + } + if((!_vector[i].hasMirror && mirror == true) || _vector[i].amount == 0){ + continue; + } + double pos = 0; + if(pwd2.size() <= i){ + break; + } + Geom::D2 d2 = pwd2[i]; + bool overflow = false; + double size_out = _vector[i].getSize(pwd2[i]); + double lenght_out = Geom::length(pwd2[i], Geom::EPSILON); + double lenght_in = 0; + boost::optional d2_prev_index = pathInfo.getPrevious(i); + if(d2_prev_index){ + lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON); + } + if(mirror == true){ + if(d2_prev_index){ + d2 = pwd2[*d2_prev_index]; + pos = _vector[i].getOpositeTime(size_out,d2); + if(lenght_out < size_out){ + overflow = true; + } + } + } else { + pos = _vector[i].getTime(d2); + if(lenght_in < size_out){ + overflow = true; + } + } + if (pos <= 0 || pos >= 1) { + continue; + } + Geom::Point ptA = d2.valueAt(pos); + Geom::Point derivA = unit_vector(derivative(d2).valueAt(pos)); + Geom::Rotate rot(Geom::Rotate::from_degrees(-90)); + derivA = derivA * rot; + Geom::Point C = ptA - derivA * helper_size; + Geom::Point D = ptA + derivA * helper_size; + Geom::Ray ray1(C, D); + char const * svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + Geom::Affine aff = Geom::Affine(); + aff *= Geom::Scale(helper_size); + if(mirror == true){ + aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90)); + } else { + aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); + } + pathv *= aff; + pathv += d2.valueAt(pos); + hp.push_back(pathv[0]); + hp.push_back(pathv[1]); + if(overflow){ + double diameter = helper_size; + if(helper_size == 0){ + diameter = 15; + char const * svgd; + svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + pathv *= Geom::Scale (diameter); + pathv += ptA-Geom::Point(diameter * 0.35,diameter * 0.35); + hp.push_back(pathv[0]); + } else { + char const * svgd; + svgd = "M 0 -1.32 A 1.32 1.32 0 0 0 -1.32 0 A 1.32 1.32 0 0 0 0 1.32 A 1.32 1.32 0 0 0 1.18 0.59 L 0 0 L 1.18 -0.59 A 1.32 1.32 0 0 0 0 -1.32 z"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + aff = Geom::Affine(); + aff *= Geom::Scale(helper_size/2.0); + if(mirror == true){ + aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90)); + } else { + aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); + } + pathv *= aff; + pathv += d2.valueAt(pos); + hp.push_back(pathv[0]); + } + } + } + if( mirror == true){ + updateCanvasIndicators(false); + } +} +void SatelliteArrayParam::updateCanvasIndicators() +{ + updateCanvasIndicators(true); +} + +void SatelliteArrayParam::addCanvasIndicators( + SPLPEItem const */*lpeitem*/, std::vector &hp_vec) +{ + hp_vec.push_back(hp); +} + +void SatelliteArrayParam::recalculate_knots() +{ + if(last_pointwise){ + _vector = last_pointwise->getSatellites(); + } +} + +void +SatelliteArrayParam::param_transform_multiply(Geom::Affine const &postmul, + bool /*set*/) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + if (prefs->getBool("/options/transform/rectcorners", true)) { + for (size_t i = 0; i < _vector.size(); ++i) { + if(!_vector[i].isTime && _vector[i].amount > 0){ + _vector[i].amount = _vector[i].amount * ((postmul.expansionX() + postmul.expansionY()) / 2); + } + } + param_set_and_write_new_value(_vector); + } + + // param_set_and_write_new_value( (*this) * postmul ); +} + +void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder, + SPDesktop *desktop, + SPItem *item, + bool mirror) +{ + //recalculate_knots(); + for (size_t i = 0; i < _vector.size(); ++i) { + size_t iPlus = i; + if( mirror == true){ + iPlus = i + _vector.size(); + } + if(!_vector[i].active){ + continue; + } + if(!_vector[i].hasMirror && mirror == true){ + continue; + } + using namespace Geom; + SatelliteType type = _vector[i].satelliteType; + //IF is for filletChamfer effect... + if(_effectType == FILLET_CHAMFER){ + const gchar *tip; + if (type == C){ + tip = _("Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == IC) { + tip = _("Inverse Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == IF) { + tip = _("Inverse Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else { + tip = _("Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } + FilletChamferKnotHolderEntity *e = + new FilletChamferKnotHolderEntity(this, iPlus); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), + knot_shape, knot_mode, knot_color); + knotholder->add(e); + } + } + if( mirror == true){ + addKnotHolderEntities(knotholder, desktop, item, false); + } +} + +void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder, + SPDesktop *desktop, + SPItem *item) +{ + knoth = knotholder; + addKnotHolderEntities(knotholder, desktop, item, true); +} + +FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index) + : _pparam(p), + _index(index) +{ +} + +void FilletChamferKnotHolderEntity::knot_set(Point const &p, + Point const &/*origin*/, + guint state) +{ + Geom::Point s = snap_knot_position(p, state); + size_t index = _index; + if( _index >= _pparam->_vector.size()){ + index = _index-_pparam->_vector.size(); + } + if (!valid_index(index)) { + return; + } + + if( !_pparam->last_pointwise ){ + return; + } + + Geom::Satellite satellite = _pparam->_vector.at(index); + if(!satellite.active || satellite.hidden){ + return; + } + Geom::Pointwise* pointwise = _pparam->last_pointwise; + Geom::Piecewise > pwd2 = pointwise->getPwd2(); + Pathinfo pathInfo(pwd2); + if(_pparam->_vector.size() <= _index){ + boost::optional d2_prev_index = pathInfo.getPrevious(index); + if(d2_prev_index){ + Geom::D2 d2_in = pwd2[*d2_prev_index]; + double mirrorTime = Geom::nearest_point(s, d2_in); + double timeStart = 0; + std::vector sats = pointwise->getSatellites(); + timeStart = sats[*d2_prev_index].getTime(d2_in); + if(timeStart > mirrorTime){ + mirrorTime = timeStart; + } + double size = satellite.toSize(mirrorTime, d2_in); + double amount = Geom::length(d2_in, Geom::EPSILON) - size; + if(satellite.isTime){ + amount = satellite.toTime(amount,pwd2[index]); + } + satellite.amount = amount; + } + } else { + satellite.setPosition(s,pwd2[index]); + } + _pparam->_vector.at(index) = satellite; + SPLPEItem * splpeitem = dynamic_cast(item); + if(splpeitem){ + sp_lpe_item_update_patheffect(splpeitem, false, false); + } +} + + +Geom::Point +FilletChamferKnotHolderEntity::knot_get() const +{ + Geom::Point tmpPoint; + size_t index = _index; + if( _index >= _pparam->_vector.size()){ + index = _index-_pparam->_vector.size(); + } + if (!valid_index(index)) { + return Point(infinity(), infinity()); + } + Geom::Satellite satellite = _pparam->_vector.at(index); + if(!_pparam->last_pointwise){ + return Point(infinity(), infinity()); + } + if(!satellite.active || satellite.hidden){ + return Point(infinity(), infinity()); + } + Geom::Pointwise* pointwise = _pparam->last_pointwise; + Geom::Piecewise > pwd2 = pointwise->getPwd2(); + Pathinfo pathInfo(pwd2); + if(pwd2.size() <= index){ + return Point(infinity(), infinity()); + } + this->knot->show(); + if( _index >= _pparam->_vector.size()){ + tmpPoint = satellite.getPosition(pwd2[index]); + boost::optional d2_prev_index = pathInfo.getPrevious(index); + if(d2_prev_index){ + Geom::D2 d2_in = pwd2[*d2_prev_index]; + double s = satellite.getSize(pwd2[index]); + double t = satellite.getOpositeTime(s,d2_in); + if(t > 1){ + t = 1; + } + if(t < 0){ + t = 0; + } + double timeStart = 0; + timeStart = pointwise->getSatellites()[*d2_prev_index].getTime(d2_in); + if(timeStart > t){ + t = timeStart; + } + tmpPoint = (d2_in).valueAt(t); + } + } else { + tmpPoint = satellite.getPosition(pwd2[index]); + } + Geom::Point const canvas_point = tmpPoint; + return canvas_point; +} + +void FilletChamferKnotHolderEntity::knot_click(guint state) +{ + if( !_pparam->last_pointwise){ + return; + } + + size_t 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).amount = 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).satelliteType; + 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).satelliteType = 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 = _("Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == IC) { + tip = _("Inverse Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == IF) { + tip = _("Inverse Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else { + tip = _("Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } + this->knot->tip = g_strdup(tip); + this->knot->show(); + } + } else if (state & GDK_SHIFT_MASK) { + Piecewise > pwd2 = _pparam->last_pointwise->getPwd2(); + Pathinfo pathInfo(pwd2); + double amount = _pparam->_vector.at(index).amount; + if(!_pparam->use_distance && !_pparam->_vector.at(index).isTime){ + boost::optional prev = pathInfo.getPrevious(index); + boost::optional > prevPwd2 = boost::none; + boost::optional prevSat = boost::none; + if(prev){ + prevPwd2 = pwd2[*prev]; + prevSat = _pparam->_vector.at(*prev); + } + amount = _pparam->_vector.at(index).len_to_rad(amount, prevPwd2, pwd2[index], prevSat); + } + bool aprox = false; + D2 d2_out = _pparam->last_pointwise->getPwd2()[index]; + boost::optional d2_prev_index = pathInfo.getPrevious(index); + if(d2_prev_index){ + Geom::D2 d2_in = _pparam->last_pointwise->getPwd2()[*d2_prev_index]; + aprox = ((d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false; + } + Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( + this->desktop, amount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index)); + + } +} + +void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite) +{ + if( !_pparam->last_pointwise){ + return; + } + size_t index = _index; + if( _index >= _pparam->_vector.size()){ + index = _index-_pparam->_vector.size(); + } + double amount = satellite.amount; + double maxAmount = amount; + if(!_pparam->use_distance && !satellite.isTime){ + Piecewise > pwd2 = _pparam->last_pointwise->getPwd2(); + Pathinfo pathInfo(pwd2); + boost::optional prev = pathInfo.getPrevious(index); + boost::optional > prevPwd2 = boost::none; + boost::optional prevSat = boost::none; + if(prev){ + prevPwd2 = pwd2[*prev]; + prevSat = _pparam->_vector.at(*prev); + } + amount = _pparam->_vector.at(index).rad_to_len(amount, prevPwd2, pwd2[index], prevSat); + if(maxAmount > 0 && amount == 0){ + amount = _pparam->_vector.at(index).amount; + } + } + satellite.amount = amount; + _pparam->_vector.at(index) = satellite; + this->parent_holder->knot_ungrabbed_handler(this->knot, 0); + _pparam->param_set_and_write_new_value(_pparam->_vector); + SPLPEItem * splpeitem = dynamic_cast(item); + if(splpeitem){ + sp_lpe_item_update_patheffect(splpeitem, false, false); + } +} + +} /* namespace LivePathEffect */ + +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/satellitearray.h b/src/live_effects/parameter/satellitearray.h new file mode 100644 index 000000000..ee0cfbad3 --- /dev/null +++ b/src/live_effects/parameter/satellitearray.h @@ -0,0 +1,108 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_SATELLITE_PAIR_ARRAY_H +#define INKSCAPE_LIVEPATHEFFECT_SATELLITE_PAIR_ARRAY_H + +/* + * Inkscape::LivePathEffectParameters + * Copyright (C) Jabiertxo Arraiza Cenoz + * Special thanks to Johan Engelen for the base of the effect -powerstroke- + * Also to ScislaC for point me to the idea + * Also su_v for his construvtive feedback and time + * To Nathan Hurst for his review and help on refactor + * and finaly to Liam P. White for his big help on coding, that save me a lot of + * hours + * + * + * This parameter act as bridge from pointwise class to serialize it as a LPE + * parameter + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/parameter/array.h" +#include "live_effects/effect-enum.h" +#include "helper/geom-pointwise.h" +#include "knot-holder-entity.h" +#include + +namespace Inkscape { + +namespace LivePathEffect { + +class FilletChamferKnotHolderEntity; + +class SatelliteArrayParam : public ArrayParam { +public: + SatelliteArrayParam(const Glib::ustring &label, + const Glib::ustring &tip, + const Glib::ustring &key, + Inkscape::UI::Widget::Registry *wr, + Effect *effect); + virtual ~SatelliteArrayParam(); + + virtual Gtk::Widget * param_newWidget() { + return NULL; + } + + void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, + guint32 color); + virtual void set_helper_size(int hs); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem,std::vector &hp_vec); + virtual bool providesKnotHolderEntities() const { + return true; + } + void param_transform_multiply(Geom::Affine const &postmul, bool /*set*/); + void set_document_unit(Glib::ustring value_document_unit); + 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); + friend class FilletChamferKnotHolderEntity; + friend class LPEFilletChamfer; +protected: + KnotHolder *knoth; +private: + SatelliteArrayParam(const SatelliteArrayParam &); + SatelliteArrayParam &operator=(const SatelliteArrayParam &); + + SPKnotShapeType knot_shape; + SPKnotModeType knot_mode; + guint32 knot_color; + Geom::PathVector hp; + int helper_size; + bool use_distance; + const gchar *unit; + Glib::ustring documentUnit; + EffectType _effectType; + Geom::Pointwise *last_pointwise; + +}; + +class FilletChamferKnotHolderEntity : public KnotHolderEntity { +public: + FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index); + virtual ~FilletChamferKnotHolderEntity() {_pparam->knoth = NULL;} + + 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(size_t index) const { + return (_pparam->_vector.size() > index); + }; + +private: + SatelliteArrayParam *_pparam; + size_t _index; +}; + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp deleted file mode 100644 index 461a6b54e..000000000 --- a/src/live_effects/parameter/satellitepairarray.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright (C) Jabiertxo Arraiza Cenoz - * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time - * and finaly to Liam P. White for his big help on coding, that save me a lot of - * hours - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "knotholder.h" -#include "ui/dialog/lpe-fillet-chamfer-properties.h" -#include "live_effects/parameter/satellitepairarray.h" -#include "live_effects/effect.h" -#include "sp-lpe-item.h" -#include -// TODO due to internal breakage in glibmm headers, -// this has to be included last. -#include - - -using namespace Geom; - -namespace Inkscape { - -namespace LivePathEffect { - -SatellitePairArrayParam::SatellitePairArrayParam( - const Glib::ustring &label, const Glib::ustring &tip, - const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, - Effect *effect) - : ArrayParam >(label, tip, key, wr, effect, 0), - knoth(NULL) -{ - knot_shape = SP_KNOT_SHAPE_DIAMOND; - knot_mode = SP_KNOT_MODE_XOR; - knot_color = 0x00ff0000; - helper_size = 0; - use_distance = false; - _effectType = FILLET_CHAMFER; - last_pointwise = NULL; -} - -SatellitePairArrayParam::~SatellitePairArrayParam() {} - -void SatellitePairArrayParam::set_oncanvas_looks(SPKnotShapeType shape, - SPKnotModeType mode, - guint32 color) -{ - knot_shape = shape; - knot_mode = mode; - knot_color = color; -} - -void SatellitePairArrayParam::set_pointwise(Geom::Pointwise *pointwise) -{ - last_pointwise = pointwise; - param_set_and_write_new_value(last_pointwise->getSatellites()); -} - -void SatellitePairArrayParam::set_document_unit(Glib::ustring 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_effect_type(EffectType et) -{ - _effectType = et; -} - -void SatellitePairArrayParam::set_helper_size(int hs) -{ - helper_size = hs; - updateCanvasIndicators(); -} - -void SatellitePairArrayParam::updateCanvasIndicators(bool mirror) -{ - if(!last_pointwise){ - return; - } - Geom::Piecewise > pwd2 = last_pointwise->getPwd2(); - if( mirror == true){ - hp.clear(); - } - for (size_t i = 0; i < _vector.size(); ++i) { - if(!_vector[i].second.getActive() || _vector[i].second.getHidden()){ - continue; - } - if((!_vector[i].second.getHasMirror() && mirror == true) || _vector[i].second.getAmount() == 0){ - continue; - } - double pos = 0; - if(pwd2.size() <= (unsigned)_vector[i].first){ - break; - } - Geom::D2 d2 = pwd2[_vector[i].first]; - bool overflow = false; - double size_out = _vector[i].second.getSize(pwd2[_vector[i].first]); - double lenght_out = Geom::length(pwd2[_vector[i].first], Geom::EPSILON); - double lenght_in = 0; - boost::optional d2_prev_index = last_pointwise->getPrevious(_vector[i].first); - if(d2_prev_index){ - lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON); - } - if(mirror == true){ - if(d2_prev_index){ - d2 = pwd2[*d2_prev_index]; - pos = _vector[i].second.getOpositeTime(size_out,d2); - if(lenght_out < size_out){ - overflow = true; - } - } - } else { - pos = _vector[i].second.getTime(d2); - if(lenght_in < size_out){ - overflow = true; - } - } - if (pos <= 0 || pos >= 1) { - continue; - } - Geom::Point ptA = d2.valueAt(pos); - Geom::Point derivA = unit_vector(derivative(d2).valueAt(pos)); - Geom::Rotate rot(Geom::Rotate::from_degrees(-90)); - derivA = derivA * rot; - Geom::Point C = ptA - derivA * helper_size; - Geom::Point D = ptA + derivA * helper_size; - Geom::Ray ray1(C, D); - char const * svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5"; - Geom::PathVector pathv = sp_svg_read_pathv(svgd); - Geom::Affine aff = Geom::Affine(); - aff *= Geom::Scale(helper_size); - if(mirror == true){ - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90)); - } else { - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); - } - pathv *= aff; - pathv += d2.valueAt(pos); - hp.push_back(pathv[0]); - hp.push_back(pathv[1]); - if(overflow){ - double diameter = helper_size; - if(helper_size == 0){ - diameter = 15; - char const * svgd; - svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; - Geom::PathVector pathv = sp_svg_read_pathv(svgd); - pathv *= Geom::Scale (diameter); - pathv += ptA-Geom::Point(diameter * 0.35,diameter * 0.35); - hp.push_back(pathv[0]); - } else { - char const * svgd; - svgd = "M 0 -1.32 A 1.32 1.32 0 0 0 -1.32 0 A 1.32 1.32 0 0 0 0 1.32 A 1.32 1.32 0 0 0 1.18 0.59 L 0 0 L 1.18 -0.59 A 1.32 1.32 0 0 0 0 -1.32 z"; - Geom::PathVector pathv = sp_svg_read_pathv(svgd); - aff = Geom::Affine(); - aff *= Geom::Scale(helper_size/2.0); - if(mirror == true){ - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90)); - } else { - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); - } - pathv *= aff; - pathv += d2.valueAt(pos); - hp.push_back(pathv[0]); - } - } - } - if( mirror == true){ - updateCanvasIndicators(false); - } -} -void SatellitePairArrayParam::updateCanvasIndicators() -{ - updateCanvasIndicators(true); -} - -void SatellitePairArrayParam::addCanvasIndicators( - SPLPEItem const */*lpeitem*/, std::vector &hp_vec) -{ - hp_vec.push_back(hp); -} - -void SatellitePairArrayParam::recalculate_knots() -{ - if(last_pointwise){ - _vector = last_pointwise->getSatellites(); - } -} - -void -SatellitePairArrayParam::param_transform_multiply(Geom::Affine const &postmul, - bool /*set*/) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - if (prefs->getBool("/options/transform/rectcorners", true)) { - for (size_t i = 0; i < _vector.size(); ++i) { - if(!_vector[i].second.getIsTime() && _vector[i].second.getAmount() > 0){ - _vector[i].second.setAmount(_vector[i].second.getAmount() * ((postmul.expansionX() + postmul.expansionY()) / 2)); - } - } - param_set_and_write_new_value(_vector); - } - - // param_set_and_write_new_value( (*this) * postmul ); -} - -void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder, - SPDesktop *desktop, - SPItem *item, - bool mirror) -{ - //recalculate_knots(); - for (size_t i = 0; i < _vector.size(); ++i) { - size_t iPlus = i; - if( mirror == true){ - iPlus = i + _vector.size(); - } - if(!_vector[i].second.getActive()){ - continue; - } - if(!_vector[i].second.getHasMirror() && mirror == true){ - continue; - } - using namespace Geom; - SatelliteType type = _vector[i].second.getSatelliteType(); - //IF is for filletChamfer effect... - if(_effectType == FILLET_CHAMFER){ - const gchar *tip; - if (type == C){ - tip = _("Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (type == IC) { - tip = _("Inverse Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (type == IF) { - tip = _("Inverse Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else { - tip = _("Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } - FilletChamferKnotHolderEntity *e = - new FilletChamferKnotHolderEntity(this, iPlus); - e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), - knot_shape, knot_mode, knot_color); - knotholder->add(e); - } - } - if( mirror == true){ - addKnotHolderEntities(knotholder, desktop, item, false); - } -} - -void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder, - SPDesktop *desktop, - SPItem *item) -{ - knoth = knotholder; - addKnotHolderEntities(knotholder, desktop, item, true); -} - -FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index) - : _pparam(p), - _index(index) -{ -} - -void FilletChamferKnotHolderEntity::knot_set(Point const &p, - Point const &/*origin*/, - guint state) -{ - Geom::Point s = snap_knot_position(p, state); - size_t index = _index; - if( _index >= _pparam->_vector.size()){ - index = _index-_pparam->_vector.size(); - } - if (!valid_index(index)) { - return; - } - - if( !_pparam->last_pointwise ){ - return; - } - - std::pair satellite = _pparam->_vector.at(index); - if(!satellite.second.getActive() || satellite.second.getHidden()){ - return; - } - Geom::Pointwise* pointwise = _pparam->last_pointwise; - Geom::Piecewise > pwd2 = pointwise->getPwd2(); - if(_pparam->_vector.size() <= _index){ - boost::optional d2_prev_index = pointwise->getPrevious(satellite.first); - if(d2_prev_index){ - Geom::D2 d2_in = pwd2[*d2_prev_index]; - double mirrorTime = Geom::nearest_point(s, d2_in); - double timeStart = 0; - std::vector satIndexes = pointwise->findPeviousSatellites(satellite.first,1); - if(satIndexes.size()>0){ - timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in); - } - if(timeStart > mirrorTime){ - mirrorTime = timeStart; - } - double size = satellite.second.toSize(mirrorTime, d2_in); - double amount = Geom::length(d2_in, Geom::EPSILON) - size; - if(satellite.second.getIsTime()){ - amount = satellite.second.toTime(amount,pwd2[satellite.first]); - } - satellite.second.setAmount(amount); - } - } else { - satellite.second.setPosition(s,pwd2[satellite.first]); - } - _pparam->_vector.at(index) = satellite; - SPLPEItem * splpeitem = dynamic_cast(item); - if(splpeitem){ - sp_lpe_item_update_patheffect(splpeitem, false, false); - } -} - - -Geom::Point -FilletChamferKnotHolderEntity::knot_get() const -{ - Geom::Point tmpPoint; - size_t index = _index; - if( _index >= _pparam->_vector.size()){ - index = _index-_pparam->_vector.size(); - } - if (!valid_index(index)) { - return Point(infinity(), infinity()); - } - std::pair satellite = _pparam->_vector.at(index); - 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 > pwd2 = pointwise->getPwd2(); - if(pwd2.size() <= (unsigned)satellite.first){ - return Point(infinity(), infinity()); - } - this->knot->show(); - if( _index >= _pparam->_vector.size()){ - tmpPoint = satellite.second.getPosition(pwd2[satellite.first]); - boost::optional d2_prev_index = pointwise->getPrevious(satellite.first); - if(d2_prev_index){ - Geom::D2 d2_in = pwd2[*d2_prev_index]; - double s = satellite.second.getSize(pwd2[satellite.first]); - double t = satellite.second.getOpositeTime(s,d2_in); - if(t > 1){ - t = 1; - } - if(t < 0){ - t = 0; - } - double timeStart = 0; - std::vector satIndexes = pointwise->findPeviousSatellites(satellite.first,1); - if(satIndexes.size()>0){ - timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in); - } - if(timeStart > t){ - t = timeStart; - } - tmpPoint = (d2_in).valueAt(t); - } - } else { - tmpPoint = satellite.second.getPosition(pwd2[satellite.first]); - } - Geom::Point const canvas_point = tmpPoint; - return canvas_point; -} - -void FilletChamferKnotHolderEntity::knot_click(guint state) -{ - if( !_pparam->last_pointwise){ - return; - } - - size_t 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.setAmount(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 = _("Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (type == IC) { - tip = _("Inverse Chamfer: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else if (type == IF) { - tip = _("Inverse Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } else { - tip = _("Fillet: Ctrl+Click toggle type, " - "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); - } - this->knot->tip = g_strdup(tip); - this->knot->show(); - } - } else if (state & GDK_SHIFT_MASK) { - double amount = _pparam->_vector.at(index).second.getAmount(); - if(!_pparam->use_distance && !_pparam->_vector.at(index).second.getIsTime()){ - amount = _pparam->last_pointwise->len_to_rad(amount, _pparam->_vector.at(index)); - } - bool aprox = false; - D2 d2_out = _pparam->last_pointwise->getPwd2()[index]; - boost::optional d2_prev_index = _pparam->last_pointwise->getPrevious(_pparam->_vector.at(index).first); - if(d2_prev_index){ - Geom::D2 d2_in = _pparam->last_pointwise->getPwd2()[*d2_prev_index]; - aprox = ((d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false; - } - Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( - this->desktop, amount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index).second); - - } -} - -void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite) -{ - if( !_pparam->last_pointwise){ - return; - } - size_t index = _index; - if( _index >= _pparam->_vector.size()){ - index = _index-_pparam->_vector.size(); - } - double amount = satellite.getAmount(); - double maxAmount = amount; - if(!_pparam->use_distance && !satellite.getIsTime()){ - amount = _pparam->last_pointwise->rad_to_len(amount, _pparam->_vector.at(index)); - if(maxAmount > 0 && amount == 0){ - amount = _pparam->_vector.at(index).second.getAmount(); - } - } - satellite.setAmount(amount); - _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(item); - if(splpeitem){ - sp_lpe_item_update_patheffect(splpeitem, false, false); - } -} - -} /* namespace LivePathEffect */ - -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h deleted file mode 100644 index fcd3bd736..000000000 --- a/src/live_effects/parameter/satellitepairarray.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef INKSCAPE_LIVEPATHEFFECT_SATELLITE_PAIR_ARRAY_H -#define INKSCAPE_LIVEPATHEFFECT_SATELLITE_PAIR_ARRAY_H - -/* - * Inkscape::LivePathEffectParameters - * Copyright (C) Jabiertxo Arraiza Cenoz - * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time - * To Nathan Hurst for his review and help on refactor - * and finaly to Liam P. White for his big help on coding, that save me a lot of - * hours - * - * - * This parameter act as bridge from pointwise class to serialize it as a LPE - * parameter - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include "live_effects/parameter/array.h" -#include "live_effects/effect-enum.h" -#include "knot-holder-entity.h" -#include <2geom/pointwise.h> - -namespace Inkscape { - -namespace LivePathEffect { - -class FilletChamferKnotHolderEntity; - -class SatellitePairArrayParam : public ArrayParam > { -public: - SatellitePairArrayParam(const Glib::ustring &label, - const Glib::ustring &tip, - const Glib::ustring &key, - Inkscape::UI::Widget::Registry *wr, - Effect *effect); - virtual ~SatellitePairArrayParam(); - - virtual Gtk::Widget * param_newWidget() { - return NULL; - } - - void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, - guint32 color); - virtual void set_helper_size(int hs); - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror); - virtual void addCanvasIndicators(SPLPEItem const *lpeitem,std::vector &hp_vec); - virtual bool providesKnotHolderEntities() const { - return true; - } - void param_transform_multiply(Geom::Affine const &postmul, bool /*set*/); - void set_document_unit(Glib::ustring value_document_unit); - 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); - friend class FilletChamferKnotHolderEntity; - friend class LPEFilletChamfer; -protected: - KnotHolder *knoth; -private: - SatellitePairArrayParam(const SatellitePairArrayParam &); - SatellitePairArrayParam &operator=(const SatellitePairArrayParam &); - - SPKnotShapeType knot_shape; - SPKnotModeType knot_mode; - guint32 knot_color; - Geom::PathVector hp; - int helper_size; - bool use_distance; - const gchar *unit; - Glib::ustring documentUnit; - EffectType _effectType; - Geom::Pointwise *last_pointwise; - -}; - -class FilletChamferKnotHolderEntity : public KnotHolderEntity { -public: - FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index); - virtual ~FilletChamferKnotHolderEntity() {_pparam->knoth = NULL;} - - 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(size_t index) const { - return (_pparam->_vector.size() > index); - }; - -private: - SatellitePairArrayParam *_pparam; - size_t _index; -}; - -} //namespace LivePathEffect - -} //namespace Inkscape - -#endif -- cgit v1.2.3