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