1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDSImpl_AttributeGraphic.cxx
21 // Author : Sergey LITONIN
24 #include "SALOMEDSImpl_AttributeGraphic.hxx"
25 #include <TDF_Attribute.hxx>
26 #include <Standard_GUID.hxx>
27 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
30 Class : SALOMEDSImpl_AttributeGraphic
31 Description : This class is intended for storing information about
32 graphic representation of objects in dirrent views
35 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeGraphic, SALOMEDSImpl_GenericAttribute )
36 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeGraphic, SALOMEDSImpl_GenericAttribute )
38 //=======================================================================
40 //purpose : Get GUID of this attribute
41 //=======================================================================
42 const Standard_GUID& SALOMEDSImpl_AttributeGraphic::GetID()
44 static Standard_GUID SALOMEDSImpl_AttributeGraphicID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" );
45 return SALOMEDSImpl_AttributeGraphicID;
48 //=======================================================================
49 //function : SALOMEDSImpl_AttributeGraphic
50 //purpose : Empty Constructor
51 //=======================================================================
52 SALOMEDSImpl_AttributeGraphic::SALOMEDSImpl_AttributeGraphic()
53 :SALOMEDSImpl_GenericAttribute("AttributeGraphic")
57 //=======================================================================
58 //function : ~SALOMEDSImpl_AttributeGraphic
59 //purpose : Destructor
60 //=======================================================================
61 SALOMEDSImpl_AttributeGraphic::~SALOMEDSImpl_AttributeGraphic()
65 //=======================================================================
66 //function : SetVisibility
67 //purpose : Set visibility of object in given view
68 //=======================================================================
69 void SALOMEDSImpl_AttributeGraphic::SetVisibility(const Standard_Integer theViewId,
70 const Standard_Boolean theValue )
72 if ( myVisibility.IsBound( theViewId ) && myVisibility( theViewId ) == theValue )
76 if ( myVisibility.IsBound( theViewId ) )
77 myVisibility.ChangeFind( theViewId ) = theValue ? 1 : 0;
79 myVisibility.Bind( theViewId, theValue ? 1 : 0 );
83 //=======================================================================
85 //purpose : Get visibility of object in given view
86 //=======================================================================
87 Standard_Boolean SALOMEDSImpl_AttributeGraphic::GetVisibility(const Standard_Integer theViewId ) const
89 return myVisibility.IsBound( theViewId ) ? myVisibility( theViewId ) : false;
93 //=======================================================================
95 //purpose : Get GUID of this attribute
96 //=======================================================================
97 const Standard_GUID& SALOMEDSImpl_AttributeGraphic::ID () const
103 //=======================================================================
104 //function : NewEmpty
105 //purpose : Create new empty attribute
106 //=======================================================================
107 Handle(TDF_Attribute) SALOMEDSImpl_AttributeGraphic::NewEmpty () const
109 return new SALOMEDSImpl_AttributeGraphic ();
112 //=======================================================================
113 //function : SetVisibility
114 //purpose : Set visibility of object in all views
115 //=======================================================================
116 void SALOMEDSImpl_AttributeGraphic::SetVisibility( const TColStd_DataMapOfIntegerInteger& theMap )
118 myVisibility = theMap;
121 //=======================================================================
122 //function : SetVisibility
123 //purpose : Get visibility of object in all views
124 //=======================================================================
125 const TColStd_DataMapOfIntegerInteger& SALOMEDSImpl_AttributeGraphic::GetVisibility()
130 //=======================================================================
132 //purpose : Restore value of attribute with value of theWith one
133 //=======================================================================
134 void SALOMEDSImpl_AttributeGraphic::Restore( const Handle(TDF_Attribute)& theWith )
136 Handle(SALOMEDSImpl_AttributeGraphic) anAttr =
137 Handle(SALOMEDSImpl_AttributeGraphic)::DownCast( theWith );
139 if ( !anAttr.IsNull() )
140 SetVisibility( anAttr->GetVisibility() );
143 //=======================================================================
145 //purpose : Paste value of current attribute to the value of entry one
146 //=======================================================================
147 void SALOMEDSImpl_AttributeGraphic::Paste( const Handle(TDF_Attribute)& theInto,
148 const Handle(TDF_RelocationTable)& ) const
150 Handle(SALOMEDSImpl_AttributeGraphic) anAttr =
151 Handle(SALOMEDSImpl_AttributeGraphic)::DownCast( theInto );
153 if ( !anAttr.IsNull() )
154 anAttr->SetVisibility( myVisibility );
157 //=======================================================================
160 //=======================================================================
161 Standard_OStream& SALOMEDSImpl_AttributeGraphic::Dump( Standard_OStream& anOS ) const
163 anOS << "Visibility of object:" << endl;
164 TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIter( myVisibility );
165 for ( ; anIter.More(); anIter.Next() )
169 if ( GetVisibility( anIter.Key() ) )
170 sprintf( str, "Viewer ID = 0x%X State = VISIBLE\n", anIter.Key() );
172 sprintf( str, "Viewer ID = 0x%X State = INVISIBLE\n", anIter.Key() );