Salome HOME
3dca41a64fec44393aef9d152b9ca7795465a190
[modules/geom.git] / src / Material / Material_Model.h
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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 #include <QVector>
32
33 #include <Graphic3d_MaterialAspect.hxx>
34
35 class Material_ResourceMgr;
36 class GEOM_VTKPropertyMaterial;
37
38 class MATERIAL_SALOME_EXPORT Material_Model
39 {
40 public:
41   //! Reflection type
42   typedef enum {
43     Ambient,  //!< Ambient 
44     Diffuse,  //!< Diffuse
45     Specular, //!< Specular
46     Emissive  //!< Emissive
47   } ReflectionType;
48
49   Material_Model();
50   virtual ~Material_Model();
51
52   void                fromProperties( const QString& );
53   QString             toProperties();
54   void                fromResources( const QString& = QString(), Material_ResourceMgr* = 0 );
55   void                toResources( const QString&, Material_ResourceMgr* );
56
57   bool                isPhysical() const;
58   void                setPhysical( bool );
59
60   bool                hasReflection( ReflectionType ) const;
61   void                setReflection( ReflectionType, bool );
62
63   QColor              color( ReflectionType ) const;
64   void                setColor( ReflectionType, const QColor& );
65
66   double              reflection( ReflectionType, bool = true ) const;
67   void                setReflection( ReflectionType, double, bool = true );
68
69   double              shininess( bool = true) const;
70   void                setShininess( double, bool = true );
71
72   double              transparency() const;
73   void                setTransparency( double );
74
75   Graphic3d_MaterialAspect  getMaterialOCCAspect( bool = true );
76   GEOM_VTKPropertyMaterial* getMaterialVTKProperty( bool = true );
77
78 private:
79   void                init();
80   void                read( const QString&, Material_ResourceMgr* );
81
82 private:
83   typedef struct {
84     QColor color;
85     double front_coef;
86     double back_coef;
87     bool   enabled;
88   } ReflectionData;
89
90   typedef QVector<ReflectionData> ReflectionList;
91
92   bool                myIsPhysical;
93   double              myFrontShininess;
94   double              myBackShininess;
95   double              myTransparency;
96   ReflectionList      myReflection;
97 };
98
99 #endif // MATERIAL_MODEL_H