[Libreoffice-commits] libvisio.git: 2 commits - src/lib

Fridrich Štrba fridrich.strba at bluewin.ch
Sat Jan 2 06:59:25 PST 2016


 src/lib/VSDContentCollector.cpp |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

New commits:
commit c3cd48cd4c896a77a07dcca0d0b01c067013e47f
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Sat Jan 2 15:58:58 2016 +0100

    Try to look a bit more like visio rounding
    
    Change-Id: I3ab893ec2e8851c93dc2882c73535e7a3955f9bb

diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 9560500..583ab9a 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -38,17 +38,22 @@ void computeRounding(double &prevX, double &prevY, double x0, double y0, double
                      double &newX0, double &newY0, double &newX, double &newY, double &maxRounding)
 {
   double prevHalfLength = sqrt((y0-prevY)*(y0-prevY)+(x0-prevX)*(x0-prevX)) / 2.0;
-  if (maxRounding > prevHalfLength)
-    maxRounding = prevHalfLength;
   double halfLength = sqrt((y-y0)*(y-y0)+(x-x0)*(x-x0)) / 2.0;
+  maxRounding = prevHalfLength;
   if (maxRounding > halfLength)
     maxRounding = halfLength;
-  if (maxRounding > rounding)
-    maxRounding = rounding;
   double lambda1 = atan2(y0-prevY, x0-prevX);
+  double lambda2 = atan2(y-y0, x-x0);
+  double angle = M_PI - lambda2 + lambda1;
+  if (angle < 0.0)
+    angle += 2.0*M_PI;
+  if (angle > M_PI)
+    angle -= M_PI;
+  double q = fabs(rounding / tan(angle / 2.0));
+  if (maxRounding > q)
+    maxRounding = q;
   newX0 = x0-maxRounding*cos(lambda1);
   newY0 = y0-maxRounding*sin(lambda1);
-  double lambda2 = atan2(y-y0, x-x0);
   newX = x0+maxRounding*cos(lambda2);
   newY = y0+maxRounding*sin(lambda2);
   prevX = x0;
commit 70f19aebaa21586aa2833b2685dc12fbfaea1923
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Sat Jan 2 15:02:54 2016 +0100

    Small improvement
    
    Change-Id: Id5832d351fb39c2d0889dbcecd12b1228e1a3e9b

diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 8ded8c8..9560500 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -37,6 +37,9 @@ namespace
 void computeRounding(double &prevX, double &prevY, double x0, double y0, double x, double y, double rounding,
                      double &newX0, double &newY0, double &newX, double &newY, double &maxRounding)
 {
+  double prevHalfLength = sqrt((y0-prevY)*(y0-prevY)+(x0-prevX)*(x0-prevX)) / 2.0;
+  if (maxRounding > prevHalfLength)
+    maxRounding = prevHalfLength;
   double halfLength = sqrt((y-y0)*(y-y0)+(x-x0)*(x-x0)) / 2.0;
   if (maxRounding > halfLength)
     maxRounding = halfLength;
@@ -48,10 +51,9 @@ void computeRounding(double &prevX, double &prevY, double x0, double y0, double
   double lambda2 = atan2(y-y0, x-x0);
   newX = x0+maxRounding*cos(lambda2);
   newY = y0+maxRounding*sin(lambda2);
-  prevX = newX;
-  prevY = newY;
+  prevX = x0;
+  prevY = y0;
   maxRounding = halfLength;
-
 }
 
 } // anonymous namespace


More information about the Libreoffice-commits mailing list