Salome HOME
Remove warnings
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeGraphic.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SALOMEDSImpl_AttributeGraphic.cxx
23 //  Author : Sergey LITONIN
24 //  Module : SALOME
25 //
26 #include "SALOMEDSImpl_AttributeGraphic.hxx"
27 #include "DF_Attribute.hxx"
28
29 using namespace std;
30
31 /*
32   Class       : SALOMEDSImpl_AttributeGraphic
33   Description : This class is intended for storing information about
34                 graphic representation of objects in dirrent views
35 */
36
37 //=======================================================================
38 //function : GetID
39 //purpose  : Get GUID of this attribute
40 //=======================================================================
41 const std::string& SALOMEDSImpl_AttributeGraphic::GetID()
42 {
43   static std::string SALOMEDSImpl_AttributeGraphicID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" );
44   return SALOMEDSImpl_AttributeGraphicID;
45 }
46
47 //=======================================================================
48 //function : SALOMEDSImpl_AttributeGraphic
49 //purpose  : Empty Constructor
50 //=======================================================================
51 SALOMEDSImpl_AttributeGraphic::SALOMEDSImpl_AttributeGraphic()
52 :SALOMEDSImpl_GenericAttribute("AttributeGraphic")
53 {
54 }
55
56 //=======================================================================
57 //function : ~SALOMEDSImpl_AttributeGraphic
58 //purpose  : Destructor
59 //=======================================================================
60 SALOMEDSImpl_AttributeGraphic::~SALOMEDSImpl_AttributeGraphic()
61 {
62 }
63
64 //=======================================================================
65 //function : SetVisibility
66 //purpose  : Set visibility of object in given view
67 //=======================================================================
68 void SALOMEDSImpl_AttributeGraphic::SetVisibility(const int theViewId,
69                                                   const bool theValue )
70 {
71   if ( myVisibility.find( theViewId ) != myVisibility.end() && myVisibility[theViewId] == theValue )
72     return;
73
74   Backup();
75   myVisibility[ theViewId ] = theValue ? 1 : 0;
76 }
77
78
79 //=======================================================================
80 //function : Get
81 //purpose  : Get visibility of object in given view
82 //=======================================================================
83 bool SALOMEDSImpl_AttributeGraphic::GetVisibility(const int theViewId )
84 {
85   bool isVisible = false;
86   if(myVisibility.find( theViewId )!=myVisibility.end()) 
87     isVisible = (bool)myVisibility[theViewId]; 
88   else 
89     isVisible = false;
90   
91   return isVisible;  
92 }
93
94
95 //=======================================================================
96 //function : ID
97 //purpose  : Get GUID of this attribute
98 //=======================================================================
99 const std::string& SALOMEDSImpl_AttributeGraphic::ID () const
100 {
101   return GetID();
102 }
103
104
105 //=======================================================================
106 //function : NewEmpty
107 //purpose  : Create new empty attribute
108 //=======================================================================
109 DF_Attribute* SALOMEDSImpl_AttributeGraphic::NewEmpty () const
110 {
111   return new SALOMEDSImpl_AttributeGraphic ();
112 }
113
114 //=======================================================================
115 //function : SetVisibility
116 //purpose  : Set visibility of object in all views
117 //=======================================================================
118 void SALOMEDSImpl_AttributeGraphic::SetVisibility( const map<int, int>& theMap )
119 {
120   myVisibility = theMap;
121 }
122
123 //=======================================================================
124 //function : SetVisibility
125 //purpose  : Get visibility of object in all views
126 //=======================================================================
127 const map<int, int>& SALOMEDSImpl_AttributeGraphic::GetVisibility()
128 {
129   return myVisibility;
130 }
131
132 //=======================================================================
133 //function : Restore
134 //purpose  : Restore value of attribute with value of theWith one
135 //=======================================================================
136 void SALOMEDSImpl_AttributeGraphic::Restore( DF_Attribute* theWith )
137 {
138   SALOMEDSImpl_AttributeGraphic* anAttr =
139     dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theWith );
140
141   if ( anAttr )
142     SetVisibility( anAttr->GetVisibility() );
143 }
144
145 //=======================================================================
146 //function : Paste
147 //purpose  : Paste value of current attribute to the value of entry one
148 //=======================================================================
149 void SALOMEDSImpl_AttributeGraphic::Paste( DF_Attribute* theInto)
150 {
151   SALOMEDSImpl_AttributeGraphic* anAttr =
152     dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theInto );
153
154   if ( anAttr )
155     anAttr->SetVisibility( myVisibility );
156 }
157