OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Style.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGTEXT_STYLE
15 #define OSGTEXT_STYLE 1
16 
17 #include <osg/Object>
18 #include <osg/Vec2>
19 #include <osgText/Export>
20 
21 #include <iosfwd>
22 #include <vector>
23 
24 namespace osgText
25 {
26 
28 {
29  public:
30 
31  Bevel();
32  Bevel(const Bevel& bevel, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
33 
35 
36  bool operator == (const Bevel& rhs) const
37  {
38  if (_smoothConcaveJunctions != rhs._smoothConcaveJunctions) return false;
39  if (_thickness != rhs._thickness) return false;
40  return _vertices==rhs._vertices;
41  }
42 
43  void setSmoothConcaveJunctions(bool flag) { _smoothConcaveJunctions = flag; }
44  bool getSmoothConcaveJunctions() const { return _smoothConcaveJunctions; }
45 
46  void setBevelThickness(float thickness) { _thickness = thickness; }
47  float getBevelThickness() const { return _thickness; }
48 
49  void flatBevel(float width=0.25f);
50 
51  void roundedBevel(float width=0.5f, unsigned int numSteps=10);
52 
53  void roundedBevel2(float width=0.5f, unsigned int numSteps=10);
54 
55  typedef std::vector<osg::Vec2> Vertices;
56 
57  void setVertices(const Vertices& vertices) { _vertices = vertices; }
58  Vertices& getVertices() { return _vertices; }
59  const Vertices& getVertices() const { return _vertices; }
60 
61  void print(std::ostream& fout);
62 
63  protected:
64 
66  float _thickness;
67  Vertices _vertices;
68 };
69 
70 
72 {
73  public:
74 
75  Style();
76  Style(const Style& style, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
77 
79 
80 
81  static osg::ref_ptr<Style>& getDefaultStyle();
82 
83  bool operator == (const Style& style) const;
84 
86  void setBevel(Bevel* bevel) { _bevel = bevel; }
87  const Bevel* getBevel() const { return _bevel.get(); }
88 
89 
91  void setWidthRatio(float widthRatio) { _widthRatio = widthRatio; }
92  float getWidthRatio() const { return _widthRatio; }
93 
95  void setThicknessRatio(float thicknessRatio) { _thicknessRatio = thicknessRatio; }
96  float getThicknessRatio() const { return _thicknessRatio; }
97 
99  void setOutlineRatio(float outlineRatio) { _outlineRatio = outlineRatio; }
100  float getOutlineRatio() const { return _outlineRatio; }
101 
103  void setSampleDensity(float sd) { _sampleDensity = sd; }
104  float getSampleDensity() const { return _sampleDensity; }
105 
106  protected:
107 
109 
110  float _widthRatio;
114 };
115 
116 }
117 
118 #endif
float getSampleDensity() const
Definition: Style.h:104
void setWidthRatio(float widthRatio)
1 is the default width of the text
Definition: Style.h:91
osg::ref_ptr< Bevel > _bevel
Definition: Style.h:108
Vertices _vertices
Definition: Style.h:67
void setOutlineRatio(float outlineRatio)
0 is off
Definition: Style.h:99
bool _smoothConcaveJunctions
Definition: Style.h:65
const Bevel * getBevel() const
Definition: Style.h:87
float getThicknessRatio() const
Definition: Style.h:96
float getWidthRatio() const
Definition: Style.h:92
void setBevel(Bevel *bevel)
NULL is no bevel.
Definition: Style.h:86
#define META_Object(library, name)
Definition: Object.h:42
GLint GLenum GLsizei width
Definition: GLU.h:71
Vertices & getVertices()
Definition: Style.h:58
std::vector< osg::Vec2 > Vertices
Definition: Style.h:55
float _sampleDensity
Definition: Style.h:113
float _widthRatio
Definition: Style.h:110
float _thicknessRatio
Definition: Style.h:111
void setVertices(const Vertices &vertices)
Definition: Style.h:57
const Vertices & getVertices() const
Definition: Style.h:59
float _thickness
Definition: Style.h:66
float _outlineRatio
Definition: Style.h:112
float getOutlineRatio() const
Definition: Style.h:100
void setSampleDensity(float sd)
1.0 is default number of samples
Definition: Style.h:103
void setThicknessRatio(float thicknessRatio)
0 is 2D text
Definition: Style.h:95
#define OSGTEXT_EXPORT
Definition: Export.h:39