X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Obstacle.cxx;h=29b0a64c4a9e8505f6fe2acce5a707be77d6ee8e;hb=f86cf7ecf17dbae2a1d84e0ebbab07c732208c2f;hp=7d0469ca666487a7b60f89e18154611947cab1e2;hpb=191c33b8fd827caa9af8886728e9df22ae55451e;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 7d0469ca..29b0a64c 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -1,3 +1,20 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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, 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "HYDROData_Obstacle.h" @@ -5,14 +22,23 @@ #include "HYDROData_ShapesGroup.h" #include "HYDROData_ShapesTool.h" #include "HYDROData_Tool.h" +#include "HYDROData_GeomTool.h" +#ifdef WIN32 + #pragma warning ( disable: 4251 ) +#endif + +#ifndef LIGHT_MODE #include +#endif + +#ifdef WIN32 + #pragma warning ( default: 4251 ) +#endif #include #include -#include - #include #include @@ -32,24 +58,31 @@ #include +#ifdef WIN32 + #pragma warning ( disable: 4251 ) +#endif + #include #include #include #include +#ifdef WIN32 + #pragma warning ( default: 4251 ) +#endif + #include // CAREFUL ! position of this file is critic #include -#include -#include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" -IMPLEMENT_STANDARD_HANDLE(HYDROData_Obstacle,HYDROData_ArtificialObject) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Obstacle,HYDROData_ArtificialObject) HYDROData_Obstacle::HYDROData_Obstacle() -: HYDROData_ArtificialObject() +: HYDROData_ArtificialObject( Geom_3d ) { } @@ -57,7 +90,8 @@ HYDROData_Obstacle::~HYDROData_Obstacle() { } -QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +QStringList HYDROData_Obstacle::DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); @@ -69,24 +103,24 @@ QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObj if ( !aGeomObjectEntry.IsEmpty() ) { QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "obstacle_sobj" ); - // aResList << QString( "%1 = theStudy.FindObjectID( \"%2\" );" ) + // aResList << QString( "%1 = theStudy.FindObjectID( \"%2\" )" ) // .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() ); QString aGeomObjectName( GetGeomObjectName().ToCString() ); if ( !aGeomObjectName.isEmpty() ) { aResList << QString( "%1 = theStudy.FindObjectByName( \"%2\", \"GEOM\" )[0];" ) .arg( aSalomeObjName ).arg( aGeomObjectName ); - aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" ) + aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() )" ) .arg( anObstacleName ).arg( aSalomeObjName ); - aResList << QString( "%1.SetGeomObjectEntry( %2.GetID() );" ) + aResList << QString( "%1.SetGeomObjectEntry( %2.GetID() )" ) .arg( anObstacleName ).arg( aSalomeObjName ); } aResList << QString( "" ); } else if ( !aFilePath.isEmpty() ) { - aResList << QString( "%1.ImportFromFile( \"%2\" );" ) + aResList << QString( "%1.ImportFromFile( \"%2\" )" ) .arg( anObstacleName ).arg( aFilePath ); aResList << QString( "" ); } @@ -95,12 +129,12 @@ QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObj double aDx, aDy, aDz; if ( getTranslation( aDx, aDy, aDz ) ) { - aResList << QString( "%1.Translate( %2, %3, %4 );" ) + aResList << QString( "%1.Translate( %2, %3, %4 )" ) .arg( anObstacleName ).arg( aDx ).arg( aDy ).arg( aDz ); aResList << QString( "" ); } - aResList << QString( "%1.Update();" ).arg( anObstacleName ); + aResList << QString( "%1.Update()" ).arg( anObstacleName ); aResList << QString( "" ); return aResList; @@ -108,7 +142,7 @@ QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObj void HYDROData_Obstacle::Update() { - removeGroupObjects(); + RemoveGroupObjects(); createGroupObjects(); checkAndSetAltitudeObject(); @@ -120,16 +154,6 @@ bool HYDROData_Obstacle::IsHas2dPrs() const return true; } -TopoDS_Shape HYDROData_Obstacle::GetTopShape() const -{ - return getTopShape(); -} - -TopoDS_Shape HYDROData_Obstacle::GetShape3D() const -{ - return getShape3D(); -} - void HYDROData_Obstacle::SetShape3D( const TopoDS_Shape& theShape ) { TopoDS_Face aShape2d = HYDROData_Projection::MakeProjection( theShape ); @@ -137,12 +161,12 @@ void HYDROData_Obstacle::SetShape3D( const TopoDS_Shape& theShape ) HYDROData_ArtificialObject::SetTopShape( aShape2d ); } -QColor HYDROData_Obstacle::DefaultFillingColor() +QColor HYDROData_Obstacle::DefaultFillingColor() const { return QColor( Qt::yellow ); } -QColor HYDROData_Obstacle::DefaultBorderColor() +QColor HYDROData_Obstacle::DefaultBorderColor() const { return QColor( Qt::transparent ); } @@ -203,16 +227,28 @@ QString HYDROData_Obstacle::GetFilePath() const bool HYDROData_Obstacle::ImportFromGeomIOR( const TCollection_AsciiString& theIOR ) { - if ( theIOR.IsEmpty() ) - return false; - - TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR.ToCString() ); - if ( aShape.IsNull() ) - return false; + bool aRes = false; - SetShape3D( aShape ); +#ifndef LIGHT_MODE + if ( theIOR.IsEmpty() ) { + return aRes; + } - return true; + int aDocId = -1; + if ( !HYDROData_Document::DocumentId( HYDROData_Document::Document( myLab ), aDocId ) || aDocId < 0 ) { + return aRes; + } + + // TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR.ToCString() ); + TopoDS_Shape aShape = HYDROData_GeomTool::GetShapeFromIOR( aDocId, theIOR.ToCString() ); + + if ( !aShape.IsNull() ) { + SetShape3D( aShape ); + aRes = true; + } +#endif + + return aRes; } void HYDROData_Obstacle::SetGeomObjectEntry( const TCollection_AsciiString& theEntry ) @@ -244,21 +280,17 @@ TCollection_AsciiString HYDROData_Obstacle::GetGeomObjectName() const return aRes; } - int argc = 0; - char** argv = 0; - CORBA::ORB_var anORB = CORBA::ORB_init( argc, argv, "omniORB4"/*CORBA::ORB_ID*/ ); - SALOME_NamingService aNameService( anORB ); - - CORBA::Object_var aSMObject = aNameService.Resolve("/myStudyManager"); - SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject); - SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID( aDocId ); - - TCollection_AsciiString anEntry = GetGeomObjectEntry(); - SALOMEDS::SObject_var aSObject = aDSStudy->FindObjectID( anEntry.ToCString() ); - if ( !aSObject->_is_nil() ) { - aRes = TCollection_AsciiString( aSObject->GetName() ); - } +#ifndef LIGHT_MODE + SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( aDocId ); + if ( !aDSStudy->_is_nil() ) { + TCollection_AsciiString anEntry = GetGeomObjectEntry(); + SALOMEDS::SObject_var aSObject = aDSStudy->FindObjectID( anEntry.ToCString() ); + if ( !aSObject->_is_nil() ) { + aRes = TCollection_AsciiString( aSObject->GetName() ); + } + } +#endif return aRes; } @@ -291,6 +323,7 @@ TopoDS_Shape HYDROData_Obstacle::ImportIGES( const QString& theFilePath ) const { TopoDS_Shape aResShape; +#ifndef LIGHT_MODE // Set "C" numeric locale to save numbers correctly Kernel_Utils::Localizer loc; @@ -325,6 +358,7 @@ TopoDS_Shape HYDROData_Obstacle::ImportIGES( const QString& theFilePath ) const catch(Standard_Failure) { aResShape.Nullify(); } +#endif return aResShape; } @@ -333,6 +367,7 @@ TopoDS_Shape HYDROData_Obstacle::ImportSTEP( const QString& theFilePath ) const { TopoDS_Shape aResShape; +#ifndef LIGHT_MODE // Set "C" numeric locale to save numbers correctly Kernel_Utils::Localizer loc; @@ -436,22 +471,14 @@ TopoDS_Shape HYDROData_Obstacle::ImportSTEP( const QString& theFilePath ) const catch (Standard_Failure) { aResShape.Nullify(); } +#endif return aResShape; } -QColor HYDROData_Obstacle::getDefaultFillingColor() const -{ - return DefaultFillingColor(); -} - -QColor HYDROData_Obstacle::getDefaultBorderColor() const -{ - return DefaultBorderColor(); -} - ObjectKind HYDROData_Obstacle::getAltitudeObjectType() const { + DEBTRACE("HYDROData_Obstacle::getAltitudeObjectType"); return KIND_OBSTACLE_ALTITUDE; }