summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-04-01 15:54:35 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-04-01 15:54:35 +0000
commitf3965759e52107c1cdcd8b7e248e5538fdaa11b6 (patch)
treeefa7e5eb155b812903d14e76244e462dd84f47d8 /src/live_effects/parameter
parentadd documentation (diff)
downloadinkscape-f3965759e52107c1cdcd8b7e248e5538fdaa11b6.tar.gz
inkscape-f3965759e52107c1cdcd8b7e248e5538fdaa11b6.zip
Added documentation and fix to coding style.
(bzr r13645.1.66)
Diffstat (limited to 'src/live_effects/parameter')
-rw-r--r--src/live_effects/parameter/satellitearray.cpp403
-rw-r--r--src/live_effects/parameter/satellitearray.h89
2 files changed, 249 insertions, 243 deletions
diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp
index 24a491b4b..bac907343 100644
--- a/src/live_effects/parameter/satellitearray.cpp
+++ b/src/live_effects/parameter/satellitearray.cpp
@@ -19,27 +19,26 @@
// this has to be included last.
#include <glibmm/i18n.h>
-
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<Geom::Satellite>(label, tip, key, wr, effect, 0),
- knoth(NULL)
+SatelliteArrayParam::SatelliteArrayParam(const Glib::ustring &label,
+ const Glib::ustring &tip,
+ const Glib::ustring &key,
+ Inkscape::UI::Widget::Registry *wr,
+ Effect *effect)
+ : ArrayParam<Geom::Satellite>(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;
+ _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;
+ _last_pointwise = NULL;
}
SatelliteArrayParam::~SatelliteArrayParam() {}
@@ -48,138 +47,141 @@ void SatelliteArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
SPKnotModeType mode,
guint32 color)
{
- knot_shape = shape;
- knot_mode = mode;
- knot_color = color;
+ _knot_shape = shape;
+ _knot_mode = mode;
+ _knot_color = color;
}
-void SatelliteArrayParam::set_pointwise(Geom::Pointwise *pointwise)
+void SatelliteArrayParam::setPointwise(Geom::Pointwise *pointwise)
{
- last_pointwise = pointwise;
- param_set_and_write_new_value(last_pointwise->getSatellites());
+ _last_pointwise = pointwise;
+ param_set_and_write_new_value(_last_pointwise->getSatellites());
}
-void SatelliteArrayParam::set_document_unit(Glib::ustring value_document_unit)
+void SatelliteArrayParam::setDocumentUnit(Glib::ustring value_document_unit)
{
- documentUnit = value_document_unit;
+ _documentUnit = value_document_unit;
}
-void SatelliteArrayParam::set_use_distance(bool use_knot_distance )
+void SatelliteArrayParam::setUseDistance(bool use_knot_distance)
{
- use_distance = use_knot_distance;
+ _use_distance = use_knot_distance;
}
-void SatelliteArrayParam::set_unit(const gchar *abbr)
+void SatelliteArrayParam::setUnit(const gchar *abbr)
{
- unit = abbr;
+ _unit = abbr;
}
-void SatelliteArrayParam::set_effect_type(EffectType et)
+void SatelliteArrayParam::setEffectType(EffectType et)
{
_effectType = et;
}
-void SatelliteArrayParam::set_helper_size(int hs)
+void SatelliteArrayParam::setHelperSize(int hs)
{
- helper_size = hs;
+ _helper_size = hs;
updateCanvasIndicators();
}
void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
{
- if(!last_pointwise){
+ if (!_last_pointwise) {
return;
}
- Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = last_pointwise->getPwd2();
- Pathinfo pathInfo(pwd2);
- if( mirror == true){
- hp.clear();
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _last_pointwise->getPwd2();
+ Pathinfo path_info(pwd2);
+ if (mirror == true) {
+ _hp.clear();
}
for (size_t i = 0; i < _vector.size(); ++i) {
- if(!_vector[i].active || _vector[i].hidden){
+ if (!_vector[i].active || _vector[i].hidden) {
continue;
}
- if((!_vector[i].hasMirror && mirror == true) || _vector[i].amount == 0){
+ if ((!_vector[i].hasMirror && mirror == true) || _vector[i].amount == 0) {
continue;
}
double pos = 0;
- if(pwd2.size() <= i){
+ if (pwd2.size() <= i) {
break;
}
Geom::D2<Geom::SBasis> d2 = pwd2[i];
bool overflow = false;
- double size_out = _vector[i].getSize(pwd2[i]);
+ double size_out = _vector[i].size(pwd2[i]);
double lenght_out = Geom::length(pwd2[i], Geom::EPSILON);
double lenght_in = 0;
- boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(i);
- if(d2_prev_index){
+ boost::optional<size_t> d2_prev_index = path_info.previous(i);
+ if (d2_prev_index) {
lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON);
}
- if(mirror == true){
- if(d2_prev_index){
+ if (mirror == true) {
+ if (d2_prev_index) {
d2 = pwd2[*d2_prev_index];
- pos = _vector[i].getOpositeTime(size_out,d2);
- if(lenght_out < size_out){
+ pos = _vector[i].time(size_out, true, d2);
+ if (lenght_out < size_out) {
overflow = true;
}
}
} else {
- pos = _vector[i].getTime(d2);
- if(lenght_in < size_out){
+ pos = _vector[i].time(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::Point point_a = d2.valueAt(pos);
+ Geom::Point deriv_a = 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";
+ deriv_a = deriv_a * rot;
+ Geom::Point point_c = point_a - deriv_a * _helper_size;
+ Geom::Point point_d = point_a + deriv_a * _helper_size;
+ Geom::Ray ray_1(point_c, point_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));
+ aff *= Geom::Scale(_helper_size);
+ if (mirror == true) {
+ aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(90));
} else {
- aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270));
+ aff *= Geom::Rotate(ray_1.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){
+ _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";
+ 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]);
+ pathv *= Geom::Scale(diameter);
+ pathv += point_a - 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";
+ 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));
+ aff *= Geom::Scale(_helper_size / 2.0);
+ if (mirror == true) {
+ aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(90));
} else {
- aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270));
+ aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(270));
}
pathv *= aff;
pathv += d2.valueAt(pos);
- hp.push_back(pathv[0]);
+ _hp.push_back(pathv[0]);
}
}
}
- if( mirror == true){
+ if (mirror == true) {
updateCanvasIndicators(false);
}
}
@@ -191,58 +193,47 @@ void SatelliteArrayParam::updateCanvasIndicators()
void SatelliteArrayParam::addCanvasIndicators(
SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
{
- hp_vec.push_back(hp);
-}
-
-void SatelliteArrayParam::recalculate_knots()
-{
- if(last_pointwise){
- _vector = last_pointwise->getSatellites();
- }
+ hp_vec.push_back(_hp);
}
-void
-SatelliteArrayParam::param_transform_multiply(Geom::Affine const &postmul,
+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);
+ 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)
+ SPItem *item, bool mirror)
{
- //recalculate_knots();
for (size_t i = 0; i < _vector.size(); ++i) {
size_t iPlus = i;
- if( mirror == true){
+ if (mirror == true) {
iPlus = i + _vector.size();
}
- if(!_vector[i].active){
+ if (!_vector[i].active) {
continue;
}
- if(!_vector[i].hasMirror && mirror == true){
+ if (!_vector[i].hasMirror && mirror == true) {
continue;
}
using namespace Geom;
SatelliteType type = _vector[i].satelliteType;
//IF is for filletChamfer effect...
- if(_effectType == FILLET_CHAMFER){
+ if (_effectType == FILLET_CHAMFER) {
const gchar *tip;
- if (type == C){
- tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
+ 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) {
@@ -261,11 +252,11 @@ void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
FilletChamferKnotHolderEntity *e =
new FilletChamferKnotHolderEntity(this, iPlus);
e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
- knot_shape, knot_mode, knot_color);
+ _knot_shape, _knot_mode, _knot_color);
knotholder->add(e);
}
}
- if( mirror == true){
+ if (mirror == true) {
addKnotHolderEntities(knotholder, desktop, item, false);
}
}
@@ -274,159 +265,155 @@ void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
SPItem *item)
{
- knoth = knotholder;
- addKnotHolderEntities(knotholder, desktop, item, true);
+ knoth = knotholder;
+ addKnotHolderEntities(knotholder, desktop, item, true);
}
-FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index)
- : _pparam(p),
- _index(index)
-{
-}
+FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(
+ SatelliteArrayParam *p, size_t index)
+ : _pparam(p), _index(index) {}
void FilletChamferKnotHolderEntity::knot_set(Point const &p,
- Point const &/*origin*/,
- guint state)
+ 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 (_index >= _pparam->_vector.size()) {
+ index = _index - _pparam->_vector.size();
}
if (!valid_index(index)) {
return;
}
- if( !_pparam->last_pointwise ){
+ if (!_pparam->_last_pointwise) {
return;
}
Geom::Satellite satellite = _pparam->_vector.at(index);
- if(!satellite.active || satellite.hidden){
+ if (!satellite.active || satellite.hidden) {
return;
}
- Geom::Pointwise* pointwise = _pparam->last_pointwise;
+ Geom::Pointwise *pointwise = _pparam->_last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- Pathinfo pathInfo(pwd2);
- if(_pparam->_vector.size() <= _index){
- boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index);
- if(d2_prev_index){
+ Pathinfo path_info(pwd2);
+ if (_pparam->_vector.size() <= _index) {
+ boost::optional<size_t> d2_prev_index = path_info.previous(index);
+ if (d2_prev_index) {
Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
- double mirrorTime = Geom::nearest_point(s, d2_in);
- double timeStart = 0;
+ double mirror_time = Geom::nearest_point(s, d2_in);
+ double time_start = 0;
std::vector<Geom::Satellite> sats = pointwise->getSatellites();
- timeStart = sats[*d2_prev_index].getTime(d2_in);
- if(timeStart > mirrorTime){
- mirrorTime = timeStart;
+ time_start = sats[*d2_prev_index].time(d2_in);
+ if (time_start > mirror_time) {
+ mirror_time = time_start;
}
- double size = satellite.toSize(mirrorTime, d2_in);
+ double size = satellite.toSize(mirror_time, d2_in);
double amount = Geom::length(d2_in, Geom::EPSILON) - size;
- if(satellite.isTime){
- amount = satellite.toTime(amount,pwd2[index]);
+ if (satellite.isTime) {
+ amount = satellite.toTime(amount, pwd2[index]);
}
satellite.amount = amount;
}
} else {
- satellite.setPosition(s,pwd2[index]);
+ satellite.setPosition(s, pwd2[index]);
}
- _pparam->_vector.at(index) = satellite;
- SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
- if(splpeitem){
+ _pparam->_vector.at(index) = satellite;
+ SPLPEItem *splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if (splpeitem) {
sp_lpe_item_update_patheffect(splpeitem, false, false);
}
}
-
-Geom::Point
-FilletChamferKnotHolderEntity::knot_get() const
+Geom::Point FilletChamferKnotHolderEntity::knot_get() const
{
- Geom::Point tmpPoint;
+ Geom::Point tmp_point;
size_t index = _index;
- if( _index >= _pparam->_vector.size()){
- index = _index-_pparam->_vector.size();
+ 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){
+ if (!_pparam->_last_pointwise) {
return Point(infinity(), infinity());
}
- if(!satellite.active || satellite.hidden){
+ if (!satellite.active || satellite.hidden) {
return Point(infinity(), infinity());
}
- Geom::Pointwise* pointwise = _pparam->last_pointwise;
+ Geom::Pointwise *pointwise = _pparam->_last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- Pathinfo pathInfo(pwd2);
- if(pwd2.size() <= index){
+ Pathinfo path_info(pwd2);
+ if (pwd2.size() <= index) {
return Point(infinity(), infinity());
}
this->knot->show();
- if( _index >= _pparam->_vector.size()){
- tmpPoint = satellite.getPosition(pwd2[index]);
- boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index);
- if(d2_prev_index){
- Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
- double s = satellite.getSize(pwd2[index]);
- double t = satellite.getOpositeTime(s,d2_in);
- if(t > 1){
+ if (_index >= _pparam->_vector.size()) {
+ tmp_point = satellite.getPosition(pwd2[index]);
+ boost::optional<size_t> d2_prev_index = path_info.previous(index);
+ if (d2_prev_index) {
+ Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
+ double s = satellite.size(pwd2[index]);
+ double t = satellite.time(s, true, d2_in);
+ if (t > 1) {
t = 1;
}
- if(t < 0){
+ if (t < 0) {
t = 0;
}
- double timeStart = 0;
- timeStart = pointwise->getSatellites()[*d2_prev_index].getTime(d2_in);
- if(timeStart > t){
- t = timeStart;
+ double time_start = 0;
+ time_start = pointwise->getSatellites()[*d2_prev_index].time(d2_in);
+ if (time_start > t) {
+ t = time_start;
}
- tmpPoint = (d2_in).valueAt(t);
+ tmp_point = (d2_in).valueAt(t);
}
} else {
- tmpPoint = satellite.getPosition(pwd2[index]);
+ tmp_point = satellite.getPosition(pwd2[index]);
}
- Geom::Point const canvas_point = tmpPoint;
+ Geom::Point const canvas_point = tmp_point;
return canvas_point;
}
void FilletChamferKnotHolderEntity::knot_click(guint state)
{
- if( !_pparam->last_pointwise){
+ if (!_pparam->_last_pointwise) {
return;
}
size_t index = _index;
- if( _index >= _pparam->_vector.size()){
- index = _index-_pparam->_vector.size();
+ 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{
+ } 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;
+ 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 = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
+ 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) {
@@ -446,55 +433,63 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
this->knot->show();
}
} else if (state & GDK_SHIFT_MASK) {
- Piecewise<D2<SBasis> > 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<size_t> prev = pathInfo.getPrevious(index);
+ Piecewise<D2<SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
+ Pathinfo path_info(pwd2);
+ double amount = _pparam->_vector.at(index).amount;
+ if (!_pparam->_use_distance && !_pparam->_vector.at(index).isTime) {
+ boost::optional<size_t> prev = path_info.previous(index);
boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none;
- boost::optional<Geom::Satellite > prevSat = boost::none;
- if(prev){
+ boost::optional<Geom::Satellite> 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);
+ amount = _pparam->_vector.at(index)
+ .lenToRad(amount, prevPwd2, pwd2[index], prevSat);
}
bool aprox = false;
- D2<SBasis> d2_out = _pparam->last_pointwise->getPwd2()[index];
- boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index);
- if(d2_prev_index){
- Geom::D2<Geom::SBasis> 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;
+ D2<SBasis> d2_out = _pparam->_last_pointwise->getPwd2()[index];
+ boost::optional<size_t> d2_prev_index = path_info.previous(index);
+ if (d2_prev_index) {
+ Geom::D2<Geom::SBasis> 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));
-
+ 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){
+ if (!_pparam->_last_pointwise) {
return;
}
size_t index = _index;
- if( _index >= _pparam->_vector.size()){
- index = _index-_pparam->_vector.size();
+ if (_index >= _pparam->_vector.size()) {
+ index = _index - _pparam->_vector.size();
}
double amount = satellite.amount;
- double maxAmount = amount;
- if(!_pparam->use_distance && !satellite.isTime){
- Piecewise<D2<SBasis> > pwd2 = _pparam->last_pointwise->getPwd2();
- Pathinfo pathInfo(pwd2);
- boost::optional<size_t> prev = pathInfo.getPrevious(index);
+ double max_amount = amount;
+ if (!_pparam->_use_distance && !satellite.isTime) {
+ Piecewise<D2<SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
+ Pathinfo path_info(pwd2);
+ boost::optional<size_t> prev = path_info.previous(index);
boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none;
- boost::optional<Geom::Satellite > prevSat = boost::none;
- if(prev){
+ boost::optional<Geom::Satellite> 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)
+ .radToLen(amount, prevPwd2, pwd2[index], prevSat);
+ if (max_amount > 0 && amount == 0) {
amount = _pparam->_vector.at(index).amount;
}
}
@@ -502,8 +497,8 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
_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<SPLPEItem *>(item);
- if(splpeitem){
+ SPLPEItem *splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if (splpeitem) {
sp_lpe_item_update_patheffect(splpeitem, false, false);
}
}
diff --git a/src/live_effects/parameter/satellitearray.h b/src/live_effects/parameter/satellitearray.h
index ee0cfbad3..bb53af12b 100644
--- a/src/live_effects/parameter/satellitearray.h
+++ b/src/live_effects/parameter/satellitearray.h
@@ -10,11 +10,11 @@
* 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
*/
@@ -32,69 +32,80 @@ class FilletChamferKnotHolderEntity;
class SatelliteArrayParam : public ArrayParam<Geom::Satellite> {
public:
- SatelliteArrayParam(const Glib::ustring &label,
- const Glib::ustring &tip,
- const Glib::ustring &key,
- Inkscape::UI::Widget::Registry *wr,
- Effect *effect);
+ 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() {
+ 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<Geom::PathVector> &hp_vec);
- virtual bool providesKnotHolderEntities() const {
+ virtual void setHelperSize(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<Geom::PathVector> &hp_vec);
+ virtual void updateCanvasIndicators();
+ virtual void updateCanvasIndicators(bool mirror);
+ 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);
+ void setDocumentUnit(Glib::ustring value_document__unit);
+ void setUseDistance(bool use_knot_distance);
+ void setUnit(const gchar *abbr);
+ void setEffectType(EffectType et);
+ void setPointwise(Geom::Pointwise *pointwise);
+ void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode,
+ guint32 color);
+
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;
+ 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;
+ Geom::Pointwise *_last_pointwise;
};
class FilletChamferKnotHolderEntity : public KnotHolderEntity {
public:
FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index);
- virtual ~FilletChamferKnotHolderEntity() {_pparam->knoth = NULL;}
+ virtual ~FilletChamferKnotHolderEntity()
+ {
+ _pparam->knoth = NULL;
+ }
- virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
+ 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 {
+ /** 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;