Salome HOME
updated copyright message
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeGraphic.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, 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, or (at your option) any later version.
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
23 //  File   : SALOMEDSImpl_AttributeGraphic.cxx
24 //  Author : Sergey LITONIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDSImpl_AttributeGraphic.hxx"
28 #include "DF_Attribute.hxx"
29
30 /*
31   Class       : SALOMEDSImpl_AttributeGraphic
32   Description : This class is intended for storing information about
33                 graphic representation of objects in dirrent views
34 */
35
36 //=======================================================================
37 //function : GetID
38 //purpose  : Get GUID of this attribute
39 //=======================================================================
40 const std::string& SALOMEDSImpl_AttributeGraphic::GetID()
41 {
42   static std::string SALOMEDSImpl_AttributeGraphicID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" );
43   return SALOMEDSImpl_AttributeGraphicID;
44 }
45
46 //=======================================================================
47 //function : SALOMEDSImpl_AttributeGraphic
48 //purpose  : Empty Constructor
49 //=======================================================================
50 SALOMEDSImpl_AttributeGraphic::SALOMEDSImpl_AttributeGraphic()
51 :SALOMEDSImpl_GenericAttribute("AttributeGraphic")
52 {
53 }
54
55 //=======================================================================
56 //function : ~SALOMEDSImpl_AttributeGraphic
57 //purpose  : Destructor
58 //=======================================================================
59 SALOMEDSImpl_AttributeGraphic::~SALOMEDSImpl_AttributeGraphic()
60 {
61 }
62
63 //=======================================================================
64 //function : SetVisibility
65 //purpose  : Set visibility of object in given view
66 //=======================================================================
67 void SALOMEDSImpl_AttributeGraphic::SetVisibility(const int theViewId,
68                                                   const bool theValue )
69 {
70   if ( myVisibility.find( theViewId ) != myVisibility.end() && ((bool)myVisibility[theViewId] == theValue) ) //!< TODO: comparing int and bool variables
71     return;
72
73   Backup();
74   myVisibility[ theViewId ] = theValue ? 1 : 0;
75 }
76
77
78 //=======================================================================
79 //function : Get
80 //purpose  : Get visibility of object in given view
81 //=======================================================================
82 bool SALOMEDSImpl_AttributeGraphic::GetVisibility(const int theViewId )
83 {
84   bool isVisible = false;
85   if(myVisibility.find( theViewId )!=myVisibility.end()) 
86     isVisible = (bool)myVisibility[theViewId]; 
87   else 
88     isVisible = false;
89   
90   return isVisible;  
91 }
92
93
94 //=======================================================================
95 //function : ID
96 //purpose  : Get GUID of this attribute
97 //=======================================================================
98 const std::string& SALOMEDSImpl_AttributeGraphic::ID () const
99 {
100   return GetID();
101 }
102
103
104 //=======================================================================
105 //function : NewEmpty
106 //purpose  : Create new empty attribute
107 //=======================================================================
108 DF_Attribute* SALOMEDSImpl_AttributeGraphic::NewEmpty () const
109 {
110   return new SALOMEDSImpl_AttributeGraphic ();
111 }
112
113 //=======================================================================
114 //function : SetVisibility
115 //purpose  : Set visibility of object in all views
116 //=======================================================================
117 void SALOMEDSImpl_AttributeGraphic::SetVisibility( const std::map<int, int>& theMap )
118 {
119   myVisibility = theMap;
120 }
121
122 //=======================================================================
123 //function : SetVisibility
124 //purpose  : Get visibility of object in all views
125 //=======================================================================
126 const std::map<int, int>& SALOMEDSImpl_AttributeGraphic::GetVisibility()
127 {
128   return myVisibility;
129 }
130
131 //=======================================================================
132 //function : Restore
133 //purpose  : Restore value of attribute with value of theWith one
134 //=======================================================================
135 void SALOMEDSImpl_AttributeGraphic::Restore( DF_Attribute* theWith )
136 {
137   SALOMEDSImpl_AttributeGraphic* anAttr =
138     dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theWith );
139
140   if ( anAttr )
141     SetVisibility( anAttr->GetVisibility() );
142 }
143
144 //=======================================================================
145 //function : Paste
146 //purpose  : Paste value of current attribute to the value of entry one
147 //=======================================================================
148 void SALOMEDSImpl_AttributeGraphic::Paste( DF_Attribute* theInto)
149 {
150   SALOMEDSImpl_AttributeGraphic* anAttr =
151     dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theInto );
152
153   if ( anAttr )
154     anAttr->SetVisibility( myVisibility );
155 }
156