1 // SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
3 // Copyright (C) 2003 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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEDS_GraphicAttribute.cxx
25 // Author : Sergey LITONIN
28 #include "SALOMEDS_GraphicAttribute.hxx"
29 #include <TDF_Attribute.hxx>
30 #include <Standard_GUID.hxx>
31 #include <TDF_Label.hxx>
32 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
35 Class : SALOMEDS_GraphicAttribute
36 Description : This class is intended for storing information about
37 graphic representation of objects in dirrent views
40 IMPLEMENT_STANDARD_HANDLE( SALOMEDS_GraphicAttribute, TDF_Attribute )
41 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDS_GraphicAttribute, TDF_Attribute )
43 //=======================================================================
45 //purpose : Get GUID of this attribute
46 //=======================================================================
47 const Standard_GUID& SALOMEDS_GraphicAttribute::GetID()
49 static Standard_GUID SALOMEDS_GraphicAttributeID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" );
50 return SALOMEDS_GraphicAttributeID;
53 //=======================================================================
54 //function : SALOMEDS_GraphicAttribute
55 //purpose : Empty Constructor
56 //=======================================================================
57 SALOMEDS_GraphicAttribute::SALOMEDS_GraphicAttribute()
61 //=======================================================================
62 //function : ~SALOMEDS_GraphicAttribute
63 //purpose : Destructor
64 //=======================================================================
65 SALOMEDS_GraphicAttribute::~SALOMEDS_GraphicAttribute()
69 //=======================================================================
70 //function : SetVisibility
71 //purpose : Set visibility of object in given view
72 //=======================================================================
73 void SALOMEDS_GraphicAttribute::SetVisibility( const Standard_Integer theViewId,
74 const Standard_Boolean theValue )
76 if ( myVisibility.IsBound( theViewId ) && myVisibility( theViewId ) == theValue )
80 if ( myVisibility.IsBound( theViewId ) )
81 myVisibility.ChangeFind( theViewId ) = theValue ? 1 : 0;
83 myVisibility.Bind( theViewId, theValue ? 1 : 0 );
87 //=======================================================================
89 //purpose : Get visibility of object in given view
90 //=======================================================================
91 Standard_Boolean SALOMEDS_GraphicAttribute::GetVisibility(
92 const Standard_Integer theViewId ) const
94 return myVisibility.IsBound( theViewId ) ? myVisibility( theViewId ) : false;
98 //=======================================================================
100 //purpose : Get GUID of this attribute
101 //=======================================================================
102 const Standard_GUID& SALOMEDS_GraphicAttribute::ID () const
108 //=======================================================================
109 //function : NewEmpty
110 //purpose : Create new empty attribute
111 //=======================================================================
112 Handle(TDF_Attribute) SALOMEDS_GraphicAttribute::NewEmpty () const
114 return new SALOMEDS_GraphicAttribute ();
117 //=======================================================================
118 //function : SetVisibility
119 //purpose : Set visibility of object in all views
120 //=======================================================================
121 void SALOMEDS_GraphicAttribute::SetVisibility( const TColStd_DataMapOfIntegerInteger& theMap )
123 myVisibility = theMap;
126 //=======================================================================
127 //function : SetVisibility
128 //purpose : Get visibility of object in all views
129 //=======================================================================
130 const TColStd_DataMapOfIntegerInteger& SALOMEDS_GraphicAttribute::GetVisibility()
135 //=======================================================================
137 //purpose : Restore value of attribute with value of theWith one
138 //=======================================================================
139 void SALOMEDS_GraphicAttribute::Restore( const Handle(TDF_Attribute)& theWith )
141 Handle(SALOMEDS_GraphicAttribute) anAttr =
142 Handle(SALOMEDS_GraphicAttribute)::DownCast( theWith );
144 if ( !anAttr.IsNull() )
145 SetVisibility( anAttr->GetVisibility() );
148 //=======================================================================
150 //purpose : Paste value of current attribute to the value of entry one
151 //=======================================================================
152 void SALOMEDS_GraphicAttribute::Paste( const Handle(TDF_Attribute)& theInto,
153 const Handle(TDF_RelocationTable)& ) const
155 Handle(SALOMEDS_GraphicAttribute) anAttr =
156 Handle(SALOMEDS_GraphicAttribute)::DownCast( theInto );
158 if ( !anAttr.IsNull() )
159 anAttr->SetVisibility( myVisibility );
162 //=======================================================================
165 //=======================================================================
166 Standard_OStream& SALOMEDS_GraphicAttribute::Dump( Standard_OStream& anOS ) const
168 anOS << "Visibility of object:" << endl;
169 TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIter( myVisibility );
170 for ( ; anIter.More(); anIter.Next() )
174 if ( GetVisibility( anIter.Key() ) )
175 sprintf( str, "Viewer ID = 0x%X State = VISIBLE\n", anIter.Key() );
177 sprintf( str, "Viewer ID = 0x%X State = INVISIBLE\n", anIter.Key() );