Salome HOME
NOMINMAX definition has been moved into CONFIGURATION repository.
[modules/geom.git] / src / GEOMGUI / GEOMGUI_DimensionProperty.cxx
index 215035a2f2c8a891a1582594d14ac4d87ed9c7f5..2ea9540e98fa632ad073800c74a632f89259622c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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
 
 #include "GEOMGUI_DimensionProperty.h"
 
+#include <Basics_OCCTVersion.hxx>
+
 // OCCT includes
 #include <Standard_ProgramError.hxx>
 #include <gp_Trsf.hxx>
 
-#include <SalomeApp_Study.h>
+#include <SalomeApp_Application.h>
 
 // Static patterns for casting value-to-string & value-from-string. The patterns are:
 //  ITEM: { name[string] : visibility : type : values[composite] };
@@ -66,13 +68,17 @@ namespace
     PATTERN_XYZ.arg( "Point1" ) + ":" +
     PATTERN_XYZ.arg( "Point2" ) + ":" +
     PATTERN_XYZ.arg( "Point3" );
-};
+}
 
 //=================================================================================
 // function : Length::Init
 // purpose  : 
 //=================================================================================
+#if OCC_VERSION_LARGE >= 0x070400ff
+void GEOMGUI_DimensionProperty::Length::Init( const Handle(PrsDim_LengthDimension)& theIO, const gp_Ax3& theLCS )
+#else
 void GEOMGUI_DimensionProperty::Length::Init( const Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS )
+#endif
 {
   gp_Trsf aFromLCS;
   aFromLCS.SetTransformation( gp_Ax3(), theLCS );
@@ -90,7 +96,11 @@ void GEOMGUI_DimensionProperty::Length::Init( const Handle(AIS_LengthDimension)&
 // function : Length::Update
 // purpose  : 
 //=================================================================================
+#if OCC_VERSION_LARGE >= 0x070400ff
+void GEOMGUI_DimensionProperty::Length::Update( Handle(PrsDim_LengthDimension)& theIO, const gp_Ax3& theLCS )
+#else
 void GEOMGUI_DimensionProperty::Length::Update( Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS )
+#endif
 {
   gp_Trsf aToLCS;
   aToLCS.SetTransformation( theLCS, gp_Ax3() );
@@ -590,9 +600,9 @@ GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( const GEOMGUI_DimensionPro
 // function : Init constructor
 // purpose  : 
 //=================================================================================
-GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( SalomeApp_Study* theStudy, const std::string& theEntry )
+GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( const std::string& theEntry )
 {
-  LoadFromAttribute( theStudy, theEntry );
+  LoadFromAttribute( theEntry );
 }
 
 //=================================================================================
@@ -840,8 +850,13 @@ void GEOMGUI_DimensionProperty::AddRecord( const Handle(AIS_Dimension)& theIO, c
   {
     case DimensionType_Length :
     {
+#if OCC_VERSION_LARGE >= 0x070400ff
+      Handle(PrsDim_LengthDimension) aLength = 
+        Handle(PrsDim_LengthDimension)::DownCast( theIO );
+#else
       Handle(AIS_LengthDimension) aLength = 
         Handle(AIS_LengthDimension)::DownCast( theIO );
+#endif
 
       aNewRecord = RecordPtr( new Length() );
       aNewRecord->AsLength()->Init( aLength, theLCS );
@@ -922,8 +937,13 @@ void GEOMGUI_DimensionProperty::SetRecord( const int theIndex,
   {
     case DimensionType_Length :
     {
+#if OCC_VERSION_LARGE >= 0x070400ff
+      Handle(PrsDim_LengthDimension) aLength = 
+        Handle(PrsDim_LengthDimension)::DownCast( theIO );
+#else
       Handle(AIS_LengthDimension) aLength = 
         Handle(AIS_LengthDimension)::DownCast( theIO );
+#endif
 
       aChangeRecord = RecordPtr( new Length() );
       aChangeRecord->AsLength()->Init( aLength, theLCS );
@@ -1018,18 +1038,17 @@ int GEOMGUI_DimensionProperty::GetType( const int theIndex ) const
 // function : LoadFromAttribute
 // purpose  : 
 //=================================================================================
-void GEOMGUI_DimensionProperty::LoadFromAttribute( SalomeApp_Study* theStudy,
-                                                   const std::string& theEntry )
+void GEOMGUI_DimensionProperty::LoadFromAttribute( const std::string& theEntry )
 {
   Clear();
 
-  _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
+  _PTR(SObject) aSObj = SalomeApp_Application::getStudy()->FindObjectID( theEntry );
   if ( !aSObj )
   {
     return;
   }
 
-  _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();
+  _PTR(StudyBuilder) aBuilder = SalomeApp_Application::getStudy()->NewBuilder();
 
   _PTR(GenericAttribute) aSeekAtt;
   _PTR(AttributeTableOfReal) aRecordsAtt;
@@ -1076,16 +1095,15 @@ void GEOMGUI_DimensionProperty::LoadFromAttribute( SalomeApp_Study* theStudy,
 // function : SaveToAttribute
 // purpose  : 
 //=================================================================================
-void GEOMGUI_DimensionProperty::SaveToAttribute( SalomeApp_Study *theStudy,
-                                                 const std::string &theEntry )
+void GEOMGUI_DimensionProperty::SaveToAttribute( const std::string &theEntry )
 {
-  _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
+  _PTR(SObject) aSObj = SalomeApp_Application::getStudy()->FindObjectID( theEntry );
   if ( !aSObj )
   {
     return;
   }
 
-  _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();
+  _PTR(StudyBuilder) aBuilder = SalomeApp_Application::getStudy()->NewBuilder();
 
   _PTR(AttributeTableOfReal) aRecordsAtt;
 
@@ -1120,7 +1138,11 @@ void GEOMGUI_DimensionProperty::SaveToAttribute( SalomeApp_Study *theStudy,
 //=================================================================================
 int GEOMGUI_DimensionProperty::TypeFromIO( const Handle(AIS_Dimension)& theIO ) const
 {
+#if OCC_VERSION_LARGE >= 0x070400ff
+  if ( theIO->IsKind( STANDARD_TYPE( PrsDim_LengthDimension ) ) )
+#else
   if ( theIO->IsKind( STANDARD_TYPE( AIS_LengthDimension ) ) )
+#endif
   {
     return DimensionType_Length;
   }