summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-07 12:55:16 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-07 12:55:16 +0000
commit62ebac099d8fa013e34a773c0fe3aee56b5a5758 (patch)
treed1eea7a31f9fd8f261bc1322f76167c228dcf0b8 /src/live_effects/parameter
parentAdd to po files (diff)
downloadinkscape-62ebac099d8fa013e34a773c0fe3aee56b5a5758.tar.gz
inkscape-62ebac099d8fa013e34a773c0fe3aee56b5a5758.zip
finish helper paths and beter handle of fillet/chamfer overflow. Also make the satellitepairarray LPE parameter usable for other pointwise effects, not only to fillet chamfer
(bzr r13645.1.35)
Diffstat (limited to 'src/live_effects/parameter')
-rw-r--r--src/live_effects/parameter/array.cpp6
-rw-r--r--src/live_effects/parameter/array.h2
-rw-r--r--src/live_effects/parameter/satellitepairarray.cpp217
-rw-r--r--src/live_effects/parameter/satellitepairarray.h16
4 files changed, 147 insertions, 94 deletions
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index e4c480d93..e8a1b9532 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -62,13 +62,13 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
sat->setActive(strncmp(strarray[4],"1",1) == 0);
sat->setHasMirror(strncmp(strarray[5],"1",1) == 0);
sat->setHidden(strncmp(strarray[6],"1",1) == 0);
- double ammount,angle;
+ double amount,angle;
float stepsTmp;
- sp_svg_number_read_d(strarray[7], &ammount);
+ sp_svg_number_read_d(strarray[7], &amount);
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->setAmount(amount);
sat->setAngle(angle);
sat->setSteps(steps);
g_strfreev (strarray);
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index d28576fce..a6e797d4e 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -129,7 +129,7 @@ protected:
str << "*";
str << nVector.second.getHidden();
str << "*";
- str << nVector.second.getAmmount();
+ str << nVector.second.getAmount();
str << "*";
str << nVector.second.getAngle();
str << "*";
diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp
index ffd04e14c..9c2c1f93b 100644
--- a/src/live_effects/parameter/satellitepairarray.cpp
+++ b/src/live_effects/parameter/satellitepairarray.cpp
@@ -34,7 +34,7 @@ SatellitePairArrayParam::SatellitePairArrayParam(
knot_color = 0x00ff0000;
helper_size = 0;
use_distance = false;
-
+ _effectType = FILLET_CHAMFER;
last_pointwise = NULL;
}
@@ -69,37 +69,61 @@ 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()
+void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
{
+ if( last_pointwise == NULL){
+ return;
+ }
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = last_pointwise->getPwd2();
- hp.clear();
- bool mirrorPass = false;
+ if( mirror == true){
+ hp.clear();
+ }
for (unsigned int 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<Geom::SBasis> d2 = pwd2[_vector[i].first];
- if(mirrorPass == true){
- double size = _vector[i].second.getSize(pwd2[_vector[i].first]);
- boost::optional<Geom::D2<Geom::SBasis> > curve_in = last_pointwise->getCurveIn(_vector[i]);
+ 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<Geom::D2<Geom::SBasis> > curve_in = last_pointwise->getCurveIn(_vector[i]);
+ if(curve_in){
+ lenght_in = Geom::length(*curve_in, Geom::EPSILON);
+ }
+ if(mirror == true){
if(curve_in){
d2 = *curve_in;
- pos = _vector[i].second.getOpositeTime(size,*curve_in);
+ pos = _vector[i].second.getOpositeTime(size_out,*curve_in);
+ if(lenght_out < size_out){
+ overflow = true;
+ }
}
} else {
pos = _vector[i].second.getTime(pwd2[_vector[i].first]);
+ if(lenght_in < size_out){
+ overflow = true;
+ }
}
- if (pos == 0) {
+ if (pos <= 0 || pos >= 1) {
continue;
}
Geom::Point ptA = d2.valueAt(pos);
@@ -113,7 +137,7 @@ void SatellitePairArrayParam::updateCanvasIndicators()
Geom::PathVector pathv = sp_svg_read_pathv(svgd);
Geom::Affine aff = Geom::Affine();
aff *= Geom::Scale(helper_size);
- if(mirrorPass == true){
+ if(mirror == true){
aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90));
} else {
aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270));
@@ -122,13 +146,40 @@ void SatellitePairArrayParam::updateCanvasIndicators()
pathv += d2.valueAt(pos);
hp.push_back(pathv[0]);
hp.push_back(pathv[1]);
- if(_vector[i].second.getHasMirror() && mirrorPass == false){
- mirrorPass = true;
- i--;
- } else {
- mirrorPass = false;
+ 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(
@@ -139,76 +190,62 @@ void SatellitePairArrayParam::addCanvasIndicators(
void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
- SPItem *item)
+ SPItem *item,
+ bool mirror)
{
for (unsigned int i = 0; i < _vector.size(); ++i) {
if(!_vector[i].second.getActive() || !_vector[i].second.getHidden()){
continue;
}
- if(_vector[i].second.getHasMirror()){
- addKnotHolderEntitieMirrored(knotholder, desktop, item, i);
+ if(!_vector[i].second.getHasMirror() && mirror == true){
+ continue;
+ }
+ int iPlus = i;
+ if( mirror == true){
+ iPlus = i + _vector.size();
}
using namespace Geom;
SatelliteType type = _vector[i].second.getSatelliteType();
- 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");
+ //IF is for filletChamfer effect...
+ if(_effectType == FILLET_CHAMFER){
+ 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");
+ }
+ 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);
}
- SatellitePairArrayParamKnotHolderEntity *e =
- new SatellitePairArrayParamKnotHolderEntity(this, i);
- 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::addKnotHolderEntitieMirrored(KnotHolder *knotholder,
+void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
- SPItem *item, int i)
+ SPItem *item)
{
- using namespace Geom;
- SatelliteType type = _vector[i].second.getSatelliteType();
- 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");
- }
- SatellitePairArrayParamKnotHolderEntity *e =
- new SatellitePairArrayParamKnotHolderEntity(this, i + _vector.size());
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
- knot_shape, knot_mode, knot_color);
- knotholder->add(e);
+ addKnotHolderEntities(knotholder, desktop, item, true);
}
-
-SatellitePairArrayParamKnotHolderEntity::SatellitePairArrayParamKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index)
+FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index)
: _pparam(p),
_index(index)
{
@@ -216,7 +253,7 @@ SatellitePairArrayParamKnotHolderEntity::SatellitePairArrayParamKnotHolderEntity
-void SatellitePairArrayParamKnotHolderEntity::knot_set(Point const &p,
+void FilletChamferKnotHolderEntity::knot_set(Point const &p,
Point const &/*origin*/,
guint state)
{
@@ -244,10 +281,11 @@ void SatellitePairArrayParamKnotHolderEntity::knot_set(Point const &p,
mirrorTime = timeStart;
}
double size = satellite.second.toSize(mirrorTime, *d2_in);
- double lenght = Geom::length(*d2_in, Geom::EPSILON) - size;
- double time = satellite.second.toTime(lenght,pwd2[satellite.first]);
- s = pwd2[satellite.first].valueAt(time);
- satellite.second.setPosition(s,pwd2[satellite.first]);
+ 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]);
@@ -260,7 +298,7 @@ void SatellitePairArrayParamKnotHolderEntity::knot_set(Point const &p,
}
Geom::Point
-SatellitePairArrayParamKnotHolderEntity::knot_get() const
+FilletChamferKnotHolderEntity::knot_get() const
{
Geom::Point tmpPoint;
int index = _index;
@@ -303,15 +341,19 @@ SatellitePairArrayParamKnotHolderEntity::knot_get() const
}
-void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state)
+void FilletChamferKnotHolderEntity::knot_click(guint state)
{
+ if( _pparam->last_pointwise == NULL){
+ return;
+ }
+
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->_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{
@@ -356,9 +398,9 @@ void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state)
this->knot->show();
}
} else if (state & GDK_SHIFT_MASK) {
- double ammount = _pparam->_vector.at(index).second.getAmmount();
+ double amount = _pparam->_vector.at(index).second.getAmount();
if(!_pparam->use_distance && !_pparam->_vector.at(index).second.getIsTime()){
- ammount = _pparam->last_pointwise->len_to_rad(ammount, _pparam->_vector.at(index));
+ amount = _pparam->last_pointwise->len_to_rad(amount, _pparam->_vector.at(index));
}
boost::optional<Geom::D2<Geom::SBasis> > d2_in = _pparam->last_pointwise->getCurveIn(_pparam->_vector.at(index));
bool aprox = false;
@@ -367,22 +409,29 @@ void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state)
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);
+ this->desktop, amount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index).second);
}
}
-void SatellitePairArrayParamKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
+void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
{
+ if( _pparam->last_pointwise == NULL){
+ return;
+ }
int index = _index;
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
- double ammount = satellite.getAmmount();
+ double amount = satellite.getAmount();
+ double maxAmount = amount;
if(!_pparam->use_distance && !satellite.getIsTime()){
- ammount = _pparam->last_pointwise->rad_to_len(ammount, _pparam->_vector.at(index));
+ 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.setAmmount(ammount);
+ 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);
diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h
index 21fb0fbd8..79a015c6d 100644
--- a/src/live_effects/parameter/satellitepairarray.h
+++ b/src/live_effects/parameter/satellitepairarray.h
@@ -20,6 +20,7 @@
#include <glib.h>
#include "live_effects/parameter/array.h"
+#include "live_effects/effect-enum.h"
#include "knot-holder-entity.h"
#include <2geom/pointwise.h>
@@ -27,7 +28,7 @@ namespace Inkscape {
namespace LivePathEffect {
-class SatellitePairArrayParamKnotHolderEntity;
+class FilletChamferKnotHolderEntity;
class SatellitePairArrayParam : public ArrayParam<std::pair<unsigned int, Geom::Satellite> > {
public:
@@ -46,7 +47,7 @@ public:
guint32 color);
virtual void set_helper_size(int hs);
virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
- virtual void addKnotHolderEntitieMirrored(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, int i);
+ 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 {
return true;
@@ -54,9 +55,11 @@ public:
void set_document_unit(Glib::ustring const * value_document_unit);
void set_use_distance(bool use_knot_distance );
void set_unit(const gchar *abbr);
+ void set_effect_type(EffectType et);
virtual void updateCanvasIndicators();
+ virtual void updateCanvasIndicators(bool mirror);
void set_pointwise(Geom::Pointwise *pointwise);
- friend class SatellitePairArrayParamKnotHolderEntity;
+ friend class FilletChamferKnotHolderEntity;
private:
SatellitePairArrayParam(const SatellitePairArrayParam &);
@@ -70,14 +73,15 @@ private:
bool use_distance;
const gchar *unit;
Glib::ustring const * documentUnit;
+ EffectType _effectType;
Geom::Pointwise *last_pointwise;
};
-class SatellitePairArrayParamKnotHolderEntity : public KnotHolderEntity {
+class FilletChamferKnotHolderEntity : public KnotHolderEntity {
public:
- SatellitePairArrayParamKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index);
- virtual ~SatellitePairArrayParamKnotHolderEntity() {}
+ FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index);
+ virtual ~FilletChamferKnotHolderEntity() {}
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
virtual Geom::Point knot_get() const;