From: jfa Date: Mon, 27 Jun 2005 12:25:40 +0000 (+0000) Subject: IPAL9191: Import MED object from MED Component X-Git-Tag: T3_0_0_a4~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a897998555ee3db366c6ec48ae207ce77150ec1f;p=modules%2Fvisu.git IPAL9191: Import MED object from MED Component --- diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index e68d110d..7b7e1b8f 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2002-02-22 16:56:46 CET\n" -"PO-Revision-Date: 2005-06-15 21:15+0400\n" +"PO-Revision-Date: 2005-06-27 12:38+0400\n" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -40,8 +40,8 @@ msgid "VisuGUI::MEN_IMPORT_TABLE" msgstr "Import table from File" #msgid "ERR_CANT_BUILD_PRESENTATION" -msgid "VisuGUI::ERR_CANT_BUILD_PRESENTATION" -msgstr "Cannot build presentation" +#msgid "VisuGUI::ERR_CANT_BUILD_PRESENTATION" +#msgstr "Cannot build presentation" #msgid "ERR_ERROR_IN_THE_FILE" msgid "VisuGUI::ERR_ERROR_IN_THE_FILE" @@ -251,6 +251,9 @@ msgstr "Global Selection" msgid "VisuGUI::MEN_PARTIAL_SELECTION" msgstr "Partial Selection" +msgid "VisuGUI::MEN_IMPORT_MED" +msgstr "Import Structure" + msgid "VisuGUI::DLG_OPACITY_TITLE" msgstr "Opacity" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index e7215415..3ab58d0d 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -267,7 +267,95 @@ OnExportTableToFile() if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()"); } -void +/*jfa tmp:void +VisuGUI:: +OnImportMedField() +{ + _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); + if (CheckLock(aCStudy)) + return; + + SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + SALOME_ListIO aListIO; + aSelectionMgr->selectedObjects(aListIO); + + SALOME_ListIteratorOfListIO It (aListIO); + QApplication::setOverrideCursor(Qt::waitCursor); + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) anIO = It.Value(); + //SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); + _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry()); + //if (!aSObject->_is_nil()) { + if (aSObject) { + CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject); + if (!CORBA::is_nil(anObject)) { + SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); + if (!CORBA::is_nil(aMED.in())) + GetVisuGen(this)->ClientImportMed(aSObject); + SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); + if (!CORBA::is_nil(aField.in())) + GetVisuGen(this)->ImportMedField(aField); + } else { + //SALOMEDS::SObject_var aSFather = aSObject->GetFather(); + _PTR(SObject) aSFather = aSObject->GetFather(); + //SALOMEDS::GenericAttribute_var anAttr; + _PTR(GenericAttribute) anAttr; + aSFather->FindAttribute(anAttr, "AttributeName"); + //SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + _PTR(AttributeName) aName (anAttr); + std::string aValue = aName->Value(); + if (strcmp(aValue.c_str(), "MEDFIELD") == 0) + GetVisuGen(this)->ClientImportMed(aSObject); + } + } + } + updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +}*/ + +void +VisuGUI:: +OnImportMedField() +{ + _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); + if (CheckLock(aCStudy)) + return; + SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy); + + SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + SALOME_ListIO aListIO; + aSelectionMgr->selectedObjects(aListIO); + + SALOME_ListIteratorOfListIO It (aListIO); + QApplication::setOverrideCursor(Qt::waitCursor); + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) anIO = It.Value(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); + if (!aSObject->_is_nil()) { + CORBA::Object_var anObject = VISU::SObjectToObject(aSObject); + if (!CORBA::is_nil(anObject)) { + SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); + if (!CORBA::is_nil(aMED.in())) + GetVisuGen(this)->ImportMed(aSObject); + SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); + if (!CORBA::is_nil(aField.in())) + GetVisuGen(this)->ImportMedField(aField); + } else { + SALOMEDS::SObject_var aSFather = aSObject->GetFather(); + SALOMEDS::GenericAttribute_var anAttr; + aSFather->FindAttribute(anAttr, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aValue = aName->Value(); + if (strcmp(aValue.in(), "MEDFIELD") == 0) + GetVisuGen(this)->ImportMed(aSObject); + } + } + } + updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +void CreateCurves( SalomeApp_Module* theModule, VISU::CutLines_i* thePrs, QDialog* theDlg, @@ -614,7 +702,7 @@ OnDisplayPrs() SALOME_ListIO aList; SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this); mgr->selectedObjects(aList); - + Handle(SALOME_InteractiveObject) anIO; for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { anIO = it.Value(); @@ -1157,7 +1245,7 @@ OnShowTable() SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() ); } } - } + } } else { // possibly this is Table SObject SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() ); @@ -1167,10 +1255,10 @@ OnShowTable() return; VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ), - SO, - false, + SO, + false, //SAL2670 Orientation of show tables - VisuGUI_TableDlg::ttAuto, + VisuGUI_TableDlg::ttAuto, Qt::Vertical ); dlg->show(); } @@ -1410,7 +1498,7 @@ OnCurveProperties() SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); if (aListIO.Extent() != 1) return; - + SalomeApp_Study* aAppStudy = GetAppStudy(this); const Handle(SALOME_InteractiveObject)& anIO = aListIO.First(); CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() ); @@ -1924,6 +2012,10 @@ createActions() createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(), tr("MEN_EXPORT_TABLE"), "", 0, aParent, false, this, SLOT(OnExportTableToFile())); + createAction( VISU_IMPORT_MED, tr("MEN_IMPORT_MED"), QIconSet(), + tr("MEN_IMPORT_MED"), "", 0, aParent, false, + this, SLOT(OnImportMedField())); + //aPixmap = aResourceMgr->loadPixmap("VISU",tr("")); createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(), tr("MEN_CREATE_PRS"), "", 0, aParent, false, this, SLOT(OnCreateMesh())); @@ -2305,13 +2397,17 @@ createPopupMenus() mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true ); mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true ); + + aRule = "client='ObjectBrowser' and type='MEDFIELD'"; + mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure + mgr->setRule( action( VISU_IMPORT_MED ), aRule, true ); } //*************************************************************************** void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle ) { SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle); - + SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -2326,6 +2422,21 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q action( VISU_EXPORT_TABLE )->addTo(theMenu); theMenu->insertSeparator(); action( VISU_DELETE )->addTo(theMenu); + } else { + if (!CORBA::is_nil(anObject)) { + SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); + if (!CORBA::is_nil(aMED.in())) { + action( VISU_IMPORT_MED )->addTo(theMenu); + } else { + _PTR(SObject) aSFather = SO->GetFather(); + _PTR(GenericAttribute) anAttr; + aSFather->FindAttribute(anAttr, "AttributeName"); + _PTR(AttributeName) aName (anAttr); + std::string aValue = aName->Value(); + if (strcmp(aValue.c_str(), "MEDFIELD") == 0) + action( VISU_IMPORT_MED )->addTo(theMenu); + } + } } } diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 4c5d475e..31467af0 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -1,28 +1,28 @@ // VISU VISUGUI : GUI of VISU component // // Copyright (C) 2003 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 -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// 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 +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : VisuGUI.h -// Author : Laurent CORNABE & Hubert ROLLAND +// Author : Laurent CORNABE & Hubert ROLLAND // Module : VISU // $Header$ @@ -72,6 +72,7 @@ protected slots: void OnExploreMEDFile(); void OnImportTableFromFile(); void OnExportTableToFile(); + void OnImportMedField(); void OnCreateMesh(); void OnCreateScalarMap(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 027f60c1..ce67fa8d 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -61,5 +61,7 @@ #define VISU_PARTIAL_SELECTION 4072 #define VISU_SCALING 4073 +#define VISU_IMPORT_MED 4074 + #endif diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 11ffff01..0df04a87 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -404,17 +404,15 @@ namespace VISU{ return Base_i::GetID(); } - void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy) + void VISU_Gen_i::SetCurrentStudy (SALOMEDS::Study_ptr theStudy) { if (!CORBA::is_nil(theStudy)) { CORBA::String_var aName = theStudy->Name(); QString aStudyName (aName.in()); - MESSAGE("VISU_Gen_i::SetCurrentStudy - StudyId = " << - theStudy->StudyId() << "; Name = '" << aName.in() << "'"); + MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'"); myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); - MESSAGE("Find application for study : " << aName.in()); bool isActive = false; SUIT_Session* aSession = SUIT_Session::session(); QPtrList anApplications = aSession->applications(); @@ -433,12 +431,13 @@ namespace VISU{ } } if (!isActive) { + MESSAGE("!!! anApp->onLoadDoc(aName.in()) !!!"); // Has to be loaded in an empty or in a new application SalomeApp_Application* anApp = dynamic_cast(aFirstApp); anApp->onLoadDoc(aName.in()); } } else { - MESSAGE("VISU_Gen_i::SetCurrentStudy : CORBA::is_nil(theStudy)"); + MESSAGE("CORBA::is_nil(theStudy)"); } } @@ -496,31 +495,39 @@ namespace VISU{ return aResult._retn(); } - Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){ - if(myStudyDocument->GetProperties()->IsLocked()) + Result_ptr VISU_Gen_i::ClientImportMed (_PTR(SObject) theMedSObject) + { + SALOMEDS::SObject_ptr aMedSObject = GetSObject(theMedSObject); + return ImportMed(aMedSObject); + } + + Result_ptr VISU_Gen_i::ImportMed (SALOMEDS::SObject_ptr theMedSObject) + { + if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); Mutex mt(myMutex); Result_i* pResult = new Result_i(myStudyDocument, Result_i::eComponent, Result_i::eImportMed); - if(pResult->Create(theMedSObject) != NULL) + if (pResult->Create(theMedSObject) != NULL) { return pResult->_this(); - else{ + } else { pResult->_remove_ref(); return VISU::Result::_nil(); } } - Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){ - if(myStudyDocument->GetProperties()->IsLocked()) + Result_ptr VISU_Gen_i::ImportMedField (SALOME_MED::FIELD_ptr theField) + { + if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); Mutex mt(myMutex); Result_i* pResult = new Result_i(myStudyDocument, Result_i::eComponent, Result_i::eImportMedField); - if(pResult->Create(theField) != NULL) + if (pResult->Create(theField) != NULL) { return pResult->_this(); - else{ + } else { pResult->_remove_ref(); return VISU::Result::_nil(); } diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 77584d64..edd59e26 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -48,6 +48,8 @@ namespace VISU{ virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject); virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField); + Result_ptr ClientImportMed (_PTR(SObject) theMedSObject); + //Create Presentation Of Submeshes virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity); virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index db8750d1..9d55e786 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -115,7 +115,9 @@ void CreateReference(SALOMEDS::Study_ptr theStudyDocument, aStudyBuilder->Addreference(newObj,aRefSObj); } -string GetComponentDataType(SALOMEDS::SObject_ptr theSObject){ +string GetComponentDataType (SALOMEDS::SObject_ptr theSObject) +{ + SALOMEDS::Study_var aStudy = theSObject->GetStudy(); SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent(); CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); return aDataType.in();