cstool/pen.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2005 by Christopher Nelson 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_CSTOOL_PEN_H__ 00020 #define __CS_CSTOOL_PEN_H__ 00021 00026 #include "csgeom/poly3d.h" 00027 #include "csgeom/polyidx.h" 00028 #include "csgeom/vector4.h" 00029 #include "csutil/cscolor.h" 00030 #include "csutil/dirtyaccessarray.h" 00031 #include "csutil/ref.h" 00032 00033 #include "ivideo/graph3d.h" 00034 00035 struct iFont; 00036 struct iGraphics2D; 00037 struct iGraphics3D; 00038 00039 enum CS_PEN_TEXT_ALIGN 00040 { 00041 CS_PEN_TA_TOP, 00042 CS_PEN_TA_BOT, 00043 CS_PEN_TA_LEFT, 00044 CS_PEN_TA_RIGHT, 00045 CS_PEN_TA_CENTER 00046 }; 00047 00048 00052 struct iPen 00053 { 00057 virtual void SetColor (float r, float g, float b, float a) = 0; 00058 00062 virtual void SetColor(const csColor4 &color) = 0; 00063 00067 virtual void SwapColors() = 0; 00068 00072 virtual void ClearTransform() = 0; 00073 00077 virtual void PushTransform() = 0; 00078 00083 virtual void PopTransform() = 0; 00084 00088 virtual void SetOrigin(const csVector3 &o) = 0; 00089 00093 virtual void Translate(const csVector3 &t) = 0; 00094 00098 virtual void Rotate(const float &a) = 0; 00099 00103 virtual void DrawLine (uint x1, uint y1, uint x2, uint y2) = 0; 00104 00108 virtual void DrawPoint (uint x1, uint y2) = 0; 00109 00113 virtual void DrawRect (uint x1, uint y1, uint x2, uint y2, 00114 bool swap_colors = false, bool fill = false) = 0; 00115 00120 virtual void DrawMiteredRect (uint x1, uint y1, uint x2, uint y2, 00121 float miter, bool swap_colors = false, bool fill = false) = 0; 00122 00127 virtual void DrawRoundedRect (uint x1, uint y1, uint x2, uint y2, 00128 float roundness, bool swap_colors = false, bool fill = false) = 0; 00129 00137 virtual void DrawArc(uint x1, uint y1, uint x2, uint y2, float start_angle, 00138 float end_angle, bool swap_colors = false, bool fill=false) = 0; 00139 00143 virtual void DrawTriangle(uint x1, uint y1, uint x2, uint y2, uint x3, uint y3, bool fill=false) = 0; 00144 00148 virtual void Write(iFont *font, uint x1, uint y1, char *text) = 0; 00149 00154 virtual void WriteBoxed(iFont *font, uint x1, uint y1, uint x2, uint y2, 00155 uint h_align, uint v_align, char *text) = 0; 00156 }; 00157 00159 class csPen : public iPen 00160 { 00162 csRef<iGraphics3D> g3d; 00163 00165 csRef<iGraphics2D> g2d; 00166 00168 csSimpleRenderMesh mesh; 00169 00171 csPolyIndexed poly_idx; 00172 00174 csPoly3D poly; 00175 00177 csVector4 color; 00178 00180 csVector4 alt_color; 00181 00183 csVector3 tt; 00184 00186 csDirtyAccessArray<csVector4> colors; 00187 00189 csArray<csReversibleTransform> transforms; 00190 00191 protected: 00195 void Start(); 00196 00200 void AddVertex(float x, float y); 00201 00205 void SetupMesh(); 00206 00210 void DrawMesh(csRenderMeshType mesh_type); 00211 00212 public: 00213 csPen(iGraphics2D *_g2d, iGraphics3D *_g3d); 00214 virtual ~csPen(); 00215 00219 virtual void SetColor (float r, float g, float b, float a); 00220 00224 virtual void SetColor(const csColor4 &color); 00225 00229 virtual void SwapColors(); 00230 00234 virtual void ClearTransform(); 00235 00239 virtual void PushTransform(); 00240 00245 virtual void PopTransform(); 00246 00250 virtual void SetOrigin(const csVector3 &o); 00251 00255 virtual void Translate(const csVector3 &t); 00256 00260 virtual void Rotate(const float &a); 00261 00265 virtual void DrawLine (uint x1, uint y1, uint x2, uint y2); 00266 00270 virtual void DrawPoint (uint x1, uint y2); 00271 00275 virtual void DrawRect (uint x1, uint y1, uint x2, uint y2, 00276 bool swap_colors = false, bool fill = false); 00277 00282 virtual void DrawMiteredRect (uint x1, uint y1, uint x2, uint y2, 00283 float miter, bool swap_colors = false, bool fill = false); 00284 00289 virtual void DrawRoundedRect (uint x1, uint y1, uint x2, uint y2, 00290 float roundness, bool swap_colors = false, bool fill = false); 00291 00299 virtual void DrawArc(uint x1, uint y1, uint x2, uint y2, 00300 float start_angle=0, float end_angle=6.2831853, 00301 bool swap_colors = false, bool fill=false); 00302 00306 virtual void DrawTriangle(uint x1, uint y1, uint x2, uint y2, uint x3, uint y3, bool fill=false); 00307 00311 virtual void Write(iFont *font, uint x1, uint y1, char *text); 00312 00317 virtual void WriteBoxed(iFont *font, uint x1, uint y1, uint x2, uint y2, 00318 uint h_align, uint v_align, char *text); 00319 }; 00320 00321 00322 #endif
Generated for Crystal Space by doxygen 1.4.6