summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/transformation.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-07-04 15:27:06 +0000
committerJaviertxo <jtx@jtx.marker.es>2013-07-04 15:27:06 +0000
commitb8ef835cd10460cf7548bae4970b395e9d7767d9 (patch)
tree12e14b42023385cf8bf8192c2ae482a4f59deff1 /src/ui/dialog/transformation.cpp
parentIm not sure what changes are (diff)
parentShape calculations. do not quantize the coordinates. (Bug 168158) (diff)
downloadinkscape-b8ef835cd10460cf7548bae4970b395e9d7767d9.tar.gz
inkscape-b8ef835cd10460cf7548bae4970b395e9d7767d9.zip
Upadate to trunk
(bzr r11950.1.122)
Diffstat (limited to 'src/ui/dialog/transformation.cpp')
-rw-r--r--src/ui/dialog/transformation.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index c071fcf95..ce8af3f1f 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -15,6 +15,10 @@
# include <config.h>
#endif
+#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
+#include <glibmm/threads.h>
+#endif
+
#include <gtkmm/dialog.h>
#include <gtkmm/stock.h>
#include <2geom/transforms.h>
@@ -27,6 +31,7 @@
#include "inkscape.h"
#include "selection.h"
#include "selection-chemistry.h"
+#include "message-stack.h"
#include "verbs.h"
#include "preferences.h"
#include "sp-namedview.h"
@@ -758,7 +763,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
double move = x;
for ( std::vector<BBoxSort> ::iterator it (sorted.begin());
it < sorted.end();
- it ++ )
+ ++it )
{
sp_item_move_rel(it->item, Geom::Translate(move, 0));
// move each next object by x relative to previous
@@ -782,7 +787,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
double move = y;
for ( std::vector<BBoxSort> ::iterator it (sorted.begin());
it < sorted.end();
- it ++ )
+ ++it )
{
sp_item_move_rel(it->item, Geom::Translate(0, move));
// move each next object by x relative to previous
@@ -898,10 +903,21 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
if (!_units_skew.isAbsolute()) { // percentage
double skewX = _scalar_skew_horizontal.getValue("%");
double skewY = _scalar_skew_vertical.getValue("%");
+ if (fabs(0.01*skewX*0.01*skewY - 1.0) < Geom::EPSILON) {
+ sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ return;
+ }
sp_item_skew_rel (item, 0.01*skewX, 0.01*skewY);
} else if (_units_skew.isRadial()) { //deg or rad
double angleX = _scalar_skew_horizontal.getValue("rad");
double angleY = _scalar_skew_vertical.getValue("rad");
+ if ((fabs(angleX - angleY + M_PI/2) < Geom::EPSILON)
+ || (fabs(angleX - angleY - M_PI/2) < Geom::EPSILON)
+ || (fabs((angleX - angleY)/3 + M_PI/2) < Geom::EPSILON)
+ || (fabs((angleX - angleY)/3 - M_PI/2) < Geom::EPSILON)) {
+ sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ return;
+ }
double skewX = tan(-angleX);
double skewY = tan(angleY);
sp_item_skew_rel (item, skewX, skewY);
@@ -912,6 +928,10 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
if (bbox) {
double width = bbox->dimensions()[Geom::X];
double height = bbox->dimensions()[Geom::Y];
+ if (fabs(skewX*skewY - width*height) < Geom::EPSILON) {
+ sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ return;
+ }
sp_item_skew_rel (item, skewX/height, skewY/width);
}
}
@@ -927,16 +947,31 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
if (!_units_skew.isAbsolute()) { // percentage
double skewX = _scalar_skew_horizontal.getValue("%");
double skewY = _scalar_skew_vertical.getValue("%");
+ if (fabs(0.01*skewX*0.01*skewY - 1.0) < Geom::EPSILON) {
+ sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ return;
+ }
sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY);
} else if (_units_skew.isRadial()) { //deg or rad
double angleX = _scalar_skew_horizontal.getValue("rad");
double angleY = _scalar_skew_vertical.getValue("rad");
+ if ((fabs(angleX - angleY + M_PI/2) < Geom::EPSILON)
+ || (fabs(angleX - angleY - M_PI/2) < Geom::EPSILON)
+ || (fabs((angleX - angleY)/3 + M_PI/2) < Geom::EPSILON)
+ || (fabs((angleX - angleY)/3 - M_PI/2) < Geom::EPSILON)) {
+ sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ return;
+ }
double skewX = tan(-angleX);
double skewY = tan(angleY);
sp_selection_skew_relative(selection, *center, skewX, skewY);
} else { // absolute displacement
double skewX = _scalar_skew_horizontal.getValue("px");
double skewY = _scalar_skew_vertical.getValue("px");
+ if (fabs(skewX*skewY - width*height) < Geom::EPSILON) {
+ sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ return;
+ }
sp_selection_skew_relative(selection, *center, skewX/height, skewY/width);
}
}
@@ -957,6 +992,10 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection)
double f = _scalar_transform_f.getValue();
Geom::Affine displayed(a, b, c, d, e, f);
+ if (displayed.isSingular()) {
+ sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ return;
+ }
if (_check_replace_matrix.get_active()) {
for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {