1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _BGFX_TOOLS_DEBUGPLOTTER_HXX 25 #define _BGFX_TOOLS_DEBUGPLOTTER_HXX 26 27 #include <basegfx/point/b2dpoint.hxx> 28 #include <basegfx/vector/b2dvector.hxx> 29 #include <basegfx/range/b2drange.hxx> 30 #include <basegfx/polygon/b2dpolygon.hxx> 31 #include <basegfx/polygon/b2dpolypolygon.hxx> 32 #include <rtl/string.hxx> 33 #include <boost/utility.hpp> // for noncopyable 34 #include <vector> 35 #include <utility> 36 #include <iostream> 37 38 39 namespace basegfx 40 { 41 class B2DCubicBezier; 42 43 /** Generates debug output for various basegfx data types. 44 45 Use this class to produce debug (trace) output for various 46 basegfx geometry data types. By default, this class outputs 47 via OSL_TRACE (i.e. to stderr), and uses the gnuplot output 48 format. 49 50 To be able to generate one coherent block of output, this 51 class delays actual writing to its destructor 52 */ 53 class DebugPlotter : private ::boost::noncopyable 54 { 55 public: 56 /** Create new debug output object 57 58 @param pTitle 59 Title of the debug output, will appear in trace output 60 */ 61 explicit DebugPlotter( const sal_Char* pTitle ); 62 63 /** Create new debug output object 64 65 @param pTitle 66 Title of the debug output, will appear in trace output 67 68 @param rOutputStream 69 Stream to write output to. Must stay valid over the 70 lifetime of this object! 71 */ 72 DebugPlotter( const sal_Char* pTitle, 73 ::std::ostream& rOutputStream ); 74 75 ~DebugPlotter(); 76 77 void plot( const B2DPoint& rPoint, 78 const sal_Char* pTitle ); 79 void plot( const B2DVector& rVec, 80 const sal_Char* pTitle ); 81 void plot( const B2DCubicBezier& rBezier, 82 const sal_Char* pTitle ); 83 void plot( const B2DRange& rRange, 84 const sal_Char* pTitle ); 85 void plot( const B2DPolygon& rPoly, 86 const sal_Char* pTitle ); 87 void plot( const B2DPolyPolygon& rPoly, 88 const sal_Char* pTitle ); 89 90 private: 91 void print( const sal_Char* ); 92 93 ::rtl::OString maTitle; 94 ::std::vector< ::std::pair< B2DPoint, ::rtl::OString > > maPoints; 95 ::std::vector< ::std::pair< B2DVector, ::rtl::OString > > maVectors; 96 ::std::vector< ::std::pair< B2DRange, ::rtl::OString > > maRanges; 97 ::std::vector< ::std::pair< B2DPolygon, ::rtl::OString > > maPolygons; 98 99 ::std::ostream* mpOutputStream; 100 }; 101 } 102 103 #endif /* _BGFX_TOOLS_DEBUGPLOTTER_HXX */ 104