Salome HOME
Update copyright information
[modules/geom.git] / src / Material / Material_Model.h
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
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 GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File   : Material_Model.h
21 // Author : Margarita KARPUNINA, Open CASCADE S.A.S. (margarita.karpunina@opencascade.com)
22 //
23 #ifndef MATERIAL_MODEL_H
24 #define MATERIAL_MODEL_H
25
26 #include "Material.h"
27
28 #include <QColor>
29 #include <QMap>
30 #include <QString>
31
32 class Graphic3d_MaterialAspect;
33
34 class vtkProperty;
35
36 class QtxResourceMgr;
37
38 class MATERIAL_SALOME_EXPORT Material_Model
39 {
40
41 public:
42
43   //! Enumeration of reflection types of material
44   typedef enum {
45     Ambient,  //!< Ambient 
46     Diffuse,  //!< Diffuse
47     Specular, //!< Specular
48     Emission  //!< Emission
49   } ReflectionType;
50
51
52   Material_Model();
53   virtual ~Material_Model();
54
55   static Material_Model* getMaterialModel( QStringList );
56
57   QString                getMaterialProperty();
58
59   Graphic3d_MaterialAspect getMaterialOCCAspect();
60   vtkProperty*             getMaterialVTKProperty();
61
62   void                initDefaults();
63   void                fromResources( QtxResourceMgr*, const QString& = QString(), bool theIsFront = true );
64   void                save( QtxResourceMgr* = 0, const QString& = QString(), bool theIsFront = true );
65
66   QtxResourceMgr*     resourceMgr() const;
67   QString             resourceSection( bool theIsFront ) const;
68
69   bool                hasAmbientReflection();
70   bool                hasDiffuseReflection();
71   bool                hasSpecularReflection();
72   bool                hasEmissionReflection();
73
74   QColor              color( ReflectionType ) const;
75   void                setColor( ReflectionType, const QColor& );
76   void                setColor( QString,
77                                 QString,
78                                 ReflectionType );
79   void                removeColor( ReflectionType );
80
81   double              coefficient( ReflectionType ) const;
82   void                setCoefficient( ReflectionType, double );  
83   void                setCoefficient( QString,
84                                       QString,
85                                       ReflectionType );
86   void                removeCoefficient( ReflectionType );
87
88   double              shininess() const;
89   void                setShininess( double );  
90
91 private:
92   void                clearModel();
93
94 private:
95   typedef QMap<ReflectionType, QColor> ColorMap;
96   typedef QMap<ReflectionType, double> CoefficientMap;
97
98   QtxResourceMgr*     myResourceMgr;
99   QString             myResourceSection;
100
101   ColorMap            myColors;
102   CoefficientMap      myCoefficients;
103
104   double              myShininess;
105
106 };
107
108 #endif // MATERIAL_MODEL_H