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