1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
19 /** \file
20  * \ingroup freestyle
21  * \brief Class to define the drawing style of a node
22  */
23 
24 #ifdef WITH_CXX_GUARDEDALLOC
25 #  include "MEM_guardedalloc.h"
26 #endif
27 
28 namespace Freestyle {
29 
30 class DrawingStyle {
31  public:
32   enum STYLE {
33     FILLED,
34     LINES,
35     POINTS,
36     INVISIBLE,
37   };
38 
DrawingStyle()39   inline DrawingStyle()
40   {
41     Style = FILLED;
42     LineWidth = 2.0f;
43     PointSize = 2.0f;
44     LightingEnabled = true;
45   }
46 
47   inline explicit DrawingStyle(const DrawingStyle &iBrother);
48 
~DrawingStyle()49   virtual ~DrawingStyle()
50   {
51   }
52 
53   /*! operators */
54   inline DrawingStyle &operator=(const DrawingStyle &ds);
55 
setStyle(const STYLE iStyle)56   inline void setStyle(const STYLE iStyle)
57   {
58     Style = iStyle;
59   }
60 
setLineWidth(const float iLineWidth)61   inline void setLineWidth(const float iLineWidth)
62   {
63     LineWidth = iLineWidth;
64   }
65 
setPointSize(const float iPointSize)66   inline void setPointSize(const float iPointSize)
67   {
68     PointSize = iPointSize;
69   }
70 
setLightingEnabled(const bool on)71   inline void setLightingEnabled(const bool on)
72   {
73     LightingEnabled = on;
74   }
75 
style()76   inline STYLE style() const
77   {
78     return Style;
79   }
80 
lineWidth()81   inline float lineWidth() const
82   {
83     return LineWidth;
84   }
85 
pointSize()86   inline float pointSize() const
87   {
88     return PointSize;
89   }
90 
lightingEnabled()91   inline bool lightingEnabled() const
92   {
93     return LightingEnabled;
94   }
95 
96  private:
97   STYLE Style;
98   float LineWidth;
99   float PointSize;
100   bool LightingEnabled;
101 
102 #ifdef WITH_CXX_GUARDEDALLOC
103   MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:DrawingStyle")
104 #endif
105 };
106 
DrawingStyle(const DrawingStyle & iBrother)107 DrawingStyle::DrawingStyle(const DrawingStyle &iBrother)
108 {
109   Style = iBrother.Style;
110   LineWidth = iBrother.LineWidth;
111   PointSize = iBrother.PointSize;
112   LightingEnabled = iBrother.LightingEnabled;
113 }
114 
115 DrawingStyle &DrawingStyle::operator=(const DrawingStyle &ds)
116 {
117   Style = ds.Style;
118   LineWidth = ds.LineWidth;
119   PointSize = ds.PointSize;
120   LightingEnabled = ds.LightingEnabled;
121 
122   return *this;
123 }
124 
125 } /* namespace Freestyle */
126