1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDSImpl_AttributeGraphic.cxx
24 // Author : Sergey LITONIN
27 #include "SALOMEDSImpl_AttributeGraphic.hxx"
28 #include "DF_Attribute.hxx"
31 Class : SALOMEDSImpl_AttributeGraphic
32 Description : This class is intended for storing information about
33 graphic representation of objects in dirrent views
36 //=======================================================================
38 //purpose : Get GUID of this attribute
39 //=======================================================================
40 const std::string& SALOMEDSImpl_AttributeGraphic::GetID()
42 static std::string SALOMEDSImpl_AttributeGraphicID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" );
43 return SALOMEDSImpl_AttributeGraphicID;
46 //=======================================================================
47 //function : SALOMEDSImpl_AttributeGraphic
48 //purpose : Empty Constructor
49 //=======================================================================
50 SALOMEDSImpl_AttributeGraphic::SALOMEDSImpl_AttributeGraphic()
51 :SALOMEDSImpl_GenericAttribute("AttributeGraphic")
55 //=======================================================================
56 //function : ~SALOMEDSImpl_AttributeGraphic
57 //purpose : Destructor
58 //=======================================================================
59 SALOMEDSImpl_AttributeGraphic::~SALOMEDSImpl_AttributeGraphic()
63 //=======================================================================
64 //function : SetVisibility
65 //purpose : Set visibility of object in given view
66 //=======================================================================
67 void SALOMEDSImpl_AttributeGraphic::SetVisibility(const int theViewId,
70 if ( myVisibility.find( theViewId ) != myVisibility.end() && myVisibility[theViewId] == theValue )
74 myVisibility[ theViewId ] = theValue ? 1 : 0;
78 //=======================================================================
80 //purpose : Get visibility of object in given view
81 //=======================================================================
82 bool SALOMEDSImpl_AttributeGraphic::GetVisibility(const int theViewId )
84 bool isVisible = false;
85 if(myVisibility.find( theViewId )!=myVisibility.end())
86 isVisible = (bool)myVisibility[theViewId];
94 //=======================================================================
96 //purpose : Get GUID of this attribute
97 //=======================================================================
98 const std::string& SALOMEDSImpl_AttributeGraphic::ID () const
104 //=======================================================================
105 //function : NewEmpty
106 //purpose : Create new empty attribute
107 //=======================================================================
108 DF_Attribute* SALOMEDSImpl_AttributeGraphic::NewEmpty () const
110 return new SALOMEDSImpl_AttributeGraphic ();
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 )
119 myVisibility = theMap;
122 //=======================================================================
123 //function : SetVisibility
124 //purpose : Get visibility of object in all views
125 //=======================================================================
126 const std::map<int, int>& SALOMEDSImpl_AttributeGraphic::GetVisibility()
131 //=======================================================================
133 //purpose : Restore value of attribute with value of theWith one
134 //=======================================================================
135 void SALOMEDSImpl_AttributeGraphic::Restore( DF_Attribute* theWith )
137 SALOMEDSImpl_AttributeGraphic* anAttr =
138 dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theWith );
141 SetVisibility( anAttr->GetVisibility() );
144 //=======================================================================
146 //purpose : Paste value of current attribute to the value of entry one
147 //=======================================================================
148 void SALOMEDSImpl_AttributeGraphic::Paste( DF_Attribute* theInto)
150 SALOMEDSImpl_AttributeGraphic* anAttr =
151 dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theInto );
154 anAttr->SetVisibility( myVisibility );