From: fps Date: Thu, 14 Nov 2013 16:58:32 +0000 (+0000) Subject: publish imported fields to study X-Git-Tag: BR_hydro_v_0_3_1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=73a4cdc781b6df02875e977ffeb9871f75edb026;p=modules%2Fgeom.git publish imported fields to study --- diff --git a/src/ImportExportGUI/CMakeLists.txt b/src/ImportExportGUI/CMakeLists.txt index 2ffcf72f0..fd1451b78 100644 --- a/src/ImportExportGUI/CMakeLists.txt +++ b/src/ImportExportGUI/CMakeLists.txt @@ -38,6 +38,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOMImpl ${PROJECT_SOURCE_DIR}/src/GEOMGUI ${PROJECT_SOURCE_DIR}/src/GEOMBase + ${PROJECT_SOURCE_DIR}/src/GEOM ${PROJECT_SOURCE_DIR}/src/DlgRef ${PROJECT_BINARY_DIR}/src/DlgRef ) diff --git a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx index e3b17f678..186f4f357 100644 --- a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx +++ b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.cxx @@ -19,12 +19,15 @@ #include #include #include +#include #include #include +#include #include #include #include +#include #include #include @@ -43,6 +46,8 @@ #include #include "ImportExportGUI_ImportXAODlg.h" +#include + //================================================================================= // Constructor //================================================================================= @@ -139,7 +144,7 @@ void ImportExportGUI_ImportXAODlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -bool ImportExportGUI_ImportXAODlg::ClickOnApply() +/*bool ImportExportGUI_ImportXAODlg::ClickOnApply() { if (!onAccept()) return false; @@ -147,6 +152,45 @@ bool ImportExportGUI_ImportXAODlg::ClickOnApply() initName(); return true; +}*/ + +bool ImportExportGUI_ImportXAODlg::ClickOnApply() +{ + if(!isApplyAndClose()) { + setIsDisableBrowsing( true ); + setIsDisplayResult( false ); + } + + QString msg; + if ( !isValid( msg ) ) { + showError( msg ); + return false; + } + SUIT_OverrideCursor wc; + SUIT_Session::session()->activeApplication()->putInfo( "" ); + + try { + if ( openCommand() ) + if (!execute (/*isApplyAndClose()*/)) + { + abortCommand(); + showError(); + return false; + } + } + catch( const SALOME::SALOME_Exception& e ) { + SalomeApp_Tools::QtCatchCorbaException( e ); + abortCommand(); + return false; + } + commitCommand(); + + if(!isApplyAndClose()) { + setIsDisableBrowsing( false ); + setIsDisplayResult( true ); + } + + return true; } //================================================================================= @@ -208,7 +252,7 @@ bool ImportExportGUI_ImportXAODlg::isValid(QString& msg) // function : execute // purpose : //================================================================================= -bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects) +bool ImportExportGUI_ImportXAODlg::execute() { bool res = false; @@ -223,29 +267,70 @@ bool ImportExportGUI_ImportXAODlg::execute(ObjectList& objects) if (!shape->_is_nil()) { m_mainShape = shape; - objects.push_back(shape._retn()); } else { m_mainShape = NULL; } - for (int i = 0; i < subShapes->length(); i++) - { - objects.push_back(GEOM::GEOM_Object::_duplicate(subShapes[i])); - } - for (int i = 0; i < groups->length(); i++) - { - objects.push_back(GEOM::GEOM_Object::_duplicate(groups[i])); - } - for (int i = 0; i < fields->length(); i++) + if (m_mainShape != NULL) { - //objects.push_back(GEOM::GEOM_Field::_duplicate(fields[i])); + addInStudy(m_mainShape, m_mainShape->GetName()); + + for (int i = 0; i < subShapes->length(); i++) + { + addInStudy(subShapes[i].in(), subShapes[i]->GetName()); + } + for (int i = 0; i < groups->length(); i++) + { + addInStudy(groups[i].in(), groups[i]->GetName()); + } + for (int i = 0; i < fields->length(); i++) + { + addFieldInStudy(fields[i].in(), m_mainShape); + } + + updateObjBrowser(); } return res; } +QString ImportExportGUI_ImportXAODlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEOM::GEOM_Object_ptr theFather) +{ + if ( !hasCommand() ) + return QString(); + + _PTR(Study) aStudy = getStudy()->studyDS(); + if ( !aStudy || theField->_is_nil() ) + return QString(); + + SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy); + + SALOMEDS::SObject_var aSO = + getGeomEngine()->AddInStudy(aStudyDS, theField, theField->GetName(), theFather); + + QString anEntry; + if ( !aSO->_is_nil() ) { + CORBA::String_var entry = aSO->GetID(); + anEntry = entry.in(); + } + + // add steps + GEOM::ListOfLong_var steps = theField->GetSteps(); + for (int i = 0; i < steps->length(); ++i) + { + GEOM::GEOM_FieldStep_ptr step = theField->GetStep(steps[i]); + QString stepName = (tr("STEP") + " %1 %2").arg( step->GetID() ).arg( step->GetStamp() ); + SALOMEDS::SObject_wrap aSOField = + getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toLatin1().constData(), theField ); + } + + aSO->UnRegister(); + + return anEntry; +} + GEOM::GEOM_Object_ptr ImportExportGUI_ImportXAODlg::getFather(GEOM::GEOM_Object_ptr object) { GEOM::GEOM_Object_var fatherObj; diff --git a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h index baacc3311..15ec77b01 100644 --- a/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h +++ b/src/ImportExportGUI/ImportExportGUI_ImportXAODlg.h @@ -42,9 +42,10 @@ protected: // redefined from GEOMBase_Helper virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid(QString&); - virtual bool execute(ObjectList&); + virtual bool execute(); virtual GEOM::GEOM_Object_ptr getFather(GEOM::GEOM_Object_ptr object); virtual QString getObjectName(GEOM::GEOM_Object_ptr object) const; + virtual QString addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEOM::GEOM_Object_ptr theFather ); private: void Init();