1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_basegfx.hxx"
30*cdf0e10cSrcweir #include <osl/diagnose.h>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <basegfx/curve/b2dcubicbezier.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <basegfx/tools/debugplotter.hxx>
35*cdf0e10cSrcweir #include <boost/bind.hpp>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir namespace basegfx
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir     namespace
41*cdf0e10cSrcweir     {
42*cdf0e10cSrcweir         void outputHeader( const ::rtl::OString& rTitle,
43*cdf0e10cSrcweir                            ::std::ostream* 		 pStm )
44*cdf0e10cSrcweir         {
45*cdf0e10cSrcweir             // output gnuplot setup
46*cdf0e10cSrcweir             if( pStm )
47*cdf0e10cSrcweir             {
48*cdf0e10cSrcweir                 *pStm << "#!/usr/bin/gnuplot -persist" << ::std::endl <<
49*cdf0e10cSrcweir                     "#" << ::std::endl <<
50*cdf0e10cSrcweir                     "# automatically generated by basegfx, don't change!" << ::std::endl <<
51*cdf0e10cSrcweir                     "#" << ::std::endl <<
52*cdf0e10cSrcweir                     "#   --- " << (const sal_Char*)rTitle << " ---" << ::std::endl <<
53*cdf0e10cSrcweir                     "#" << ::std::endl <<
54*cdf0e10cSrcweir                     "set parametric" << ::std::endl <<
55*cdf0e10cSrcweir                     "# set terminal postscript eps enhanced color " << ::std::endl <<
56*cdf0e10cSrcweir                     "# set output \"plot.eps\"" << ::std::endl <<
57*cdf0e10cSrcweir                     // This function plots a cubic bezier curve. P,q,r,s
58*cdf0e10cSrcweir                     // are the control point elements of the corresponding
59*cdf0e10cSrcweir                     // output coordinate component (i.e. x components for
60*cdf0e10cSrcweir                     // the x plot, and y components for the y plot)
61*cdf0e10cSrcweir                     "cubicBezier(p,q,r,s,t) = p*(1-t)**3+q*3*(1-t)**2*t+r*3*(1-t)*t**2+s*t**3" << ::std::endl <<
62*cdf0e10cSrcweir                     // This function plots the derivative of a cubic
63*cdf0e10cSrcweir                     // bezier curve. P,q,r,s are the control point
64*cdf0e10cSrcweir                     // components of the _original_ curve
65*cdf0e10cSrcweir                     "cubicBezDerivative(p,q,r,s,t) = 3*(q-p)*(1-t)**2+6*(r-q)*(1-t)*t+3*(s-r)*t**2" << ::std::endl <<
66*cdf0e10cSrcweir                     // Plot a line's component of a line between a and b
67*cdf0e10cSrcweir                     // (where a and b should be the corresponding
68*cdf0e10cSrcweir                     // components of the line's start and end point,
69*cdf0e10cSrcweir                     // respectively)
70*cdf0e10cSrcweir                     "line(p,q,r) = p*(1-t)+q*t" << ::std::endl <<
71*cdf0e10cSrcweir                     // Plot a line's x component of a line in implicit
72*cdf0e10cSrcweir                     // form ax + by + c = 0
73*cdf0e10cSrcweir                     "implicitLineX(a,b,c,t) = a*-c + t*-b" << ::std::endl <<
74*cdf0e10cSrcweir                     // Plot a line's y component of a line in implicit
75*cdf0e10cSrcweir                     // form ax + by + c = 0
76*cdf0e10cSrcweir                     "implicitLineY(a,b,c,t) = b*-c + t*a" << ::std::endl <<
77*cdf0e10cSrcweir                     "pointmarkx(c,t) = c-0.03*t" << ::std::endl <<										 // hack for displaying single points in parametric form
78*cdf0e10cSrcweir                     "pointmarky(c,t) = c+0.03*t" << ::std::endl <<										 // hack for displaying single points in parametric form
79*cdf0e10cSrcweir                     "# end of setup" << ::std::endl;
80*cdf0e10cSrcweir             }
81*cdf0e10cSrcweir             else
82*cdf0e10cSrcweir             {
83*cdf0e10cSrcweir                 OSL_TRACE( "#!/usr/bin/gnuplot -persist\n",
84*cdf0e10cSrcweir                            "#\n",
85*cdf0e10cSrcweir                            "# automatically generated by basegfx, don't change!\n",
86*cdf0e10cSrcweir                            "#\n",
87*cdf0e10cSrcweir                            "#   --- %s ---\n",
88*cdf0e10cSrcweir                            "#\n",
89*cdf0e10cSrcweir                            "set parametric\n",
90*cdf0e10cSrcweir                            // This function plots a cubic bezier curve. P,q,r,s
91*cdf0e10cSrcweir                            // are the control point elements of the corresponding
92*cdf0e10cSrcweir                            // output coordinate component (i.e. x components for
93*cdf0e10cSrcweir                            // the x plot, and y components for the y plot)
94*cdf0e10cSrcweir                            "cubicBezier(p,q,r,s,t) = p*(1-t)**3+q*3*(1-t)**2*t+r*3*(1-t)*t**2+s*t**3\n",
95*cdf0e10cSrcweir                            // This function plots the derivative of a cubic
96*cdf0e10cSrcweir                            // bezier curve. P,q,r,s are the control point
97*cdf0e10cSrcweir                            // components of the _original_ curve
98*cdf0e10cSrcweir                            "cubicBezDerivative(p,q,r,s,t) = 3*(q-p)*(1-t)**2+6*(r-q)*(1-t)*t+3*(s-r)*t**2\n",
99*cdf0e10cSrcweir                            // Plot a line's component of a line between a and b
100*cdf0e10cSrcweir                            // (where a and b should be the corresponding
101*cdf0e10cSrcweir                            // components of the line's start and end point,
102*cdf0e10cSrcweir                            // respectively)
103*cdf0e10cSrcweir                            "line(p,q,r) = p*(1-t)+q*t\n",
104*cdf0e10cSrcweir                            // Plot a line's x component of a line in implicit
105*cdf0e10cSrcweir                            // form ax + by + c = 0
106*cdf0e10cSrcweir                            "implicitLineX(a,b,c,t) = a*-c + t*-b\n",
107*cdf0e10cSrcweir                            // Plot a line's y component of a line in implicit
108*cdf0e10cSrcweir                            // form ax + by + c = 0
109*cdf0e10cSrcweir                            "implicitLineY(a,b,c,t) = b*-c + t*a\n",
110*cdf0e10cSrcweir                            "pointmarkx(c,t) = c-0.03*t\n",										 // hack for displaying single points in parametric form
111*cdf0e10cSrcweir                            "pointmarky(c,t) = c+0.03*t\n",										 // hack for displaying single points in parametric form
112*cdf0e10cSrcweir                            "# end of setup\n",
113*cdf0e10cSrcweir                            (const sal_Char*)rTitle );
114*cdf0e10cSrcweir             }
115*cdf0e10cSrcweir         }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir         class Writer
118*cdf0e10cSrcweir         {
119*cdf0e10cSrcweir         public:
120*cdf0e10cSrcweir             Writer( ::std::ostream* pStm ) :
121*cdf0e10cSrcweir                 mpStream( pStm )
122*cdf0e10cSrcweir             {
123*cdf0e10cSrcweir             }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir             void outputPoint( const ::std::pair< B2DPoint, ::rtl::OString >& rElem )
126*cdf0e10cSrcweir             {
127*cdf0e10cSrcweir                 if( mpStream )
128*cdf0e10cSrcweir                     *mpStream << " " << rElem.first.getX() << "\t" << rElem.first.getY() << ::std::endl;
129*cdf0e10cSrcweir                 else
130*cdf0e10cSrcweir                     OSL_TRACE( " %f\t%f\n", rElem.first.getX(), rElem.first.getY() );
131*cdf0e10cSrcweir             }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir             void outputVector( const ::std::pair< B2DVector, ::rtl::OString >& rElem )
134*cdf0e10cSrcweir             {
135*cdf0e10cSrcweir                 if( mpStream )
136*cdf0e10cSrcweir                     *mpStream << " " << rElem.first.getX() << "\t" << rElem.first.getY() << ::std::endl << ::std::endl;
137*cdf0e10cSrcweir                 else
138*cdf0e10cSrcweir                     OSL_TRACE( " %f\t%f\n\n", rElem.first.getX(), rElem.first.getY() );
139*cdf0e10cSrcweir             }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir             void outputRect( const ::std::pair< B2DRange, ::rtl::OString >& rElem )
142*cdf0e10cSrcweir             {
143*cdf0e10cSrcweir                 const double nX0( rElem.first.getMinX() );
144*cdf0e10cSrcweir                 const double nY0( rElem.first.getMinY() );
145*cdf0e10cSrcweir                 const double nX1( rElem.first.getMaxX() );
146*cdf0e10cSrcweir                 const double nY1( rElem.first.getMaxY() );
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir                 if( mpStream )
149*cdf0e10cSrcweir                     *mpStream << " "
150*cdf0e10cSrcweir                               << nX0 << "\t" << nY0 << "\t"
151*cdf0e10cSrcweir                               << nX1 << "\t" << nY0 << "\t"
152*cdf0e10cSrcweir                               << nX1 << "\t" << nY1 << "\t"
153*cdf0e10cSrcweir                               << nX0 << "\t" << nY1 << "\t"
154*cdf0e10cSrcweir                               << nX0 << "\t" << nY0 << ::std::endl << ::std::endl;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir                 else
157*cdf0e10cSrcweir                     OSL_TRACE( " %f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n\n",
158*cdf0e10cSrcweir                                nX0, nY0,
159*cdf0e10cSrcweir                                nX1, nY0,
160*cdf0e10cSrcweir                                nX1, nY1,
161*cdf0e10cSrcweir                                nX0, nY1,
162*cdf0e10cSrcweir                                nX0, nY0 );
163*cdf0e10cSrcweir             }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         private:
166*cdf0e10cSrcweir             ::std::ostream* 	mpStream;
167*cdf0e10cSrcweir         };
168*cdf0e10cSrcweir     }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     DebugPlotter::DebugPlotter( const sal_Char* pTitle ) :
171*cdf0e10cSrcweir         maTitle( pTitle ),
172*cdf0e10cSrcweir         maPoints(),
173*cdf0e10cSrcweir         maVectors(),
174*cdf0e10cSrcweir         maRanges(),
175*cdf0e10cSrcweir         maPolygons(),
176*cdf0e10cSrcweir         mpOutputStream(NULL)
177*cdf0e10cSrcweir     {
178*cdf0e10cSrcweir     }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     DebugPlotter::DebugPlotter( const sal_Char* pTitle,
181*cdf0e10cSrcweir                                 ::std::ostream& rOutputStream ) :
182*cdf0e10cSrcweir         maTitle( pTitle ),
183*cdf0e10cSrcweir         maPoints(),
184*cdf0e10cSrcweir         maVectors(),
185*cdf0e10cSrcweir         maRanges(),
186*cdf0e10cSrcweir         maPolygons(),
187*cdf0e10cSrcweir         mpOutputStream(&rOutputStream)
188*cdf0e10cSrcweir     {
189*cdf0e10cSrcweir     }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     DebugPlotter::~DebugPlotter()
192*cdf0e10cSrcweir     {
193*cdf0e10cSrcweir         const bool bHavePoints( !maPoints.empty() );
194*cdf0e10cSrcweir         const bool bHaveVectors( !maVectors.empty() );
195*cdf0e10cSrcweir         const bool bHaveRanges( !maRanges.empty() );
196*cdf0e10cSrcweir         const bool bHavePolygons( !maPolygons.empty() );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir         if( bHavePoints ||
199*cdf0e10cSrcweir             bHaveVectors ||
200*cdf0e10cSrcweir             bHaveRanges ||
201*cdf0e10cSrcweir             bHavePolygons )
202*cdf0e10cSrcweir         {
203*cdf0e10cSrcweir             outputHeader( maTitle, mpOutputStream );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir             print( "\n\n# parametric primitive output\n"
206*cdf0e10cSrcweir                    "plot [t=0:1] \\\n" );
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir             // output plot declarations for used entities
209*cdf0e10cSrcweir             bool bNeedColon( false );
210*cdf0e10cSrcweir             if( bHavePoints )
211*cdf0e10cSrcweir             {
212*cdf0e10cSrcweir                 print( " '-' using ($1):($2) title \"Points\" with points" );
213*cdf0e10cSrcweir                 bNeedColon = true;
214*cdf0e10cSrcweir             }
215*cdf0e10cSrcweir             if( bHaveVectors )
216*cdf0e10cSrcweir             {
217*cdf0e10cSrcweir                 if( bNeedColon )
218*cdf0e10cSrcweir                     print( ", \\\n" );
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir                 print( " '-' using ($1):($2) title \"Vectors\" with lp" );
221*cdf0e10cSrcweir                 bNeedColon = true;
222*cdf0e10cSrcweir             }
223*cdf0e10cSrcweir             if( bHaveRanges )
224*cdf0e10cSrcweir             {
225*cdf0e10cSrcweir                 if( bNeedColon )
226*cdf0e10cSrcweir                     print( ", \\\n" );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir                 print( " '-' using ($1):($2) title \"Ranges\" with lines" );
229*cdf0e10cSrcweir                 bNeedColon = true;
230*cdf0e10cSrcweir             }
231*cdf0e10cSrcweir             if( bHavePolygons )
232*cdf0e10cSrcweir             {
233*cdf0e10cSrcweir                 const ::std::size_t nSize( maPolygons.size() );
234*cdf0e10cSrcweir                 for( ::std::size_t i=0; i<nSize; ++i )
235*cdf0e10cSrcweir                 {
236*cdf0e10cSrcweir                     if( maPolygons.at(i).first.areControlPointsUsed() )
237*cdf0e10cSrcweir                     {
238*cdf0e10cSrcweir                         const B2DPolygon& rCurrPoly( maPolygons.at(i).first );
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir                         const sal_uInt32 nCount( rCurrPoly.count() );
241*cdf0e10cSrcweir                         for( sal_uInt32 k=0; k<nCount; ++k )
242*cdf0e10cSrcweir                         {
243*cdf0e10cSrcweir                             if( bNeedColon )
244*cdf0e10cSrcweir                                 print( ", \\\n" );
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir                             const B2DPoint& rP0( rCurrPoly.getB2DPoint(k) );
247*cdf0e10cSrcweir                             const B2DPoint& rP1( rCurrPoly.getNextControlPoint(k) );
248*cdf0e10cSrcweir                             const B2DPoint& rP2( rCurrPoly.getPrevControlPoint((k + 1) % nCount) );
249*cdf0e10cSrcweir                             const B2DPoint& rP3( k+1<nCount ? rCurrPoly.getB2DPoint(k+1) : rCurrPoly.getB2DPoint(k) );
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir                             if( mpOutputStream )
252*cdf0e10cSrcweir                                 *mpOutputStream << "  cubicBezier("
253*cdf0e10cSrcweir                                                 << rP0.getX() << ","
254*cdf0e10cSrcweir                                     << rP1.getX() << ","
255*cdf0e10cSrcweir                                     << rP2.getX() << ","
256*cdf0e10cSrcweir                                     << rP3.getX() << ",t), \\\n   cubicBezier("
257*cdf0e10cSrcweir                                     << rP0.getY() << ","
258*cdf0e10cSrcweir                                     << rP1.getY() << ","
259*cdf0e10cSrcweir                                     << rP2.getY() << ","
260*cdf0e10cSrcweir                                     << rP3.getY() << ",t)";
261*cdf0e10cSrcweir                             else
262*cdf0e10cSrcweir                                 OSL_TRACE( "  cubicBezier(%f,%f,%f,%f,t), \\\n"
263*cdf0e10cSrcweir                                            "   cubicBezier(%f,%f,%f,%f,t)",
264*cdf0e10cSrcweir                                            rP0.getX(),
265*cdf0e10cSrcweir                                            rP1.getX(),
266*cdf0e10cSrcweir                                            rP2.getX(),
267*cdf0e10cSrcweir                                            rP3.getX(),
268*cdf0e10cSrcweir                                            rP0.getY(),
269*cdf0e10cSrcweir                                            rP1.getY(),
270*cdf0e10cSrcweir                                            rP2.getY(),
271*cdf0e10cSrcweir                                            rP3.getY() );
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir                             bNeedColon = true;
274*cdf0e10cSrcweir                         }
275*cdf0e10cSrcweir                     }
276*cdf0e10cSrcweir                     else
277*cdf0e10cSrcweir                     {
278*cdf0e10cSrcweir                         if( bNeedColon )
279*cdf0e10cSrcweir                             print( ", \\\n" );
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir                         if( mpOutputStream )
282*cdf0e10cSrcweir                             *mpOutputStream << " '-' using ($1):($2) title \"Polygon "
283*cdf0e10cSrcweir                                             << (const sal_Char*)maPolygons.at(i).second << "\" with lp";
284*cdf0e10cSrcweir                         else
285*cdf0e10cSrcweir                             OSL_TRACE( " '-' using ($1):($2) title \"Polygon %s\" with lp",
286*cdf0e10cSrcweir                                        (const sal_Char*)maPolygons.at(i).second );
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir                         bNeedColon = true;
289*cdf0e10cSrcweir                     }
290*cdf0e10cSrcweir                 }
291*cdf0e10cSrcweir             }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir             if( bHavePoints )
294*cdf0e10cSrcweir             {
295*cdf0e10cSrcweir                 Writer aWriter( mpOutputStream );
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir                 ::std::for_each( maPoints.begin(),
298*cdf0e10cSrcweir                                  maPoints.end(),
299*cdf0e10cSrcweir                                  ::boost::bind( &Writer::outputPoint,
300*cdf0e10cSrcweir                                                 ::boost::ref( aWriter ),
301*cdf0e10cSrcweir                                                 _1 ) );
302*cdf0e10cSrcweir                 print( "e\n" );
303*cdf0e10cSrcweir             }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir             if( bHaveVectors )
306*cdf0e10cSrcweir             {
307*cdf0e10cSrcweir                 Writer aWriter( mpOutputStream );
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir                 ::std::for_each( maVectors.begin(),
310*cdf0e10cSrcweir                                  maVectors.end(),
311*cdf0e10cSrcweir                                  ::boost::bind( &Writer::outputVector,
312*cdf0e10cSrcweir                                                 ::boost::ref( aWriter ),
313*cdf0e10cSrcweir                                                 _1 ) );
314*cdf0e10cSrcweir                 print( "e\n" );
315*cdf0e10cSrcweir             }
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir             if( bHaveRanges )
318*cdf0e10cSrcweir             {
319*cdf0e10cSrcweir                 Writer aWriter( mpOutputStream );
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir                 ::std::for_each( maRanges.begin(),
322*cdf0e10cSrcweir                                  maRanges.end(),
323*cdf0e10cSrcweir                                  ::boost::bind( &Writer::outputRect,
324*cdf0e10cSrcweir                                                 ::boost::ref( aWriter ),
325*cdf0e10cSrcweir                                                 _1 ) );
326*cdf0e10cSrcweir                 print( "e\n" );
327*cdf0e10cSrcweir             }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir             if( bHavePolygons )
330*cdf0e10cSrcweir             {
331*cdf0e10cSrcweir                 const ::std::size_t nSize( maPolygons.size() );
332*cdf0e10cSrcweir                 for( ::std::size_t i=0; i<nSize; ++i )
333*cdf0e10cSrcweir                 {
334*cdf0e10cSrcweir                     if( !maPolygons.at(i).first.areControlPointsUsed() )
335*cdf0e10cSrcweir                     {
336*cdf0e10cSrcweir                         const B2DPolygon& rCurrPoly( maPolygons.at(i).first );
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir                         const sal_uInt32 nCount( rCurrPoly.count() );
339*cdf0e10cSrcweir                         for( sal_uInt32 k=0; k<nCount; ++k )
340*cdf0e10cSrcweir                         {
341*cdf0e10cSrcweir                             const B2DPoint& rP( rCurrPoly.getB2DPoint(k) );
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir                             if( mpOutputStream )
344*cdf0e10cSrcweir                                 *mpOutputStream << " " << rP.getX() << "," << rP.getY();
345*cdf0e10cSrcweir                             else
346*cdf0e10cSrcweir                                 OSL_TRACE( " %f,%f",
347*cdf0e10cSrcweir                                            rP.getX(),
348*cdf0e10cSrcweir                                            rP.getX() );
349*cdf0e10cSrcweir                         }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir                         print( "\ne\n" );
352*cdf0e10cSrcweir                     }
353*cdf0e10cSrcweir                 }
354*cdf0e10cSrcweir             }
355*cdf0e10cSrcweir         }
356*cdf0e10cSrcweir     }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir     void DebugPlotter::plot( const B2DPoint& rPoint,
359*cdf0e10cSrcweir                              const sal_Char* pTitle )
360*cdf0e10cSrcweir     {
361*cdf0e10cSrcweir         maPoints.push_back( ::std::make_pair( rPoint,
362*cdf0e10cSrcweir                                               ::rtl::OString( pTitle ) ) );
363*cdf0e10cSrcweir     }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     void DebugPlotter::plot( const B2DVector&	rVec,
366*cdf0e10cSrcweir                              const sal_Char* 	pTitle )
367*cdf0e10cSrcweir     {
368*cdf0e10cSrcweir         maVectors.push_back( ::std::make_pair( rVec,
369*cdf0e10cSrcweir                                                ::rtl::OString( pTitle ) ) );
370*cdf0e10cSrcweir     }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir     void DebugPlotter::plot( const B2DCubicBezier&	rBezier,
373*cdf0e10cSrcweir                              const sal_Char* 		pTitle )
374*cdf0e10cSrcweir     {
375*cdf0e10cSrcweir         B2DPolygon aPoly;
376*cdf0e10cSrcweir         aPoly.append(rBezier.getStartPoint());
377*cdf0e10cSrcweir 		aPoly.appendBezierSegment(rBezier.getControlPointA(), rBezier.getControlPointB(), rBezier.getEndPoint());
378*cdf0e10cSrcweir         maPolygons.push_back( ::std::make_pair( aPoly,
379*cdf0e10cSrcweir                                                 ::rtl::OString( pTitle ) ) );
380*cdf0e10cSrcweir     }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir     void DebugPlotter::plot( const B2DRange& rRange,
383*cdf0e10cSrcweir                              const sal_Char* pTitle )
384*cdf0e10cSrcweir     {
385*cdf0e10cSrcweir         maRanges.push_back( ::std::make_pair( rRange,
386*cdf0e10cSrcweir                                               ::rtl::OString( pTitle ) ) );
387*cdf0e10cSrcweir     }
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir     void DebugPlotter::plot( const B2DPolygon&	rPoly,
390*cdf0e10cSrcweir                              const sal_Char* 	pTitle )
391*cdf0e10cSrcweir     {
392*cdf0e10cSrcweir         maPolygons.push_back( ::std::make_pair( rPoly,
393*cdf0e10cSrcweir                                                 ::rtl::OString( pTitle ) ) );
394*cdf0e10cSrcweir     }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir     void DebugPlotter::plot( const B2DPolyPolygon&	rPoly,
397*cdf0e10cSrcweir                              const sal_Char* 		pTitle )
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         const ::rtl::OString aTitle( pTitle );
400*cdf0e10cSrcweir         const sal_uInt32 nCount( rPoly.count() );
401*cdf0e10cSrcweir         for( sal_uInt32 i=0; i<nCount; ++i )
402*cdf0e10cSrcweir             maPolygons.push_back( ::std::make_pair( rPoly.getB2DPolygon( i ),
403*cdf0e10cSrcweir                                                     aTitle ) );
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     void DebugPlotter::print( const sal_Char* pStr )
407*cdf0e10cSrcweir     {
408*cdf0e10cSrcweir         if( mpOutputStream )
409*cdf0e10cSrcweir             *mpOutputStream << pStr;
410*cdf0e10cSrcweir         else
411*cdf0e10cSrcweir             OSL_TRACE( pStr );
412*cdf0e10cSrcweir     }
413*cdf0e10cSrcweir }
414