-// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSImpl_AttributeGraphic.cxx
// Author : Sergey LITONIN
// Module : SALOME
-
+//
#include "SALOMEDSImpl_AttributeGraphic.hxx"
-#include <TDF_Attribute.hxx>
-#include <Standard_GUID.hxx>
-#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
+#include "DF_Attribute.hxx"
/*
Class : SALOMEDSImpl_AttributeGraphic
graphic representation of objects in dirrent views
*/
-IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeGraphic, SALOMEDSImpl_GenericAttribute )
-IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeGraphic, SALOMEDSImpl_GenericAttribute )
-
//=======================================================================
//function : GetID
//purpose : Get GUID of this attribute
//=======================================================================
-const Standard_GUID& SALOMEDSImpl_AttributeGraphic::GetID()
+const std::string& SALOMEDSImpl_AttributeGraphic::GetID()
{
- static Standard_GUID SALOMEDSImpl_AttributeGraphicID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" );
+ static std::string SALOMEDSImpl_AttributeGraphicID( "F17AE8F0-E354-4d6f-8E42-38385C36E67E" );
return SALOMEDSImpl_AttributeGraphicID;
}
//function : SetVisibility
//purpose : Set visibility of object in given view
//=======================================================================
-void SALOMEDSImpl_AttributeGraphic::SetVisibility(const Standard_Integer theViewId,
- const Standard_Boolean theValue )
+void SALOMEDSImpl_AttributeGraphic::SetVisibility(const int theViewId,
+ const bool theValue )
{
- if ( myVisibility.IsBound( theViewId ) && myVisibility( theViewId ) == theValue )
+ if ( myVisibility.find( theViewId ) != myVisibility.end() && myVisibility[theViewId] == theValue )
return;
Backup();
- if ( myVisibility.IsBound( theViewId ) )
- myVisibility.ChangeFind( theViewId ) = theValue ? 1 : 0;
- else
- myVisibility.Bind( theViewId, theValue ? 1 : 0 );
+ myVisibility[ theViewId ] = theValue ? 1 : 0;
}
//function : Get
//purpose : Get visibility of object in given view
//=======================================================================
-Standard_Boolean SALOMEDSImpl_AttributeGraphic::GetVisibility(const Standard_Integer theViewId ) const
+bool SALOMEDSImpl_AttributeGraphic::GetVisibility(const int theViewId )
{
- return myVisibility.IsBound( theViewId ) ? myVisibility( theViewId ) : false;
+ bool isVisible = false;
+ if(myVisibility.find( theViewId )!=myVisibility.end())
+ isVisible = (bool)myVisibility[theViewId];
+ else
+ isVisible = false;
+
+ return isVisible;
}
//function : ID
//purpose : Get GUID of this attribute
//=======================================================================
-const Standard_GUID& SALOMEDSImpl_AttributeGraphic::ID () const
+const std::string& SALOMEDSImpl_AttributeGraphic::ID () const
{
return GetID();
}
//function : NewEmpty
//purpose : Create new empty attribute
//=======================================================================
-Handle(TDF_Attribute) SALOMEDSImpl_AttributeGraphic::NewEmpty () const
+DF_Attribute* SALOMEDSImpl_AttributeGraphic::NewEmpty () const
{
return new SALOMEDSImpl_AttributeGraphic ();
}
//function : SetVisibility
//purpose : Set visibility of object in all views
//=======================================================================
-void SALOMEDSImpl_AttributeGraphic::SetVisibility( const TColStd_DataMapOfIntegerInteger& theMap )
+void SALOMEDSImpl_AttributeGraphic::SetVisibility( const std::map<int, int>& theMap )
{
myVisibility = theMap;
}
//function : SetVisibility
//purpose : Get visibility of object in all views
//=======================================================================
-const TColStd_DataMapOfIntegerInteger& SALOMEDSImpl_AttributeGraphic::GetVisibility()
+const std::map<int, int>& SALOMEDSImpl_AttributeGraphic::GetVisibility()
{
return myVisibility;
}
//function : Restore
//purpose : Restore value of attribute with value of theWith one
//=======================================================================
-void SALOMEDSImpl_AttributeGraphic::Restore( const Handle(TDF_Attribute)& theWith )
+void SALOMEDSImpl_AttributeGraphic::Restore( DF_Attribute* theWith )
{
- Handle(SALOMEDSImpl_AttributeGraphic) anAttr =
- Handle(SALOMEDSImpl_AttributeGraphic)::DownCast( theWith );
+ SALOMEDSImpl_AttributeGraphic* anAttr =
+ dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theWith );
- if ( !anAttr.IsNull() )
+ if ( anAttr )
SetVisibility( anAttr->GetVisibility() );
}
//function : Paste
//purpose : Paste value of current attribute to the value of entry one
//=======================================================================
-void SALOMEDSImpl_AttributeGraphic::Paste( const Handle(TDF_Attribute)& theInto,
- const Handle(TDF_RelocationTable)& ) const
+void SALOMEDSImpl_AttributeGraphic::Paste( DF_Attribute* theInto)
{
- Handle(SALOMEDSImpl_AttributeGraphic) anAttr =
- Handle(SALOMEDSImpl_AttributeGraphic)::DownCast( theInto );
+ SALOMEDSImpl_AttributeGraphic* anAttr =
+ dynamic_cast<SALOMEDSImpl_AttributeGraphic*>( theInto );
- if ( !anAttr.IsNull() )
+ if ( anAttr )
anAttr->SetVisibility( myVisibility );
}
-//=======================================================================
-//function : Dump
-//purpose : Dump
-//=======================================================================
-Standard_OStream& SALOMEDSImpl_AttributeGraphic::Dump( Standard_OStream& anOS ) const
-{
- anOS << "Visibility of object:" << endl;
- TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIter( myVisibility );
- for ( ; anIter.More(); anIter.Next() )
- {
- char str[ 100 ];
-
- if ( GetVisibility( anIter.Key() ) )
- sprintf( str, "Viewer ID = 0x%X State = VISIBLE\n", anIter.Key() );
- else
- sprintf( str, "Viewer ID = 0x%X State = INVISIBLE\n", anIter.Key() );
-
- anOS << str;
- }
-
- anOS << "Integer";
- return anOS;
-}
-