summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabiertxof <jtx@jtx>2017-05-06 17:45:16 +0000
committerJabiertxof <jtx@jtx>2017-05-06 17:45:16 +0000
commit5004996c798cdbad5ff7abbaf2e7272411631cee (patch)
tree9fbb940c15170a68e284dd8ca4a09f84eb8c311d /src
parentUpdating code to trunk (diff)
downloadinkscape-5004996c798cdbad5ff7abbaf2e7272411631cee.tar.gz
inkscape-5004996c798cdbad5ff7abbaf2e7272411631cee.zip
Pre merge fixing
(bzr r13645.1.177)
Diffstat (limited to 'src')
-rw-r--r--src/helper/geom-pathvectorsatellites.cpp5
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp56
-rw-r--r--src/live_effects/lpe-fillet-chamfer.h3
-rw-r--r--src/live_effects/parameter/satellitesarray.cpp15
-rw-r--r--src/live_effects/parameter/satellitesarray.h2
5 files changed, 51 insertions, 30 deletions
diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp
index dd231d78f..e995c0a9b 100644
--- a/src/helper/geom-pathvectorsatellites.cpp
+++ b/src/helper/geom-pathvectorsatellites.cpp
@@ -67,9 +67,7 @@ void PathVectorSatellites::setSelected(std::vector<size_t> selected)
size_t counter = 0;
for (size_t i = 0; i < _satellites.size(); ++i) {
for (size_t j = 0; j < _satellites[i].size(); ++j) {
- std::cout << j;
if (find (selected.begin(), selected.end(), counter) != selected.end()) {
-
_satellites[i][j].setSelected(true);
} else {
_satellites[i][j].setSelected(false);
@@ -134,6 +132,9 @@ void PathVectorSatellites::updateAmount(double radius, bool apply_no_radius, boo
if (!use_knot_distance && !flexible) {
if (previous_index) {
_satellites[i][j].amount = _satellites[i][j].radToLen(power, _pathvector[i][*previous_index], _pathvector[i][j]);
+ if (power && !_satellites[i][j].amount) {
+ g_warning("Seems a too high radius value");
+ }
} else {
_satellites[i][j].amount = 0.0;
}
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index abb6fa9d2..e968a7822 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -234,7 +234,15 @@ void LPEFilletChamfer::refreshKnots()
void LPEFilletChamfer::updateAmount()
{
- _pathvector_satellites->updateAmount(radius, apply_no_radius, apply_with_radius, only_selected,
+ setSelected(_pathvector_satellites);
+ double power = radius;
+ if (!flexible) {
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Glib::ustring display_unit = nv->display_units->abbr;
+ power = Inkscape::Util::Quantity::convert(power, unit.get_abbreviation(), display_unit.c_str());
+ }
+ _pathvector_satellites->updateAmount(power, apply_no_radius, apply_with_radius, only_selected,
use_knot_distance, flexible);
satellites_param.setPathVectorSatellites(_pathvector_satellites);
}
@@ -250,34 +258,45 @@ void LPEFilletChamfer::updateAmount()
void LPEFilletChamfer::updateChamferSteps()
{
+ setSelected(_pathvector_satellites);
_pathvector_satellites->updateSteps(chamfer_steps, apply_no_radius, apply_with_radius, only_selected);
satellites_param.setPathVectorSatellites(_pathvector_satellites);
}
void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype)
{
+ setSelected(_pathvector_satellites);
_pathvector_satellites->updateSatelliteType(satellitetype, apply_no_radius, apply_with_radius, only_selected);
satellites_param.setPathVectorSatellites(_pathvector_satellites);
}
+void LPEFilletChamfer::setSelected(PathVectorSatellites *_pathvector_satellites){
+ Geom::PathVector const pathv = _pathvector_satellites->getPathVector();
+ Satellites satellites = _pathvector_satellites->getSatellites();
+ for (size_t i = 0; i < satellites.size(); ++i) {
+ for (size_t j = 0; j < satellites[i].size(); ++j) {
+ Geom::Curve const &curve_in = pathv[i][j];
+ if (only_selected && isNodePointSelected(curve_in.initialPoint()) ){
+ satellites[i][j].setSelected(true);
+ } else {
+ satellites[i][j].setSelected(false);
+ }
+ }
+ }
+ _pathvector_satellites->setSatellites(satellites);
+}
+
void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
{
- SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem);
- SPShape *shape = dynamic_cast<SPShape *>(splpeitem);
- if (shape) {
- SPCurve *c = shape->getCurve();
- SPPath *path = dynamic_cast<SPPath *>(shape);
- if (path) {
- c = path->get_original_curve();
- }
+ if (sp_curve) {
//fillet chamfer specific calls
satellites_param.setUseDistance(use_knot_distance);
satellites_param.setCurrentZoom(current_zoom);
//mandatory call
satellites_param.setEffectType(effectType());
- Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
- //if are diferent sizes call to poinwise recalculate
- //TODO: Update the satellite data in paths modified, Goal 0.93
+ Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(sp_curve->get_pathvector());
+ //if are diferent sizes call to recalculate
+ //TODO: Update the satellite data in paths modified,
Satellites satellites = satellites_param.data();
if (satellites.empty()) {
doOnApply(lpeItem);
@@ -305,16 +324,15 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
} else {
satellites_param.setHelperSize(helper_size);
}
- size_t index = 0;
for (size_t i = 0; i < satellites.size(); ++i) {
for (size_t j = 0; j < satellites[i].size(); ++j) {
+ Geom::Curve const &curve_in = pathv[i][j];
if (satellites[i][j].is_time != flexible) {
satellites[i][j].is_time = flexible;
double amount = satellites[i][j].amount;
if (pathv[i].size() == j) {
continue;
}
- Geom::Curve const &curve_in = pathv[i][j];
if (satellites[i][j].is_time) {
double time = timeAtArcLength(amount, curve_in);
satellites[i][j].amount = time;
@@ -327,11 +345,9 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
satellites[i][j].has_mirror = mirror_knots;
}
satellites[i][j].hidden = hide_knots;
- Geom::Curve const &curve_in = pathv[i][j];
if (only_selected && isNodePointSelected(curve_in.initialPoint()) ){
- selected_nodes_index.push_back(index);
+ satellites[i][j].setSelected(true);
}
- index ++;
}
}
if (!_pathvector_satellites) {
@@ -339,10 +355,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
}
_pathvector_satellites->setPathVector(pathv);
_pathvector_satellites->setSatellites(satellites);
- if (only_selected) {
- _pathvector_satellites->setSelected(selected_nodes_index);
- }
- satellites_param.setPathVectorSatellites(_pathvector_satellites);
+ satellites_param.setPathVectorSatellites(_pathvector_satellites, false);
refreshKnots();
} else {
g_warning("LPE Fillet can only be applied to shapes (not groups).");
@@ -358,6 +371,7 @@ LPEFilletChamfer::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<
void
LPEFilletChamfer::addChamferSteps(Geom::Path &tmp_path, Geom::Path path_chamfer, Geom::Point end_arc_point, size_t steps)
{
+ setSelected(_pathvector_satellites);
double path_subdivision = 1.0 / steps;
for (size_t i = 1; i < steps; i++) {
Geom::Point chamfer_step = path_chamfer.pointAt(path_subdivision * i);
diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h
index 2cee04a1e..7f5dd7d4c 100644
--- a/src/live_effects/lpe-fillet-chamfer.h
+++ b/src/live_effects/lpe-fillet-chamfer.h
@@ -40,7 +40,8 @@ public:
void addChamferSteps(Geom::Path &tmp_path, Geom::Path path_chamfer, Geom::Point end_arc_point, size_t steps);
void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec);
void updateSatelliteType(SatelliteType satellitetype);
- //void convertUnit();
+ void setSelected(PathVectorSatellites *_pathvector_satellites);
+ //void convertUnit();
void updateChamferSteps();
void updateAmount();
void refreshKnots();
diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp
index c7bc7f026..7626317a1 100644
--- a/src/live_effects/parameter/satellitesarray.cpp
+++ b/src/live_effects/parameter/satellitesarray.cpp
@@ -39,6 +39,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label,
_last_pathvector_satellites = NULL;
}
+
void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
SPKnotModeType mode,
guint32 color)
@@ -48,10 +49,14 @@ void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
_knot_color = color;
}
-void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites)
+void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write)
{
_last_pathvector_satellites = pathVectorSatellites;
- param_set_and_write_new_value(_last_pathvector_satellites->getSatellites());
+ if (write) {
+ param_set_and_write_new_value(_last_pathvector_satellites->getSatellites());
+ } else {
+ param_setValue(_last_pathvector_satellites->getSatellites());
+ }
}
void SatellitesArrayParam::setUseDistance(bool use_knot_distance)
@@ -226,6 +231,9 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPItem *item,
bool mirror)
{
+ if (!_last_pathvector_satellites) {
+ return;
+ }
Geom::PathVector pathv = _last_pathvector_satellites->getPathVector();
size_t index = 0;
for (size_t i = 0; i < _vector.size(); ++i) {
@@ -442,7 +450,6 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
if (state & GDK_CONTROL_MASK) {
if (state & GDK_MOD1_MASK) {
_pparam->_vector[path_index][curve_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;
@@ -462,7 +469,6 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
break;
}
_pparam->_vector[path_index][curve_index].satellite_type = 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 == CHAMFER) {
@@ -555,7 +561,6 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite)
satellite.amount = amount;
_pparam->_vector[path_index][curve_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) {
sp_lpe_item_update_patheffect(splpeitem, false, false);
diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h
index edaf2f08d..5ae372ac2 100644
--- a/src/live_effects/parameter/satellitesarray.h
+++ b/src/live_effects/parameter/satellitesarray.h
@@ -55,7 +55,7 @@ public:
void setCurrentZoom(double current_zoom);
void setGlobalKnotHide(bool global_knot_hide);
void setEffectType(EffectType et);
- void setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites);
+ void setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write = true);
void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
friend class FilletChamferKnotHolderEntity;