ooo-build r12499 - in branches/ooo-build-2-4: . patches/src680



Author: thorstenb
Date: Fri May  9 10:56:45 2008
New Revision: 12499
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12499&view=rev

Log:
	* patches/src680/svg-import-basegfx.diff: (almost) finished
	elliptical arc emulation via cubic beziers



Modified:
   branches/ooo-build-2-4/ChangeLog
   branches/ooo-build-2-4/patches/src680/svg-import-basegfx.diff

Modified: branches/ooo-build-2-4/patches/src680/svg-import-basegfx.diff
==============================================================================
--- branches/ooo-build-2-4/patches/src680/svg-import-basegfx.diff	(original)
+++ branches/ooo-build-2-4/patches/src680/svg-import-basegfx.diff	Fri May  9 10:56:45 2008
@@ -43,8 +43,8 @@
  
  		// create 3d PolyPolygon from given 2d PolyPolygon. The given fZCoordinate is used to expand the
  		// third coordinate.
---- basegfx/source/polygon/b2dsvgpolypolygon.cxx	18 Jul 2007 11:07:24 -0000	1.7
-+++ basegfx/source/polygon/b2dsvgpolypolygon.cxx	28 Feb 2008 11:11:31 -0000
+--- basegfx/source/polygon/b2dsvgpolypolygon.cxx.orig	2008-05-09 12:49:06.000000000 +0200
++++ basegfx/source/polygon/b2dsvgpolypolygon.cxx	2008-05-09 12:53:16.000000000 +0200
 @@ -37,7 +37,9 @@
  #include "precompiled_basegfx.hxx"
  
@@ -102,7 +102,7 @@
              void lcl_skipNumber(sal_Int32& 				io_rPos, 
                                  const ::rtl::OUString& 	rStr, 
                                  const sal_Int32 		nLen)
-@@ -623,24 +656,169 @@
+@@ -623,24 +656,185 @@
                          break;
                      }
  
@@ -168,9 +168,9 @@
 +                                // |y1'| = |-sin phi  cos phi|  |(y1 - y2)/2|
 +                                const B2DPoint p1(nLastX, nLastY);
 +                                const B2DPoint p2(nX, nY);
-+                                B2DHomMatrix aRotate; aRotate.rotate(-fPhi*M_PI/180);
++                                B2DHomMatrix aTransform; aTransform.rotate(-fPhi*M_PI/180);
 +                                
-+                                const B2DPoint p1_prime( aRotate * B2DPoint(((p1-p2)/2.0)) );
++                                const B2DPoint p1_prime( aTransform * B2DPoint(((p1-p2)/2.0)) );
 +
 +                                //           ______________________________________       rx y1'
 +                                // |cx'|  + /  rx^2 ry^2 - rx^2 y1'^2 - ry^2 x1^2           ry
@@ -192,7 +192,7 @@
 +                                    // with s=fRX/fRY)
 +                                    const double fRatio(fRX/fRY);
 +                                    const double fRadicant2(
-+                                        p1_prime.getY()*p1_prime.getY() - 
++                                        p1_prime.getY()*p1_prime.getY() +
 +                                        p1_prime.getX()*p1_prime.getX()/(fRatio*fRatio));
 +                                    if( fRadicant2 < 0.0 )
 +                                    {
@@ -211,6 +211,19 @@
 +                                }
 +                                else
 +                                {
++                                    // todo:   <path d="M200,100 h 50 
++                                    // a25,50 20 0,0 50,-25 l 50,-25"
++                                    // fill="none" stroke="green" stroke-width="5"  />
++                                    //
++                                    // sweep flag not considered right for e.g. 
++                                    // <path d="M0,400 l 50,-25 
++                                    // a25,25 -30 0,1 50,-25 l 50,-25 
++                                    // a25,50 -30 0,1 50,-25 l 50,-25 
++                                    // a25,75 -30 0,1 50,-25 l 50,-25 
++                                    // a25,100 -30 0,1 50,-25 l 50,-25"
++                                    // fill="none" stroke="red" stroke-width="5"  />
++
++
 +                                    const double fFactor(
 +                                        (bLargeArcFlag==bSweepFlag) ? -1.0 : 1.0 *
 +                                        sqrt((fRX*fRX*fRY*fRY - fRX*fRX*p1_prime.getY()*p1_prime.getY() - fRY*fRY*p1_prime.getX()*p1_prime.getX())/
@@ -222,12 +235,6 @@
 +                                        -fFactor*fRY*p1_prime.getX()/fRX);
 +                                }
 +
-+                                // |cx|   | cos phi  -sin phi |  | cx' |    (x1+x2)/2
-+                                // |cy| = | sin phi   cos phi |  | cy' | +  (y1+y2)/2 
-+                                aRotate.identity(); aRotate.rotate(fPhi*M_PI/180);
-+                                const B2DPoint aCenter( aRotate * aCenter_prime + 
-+                                                        (p1+p2)/2.0);
-+                                
 +                                //              +           u - v 
 +                                // angle(u,v) =  arccos( ------------ )     (take the sign of (ux vy - uy vx))
 +                                //              -        ||u|| ||v||
@@ -263,11 +270,20 @@
 +
 +                                // finally, create bezier polygon from this
 +                                B2DPolygon aSegment(
-+                                    tools::createPolygonFromEllipseSegment( 
-+                                        aCenter,
-+                                        fRX,fRY,
++                                    tools::createPolygonFromUnitEllipseSegment( 
 +                                        fTheta1, fTheta2 ));
 +
++                                // transform ellipse by rotation & move to final center
++                                aTransform.identity(); 
++                                aTransform.scale(fRX,fRY);
++                                aTransform.translate(aCenter_prime.getX(),
++                                                     aCenter_prime.getY());
++                                aTransform.rotate(fPhi*M_PI/180);
++                                const B2DPoint aOffset((p1+p2)/2.0);
++                                aTransform.translate(aOffset.getX(),
++                                                     aOffset.getY());
++                                aSegment.transform(aTransform);
++                                
 +                                // createPolygonFromEllipseSegment()
 +                                // always creates arcs that are
 +                                // positively oriented - flip polygon
@@ -283,7 +299,7 @@
                          }
                          break;
                      }
-@@ -665,6 +843,32 @@
+@@ -665,6 +859,32 @@
              return true;
          }
  
@@ -316,7 +332,7 @@
          ::rtl::OUString exportToSvgD(
  			const B2DPolyPolygon& rPolyPolygon,
  			bool bUseRelativeCoordinates, 
-@@ -678,13 +882,23 @@
+@@ -678,13 +898,23 @@
              {
                  const B2DPolygon aPolygon(rPolyPolygon.getB2DPolygon(i));
                  const sal_uInt32 nPointCount(aPolygon.count());
@@ -342,7 +358,7 @@
  
                      if(0 == j)
                      {
-@@ -697,16 +911,18 @@
+@@ -697,16 +927,18 @@
                      else
                      {
  						// handle edge from j-1 to j
@@ -368,7 +384,7 @@
  							bool bIsQuadraticBezier(false);
  
  							if(bDetectQuadraticBeziers)
-@@ -798,7 +1014,13 @@
+@@ -798,7 +1030,13 @@
                          }
                          else
                          {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]