From b29346253f2ca9139088351013761a970e1647ba Mon Sep 17 00:00:00 2001 From: abn Date: Tue, 30 Aug 2016 14:52:36 +0200 Subject: [PATCH] Merge 'abn/V8_1_fix' branch into V8_1_BR. --- idl/MEDDataManager.idl | 6 +- idl/MEDPresentationManager.idl | 8 +- idl/MED_Gen.idl | 22 +- resources/SalomeApp.xml.in | 2 +- src/MEDCalc/cmp/MED.cxx | 119 ++- src/MEDCalc/cmp/MED.hxx | 20 +- src/MEDCalc/cmp/MEDDataManager_i.cxx | 23 +- src/MEDCalc/cmp/MEDDataManager_i.hxx | 6 +- src/MEDCalc/cmp/MEDPresentation.cxx | 119 ++- src/MEDCalc/cmp/MEDPresentation.hxx | 20 +- src/MEDCalc/cmp/MEDPresentationContour.cxx | 11 +- src/MEDCalc/cmp/MEDPresentationContour.hxx | 2 + .../cmp/MEDPresentationDeflectionShape.cxx | 18 +- .../cmp/MEDPresentationDeflectionShape.hxx | 2 + src/MEDCalc/cmp/MEDPresentationManager_i.cxx | 22 +- src/MEDCalc/cmp/MEDPresentationManager_i.hxx | 1 + src/MEDCalc/cmp/MEDPresentationManager_i.txx | 5 +- src/MEDCalc/cmp/MEDPresentationMeshView.cxx | 25 +- src/MEDCalc/cmp/MEDPresentationMeshView.hxx | 3 + .../cmp/MEDPresentationPointSprite.cxx | 27 +- .../cmp/MEDPresentationPointSprite.hxx | 3 + src/MEDCalc/cmp/MEDPresentationScalarMap.cxx | 2 +- src/MEDCalc/cmp/MEDPresentationSlices.cxx | 8 +- .../cmp/MEDPresentationVectorField.cxx | 20 +- .../cmp/MEDPresentationVectorField.hxx | 2 + src/MEDCalc/gui/DatasourceController.cxx | 46 +- src/MEDCalc/gui/MEDModule.cxx | 57 +- src/MEDCalc/gui/MEDModule.hxx | 8 +- src/MEDCalc/gui/MEDWidgetHelper.cxx | 2 + src/MEDCalc/gui/MED_msg_en.ts | 717 +++++++++--------- src/MEDCalc/gui/MED_msg_fr.ts | 702 +++++++++-------- src/MEDCalc/gui/PresentationController.cxx | 202 +++-- src/MEDCalc/gui/PresentationController.hxx | 8 +- src/MEDCalc/gui/PresentationEvent.hxx | 1 + src/MEDCalc/gui/ProcessingController.cxx | 32 +- src/MEDCalc/gui/WorkspaceController.cxx | 6 + .../gui/dialogs/DlgChangeUnderlyingMesh.cxx | 19 +- .../gui/dialogs/DlgInterpolateField.cxx | 19 +- .../dialogs/WidgetPresentationParameters.cxx | 27 +- .../dialogs/WidgetPresentationParameters.hxx | 2 +- .../dialogs/WidgetPresentationParameters.ui | 3 + src/MEDCalc/test/tui/mesh_view.py | 2 +- src/MEDCalc/tui/__init__.py | 4 +- src/MEDCalc/tui/medcorba.py | 11 +- src/MEDCalc/tui/medio.py | 7 + src/MEDCalc/tui/medpresentation.py | 15 +- 46 files changed, 1448 insertions(+), 938 deletions(-) diff --git a/idl/MEDDataManager.idl b/idl/MEDDataManager.idl index c18cc2d38..b1e80d3db 100644 --- a/idl/MEDDataManager.idl +++ b/idl/MEDDataManager.idl @@ -124,8 +124,8 @@ module MEDCALC // Mesh data management //========================================================== - MeshHandler getMesh(in long meshId) raises (SALOME::SALOME_Exception); - MeshHandlerList getMeshList(in long datasourceId); + MeshHandler getMeshHandler(in long meshId) raises (SALOME::SALOME_Exception); + MeshHandlerList getMeshHandlerList(in long datasourceId); //========================================================== // Field data management @@ -168,6 +168,8 @@ module MEDCALC // Print out server data void serverlog(); + + void cleanUp() raises (SALOME::SALOME_Exception); }; }; diff --git a/idl/MEDPresentationManager.idl b/idl/MEDPresentationManager.idl index b86b63e45..006d89ddd 100644 --- a/idl/MEDPresentationManager.idl +++ b/idl/MEDPresentationManager.idl @@ -84,14 +84,18 @@ module MEDCALC // const long SCALAR_BAR_RANGE_VAL_MAX_DEFAULT = -1; const string DISPLAY_DEFAULT = DISPLAY_EUCLIDEAN_NORM; const SliceOrientationType SLICE_ORIENTATION_DEFAULT = SLICE_NORMAL_TO_X; + const long NB_CONTOURS_DEFAULT = 10; const long NB_SLICES_DEFAULT = 1; + const long NB_CONTOURS_MAX = 50; + const long NB_SLICES_MAX = 20; + /* Structs */ // Just showing the mesh struct MeshViewParameters { - long fieldHandlerId; // TODO should be a meshHandlerId really ... + long meshHandlerId; MeshModeType mode; }; @@ -185,6 +189,8 @@ module MEDCALC // ViewModeType getPresentationViewMode(in long presId); PresentationsList getAllPresentations(); + + void cleanUp() raises (SALOME::SALOME_Exception); }; }; diff --git a/idl/MED_Gen.idl b/idl/MED_Gen.idl index beefb0e19..7b13765e5 100644 --- a/idl/MED_Gen.idl +++ b/idl/MED_Gen.idl @@ -43,7 +43,7 @@ module MED_ORB in MEDCALC::DatasourceHandler datasourceHandler) raises (SALOME::SALOME_Exception); - status registerPresentation(in SALOMEDS::Study study, + status registerPresentationField(in SALOMEDS::Study study, in long fieldId, in string name, in string type, @@ -51,17 +51,31 @@ module MED_ORB in long presentationId) raises (SALOME::SALOME_Exception); + status registerPresentationMesh(in SALOMEDS::Study study, + in long meshId, + in string name, + in string type, + in string ico, + in long presentationId) + raises (SALOME::SALOME_Exception); + status unregisterPresentation(in SALOMEDS::Study study, in long presentationId) raises (SALOME::SALOME_Exception); - PresentationsList getSiblingPresentations(in SALOMEDS::Study study, - in long presentationId) - raises (SALOME::SALOME_Exception); +// PresentationsList getSiblingPresentations(in SALOMEDS::Study study, +// in long presentationId) +// raises (SALOME::SALOME_Exception); // Get all presentations in study: PresentationsList getStudyPresentations(in SALOMEDS::Study study) raises (SALOME::SALOME_Exception); + + string getStudyPresentationEntry(in SALOMEDS::Study study, + in long presentationId) + raises (SALOME::SALOME_Exception); + + void cleanUp(); }; }; diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index eeeb7e6e6..a690d0719 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -42,7 +42,7 @@
- +
diff --git a/src/MEDCalc/cmp/MED.cxx b/src/MEDCalc/cmp/MED.cxx index 4b0ce7df0..5ce6dac6f 100644 --- a/src/MEDCalc/cmp/MED.cxx +++ b/src/MEDCalc/cmp/MED.cxx @@ -50,7 +50,8 @@ MED::MED(CORBA::ORB_ptr orb, const char* instanceName, const char* interfaceName) : Engines_Component_i(orb, poa, contId, instanceName, interfaceName), - _fieldSeriesEntries() + _fieldSeriesEntries(), + _meshEntries() { _thisObj = this; _id = _poa->activate_object(_thisObj); // register and activate this servant object @@ -109,11 +110,12 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study, // We can add the meshes as children of the datasource MEDCALC::MeshHandlerList* meshHandlerList = - MEDFactoryClient::getDataManager()->getMeshList(datasourceHandler.id); + MEDFactoryClient::getDataManager()->getMeshHandlerList(datasourceHandler.id); for(CORBA::ULong iMesh=0; iMeshlength(); iMesh++) { MEDCALC::MeshHandler meshHandler = (*meshHandlerList)[iMesh]; SALOMEDS::SObject_var soMesh = studyBuilder->NewObject(soDatasource); + _meshEntries[meshHandler.id] = soMesh->GetID(); soMesh->SetAttrString("AttributeName", meshHandler.name); soMesh->SetAttrString("AttributePixMap", "ICO_DATASOURCE_MESH"); anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter"); @@ -157,7 +159,7 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study, } MED_ORB::status -MED::registerPresentation(SALOMEDS::Study_ptr study, +MED::registerPresentationField(SALOMEDS::Study_ptr study, CORBA::Long fieldId, const char* name, const char* type, @@ -170,12 +172,12 @@ MED::registerPresentation(SALOMEDS::Study_ptr study, MEDCALC::FieldHandler_var fldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); int fieldSeriesId = fldHandler->fieldseriesId; if (fieldSeriesId < 0){ - std::cerr << "MED::registerPresentation(): Error getting field handler\n"; + std::cerr << "MED::registerPresentationField(): Error getting field handler\n"; return MED_ORB::OP_ERROR ; } if (_fieldSeriesEntries.find(fieldSeriesId) == _fieldSeriesEntries.end()) { - std::cerr << "MED::registerPresentation(): Field series not found\n"; + std::cerr << "MED::registerPresentationField(): Field series not found\n"; return MED_ORB::OP_ERROR ; } std::string entry = _fieldSeriesEntries[fieldSeriesId]; @@ -183,7 +185,7 @@ MED::registerPresentation(SALOMEDS::Study_ptr study, SALOMEDS::SObject_ptr soFieldseries = sobject._retn(); if (soFieldseries->IsNull()) { - std::cerr << "MED::registerPresentation(): Entry not found\n"; + std::cerr << "MED::registerPresentationField(): Entry not found\n"; return MED_ORB::OP_ERROR; } @@ -207,6 +209,57 @@ MED::registerPresentation(SALOMEDS::Study_ptr study, return MED_ORB::OP_OK; } +MED_ORB::status +MED::registerPresentationMesh(SALOMEDS::Study_ptr study, + CORBA::Long meshId, + const char* name, + const char* type, + const char* ico, + CORBA::Long presentationId) +{ + // set exception handler to catch unexpected CORBA exceptions + Unexpect aCatch(SALOME_SalomeException); + + MEDCALC::MeshHandler_var meshHandler = MEDFactoryClient::getDataManager()->getMeshHandler(meshId); + if (meshHandler->id < 0){ + std::cerr << "MED::registerPresentationMesh(): Error getting mesh handler\n"; + return MED_ORB::OP_ERROR ; + } + + if (_meshEntries.find(meshHandler->id) == _meshEntries.end()) { + std::cerr << "MED::registerPresentationMesh(): mesh not found\n"; + return MED_ORB::OP_ERROR ; + } + std::string entry = _meshEntries[meshHandler->id]; + SALOMEDS::SObject_var sobject = study->FindObjectID(entry.c_str()); + SALOMEDS::SObject_ptr soMesh = sobject._retn(); + + if (soMesh->IsNull()) { + std::cerr << "MED::registerPresentationMesh(): Entry not found\n"; + return MED_ORB::OP_ERROR; + } + + SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); + SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); + SALOMEDS::SObject_var soPresentation = studyBuilder->NewObject(soMesh); + useCaseBuilder->AppendTo(soPresentation->GetFather(), soPresentation); + + soPresentation->SetAttrString("AttributeName", name); + soPresentation->SetAttrString("AttributePixMap", ico); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + anAttr = studyBuilder->FindOrCreateAttribute(soPresentation, "AttributeParameter"); + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + aParam->SetInt(MESH_ID, meshId); + aParam->SetBool(IS_PRESENTATION, true); + aParam->SetInt(PRESENTATION_ID, presentationId); + aParam->SetString(PRESENTATION_TYPE, type); + + return MED_ORB::OP_OK; +} + + MED_ORB::status MED::unregisterPresentation(SALOMEDS::Study_ptr study, CORBA::Long presentationId) @@ -271,9 +324,8 @@ MED::getStudyPresentations(SALOMEDS::Study_ptr study) return presList; } - -MED_ORB::PresentationsList* -MED::getSiblingPresentations(SALOMEDS::Study_ptr study, CORBA::Long presentationId) +char* +MED::getStudyPresentationEntry(SALOMEDS::Study_ptr study, int presentationId) { // set exception handler to catch unexpected CORBA exceptions Unexpect aCatch(SALOME_SalomeException); @@ -286,48 +338,29 @@ MED::getSiblingPresentations(SALOMEDS::Study_ptr study, CORBA::Long presentation SALOMEDS::GenericAttribute_var anAttribute; SALOMEDS::SComponent_var father = study->FindComponent("MED"); SALOMEDS::ChildIterator_var it = study->NewChildIterator(father); - for (it->InitEx(true); it->More(); it->Next()) { - SALOMEDS::SObject_var child(it->Value()); - - if (child->FindAttribute(anAttribute, "AttributeParameter")) { - SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute); - if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER)) - continue; + for (it->InitEx(true); it->More(); it->Next()) + { + SALOMEDS::SObject_var child(it->Value()); + if (child->FindAttribute(anAttribute, "AttributeParameter")) + { + SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute); + if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER)) + continue; - if (presentationId == attrParam->GetInt(PRESENTATION_ID)) { - // get siblings - SALOMEDS::ChildIterator_var siblItr = study->NewChildIterator(child->GetFather()); - for (siblItr->InitEx(true); siblItr->More(); siblItr->Next()) { - SALOMEDS::SObject_var sibl(siblItr->Value()); - - if (sibl->FindAttribute(anAttribute, "AttributeParameter")) { - SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute); - if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER)) - continue; - - if (attrParam->GetInt(PRESENTATION_ID) != presentationId) { - CORBA::ULong size = presList->length(); - presList->length(size+1); - (*presList)[size] = attrParam->GetInt(PRESENTATION_ID); - } - } + if (attrParam->GetInt(PRESENTATION_ID) == presentationId) + return CORBA::string_dup(child->GetID()); } - return presList; - } } - } - - return presList; + return CORBA::string_dup(""); } + Engines::TMPFile* MED::DumpPython(CORBA::Object_ptr theStudy, CORBA::Boolean isPublished, CORBA::Boolean isMultiFile, CORBA::Boolean& isValidScript) { - std::cout << "In MED::DumpPython\n"; - SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy); if(CORBA::is_nil(aStudy)) { std::cerr << "Error: Cannot find the study\n"; @@ -433,6 +466,12 @@ MED::getObjectInfo(CORBA::Long studyId, const char* entry) return CORBA::string_dup(oss.str().c_str()); } +void MED::cleanUp() +{ + _fieldSeriesEntries.clear(); + _meshEntries.clear(); +} + extern "C" { /*! diff --git a/src/MEDCalc/cmp/MED.hxx b/src/MEDCalc/cmp/MED.hxx index 57a3cc381..fb78501ca 100644 --- a/src/MEDCalc/cmp/MED.hxx +++ b/src/MEDCalc/cmp/MED.hxx @@ -55,23 +55,34 @@ public: MED_ORB::status addDatasourceToStudy(SALOMEDS::Study_ptr study, const MEDCALC::DatasourceHandler& datasourceHandler); - MED_ORB::status registerPresentation(SALOMEDS::Study_ptr study, + MED_ORB::status registerPresentationField(SALOMEDS::Study_ptr study, CORBA::Long fieldId, const char* name, const char* type, const char* ico, CORBA::Long presentationId); + MED_ORB::status registerPresentationMesh(SALOMEDS::Study_ptr study, + CORBA::Long meshId, + const char* name, + const char* type, + const char* ico, + CORBA::Long presentationId); + MED_ORB::status unregisterPresentation(SALOMEDS::Study_ptr study, CORBA::Long presentationId); - // Caller owns the returned list, and is responsible for the list deletion. - MED_ORB::PresentationsList* getSiblingPresentations(SALOMEDS::Study_ptr study, - CORBA::Long presentationId); +// // Caller owns the returned list, and is responsible for the list deletion. +// MED_ORB::PresentationsList* getSiblingPresentations(SALOMEDS::Study_ptr study, +// CORBA::Long presentationId); // Get all presentations registered in the study MED_ORB::PresentationsList* getStudyPresentations(SALOMEDS::Study_ptr study); + char* getStudyPresentationEntry(SALOMEDS::Study_ptr study, int presentationId); + + void cleanUp(); + /*! Dump the study as a Python file */ virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, CORBA::Boolean isPublished, @@ -84,6 +95,7 @@ public: private: std::map _fieldSeriesEntries; + std::map _meshEntries; }; extern "C" diff --git a/src/MEDCalc/cmp/MEDDataManager_i.cxx b/src/MEDCalc/cmp/MEDDataManager_i.cxx index f4b624323..6a703eabb 100644 --- a/src/MEDCalc/cmp/MEDDataManager_i.cxx +++ b/src/MEDCalc/cmp/MEDDataManager_i.cxx @@ -52,11 +52,30 @@ MEDDataManager_i::MEDDataManager_i() _meshLastId = 0; _fieldseriesLastId = 0; } + MEDDataManager_i::~MEDDataManager_i() { LOG("Deleting MEDDataManager_i instance"); } +void MEDDataManager_i::cleanUp() +{ + _fieldLastId = 0; + _sourceLastId = 0; + _meshLastId = 0; + _fieldseriesLastId = 0; + + // [ABN] Is it the proper way? + _datasourceHandlerMap.clear(); + _meshHandlerMap.clear(); + _fieldseriesHandlerMap.clear(); + _fieldHandlerMap.clear(); + _fieldDoubleMap.clear(); + _meshMap.clear(); + _fieldPersistencyMap.clear(); +} + + std::string MEDDataManager_i::file_to_source(const char * filepath) { string source("file://"); @@ -236,7 +255,7 @@ MEDDataManager_i::getDatasourceHandlerFromID(CORBA::Long sourceid) return NULL; } -MEDCALC::MeshHandler * MEDDataManager_i::getMesh(CORBA::Long meshId) { +MEDCALC::MeshHandler * MEDDataManager_i::getMeshHandler(CORBA::Long meshId) { if ( _meshHandlerMap.count(meshId) == 0 ) { std::string message = std::string("The mesh of id=") + ToString(meshId) + @@ -253,7 +272,7 @@ MEDCALC::MeshHandler * MEDDataManager_i::getMesh(CORBA::Long meshId) { * specified datasource. It corresponds to the list ofmeshes defined * in the datasource. */ -MEDCALC::MeshHandlerList * MEDDataManager_i::getMeshList(CORBA::Long datasourceId) { +MEDCALC::MeshHandlerList * MEDDataManager_i::getMeshHandlerList(CORBA::Long datasourceId) { // We initiate a list with the maximum lentgh MEDCALC::MeshHandlerList_var meshHandlerList = new MEDCALC::MeshHandlerList(); diff --git a/src/MEDCalc/cmp/MEDDataManager_i.hxx b/src/MEDCalc/cmp/MEDDataManager_i.hxx index fdab5af40..f6a5611b0 100644 --- a/src/MEDCalc/cmp/MEDDataManager_i.hxx +++ b/src/MEDCalc/cmp/MEDDataManager_i.hxx @@ -75,8 +75,8 @@ public: // ----------------------------------------------------------- // Mesh management - MEDCALC_EXPORT MEDCALC::MeshHandlerList * getMeshList(CORBA::Long datasourceId); - MEDCALC_EXPORT MEDCALC::MeshHandler * getMesh(CORBA::Long meshId); + MEDCALC_EXPORT MEDCALC::MeshHandlerList * getMeshHandlerList(CORBA::Long datasourceId); + MEDCALC_EXPORT MEDCALC::MeshHandler * getMeshHandler(CORBA::Long meshId); // ----------------------------------------------------------- // Field management @@ -107,6 +107,8 @@ public: MEDCALC_EXPORT void serverlog(); + MEDCALC_EXPORT void cleanUp(); + // // =========================================================== // Other public functions (non available via CORBA) diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index a0beac542..84b74bc67 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -36,37 +36,20 @@ const std::string MEDPresentation::PROP_COMPONENT = "component_"; const std::string MEDPresentation::PROP_COLOR_MAP = "colorMap"; const std::string MEDPresentation::PROP_SCALAR_BAR_RANGE = "scalarBarRange"; -MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name, +MEDPresentation::MEDPresentation(MEDPresentation::TypeID handlerId, const std::string& name, const MEDCALC::ViewModeType viewMode, const MEDCALC::ColorMapType colorMap, const MEDCALC::ScalarBarRangeType sbRange) - : _fieldHandlerId(fieldHandlerId), _propertiesStr(), - //_pipeline(0), _display(0) + : _handlerId(handlerId), _propertiesStr(), + _mcFieldType(MEDCoupling::ON_CELLS), + _pvFieldType(""), _meshName(""), _fieldName(""), _fileName(""), _selectedComponentIndex(-1), _viewMode(viewMode), _colorMap(colorMap), _sbRange(sbRange), - _renderViewPyId(-1), // will be set by getRenderViewCommand() + _renderViewPyId(-1), // will be set by MEDPresentationManager_i::_makePresentation() _globalDict(0) { - MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); - MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId); - MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid); - MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); - - _fileName = dataSHandler->uri; - _fieldName = fieldHandler->fieldname; - _mcFieldType = (MEDCoupling::TypeOfField) fieldHandler->type; - _pvFieldType = getPVFieldTypeString(_mcFieldType); - _meshName = meshHandler->name; - - if (_fileName.substr(0, 7) != std::string("file://")) { - const char* msg = "MEDPresentation(): Data source is not a file! Can not proceed."; - STDLOG(msg); - throw MEDPresentationException(msg); - } - _fileName = _fileName.substr(7, _fileName.size()); - setStringProperty(MEDPresentation::PROP_NAME, name); setIntProperty(MEDPresentation::PROP_NB_COMPONENTS, 0); @@ -90,17 +73,51 @@ MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const s _rangeVar = oss_r.str(); } +/** + * For most of the presentations the field name etc is required. + * For the MEDPresentationMeshView however, the handler ID is a mesh handler ID, not a field, and the + * treatment is specific. + */ +void +MEDPresentation::initFieldMeshInfos() +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(_handlerId); + MEDCALC::MeshHandler* meshHandler = dataManager->getMeshHandler(fieldHandler->meshid); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + extractFileName(std::string(dataSHandler->uri)); + + _fieldName = fieldHandler->fieldname; + _mcFieldType = (MEDCoupling::TypeOfField) fieldHandler->type; + _pvFieldType = getPVFieldTypeString(_mcFieldType); + _colorByType = _pvFieldType; // by default the same; overriden in DeflectionShape, VectorField, PointSprite and Contour + _meshName = meshHandler->name; +} + +void +MEDPresentation::extractFileName(const std::string& name) +{ + _fileName = name; + if (_fileName.substr(0, 7) != std::string("file://")) { + const char* msg = "MEDPresentation(): Data source is not a file! Can not proceed."; + STDLOG(msg); + throw MEDPresentationException(msg); + } + _fileName = _fileName.substr(7, _fileName.size()); +} + MEDPresentation::~MEDPresentation() { STDLOG("~MEDPresentation(): clear display"); { MEDPyLockWrapper lock; - std::ostringstream oss_v, oss; - oss_v << "__view" << _renderViewPyId; - oss << "pvs.Hide(" << _objVar << ", view=" << oss_v.str() << ");"; - oss << "pvs.Render();"; + std::ostringstream oss; - PyRun_SimpleString(oss.str().c_str()); + oss << "pvs.Hide(" << _objVar << ", view=" << getRenderViewVar() << ");"; + execPyLine(oss.str()); + execPyLine(getRenderViewVar() + ".ResetCamera();"); + execPyLine("pvs.Render();"); } } @@ -280,9 +297,14 @@ MEDPresentation::createSource() oss << "medcalc.SelectSourceField(" << _srcObjVar << ", '" << _meshName << "', '" << _fieldName << "', '" << typ << "');"; pushAndExecPyLine(oss.str()); oss.str(""); + // Generate complete vector fields: fields with 2 components will copied into _vector and + // have a third null component added. oss << _srcObjVar << ".GenerateVectors = 1;"; pushAndExecPyLine(oss.str()); oss.str(""); + // Make sure this is set so we stick to time steps: + pushAndExecPyLine("pvs.GetAnimationScene().PlayMode = 'Snap To TimeSteps'"); + // Deal with GAUSS fields: if(_mcFieldType == MEDCoupling::ON_GAUSS_PT) { @@ -316,7 +338,7 @@ MEDPresentation::setOrCreateRenderView() pushAndExecPyLine(oss2.str()); oss2.str(""); if (_viewMode == MEDCALC::VIEW_MODE_OVERLAP) { // this might potentially re-assign to an existing view variable, but this is OK, we - // normally reassign exaclty the same RenderView object. + // normally reassign exactly the same RenderView object. oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');"; pushAndExecPyLine(oss2.str()); oss2.str(""); } else if (_viewMode == MEDCALC::VIEW_MODE_REPLACE) { @@ -432,10 +454,10 @@ MEDPresentation::showScalarBar() } void -MEDPresentation::colorBy(const std::string & fieldType) +MEDPresentation::colorBy() { std::ostringstream oss; - oss << "pvs.ColorBy(" << _dispVar << ", ('" << fieldType << "', '" << _fieldName << "'));"; + oss << "pvs.ColorBy(" << _dispVar << ", ('" << _colorByType << "', '" << _fieldName << "'));"; pushAndExecPyLine(oss.str()); } @@ -473,13 +495,46 @@ MEDPresentation::GeneratePythonId() return INIT_ID++; } -void +bool MEDPresentation::activateView() { MEDPyLockWrapper lock; - pushAndExecPyLine("pvs.SetActiveView(" + getRenderViewVar() + ");"); + + execPyLine("__alive = " + getRenderViewVar() + " in pvs.GetRenderViews()"); + PyObject * obj = getPythonObjectFromMain("__alive"); + bool alive = true; + if (obj && PyBool_Check(obj)) + alive = (obj == Py_True); + + if (alive) + // The view is still there,just activate it: + pushAndExecPyLine("pvs.SetActiveView(" + getRenderViewVar() + ");"); + else + { + // The view disappeared, recreate it in a new layout. The transfer of the objects is to be done by the caller. + std::ostringstream oss; + oss << "pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');"; + pushAndExecPyLine(oss.str()); oss.str(""); + oss << getRenderViewVar() << " = pvs.CreateView('RenderView');"; + pushAndExecPyLine(oss.str()); oss.str(""); + } + return alive; } +/**! + * Called when the view has been recreated (because the user closed it). + * All the objects and set up are re-shown in the new view (which is stored in the same Python variable). + */ +void +MEDPresentation::recreateViewSetup() +{ + showObject(); + colorBy(); + showScalarBar(); + selectColorMap(); + rescaleTransferFunction(); + resetCameraAndRender(); +} std::string MEDPresentation::paravisDump() const diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index dc05e9fca..800b7cd91 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -40,6 +40,8 @@ class MEDCALC_EXPORT MEDPresentation public: typedef ::CORBA::Long TypeID; + virtual void initFieldMeshInfos(); + virtual ~MEDPresentation(); static const std::string PROP_NAME; // name of the presentation @@ -55,7 +57,10 @@ public: virtual void setIntProperty(const std::string& propName, const int propValue); int getIntProperty(const std::string& propName) const; - void activateView(); // non const because generates a Python trace + // returns True if the view was still alive, False if it must have been recreated + // because the user closed it. + bool activateView(); + virtual void recreateViewSetup(); void dumpIntProperties() const; void dumpStringProperties() const; @@ -69,7 +74,7 @@ protected: typedef std::pair PyObjectId; static int GeneratePythonId(); - MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name, + MEDPresentation(MEDPresentation::TypeID handlerId, const std::string& name, const MEDCALC::ViewModeType viewMode, const MEDCALC::ColorMapType colorMap, const MEDCALC::ScalarBarRangeType sbRange); @@ -80,7 +85,7 @@ protected: void createSource(); void selectFieldComponent(); void showObject(); - void colorBy(const std::string & fieldType); + void colorBy(); void showScalarBar(); void rescaleTransferFunction(); void selectColorMap(); @@ -92,14 +97,13 @@ protected: void execPyLine(const std::string & lin); void pushAndExecPyLine(const std::string & lin); - MEDPresentation::TypeID getID() const { return _fieldHandlerId; } + MEDPresentation::TypeID getID() const { return _handlerId; } void fillAvailableFieldComponents(); void applyCellToPointIfNeeded(); + void extractFileName(const std::string& name); // void convertTo3DVectorField(); -// virtual MEDCALC::ViewModeType getViewMode() = 0; - template void updateComponent(const std::string& newCompo); @@ -133,8 +137,10 @@ protected: MEDCoupling::TypeOfField _mcFieldType; ///! ParaView field type: "CELLS" or "POINTS" std::string _pvFieldType; + ///! ParaView field type: "CELLS" or "POINTS" used in the ColorBy method. Not necessarily equal to _pvFieldType. + std::string _colorByType; - MEDPresentation::TypeID _fieldHandlerId; + MEDPresentation::TypeID _handlerId; // either a field or a mesh id (a field ID though, most of the time) int _selectedComponentIndex; MEDCALC::ViewModeType _viewMode; diff --git a/src/MEDCalc/cmp/MEDPresentationContour.cxx b/src/MEDCalc/cmp/MEDPresentationContour.cxx index ee4628505..5a25cef58 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.cxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.cxx @@ -36,6 +36,13 @@ MEDPresentationContour::MEDPresentationContour(const MEDCALC::ContourParameters& setIntProperty(MEDPresentationContour::PROP_NB_CONTOUR, params.nbContours); } +void +MEDPresentationContour::initFieldMeshInfos() +{ + MEDPresentation::initFieldMeshInfos(); + _colorByType = "POINTS"; +} + void MEDPresentationContour::setNumberContours() { @@ -73,7 +80,7 @@ MEDPresentationContour::internalGeneratePipeline() throw KERNEL::createSalomeException(mes); } - setOrCreateRenderView(); // instanciate __viewXXX + setOrCreateRenderView(); // instanciate __viewXXX, needs to be after the exception above otherwise previous elements in the view will be hidden. // Contour needs point data: applyCellToPointIfNeeded(); @@ -90,7 +97,7 @@ MEDPresentationContour::internalGeneratePipeline() // Set number of contours setNumberContours(); - colorBy("POINTS"); // necessarily POINTS because of the conversion above + colorBy(); // see initFieldInfo() - necessarily POINTS because of the conversion above showScalarBar(); selectColorMap(); rescaleTransferFunction(); diff --git a/src/MEDCalc/cmp/MEDPresentationContour.hxx b/src/MEDCalc/cmp/MEDPresentationContour.hxx index d7fbc19de..404dba155 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.hxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.hxx @@ -32,6 +32,8 @@ public: MEDPresentationContour(const MEDCALC::ContourParameters& params, const MEDCALC::ViewModeType viewMode); virtual ~MEDPresentationContour() {} + virtual void initFieldMeshInfos(); + void updatePipeline(const MEDCALC::ContourParameters& params); void getParameters(MEDCALC::ContourParameters & params) const { params = _params; } ; diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx index fdb5d5c3a..e727bc327 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx @@ -36,6 +36,13 @@ MEDPresentationDeflectionShape::MEDPresentationDeflectionShape(const MEDCALC::De { } +void +MEDPresentationDeflectionShape::initFieldMeshInfos() +{ + MEDPresentation::initFieldMeshInfos(); + _colorByType = "POINTS"; +} + void MEDPresentationDeflectionShape::autoScale() { @@ -54,18 +61,20 @@ MEDPresentationDeflectionShape::internalGeneratePipeline() MEDPyLockWrapper lock; - setOrCreateRenderView(); createSource(); // Populate internal array of available components: fillAvailableFieldComponents(); - if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) <= 1) + int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS); + if (nbCompo <= 1) { const char * msg = "Deflection shape presentation does not work for scalar field!"; // this message will appear in GUI too STDLOG(msg); throw KERNEL::createSalomeException(msg); } + setOrCreateRenderView(); // needs to be after the exception above otherwise previous elements in the view will be hidden. + // Warp needs point data: applyCellToPointIfNeeded(); @@ -75,10 +84,11 @@ MEDPresentationDeflectionShape::internalGeneratePipeline() showObject(); // to be done first so that the scale factor computation properly works - oss << _objVar << ".Vectors = ['POINTS', '" << _fieldName << "'];"; + std::string fieldName = nbCompo <= 2 ? _fieldName + "_Vector" : _fieldName; + oss << _objVar << ".Vectors = ['POINTS', '" << fieldName << "'];"; pushAndExecPyLine(oss.str()); oss.str(""); - colorBy("POINTS"); + colorBy(); // see initFieldInfo() - necessarily POINTS showScalarBar(); selectColorMap(); rescaleTransferFunction(); diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx index f4ead11e3..f1d881465 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx @@ -31,6 +31,8 @@ public: MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params, const MEDCALC::ViewModeType viewMode); virtual ~MEDPresentationDeflectionShape() {} + virtual void initFieldMeshInfos(); + void updatePipeline(const MEDCALC::DeflectionShapeParameters& params); void getParameters(MEDCALC::DeflectionShapeParameters & params) const { params = _params; } ; diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index 63ffed2af..6317ed3e4 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -295,7 +295,17 @@ MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID) } MEDPresentation* presentation = (*citr).second; - presentation->activateView(); + if (!presentation->activateView()) + { + // The view has been recreated - transfer all presentations that were in the deleted view to this new one + int viewId = presentation->getPyViewID(); + std::map::iterator citr = _presentations.begin(); + for (; citr != _presentations.end(); ++citr) + { + if(citr->second->getPyViewID() == viewId) + citr->second->recreateViewSetup(); + } + } _activeViewPythonId = presentation->getPyViewID(); STDLOG("Activated view " << _activeViewPythonId); return true; @@ -346,3 +356,13 @@ MEDPresentationManager_i::getAllPresentations() (*presList)[i] = it->first; return presList; } + +void +MEDPresentationManager_i::cleanUp() +{ + _activeViewPythonId = -1; + std::map::iterator it; + for (it = _presentations.begin(); it != _presentations.end(); ++it) + delete(it->second); + _presentations.clear(); +} diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx index cd2549494..cc2ae289e 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx @@ -75,6 +75,7 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, // MEDCALC_EXPORT MEDCALC::ViewModeType getPresentationViewMode(MEDPresentation::TypeID); MEDCALC_EXPORT char * getParavisDump(MEDPresentation::TypeID presentationID); MEDCALC_EXPORT MEDCALC::PresentationsList* getAllPresentations(); + MEDCALC_EXPORT void cleanUp(); private: MEDPresentationManager_i(); diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.txx b/src/MEDCalc/cmp/MEDPresentationManager_i.txx index f147554a3..e4b6cf8e9 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.txx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.txx @@ -32,8 +32,7 @@ MEDPresentationManager_i::_makePresentation(const PresentationParameters params, std::vector to_del; if (viewMode == MEDCALC::VIEW_MODE_REPLACE) { - // Remove all presentations from this view: - STDLOG("About to remove all presentations from view " << activeViewId); + // Prepare all presentations to be removed from this view: std::map::const_iterator it; for (it = _presentations.begin(); it != _presentations.end(); ++it) { @@ -49,6 +48,7 @@ MEDPresentationManager_i::_makePresentation(const PresentationParameters params, STDLOG("Generated presentation ID: " << newID); try { presentation = new PresentationType(params, viewMode); // on stack or on heap?? heap for now + presentation->initFieldMeshInfos(); // In replace or overlap mode we force the display in the active view: if(activeViewId != -1 && (viewMode == MEDCALC::VIEW_MODE_REPLACE || viewMode == MEDCALC::VIEW_MODE_OVERLAP)) presentation->setPyViewID(activeViewId); @@ -65,6 +65,7 @@ MEDPresentationManager_i::_makePresentation(const PresentationParameters params, presentation->generatePipeline(); // If generatePipeline didn't throw, we can actually remove presentations to be deleted: + STDLOG("About to remove all presentations from view " << activeViewId); for (std::vector::const_iterator it2 = to_del.begin(); it2 != to_del.end(); ++it2) removePresentation(*it2); diff --git a/src/MEDCalc/cmp/MEDPresentationMeshView.cxx b/src/MEDCalc/cmp/MEDPresentationMeshView.cxx index 60ce767e6..d68454c3b 100644 --- a/src/MEDCalc/cmp/MEDPresentationMeshView.cxx +++ b/src/MEDCalc/cmp/MEDPresentationMeshView.cxx @@ -18,6 +18,7 @@ // #include "MEDPresentationMeshView.hxx" +#include "MEDFactoryClient.hxx" #include #undef LOG // should be fixed in KERNEL - double definition @@ -31,13 +32,25 @@ const std::string MEDPresentationMeshView::PROP_MESH_MODE = "meshMode"; MEDPresentationMeshView::MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params, const MEDCALC::ViewModeType viewMode) : // Cheating a bit here - a mesh view doesn't need a color map or a range: - MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, MEDCALC::COLOR_MAP_DEFAULT, + MEDPresentation(params.meshHandlerId, TYPE_NAME, viewMode, MEDCALC::COLOR_MAP_DEFAULT, MEDCALC::SCALAR_BAR_RANGE_DEFAULT), _params(params) { setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, params.mode); } +void +MEDPresentationMeshView::initFieldMeshInfos() +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + MEDCALC::MeshHandler* meshHandler = dataManager->getMeshHandler(_handlerId); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + extractFileName(std::string(dataSHandler->uri)); + + _meshName = meshHandler->name; +} + void MEDPresentationMeshView::representationType() { @@ -76,6 +89,12 @@ MEDPresentationMeshView::internalGeneratePipeline() oss << _objVar << " = " << _srcObjVar << ";"; pushAndExecPyLine(oss.str()); oss.str(""); + recreateViewSetup(); +} + +void +MEDPresentationMeshView::recreateViewSetup() +{ showObject(); representationType(); resetCameraAndRender(); @@ -84,8 +103,8 @@ MEDPresentationMeshView::internalGeneratePipeline() void MEDPresentationMeshView::updatePipeline(const MEDCALC::MeshViewParameters& params) { - if (params.fieldHandlerId != _params.fieldHandlerId) - throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!"); + if (params.meshHandlerId != _params.meshHandlerId) + throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching meshHandlerId!"); if (params.mode != _params.mode) updateMeshMode(params.mode); diff --git a/src/MEDCalc/cmp/MEDPresentationMeshView.hxx b/src/MEDCalc/cmp/MEDPresentationMeshView.hxx index 9eb9ecede..0075e216d 100644 --- a/src/MEDCalc/cmp/MEDPresentationMeshView.hxx +++ b/src/MEDCalc/cmp/MEDPresentationMeshView.hxx @@ -30,6 +30,7 @@ public: static const std::string PROP_MESH_MODE; MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params, const MEDCALC::ViewModeType viewMode); + virtual void initFieldMeshInfos(); virtual ~MEDPresentationMeshView() {} void updatePipeline(const MEDCALC::MeshViewParameters& params); @@ -37,6 +38,8 @@ public: void getParameters(MEDCALC::MeshViewParameters & params) const { params = _params; } ; void setParameters(const MEDCALC::MeshViewParameters & params) { _params = params; } ; + virtual void recreateViewSetup(); + protected: void updateMeshMode(const MEDCALC::MeshModeType mode); virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx index e748b46fc..ad58b265d 100644 --- a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx @@ -36,6 +36,22 @@ MEDPresentationPointSprite::MEDPresentationPointSprite(const MEDCALC::PointSprit { } +void +MEDPresentationPointSprite::initFieldMeshInfos() +{ + MEDPresentation::initFieldMeshInfos(); + _colorByType = "POINTS"; +} + +void +MEDPresentationPointSprite::scaleBallRadius() +{ + std::ostringstream oss; + oss << _dispVar << ".RadiusVectorComponent = " << _selectedComponentIndex << ";"; + pushAndExecPyLine(oss.str()); oss.str(""); +} + + void MEDPresentationPointSprite::internalGeneratePipeline() { @@ -62,7 +78,7 @@ MEDPresentationPointSprite::internalGeneratePipeline() oss << "__avgSize = medcalc.ComputeCellAverageSize(" << _srcObjVar << ");"; pushAndExecPyLine(oss.str()); oss.str(""); - colorBy("POINTS"); // like in Contour + colorBy(); // see initFieldInfo() - necessarily POINTS like in Contour // Set point sprite: oss << _dispVar << ".SetRepresentationType('Point Sprite');"; @@ -74,8 +90,7 @@ MEDPresentationPointSprite::internalGeneratePipeline() oss << _dispVar << ".RadiusMode = 'Scalar';"; pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << ".RadiusVectorComponent = " << _selectedComponentIndex << ";"; - pushAndExecPyLine(oss.str()); oss.str(""); + scaleBallRadius(); oss << _dispVar << ".RadiusIsProportional = 0 ;"; pushAndExecPyLine(oss.str()); oss.str(""); oss << _dispVar << ".RadiusTransferFunctionEnabled = 1 ;"; @@ -98,7 +113,11 @@ MEDPresentationPointSprite::updatePipeline(const MEDCALC::PointSpriteParameters& throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!"); if (std::string(params.displayedComponent) != std::string(_params.displayedComponent)) - updateComponent(std::string(params.displayedComponent)); + { + updateComponent(std::string(params.displayedComponent)); + scaleBallRadius(); + pushAndExecPyLine("pvs.Render();"); + } if (params.scalarBarRange != _params.scalarBarRange) updateScalarBarRange(params.scalarBarRange); if (params.colorMap != _params.colorMap) diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx index e38b9ea1f..03b68346a 100644 --- a/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx @@ -31,6 +31,8 @@ public: MEDPresentationPointSprite(const MEDCALC::PointSpriteParameters& params, const MEDCALC::ViewModeType viewMode); virtual ~MEDPresentationPointSprite() {} + virtual void initFieldMeshInfos(); + void updatePipeline(const MEDCALC::PointSpriteParameters& params); void getParameters(MEDCALC::PointSpriteParameters & params) const { params = _params; } ; @@ -38,6 +40,7 @@ public: protected: virtual void internalGeneratePipeline(); + void scaleBallRadius(); private: MEDCALC::PointSpriteParameters _params; diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx index ef8804a4e..f308b539b 100644 --- a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx @@ -54,7 +54,7 @@ MEDPresentationScalarMap::internalGeneratePipeline() showObject(); - colorBy(_pvFieldType); + colorBy(); showScalarBar(); selectColorMap(); rescaleTransferFunction(); diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.cxx b/src/MEDCalc/cmp/MEDPresentationSlices.cxx index 8654e25bc..aa4f6e34c 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.cxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.cxx @@ -93,13 +93,7 @@ MEDPresentationSlices::generateAndDisplay() adaptNumberOfSlices(); setSliceParametersAndGroup(); - showObject(); - - colorBy(_pvFieldType); - showScalarBar(); - selectColorMap(); - rescaleTransferFunction(); - resetCameraAndRender(); + recreateViewSetup(); } std::string diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx index 92b857761..e7f69dcf8 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx @@ -36,6 +36,13 @@ MEDPresentationVectorField::MEDPresentationVectorField(const MEDCALC::VectorFiel { } +void +MEDPresentationVectorField::initFieldMeshInfos() +{ + MEDPresentation::initFieldMeshInfos(); + _colorByType = "POINTS"; +} + void MEDPresentationVectorField::autoScale() { @@ -54,18 +61,20 @@ MEDPresentationVectorField::internalGeneratePipeline() MEDPyLockWrapper lock; - setOrCreateRenderView(); createSource(); // Populate internal array of available components: fillAvailableFieldComponents(); - if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) <= 1) + int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS); + if (nbCompo <= 1) { const char * msg = "Vector field presentation does not work for scalar field!"; // this message will appear in GUI too STDLOG(msg); throw KERNEL::createSalomeException(msg); } + setOrCreateRenderView(); // instanciate __viewXXX, needs to be after the exception above otherwise previous elements in the view will be hidden. + std::ostringstream oss; oss << _objVar << " = pvs.Glyph(Input=" << _srcObjVar << ", GlyphType='Arrow');"; pushAndExecPyLine(oss.str()); oss.str(""); @@ -74,7 +83,10 @@ MEDPresentationVectorField::internalGeneratePipeline() oss << _objVar << ".Scalars = ['"<< _pvFieldType << "', 'None'];"; pushAndExecPyLine(oss.str()); oss.str(""); - oss << _objVar << ".Vectors = ['"<< _pvFieldType << "', '" << _fieldName << "'];"; + + std::string fieldName = nbCompo <= 2 ? _fieldName + "_Vector" : _fieldName; + oss << _objVar << ".Vectors = ['"<< _pvFieldType << "', '" << fieldName << "'];"; + pushAndExecPyLine(oss.str()); oss.str(""); oss << _objVar << ".ScaleMode = 'vector';"; pushAndExecPyLine(oss.str()); oss.str(""); @@ -83,7 +95,7 @@ MEDPresentationVectorField::internalGeneratePipeline() oss << _objVar << "GlyphTransform = 'Transform2';"; // not sure this is really needed? pushAndExecPyLine(oss.str()); oss.str(""); - colorBy("POINTS"); + colorBy(); // see initFieldInfo() - necessarily POINTS showScalarBar(); selectColorMap(); rescaleTransferFunction(); diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.hxx b/src/MEDCalc/cmp/MEDPresentationVectorField.hxx index 339bf02a0..f8d5ef00b 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.hxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.hxx @@ -31,6 +31,8 @@ public: MEDPresentationVectorField(const MEDCALC::VectorFieldParameters& params, const MEDCALC::ViewModeType viewMode); virtual ~MEDPresentationVectorField() {} + virtual void initFieldMeshInfos(); + void updatePipeline(const MEDCALC::VectorFieldParameters& params); void getParameters(MEDCALC::VectorFieldParameters & params) const { params = _params; } ; diff --git a/src/MEDCalc/gui/DatasourceController.cxx b/src/MEDCalc/gui/DatasourceController.cxx index cbf2649d5..dda57da3d 100644 --- a/src/MEDCalc/gui/DatasourceController.cxx +++ b/src/MEDCalc/gui/DatasourceController.cxx @@ -230,10 +230,19 @@ void DatasourceController::OnExpandField() SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); for (int i=0; isize(); i++) { SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i); + std::string name(_studyEditor->getName(soFieldseries)); + if (soFieldseries->_is_nil() || name == "MEDCalc") + return; // First retrieve the fieldseries id associated to this study object - long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_SERIES_ID); - //long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_ID); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soFieldseries->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER)) + return; + } + long fieldseriesId = aParam->GetInt(FIELD_SERIES_ID); STDLOG("Expand the field timeseries "<at(0); - - bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE); + std::string name(_studyEditor->getName(soField)); + if (soField->_is_nil() || name == "MEDCalc") + return; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soField->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN)) + return; + } + bool isInWorkspace = aParam->GetBool(IS_IN_WORKSPACE); if ( isInWorkspace ) { QMessageBox::warning(_salomeModule->getApp()->desktop(), tr("Operation not allowed"), @@ -288,7 +306,9 @@ void DatasourceController::OnUseInWorkspace() { return; } - int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID); + if (! aParam->IsSet(FIELD_ID, PT_INTEGER)) + return; + int fieldId = aParam->GetInt(FIELD_ID); // If fieldId equals -1, then it means that it is not a field // managed by the MED module, and we stop this function process. @@ -338,10 +358,20 @@ void DatasourceController::OnUseInWorkspace() { // each item, we just import the whole set of items. for (int i=0; isize(); i++) { SALOMEDS::SObject_var soField = listOfSObject->at(i); - - bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE); + if (soField->_is_nil()) + continue; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soField->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN)) + return; + } + bool isInWorkspace = aParam->GetBool(IS_IN_WORKSPACE); if ( !isInWorkspace ) { - int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID); + if (! aParam->IsSet(FIELD_ID, PT_INTEGER)) + continue; + int fieldId = aParam->GetInt(FIELD_ID); MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); DatasourceEvent* event = new DatasourceEvent(); diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index 3a9cc15db..d7fe92a03 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -96,7 +96,11 @@ MEDModule::init() if ( CORBA::is_nil( _MED_engine ) ) { Engines::EngineComponent_var comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "MED" ); + if (CORBA::is_nil( comp )) + STDLOG("Could not FindOrLoad_Component MED"); _MED_engine = MED_ORB::MED_Gen::_narrow( comp ); + if (CORBA::is_nil( _MED_engine )) + STDLOG("Could not narrow MED engine"); } } @@ -127,6 +131,10 @@ MEDModule::initialize( CAM_Application* app ) // The following initializes the GUI widget and associated actions this->createModuleWidgets(); this->createModuleActions(); + + // Now that the workspace controller is created, ParaView core application has normally been started, + // and hidden GUI elements have been created. We can fire the VCR toolbar activation: + initToolbars(); } QString @@ -214,6 +222,12 @@ MEDModule::activateModule( SUIT_Study* theStudy ) bool MEDModule::deactivateModule( SUIT_Study* theStudy ) { + // Clean up engine: + STDLOG("MEDModule::deactivateModule(): cleaning up engine side."); + _MED_engine->cleanUp(); + MEDFactoryClient::getFactory()->getPresentationManager()->cleanUp(); + MEDFactoryClient::getFactory()->getDataManager()->cleanUp(); + _workspaceController->showDockWidgets(false); _presentationController->showDockWidgets(false); //this->unsetDockLayout(); @@ -269,11 +283,6 @@ MEDModule::createModuleWidgets() { connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)), _presentationController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*))); - - - // Now that the workspace controller is created, ParaView core application has normally been started, - // and hidden GUI elements have been created. We can fire the VCR toolbar activation: - initToolbars(); } void @@ -379,8 +388,12 @@ MEDModule::addActionInPopupMenu(int actionId,const QString& menus,const QString& //} +/** + * Returns presentation name, type and ID from the currently selected presentation in the object + * browser. + */ bool -MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, std::string & type, int & fieldId, int & presId) const +MEDModule::itemClickGeneric(std::string & name, std::string & type, int & presId) const { DataObjectList dol = getApp()->objectBrowser()->getSelected(); if (dol.isEmpty()) @@ -409,9 +422,9 @@ MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, std:: || ! attrParam->GetBool(IS_PRESENTATION)) { // Not a presentation return false; } - if (!attrParam->IsSet(FIELD_ID, PT_INTEGER)) - return false; - fieldId = attrParam->GetInt(FIELD_ID); +// if (!attrParam->IsSet(FIELD_ID, PT_INTEGER)) +// return false; +// fieldId = attrParam->GetInt(FIELD_ID); if (!attrParam->IsSet(PRESENTATION_ID, PT_INTEGER)) return false; presId = attrParam->GetInt(PRESENTATION_ID); @@ -424,9 +437,9 @@ MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, std:: void MEDModule::onClick(const QModelIndex & index) { - int fieldId, presId; + int presId; std::string name, type; - if (!itemClickGeneric(index, name, type, fieldId, presId)) + if (!itemClickGeneric(name, type, presId)) { // Not a presentation - clear widget: emit presentationSelected(-1, QString(""), QString("")); @@ -446,26 +459,20 @@ MEDModule::onClick(const QModelIndex & index) void MEDModule::onDblClick(const QModelIndex& index) { - int fieldId, presId; + int presId; std::string name, type; - if (!itemClickGeneric(index, name, type, fieldId, presId)) + if (!itemClickGeneric(name, type, presId)) return; - STDLOG("Presentation edition: NOT IMPLEMENTED YET"); - STDLOG(" Presentation infos:"); +// STDLOG("Presentation double click"); +// STDLOG(" Presentation infos:"); // STDLOG(" - Component: " + item->componentDataType().toStdString()); // STDLOG(" - Item entry: " + item->entry().toStdString()); // STDLOG(" - Item name: " + item->name().toStdString()); - std::ostringstream oss; - oss << fieldId; - STDLOG(" - Field id: " + oss.str()); - STDLOG(" - Presentation name: " + name); - - // :TODO: - // get edited values from a popup widget - // get presentation - // call presentation edit function - +// std::ostringstream oss; +// oss << fieldId; +// STDLOG(" - Field id: " + oss.str()); +// STDLOG(" - Presentation name: " + name); } void diff --git a/src/MEDCalc/gui/MEDModule.hxx b/src/MEDCalc/gui/MEDModule.hxx index c53e6458a..fa38c1790 100644 --- a/src/MEDCalc/gui/MEDModule.hxx +++ b/src/MEDCalc/gui/MEDModule.hxx @@ -87,6 +87,8 @@ public: inline SALOME_AppStudyEditor* getStudyEditor() { return _studyEditor; } void requestSALOMETermination() const; + bool itemClickGeneric(std::string & name, std::string & type, int & presId) const; + signals: void presentationSelected(int presId, const QString& presType, const QString& presName); @@ -101,9 +103,6 @@ private: void createModuleActions(); void initToolbars(); - bool itemClickGeneric(const QModelIndex & index, std::string & name, - std::string & type, int & fieldId, int & presId) const; - static void init(); private: @@ -118,9 +117,6 @@ private: static MED_ORB::MED_Gen_var _MED_engine; - // GUI needs to talk directly to the pres manager to activate a view, get some params, etc ...: - static MEDCALC::MEDPresentationManager_ptr _presManager; - #ifdef MED_HAS_QTTESTING TestController * _testController; #endif diff --git a/src/MEDCalc/gui/MEDWidgetHelper.cxx b/src/MEDCalc/gui/MEDWidgetHelper.cxx index 8935a3ade..c1ee040a5 100644 --- a/src/MEDCalc/gui/MEDWidgetHelper.cxx +++ b/src/MEDCalc/gui/MEDWidgetHelper.cxx @@ -64,7 +64,9 @@ void MEDWidgetHelper::updateWidget(bool connect) loadParametersFromEngine(); // Set properly color map and scalar bar range + STDLOG("MEDWidgetHelper::udpateWidget() colorMap is " << _colorMap); _paramWidget->setColorMap(_colorMap); + STDLOG("MEDWidgetHelper::udpateWidget() scalarBarRange is " << _scalarBarRange); _paramWidget->setScalarBarRange(_scalarBarRange); if (connect) diff --git a/src/MEDCalc/gui/MED_msg_en.ts b/src/MEDCalc/gui/MED_msg_en.ts index 8e55b5ecb..69f0b813b 100644 --- a/src/MEDCalc/gui/MED_msg_en.ts +++ b/src/MEDCalc/gui/MED_msg_en.ts @@ -1,624 +1,625 @@ - - + + PresentationController - TITLE_PRESENTATION_PARAMETERS - Presentation parameters + TITLE_PRESENTATION_PARAMETERS + Presentation parameters - LAB_PRESENTATION_MESH_VIEW - Mesh + LAB_PRESENTATION_MESH_VIEW + Mesh - TIP_PRESENTATION_MESH_VIEW - Mesh + TIP_PRESENTATION_MESH_VIEW + Mesh - LAB_PRESENTATION_SCALAR_MAP - Scalar map + LAB_PRESENTATION_SCALAR_MAP + Scalar map - TIP_PRESENTATION_SCALAR_MAP - Scalar map + TIP_PRESENTATION_SCALAR_MAP + Scalar map - LAB_PRESENTATION_CONTOUR - Contour + LAB_PRESENTATION_CONTOUR + Contour - TIP_PRESENTATION_CONTOUR - Contour + TIP_PRESENTATION_CONTOUR + Contour - LAB_PRESENTATION_VECTOR_FIELD - Vector field + LAB_PRESENTATION_VECTOR_FIELD + Vector field - TIP_PRESENTATION_VECTOR_FIELD - Vector field + TIP_PRESENTATION_VECTOR_FIELD + Vector field - LAB_PRESENTATION_SLICES - Slices + LAB_PRESENTATION_SLICES + Slices - TIP_PRESENTATION_SLICES - Slices + TIP_PRESENTATION_SLICES + Slices - LAB_PRESENTATION_DEFLECTION_SHAPE - Deflection shape + LAB_PRESENTATION_DEFLECTION_SHAPE + Deflection shape - TIP_PRESENTATION_DEFLECTION_SHAPE - Deflection shape + TIP_PRESENTATION_DEFLECTION_SHAPE + Deflection shape - LAB_PRESENTATION_POINT_SPRITE - Point sprite + LAB_PRESENTATION_POINT_SPRITE + Point sprite - TIP_PRESENTATION_POINT_SPRITE - Point sprite + TIP_PRESENTATION_POINT_SPRITE + Point sprite - LAB_DELETE_PRESENTATION - Delete presentation + LAB_DELETE_PRESENTATION + Delete presentation - TIP_DELETE_PRESENTATION - Delete selected presentation + TIP_DELETE_PRESENTATION + Delete selected presentation - LAB_PARAVIS_DUMP - Dump pipeline + LAB_PARAVIS_DUMP + Dump pipeline - TIP_PARAVIS_DUMP - Dump the low level Python commands of the presentation - + TIP_PARAVIS_DUMP + Dump the low level Python commands of the presentation + - MENU_PRESENTATIONS - Presentations + MENU_PRESENTATIONS + Presentations - MEDPresentationMeshView - Mesh view + MEDPresentationMeshView + Mesh view - MEDPresentationScalarMap - Scalar map + MEDPresentationScalarMap + Scalar map - MEDPresentationContour - Contour + MEDPresentationContour + Contour - MEDPresentationVectorField - Vector field + MEDPresentationVectorField + Vector field - MEDPresentationSlices - Slices + MEDPresentationSlices + Slices - MEDPresentationDeflectionShape - Deflection shape + MEDPresentationDeflectionShape + Deflection shape - MEDPresentationPointSprite - Point sprite + MEDPresentationPointSprite + Point sprite - - + + ProcessingController - MENU_PROCESSING - Processing + MENU_PROCESSING + Processing - LAB_PROCESSING_CHANGE_MESH - Change underlying mesh + LAB_PROCESSING_CHANGE_MESH + Change underlying mesh - LAB_PROCESSING_INTERPOLATE_FIELD - Interpolate field + LAB_PROCESSING_INTERPOLATE_FIELD + Interpolate field - - + + DatasourceController - - LAB_ADD_DATA_SOURCE - Add Data Source + + LAB_ADD_DATA_SOURCE + Add Data Source - - TIP_ADD_DATA_SOURCE - Add a file data source (file providing med data) + + TIP_ADD_DATA_SOURCE + Add a file data source (file providing med data) - - LAB_ADD_IMAGE_SOURCE - Add Image Source + + LAB_ADD_IMAGE_SOURCE + Add Image Source - - TIP_ADD_IMAGE_SOURCE - Create a Data Source from an image file + + TIP_ADD_IMAGE_SOURCE + Create a Data Source from an image file - - LAB_EXPAND_FIELD - Expand field timeseries + + LAB_EXPAND_FIELD + Expand field timeseries - - LAB_USE_IN_WORKSPACE - Use in workspace + + LAB_USE_IN_WORKSPACE + Use in workspace - - IMPORT_MED_FIELDS - Import MED fields + + IMPORT_MED_FIELDS + Import MED fields - - OPERATION_FAILED - Operation failed + + OPERATION_FAILED + Operation failed - - CREATION_FAILED - The creation of med data from the image file failed + + CREATION_FAILED + The creation of med data from the image file failed - - OPERATION_NOT_ALLOWED - Operation not allowed + + OPERATION_NOT_ALLOWED + Operation not allowed - - FIELD_ALREADY_DEFINED - This field is already defined in the workspace + + FIELD_ALREADY_DEFINED + This field is already defined in the workspace - - + + WidgetPresentationParameters - LAB_DEFAULT_DYN_TITLE - Default parameters - + LAB_DEFAULT_DYN_TITLE + Default parameters + + + LAB_DISP_COMP + Displayed component: + + + LAB_EUCLIDEAN_NORM + Euclidean norm + + + LAB_SCALARBAR + Scalar bar: + - LAB_DISP_COMP - Displayed component: + LAB_RANGE + Range: - LAB_EUCLIDEAN_NORM - Euclidean norm + LAB_ALL_TIMESTEPS + All timesteps - LAB_SCALARBAR - Scalar bar: + LAB_CURRENT_TIMESTEP + Current timestep - LAB_RANGE - Range: + LAB_USER_RANGE + User-specified - LAB_ALL_TIMESTEPS - All timesteps + LAB_TIMESTEP + Timestep: - LAB_CURRENT_TIMESTEP - Current timestep + LAB_MIN_VALUE + Min value: - LAB_USER_RANGE - User-specified + LAB_MAX_VALUE + Max value: - LAB_TIMESTEP - Timestep: + LAB_COLOR_MAP + Color map: - LAB_MIN_VALUE - Min value: + LAB_MESH_WIREFRAME + Wireframe - LAB_MAX_VALUE - Max value: + LAB_MESH_SURFACE + Surface - LAB_COLOR_MAP - Color map: + LAB_MESH_SURF_EDGES + Surface With Edges - - LAB_MESH_WIREFRAME - Wireframe + LAB_DISP_MESH_MODE + Mesh display: - LAB_MESH_SURFACE - Surface + LAB_NB_CONTOURS + Number of contours (max. %1): - LAB_MESH_SURF_EDGES - Surface With Edges + LAB_NB_SLICES + Number of slices (max. %1): - LAB_DISP_MESH_MODE - Mesh display: + LAB_SPINBOX_TOOLTIP + Hit 'Enter' to apply - LAB_NB_CONTOURS - Number of contours: + LAB_SLICE_ORIENT + Slice orientation: - LAB_NB_SLICES - Number of slices: + LAB_SLICE_NORMAL_TO_X + Normal to X - LAB_SLICE_ORIENT - Slice orientation: + LAB_SLICE_NORMAL_TO_Y + Normal to Y - - LAB_SLICE_NORMAL_TO_X - Normal to X + LAB_SLICE_NORMAL_TO_Z + Normal to Z - LAB_SLICE_NORMAL_TO_Y - Normal to Y + LAB_SLICE_NORMAL_TO_XY + Normal to XY - LAB_SLICE_NORMAL_TO_Z - Normal to Z + LAB_SLICE_NORMAL_TO_XZ + Normal to XZ - LAB_SLICE_NORMAL_TO_XY - Normal to XY + LAB_SLICE_NORMAL_TO_YZ + Normal to YZ - LAB_SLICE_NORMAL_TO_XZ - Normal to XZ + LAB_SLICE_NORMAL_TO_XYZ + Normal to XYZ - LAB_SLICE_NORMAL_TO_YZ - Normal to YZ + LAB_BLUE_TO_RED + Blue to red rainbow - LAB_SLICE_NORMAL_TO_XYZ - Normal to XYZ + LAB_COOL_TO_WARM + Cool to warm - - - + + DlgAlias - - SELECT_AN_ALIAS_FOR_THE_FIELD - Select an alias for the field + + SELECT_AN_ALIAS_FOR_THE_FIELD + Select an alias for the field - - DEFINE_AN_ALIAS - You can define an alias to manipulate the field in console: + + DEFINE_AN_ALIAS + You can define an alias to manipulate the field in console: - - ALIAS - Alias + + ALIAS + Alias - - MSG_OPERATION_DEFINES_VARIABLE - (this operation defines a variable named <alias> in TUI console. Enter "<alias>.help()" to see available functions, or simply "doc") + + MSG_OPERATION_DEFINES_VARIABLE + (this operation defines a variable named <alias> in TUI console. Enter "<alias>.help()" to see available functions, or simply "doc") - - + + DlgChangeUnderlyingMesh - - FORM - Form + + FORM + Form - - MESH_GT - Mesh -> + + MESH_GT + Mesh -> - - MSG_EXPLORER - (Explorer provides a view on MED data sources (mesh and fields) referenced in data space) + + MSG_EXPLORER + (Explorer provides a view on MED data sources (mesh and fields) referenced in data space) - - DATA_VERIFICATION - Data verification + + DATA_VERIFICATION + Data verification - - - SELECT_MESH - You must select a mesh in the explorer and clic the button Mesh + + + SELECT_MESH + You must select a mesh in the explorer and clic the button Mesh - - + + DlgInterpolateField - - SELECT_MESH - You must select a mesh in the explorer and clic the button Mesh + + SELECT_MESH + You must select a mesh in the explorer and clic the button Mesh - - TARGET_MESH_GT - Target mesh -> + + TARGET_MESH_GT + Target mesh -> - - MSG_EXPLORER - (Explorer provides a view on MED data sources (mesh and fields) referenced in data space) + + MSG_EXPLORER + (Explorer provides a view on MED data sources (mesh and fields) referenced in data space) - - LABEL_PRECISION - Interpolator precision + + LABEL_PRECISION + Interpolator precision - - LABEL_INTERSECTION_TYPE - Intersection type + + LABEL_INTERSECTION_TYPE + Intersection type - - LABEL_METHOD - Interpolation method + + LABEL_METHOD + Interpolation method - - LABEL_DEFAULT_VALUE - Default value of resulting field + + LABEL_DEFAULT_VALUE + Default value of resulting field - - LABEL_REVERSE - Reverse interpolation ? + + LABEL_REVERSE + Reverse interpolation ? - - LABEL_NATURE - Field nature + + LABEL_NATURE + Field nature - - + + DlgImageToMed - - FORM - Form + + FORM + Form - - IMAGE_FILE - Image file: + + IMAGE_FILE + Image file: - - MED_FILE - MED file: + + MED_FILE + MED file: - - SELECT_IMAGE_FILE - Select image file + + SELECT_IMAGE_FILE + Select image file - - SPECIFY_MED_FILE - Specify a MED file + + SPECIFY_MED_FILE + Specify a MED file - - LOAD_AUTOMATICALLY - Load automatically + + LOAD_AUTOMATICALLY + Load automatically - - + + DlgUseInWorkspace - - FORM - Form + + FORM + Form - - PRESSURE - Pressure: + + PRESSURE + Pressure: - - TEMPERATURE - Temperature: + + TEMPERATURE + Temperature: - - + + GenericDialog - - DIALOG - Dialog + + DIALOG + Dialog - - + + MEDModule - - - IMPORT_FROM_FILE - Import from File + + + IMPORT_FROM_FILE + Import from File - - IMPORT_MED_FILE - Import MED file + + IMPORT_MED_FILE + Import MED file - - MEN_FILE - &File + + MEN_FILE + &File - PREF_TAB_GENERAL - General + PREF_TAB_GENERAL + General - PREF_THEME_GROUP - Theme + PREF_THEME_GROUP + Theme - PREF_ICONS - Icons + PREF_ICONS + Icons - PREF_ICON_THEME_MODERN - Modern + PREF_ICON_THEME_MODERN + Modern - PREF_ICON_THEME_CLASSIC - Classic + PREF_ICON_THEME_CLASSIC + Classic - - + + WorkspaceController - - VISUALIZE_SCALAR_MAP - Visualize (scalar map) + + VISUALIZE_SCALAR_MAP + Visualize (scalar map) - - USE_IN_CONSOLE - Use (in console) + + USE_IN_CONSOLE + Use (in console) - - EXPORT_TO_PARAVIS - Export (to PARAVIS) + + EXPORT_TO_PARAVIS + Export (to PARAVIS) - - SAVE_AS_MED - Save (as MED file) + + SAVE_AS_MED + Save (as MED file) - - REMOVE_FROM_WORKSPACE - Remove (from workspace) + + REMOVE_FROM_WORKSPACE + Remove (from workspace) - - LAB_SAVE_WORKSPACE - Save workspace + + LAB_SAVE_WORKSPACE + Save workspace - - TIP_SAVE_WORKSPACE - Save the workspace (fields and meshes) in a MED file + + TIP_SAVE_WORKSPACE + Save the workspace (fields and meshes) in a MED file - - LAB_CLEAN_WORKSPACE - Clean workspace + + LAB_CLEAN_WORKSPACE + Clean workspace - - TIP_CLEAN_WORKSPACE - Clean all data in the workspace + + TIP_CLEAN_WORKSPACE + Clean all data in the workspace - - SAVE_SELECTED_FIELDS - Save selected fields + + SAVE_SELECTED_FIELDS + Save selected fields - - SAVE_WORKSPACE_DATA - Save workspace data + + SAVE_WORKSPACE_DATA + Save workspace data - - NOT_IMPLEMENTED_YET - Not implemented yet + + NOT_IMPLEMENTED_YET + Not implemented yet - - FUNCTION_NOT_IMPLEMENTED - This function is not implemented yet + + FUNCTION_NOT_IMPLEMENTED + This function is not implemented yet - - + + @default - - - - - - FILE_FILTER_MED - MED files (*.med) - - - - FILE_FILTER_PNG - PNG image (*.png) - - - - FILE_FILTER_JPG - JPG image (*.jpg) + + + + + + FILE_FILTER_MED + MED files (*.med) - - FILE_FILTER_PGM - PGM image (*.jpg) + + FILE_FILTER_PNG + PNG image (*.png) - - FILE_FILTER_ALL - All files (*.*) + + FILE_FILTER_JPG + JPG image (*.jpg) - LAB_VIEW_MODE - View mode: + + FILE_FILTER_PGM + PGM image (*.jpg) - LAB_VIEW_MODE_REPLACE - Replace + + FILE_FILTER_ALL + All files (*.*) - LAB_VIEW_MODE_OVERLAP - Overlap + LAB_VIEW_MODE + View mode: - LAB_VIEW_MODE_NEW_LAYOUT - New layout + LAB_VIEW_MODE_REPLACE + Replace - LAB_VIEW_MODE_SPLIT_VIEW - Split + LAB_VIEW_MODE_OVERLAP + Overlap - LAB_BLUE_TO_RED - Blue to red rainbow + LAB_VIEW_MODE_NEW_LAYOUT + New layout - LAB_COOL_TO_WARM - Cool to warm + LAB_VIEW_MODE_SPLIT_VIEW + Split - + diff --git a/src/MEDCalc/gui/MED_msg_fr.ts b/src/MEDCalc/gui/MED_msg_fr.ts index be5cf5ba2..8b92efa4b 100644 --- a/src/MEDCalc/gui/MED_msg_fr.ts +++ b/src/MEDCalc/gui/MED_msg_fr.ts @@ -1,533 +1,625 @@ - - + + PresentationController - TITLE_PRESENTATION_PARAMETERS - Paramètres de presentation + TITLE_PRESENTATION_PARAMETERS + Paramètres de presentation - LAB_PRESENTATION_SCALAR_MAP - Carte scalaire + LAB_PRESENTATION_MESH_VIEW + Maillage - TIP_PRESENTATION_SCALAR_MAP - Carte scalaire + TIP_PRESENTATION_MESH_VIEW + Maillage - LAB_PRESENTATION_CONTOUR - Contour + LAB_PRESENTATION_SCALAR_MAP + Carte scalaire - TIP_PRESENTATION_CONTOUR - Contour + TIP_PRESENTATION_SCALAR_MAP + Carte scalaire - LAB_PRESENTATION_VECTOR_FIELD - Champ de vecteurs + LAB_PRESENTATION_CONTOUR + Contour - TIP_PRESENTATION_VECTOR_FIELD - Champ de vecteurs + TIP_PRESENTATION_CONTOUR + Contour - LAB_PRESENTATION_SLICES - Coupes + LAB_PRESENTATION_VECTOR_FIELD + Champ de vecteurs - TIP_PRESENTATION_SLICES - Coupes + TIP_PRESENTATION_VECTOR_FIELD + Champ de vecteurs - LAB_PRESENTATION_DEFLECTION_SHAPE - Déformée + LAB_PRESENTATION_SLICES + Coupes - TIP_PRESENTATION_DEFLECTION_SHAPE - Déformée + TIP_PRESENTATION_SLICES + Coupes - LAB_PRESENTATION_POINT_SPRITE - Point sprite + LAB_PRESENTATION_DEFLECTION_SHAPE + Déformée - TIP_PRESENTATION_POINT_SPRITE - Point sprite + TIP_PRESENTATION_DEFLECTION_SHAPE + Déformée - MENU_PRESENTATIONS - Présentations + LAB_PRESENTATION_POINT_SPRITE + Point sprite - MEDPresentationScalarMap - Carte scalaire + TIP_PRESENTATION_POINT_SPRITE + Point sprite - MEDPresentationContour - Contour + LAB_DELETE_PRESENTATION + Supprimer - MEDPresentationVectorField - Champ de vecteurs + TIP_DELETE_PRESENTATION + Supprime la présentation sélectionnée - MEDPresentationSlices - Coupes + LAB_PARAVIS_DUMP + Trace du pipeline - MEDPresentationDeflectionShape - Déformée + TIP_PARAVIS_DUMP + Affiche les commandes Python bas niveau de la présentation - MEDPresentationPointSprite - Point sprite + MENU_PRESENTATIONS + Présentations - - + + MEDPresentationMeshView + Maillage + + + MEDPresentationScalarMap + Carte scalaire + + + MEDPresentationContour + Contour + + + MEDPresentationVectorField + Champ de vecteurs + + + MEDPresentationSlices + Coupes + + + MEDPresentationDeflectionShape + Déformée + + + MEDPresentationPointSprite + Point sprite + + + ProcessingController - MENU_PROCESSING - Traitement + MENU_PROCESSING + Traitement - LAB_PROCESSING_CHANGE_MESH - Changer le maillage sous-jacent + LAB_PROCESSING_CHANGE_MESH + Changer le maillage sous-jacent - LAB_PROCESSING_INTERPOLATE_FIELD - Interpoler le champ + LAB_PROCESSING_INTERPOLATE_FIELD + Interpoler le champ - - + + DatasourceController - - LAB_ADD_DATA_SOURCE - Importer des données MED + + LAB_ADD_DATA_SOURCE + Importer des données MED - - TIP_ADD_DATA_SOURCE - Ajouter des données par import de fichiers MED + + TIP_ADD_DATA_SOURCE + Ajouter des données par import de fichiers MED - - LAB_ADD_IMAGE_SOURCE - Ajouter une image + + LAB_ADD_IMAGE_SOURCE + Ajouter une image - - TIP_ADD_IMAGE_SOURCE - Ajouter des données par import d'un fichier image + + TIP_ADD_IMAGE_SOURCE + Ajouter des données par import d'un fichier image - - LAB_EXPAND_FIELD - Étendre les series temporelles du champ + + LAB_EXPAND_FIELD + Étendre les series temporelles du champ - - LAB_USE_IN_WORKSPACE - Utiliser dans l'espace de travail + + LAB_USE_IN_WORKSPACE + Utiliser dans l'espace de travail - - IMPORT_MED_FIELDS - Importer des champs (format MED) + + IMPORT_MED_FIELDS + Importer des champs (format MED) - - OPERATION_FAILED - L'opération a échoué + + OPERATION_FAILED + L'opération a échoué - - CREATION_FAILED - La création des données MED à partir d'un fichier image a échoué + + CREATION_FAILED + La création des données MED à partir d'un fichier image a échoué - - OPERATION_NOT_ALLOWED - Opération non autorisée + + OPERATION_NOT_ALLOWED + Opération non autorisée - - FIELD_ALREADY_DEFINED - Ce champ est déjà défini dans l'espace de travail + + FIELD_ALREADY_DEFINED + Ce champ est déjà défini dans l'espace de travail - - + + WidgetPresentationParameters - LAB_DISP_COMP - Composante affichée : + LAB_DEFAULT_DYN_TITLE + Paramètres par défaut + + + LAB_DISP_COMP + Composante affichée : + + + LAB_EUCLIDEAN_NORM + Norme euclidienne - LAB_EUCLIDEAN_NORM - Norme euclidienne + LAB_SCALARBAR + Echelle de valeurs : - LAB_SCALARBAR - Echelle de valeurs : + LAB_RANGE + Intervalle : - LAB_RANGE - Intervalle : + LAB_ALL_TIMESTEPS + Tous les pas de temps - LAB_ALL_TIMESTEPS - Tous les pas de temps + LAB_CURRENT_TIMESTEP + Pas de temps courant - LAB_CURRENT_TIMESTEP - Pas de temps courant + LAB_USER_RANGE + Personnalisé : - LAB_USER_RANGE - Personnalisé : + LAB_TIMESTEP + Pas de temps : - LAB_TIMESTEP - Pas de temps : + LAB_MIN_VALUE + Valeur min : - LAB_MIN_VALUE - Valeur min : + LAB_MAX_VALUE + Valeur max : - LAB_MAX_VALUE - Valeur max : + LAB_COLOR_MAP + Table de couleurs : - LAB_COLOR_MAP - Table de couleurs : + LAB_MESH_WIREFRAME + Fil de fer - LAB_BLUE_TO_RED - Arc-en-ciel bleu vers rouge + LAB_MESH_SURFACE + Surface + + + LAB_MESH_SURF_EDGES + Surface Avec Arrêtes + + + LAB_DISP_MESH_MODE + Affichage du maillage: + + + LAB_NB_CONTOURS + Nombre de contours (max. %1) : + + + LAB_NB_SLICES + Nombres de coupes (max. %1) : + + + LAB_SPINBOX_TOOLTIP + Taper 'Entrée' pour appliquer + + + LAB_SLICE_ORIENT + Orientation des coupes: + + + LAB_SLICE_NORMAL_TO_X + Normale à X + + + LAB_SLICE_NORMAL_TO_Y + Normale à Y + + + LAB_SLICE_NORMAL_TO_Z + Normale à Z + + + LAB_SLICE_NORMAL_TO_XY + Normale à XY + + + LAB_SLICE_NORMAL_TO_XZ + Normale à XZ + + + LAB_SLICE_NORMAL_TO_YZ + Normale à YZ + + + LAB_SLICE_NORMAL_TO_XYZ + Normale à XYZ + + + LAB_BLUE_TO_RED + Arc-en-ciel bleu vers rouge - LAB_COOL_TO_WARM - Froid vers chaud + LAB_COOL_TO_WARM + Froid vers chaud - - + + DlgAlias - - SELECT_AN_ALIAS_FOR_THE_FIELD - Selectionner un alias pour ce champ + + SELECT_AN_ALIAS_FOR_THE_FIELD + Selectionner un alias pour ce champ - - DEFINE_AN_ALIAS - Vous pouvez définir un alias pour manipuler le champs dans la console: + + DEFINE_AN_ALIAS + Vous pouvez définir un alias pour manipuler le champs dans la console: - - ALIAS - Alias + + ALIAS + Alias - - MSG_OPERATION_DEFINES_VARIABLE - (cette opération définit une variable nommée <alias> dans la console texte. Tapez "<alias>.help()" pour voir les fonctions disponibles, ou simplement "doc") + + MSG_OPERATION_DEFINES_VARIABLE + (cette opération définit une variable nommée <alias> dans la console texte. Tapez "<alias>.help()" pour voir les fonctions disponibles, ou simplement "doc") - - + + DlgChangeUnderlyingMesh - - FORM - Formulaire + + FORM + Formulaire - - MESH_GT - Maillage -> + + MESH_GT + Maillage -> - - MSG_EXPLORER - (L'explorateur fournit une vue des données MED (maillage et champs) référencées dans l'espace des données) + + MSG_EXPLORER + (L'explorateur fournit une vue des données MED (maillage et champs) référencées dans l'espace des données) - - DATA_VERIFICATION - Vérification des données + + DATA_VERIFICATION + Vérification des données - - - SELECT_MESH - Vous devez sélectionner un maillage dans l'explorateur et cliquer sur le bouton Maillage + + + SELECT_MESH + Vous devez sélectionner un maillage dans l'explorateur et cliquer sur le bouton Maillage - - + + DlgInterpolateField - - SELECT_MESH - Vous devez sélectionner un maillage dans l'explorateur et cliquer sur le bouton Maillage + + SELECT_MESH + Vous devez sélectionner un maillage dans l'explorateur et cliquer sur le bouton Maillage - - TARGET_MESH_GT - Maillage cible -> + + TARGET_MESH_GT + Maillage cible -> - - MSG_EXPLORER - (L'explorateur fournit une vue des données MED (maillage et champs) référencées dans l'espace des données) + + MSG_EXPLORER + (L'explorateur fournit une vue des données MED (maillage et champs) référencées dans l'espace des données) - - LABEL_PRECISION - Précision de l'interpolateur + + LABEL_PRECISION + Précision de l'interpolateur - - LABEL_INTERSECTION_TYPE - Type d'intersection + + LABEL_INTERSECTION_TYPE + Type d'intersection - - LABEL_METHOD - Méthode d'interpolation + + LABEL_METHOD + Méthode d'interpolation - - LABEL_DEFAULT_VALUE - Valeur par défaut du champ résultant + + LABEL_DEFAULT_VALUE + Valeur par défaut du champ résultant - - LABEL_REVERSE - Interpolation inverse ? + + LABEL_REVERSE + Interpolation inverse ? - - LABEL_NATURE - Nature du champ + + LABEL_NATURE + Nature du champ - - + + DlgImageToMed - - FORM - Formulaire + + FORM + Formulaire - - IMAGE_FILE - Fichier image : + + IMAGE_FILE + Fichier image : - - MED_FILE - Fichier MED : + + MED_FILE + Fichier MED : - - SELECT_IMAGE_FILE - Selectionner un fichier image + + SELECT_IMAGE_FILE + Selectionner un fichier image - - SPECIFY_MED_FILE - Spécifier un fichier MED + + SPECIFY_MED_FILE + Spécifier un fichier MED - - LOAD_AUTOMATICALLY - Charger automatiquement + + LOAD_AUTOMATICALLY + Charger automatiquement - - + + DlgUseInWorkspace - - FORM - Formulaire + + FORM + Formulaire - - PRESSURE - Pression : + + PRESSURE + Pression : - - TEMPERATURE - Température : + + TEMPERATURE + Température : - - + + GenericDialog - - DIALOG - Dialogue + + DIALOG + Dialogue - - + + MEDModule - - - IMPORT_FROM_FILE - Importer depuis un fichier + + + IMPORT_FROM_FILE + Importer depuis un fichier - - IMPORT_MED_FILE - Importer un fichier MED + + IMPORT_MED_FILE + Importer un fichier MED - - MEN_FILE - &Fichier + + MEN_FILE + &Fichier - PREF_TAB_GENERAL - Général + PREF_TAB_GENERAL + Général - PREF_THEME_GROUP - Thème + PREF_THEME_GROUP + Thème - PREF_ICONS - Icones + PREF_ICONS + Icones - PREF_ICON_THEME_MODERN - Moderne + PREF_ICON_THEME_MODERN + Moderne - PREF_ICON_THEME_CLASSIC - Classique + PREF_ICON_THEME_CLASSIC + Classique - - + + WorkspaceController - - VISUALIZE_SCALAR_MAP - Visualiser (carte scalaire) + + VISUALIZE_SCALAR_MAP + Visualiser (carte scalaire) - - USE_IN_CONSOLE - Utiliser (dans la console) + + USE_IN_CONSOLE + Utiliser (dans la console) - - EXPORT_TO_PARAVIS - Exporter (vers PARAVIS) + + EXPORT_TO_PARAVIS + Exporter (vers PARAVIS) - - SAVE_AS_MED - Sauvegarder (dans un fichier MED) + + SAVE_AS_MED + Sauvegarder (dans un fichier MED) - - REMOVE_FROM_WORKSPACE - Supprimer (de l'espace de travail) + + REMOVE_FROM_WORKSPACE + Supprimer (de l'espace de travail) - - LAB_SAVE_WORKSPACE - Sauvegarder l'espace de travail + + LAB_SAVE_WORKSPACE + Sauvegarder l'espace de travail - - TIP_SAVE_WORKSPACE - Sauvegarder l'espace de travail (champs et maillages) dans un fichier MED + + TIP_SAVE_WORKSPACE + Sauvegarder l'espace de travail (champs et maillages) dans un fichier MED - - LAB_CLEAN_WORKSPACE - Nettoyer l'espace de travail + + LAB_CLEAN_WORKSPACE + Nettoyer l'espace de travail - - TIP_CLEAN_WORKSPACE - Effacer toute les données de l'espace de travail + + TIP_CLEAN_WORKSPACE + Effacer toute les données de l'espace de travail - - SAVE_SELECTED_FIELDS - Sauvegarder les champs sélectionnés + + SAVE_SELECTED_FIELDS + Sauvegarder les champs sélectionnés - - SAVE_WORKSPACE_DATA - Sauvegarder les données de l'espace de travail + + SAVE_WORKSPACE_DATA + Sauvegarder les données de l'espace de travail - - NOT_IMPLEMENTED_YET - Non implémenté + + NOT_IMPLEMENTED_YET + Non implémenté - - FUNCTION_NOT_IMPLEMENTED - Cette function n'est pas encore implémentée + + FUNCTION_NOT_IMPLEMENTED + Cette function n'est pas encore implémentée - - + + @default - - - - - - FILE_FILTER_MED - Fichiers MED (*.med) + + + + + + FILE_FILTER_MED + Fichiers MED (*.med) - - FILE_FILTER_PNG - Image PNG (*.png) + + FILE_FILTER_PNG + Image PNG (*.png) - - FILE_FILTER_JPG - Image JPG (*.jpg) + + FILE_FILTER_JPG + Image JPG (*.jpg) - - FILE_FILTER_PGM - Image PGM (*.jpg) + + FILE_FILTER_PGM + Image PGM (*.jpg) - - FILE_FILTER_ALL - Tous les fichiers (*.*) + + FILE_FILTER_ALL + Tous les fichiers (*.*) - LAB_VIEW_MODE - Mode de rendu : + LAB_VIEW_MODE + Mode de rendu : - LAB_VIEW_MODE_REPLACE - Remplacer + LAB_VIEW_MODE_REPLACE + Remplacer - LAB_VIEW_MODE_OVERLAP - Superposer + LAB_VIEW_MODE_OVERLAP + Superposer - LAB_VIEW_MODE_NEW_LAYOUT - Nouvel onglet + LAB_VIEW_MODE_NEW_LAYOUT + Nouvel onglet - LAB_VIEW_MODE_SPLIT_VIEW - Scinder + LAB_VIEW_MODE_SPLIT_VIEW + Scinder - + diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx index 3b8e9e219..c0fd9bce4 100644 --- a/src/MEDCalc/gui/PresentationController.cxx +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -47,6 +47,9 @@ #include #include +#include +#include + #include #include @@ -107,19 +110,20 @@ PresentationController::~PresentationController() delete((*it).second); } -/** - * [ABN] Created this probably because I don't know the right way to deal with non existent - * attributes in an object from the study ... - */ int PresentationController::getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char * name) { - int theInt = -1; - try { - theInt = _studyEditor->getParameterInt(obj,name); + if (obj->_is_nil()) + return -1; + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( obj->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (aParam->IsSet(name, PT_INTEGER)) + return aParam->GetInt(name); } - catch(...) { } - return theInt; + return -1; } std::string @@ -178,7 +182,7 @@ PresentationController::createActions() // Presentations int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar"); - int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1); + int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, -1, 10); label = tr("LAB_PRESENTATION_MESH_VIEW"); tooltip = tr("TIP_PRESENTATION_MESH_VIEW"); @@ -305,34 +309,54 @@ PresentationController::visualize(PresentationEvent::EventType eventType) // visualisation using the tui command (so that the user can see how // to make a view of an object from the tui console). for (int i=0; isize(); i++) { - SALOMEDS::SObject_var soField = listOfSObject->at(i); - int fieldId = getIntParamFromStudyEditor(soField, FIELD_ID); - if (fieldId < 0) // is it a field serie ? + SALOMEDS::SObject_var soObj = listOfSObject->at(i); + std::string name(_studyEditor->getName(soObj)); + if (soObj->_is_nil() || name == "MEDCalc") + return; + + int fieldId = getIntParamFromStudyEditor(soObj, FIELD_ID); + int meshId = getIntParamFromStudyEditor(soObj, MESH_ID); + MEDCALC::FieldHandler* fieldHandler = 0; + MEDCALC::MeshHandler* meshHandler = 0; + + // is it a mesh? + if (meshId >= 0) { - int fieldSeriesId = getIntParamFromStudyEditor(soField, FIELD_SERIES_ID); - // If fieldId and fieldSeriesId equals -1, then it means that it is not a field - // managed by the MED module, and we stop this function process. - if ( fieldSeriesId < 0) + if (eventType != PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW) continue; - MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId); - if (fieldHandlerList->length() < 0) - continue; - // For a field series, get the first real field entry: - MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0]; - fieldId = fieldHandler.id; + meshHandler = MEDFactoryClient::getDataManager()->getMeshHandler(meshId); + } + else + { + if (fieldId < 0) // is it a field serie ? + { + int fieldSeriesId = getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID); + // If fieldId and fieldSeriesId equals -1, then it means that it is not a field + // managed by the MED module, and we stop this function process. + if ( fieldSeriesId < 0) + continue; + + MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId); + if (fieldHandlerList->length() < 0) + continue; + // For a field series, get the first real field entry: + MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0]; + fieldId = fieldHandler.id; + } + fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); } - MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); - if (! fieldHandler) { + if ((!fieldHandler) && (!meshHandler)) { QMessageBox::warning(_salomeModule->getApp()->desktop(), tr("Operation not allowed"), - tr("No field is defined")); + tr("No field (or mesh) is defined")); return; } PresentationEvent* event = new PresentationEvent(); event->eventtype = eventType; event->fieldHandler = fieldHandler; + event->meshHandler = meshHandler; emit presentationSignal(event); // --> processPresentationEvent() } } @@ -391,6 +415,9 @@ PresentationController::onDeletePresentation() // For each object, emit a signal to the workspace to request pres deletion for (int i=0; isize(); i++) { SALOMEDS::SObject_var soPres = listOfSObject->at(i); + std::string name(_studyEditor->getName(soPres)); + if (soPres->_is_nil() || name == "MEDCalc") + return; int presId = getIntParamFromStudyEditor(soPres,PRESENTATION_ID); // If fieldId equals -1, then it means that it is not a field // managed by the MED module, and we stop this function process. @@ -489,8 +516,10 @@ PresentationController::processPresentationEvent(const PresentationEvent* event) // dedicated widget helper class? if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW ) { - commands += QString("presentation_id = medcalc.MakeMeshView(accessField(%1), viewMode=%2)").arg(fieldHandler->id).arg(viewMode); - commands += QString("presentation_id"); + // Do we request mesh view from a field or from a mesh only? + int meshId = event->meshHandler ? event->meshHandler->id : event->fieldHandler->meshid; + commands += QString("presentation_id = medcalc.MakeMeshView(%1, viewMode=%2)").arg(meshId).arg(viewMode); + commands += QString("presentation_id"); } else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)") @@ -602,6 +631,7 @@ PresentationController::findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager { const char * msg ="findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!"; STDLOG(msg); + return wh; } _presHelperMap[presId] = wh; return wh; @@ -621,6 +651,8 @@ PresentationController::onPresentationSelected(int presId, const QString& presTy } else { + if(_currentWidgetHelper) + _currentWidgetHelper->releaseWidget(); // Activate corresponding ParaView render view _presManager->activateView(presId); // Update widgets parameters @@ -641,6 +673,9 @@ PresentationController::onParavisDump() // For the first object only, request the dump for (int i=0; isize(); i++) { SALOMEDS::SObject_var soPres = listOfSObject->at(i); + std::string name(_studyEditor->getName(soPres)); + if (soPres->_is_nil() || name == "MEDCalc") + return; int presId = getIntParamFromStudyEditor(soPres,PRESENTATION_ID); // If fieldId equals -1, then it means that it is not a field // managed by the MED module, and we stop this function process. @@ -657,7 +692,7 @@ PresentationController::onParavisDump() } void -PresentationController::updateTreeViewWithNewPresentation(long fieldId, long presentationId) +PresentationController::updateTreeViewWithNewPresentation(long dataId, long presentationId) { if (presentationId < 0) { std::cerr << "Unknown presentation\n"; @@ -678,37 +713,36 @@ PresentationController::updateTreeViewWithNewPresentation(long fieldId, long pre SalomeApp_Study* study = dynamic_cast(_salomeModule->application()->activeStudy()); _PTR(Study) studyDS = study->studyDS(); - _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, - oss.str().c_str(), type.c_str(),ico.c_str(), presentationId); - - - // MEDCALC::ViewModeType viewMode = MEDFactoryClient::getPresentationManager()->getPresentationViewMode(presentationId); - // - // // Remove sibling presentations if view mode is set to REPLACE - // if (viewMode == MEDCALC::VIEW_MODE_REPLACE) { - // MED_ORB::PresentationsList* presList = _salomeModule->engine()->getSiblingPresentations(_CAST(Study, studyDS)->GetStudy(), presentationId); - // CORBA::ULong size = presList->length(); - // - // std::stringstream sstm; - // sstm << "Removing sibling presentation(s): "; - // for (int i = 0; i < size; ++i) - // sstm << (*presList)[i] << " "; - // STDLOG(sstm.str()); - // - // for (int i = 0; i < size; ++i) { - // PresentationEvent* event = new PresentationEvent(); - // event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION; - // XmedDataObject* dataObject = new XmedDataObject(); - // dataObject->setPresentationId((*presList)[i]); - // event->objectdata = dataObject; - // emit presentationSignal(event); // --> WorkspaceController::processPresentationEvent - // } - // - // delete presList; - // } + // Mesh views are always registered at the mesh level: + if (type == MEDPresentationMeshView::TYPE_NAME) + { + _salomeModule->engine()->registerPresentationMesh(_CAST(Study, studyDS)->GetStudy(), dataId, + oss.str().c_str(), type.c_str(),ico.c_str(), presentationId); + } + else + _salomeModule->engine()->registerPresentationField(_CAST(Study, studyDS)->GetStudy(), dataId, + oss.str().c_str(), type.c_str(),ico.c_str(), presentationId); // update Object browser _salomeModule->getApp()->updateObjectBrowser(true); + + // auto-select new presentation + std::string entry = _salomeModule->engine()->getStudyPresentationEntry(_CAST(Study, studyDS)->GetStudy(), presentationId); + SALOME_ListIO selectedObjects; + LightApp_Study* lightStudy = dynamic_cast( _salomeModule->application()->activeStudy() ); + QString component = lightStudy->componentDataType( entry.c_str() ); + selectedObjects.Append( new SALOME_InteractiveObject( (const char*)entry.c_str(), + (const char*)component.toLatin1(), + ""/*refobj->Name().c_str()*/ ) ); + //QStringList selectedObjects; + //selectedObjects << QString(entry.c_str()); + LightApp_SelectionMgr* aSelectionMgr = _salomeModule->getApp()->selectionMgr(); + aSelectionMgr->setSelectedObjects(selectedObjects, false); + + // emit onPresentationSelected + int presId = -1; + _salomeModule->itemClickGeneric(name, type, presId); + onPresentationSelected(presId, QString::fromStdString(type), QString::fromStdString(name)); } void @@ -728,30 +762,43 @@ PresentationController::updateTreeViewForPresentationRemoval(long presentationId _salomeModule->getApp()->updateObjectBrowser(true); } +void +PresentationController::_dealWithReplaceMode() +{ + // Deal with replace mode: presentations with invalid IDs have to be removed: + SalomeApp_Study* study = dynamic_cast(_salomeModule->application()->activeStudy()); + _PTR(Study) studyDS = study->studyDS(); + + MEDCALC::PresentationsList * lstManager = _presManager->getAllPresentations(); + MED_ORB::PresentationsList * lstModule = _salomeModule->engine()->getStudyPresentations(_CAST(Study, studyDS)->GetStudy()); + // The IDs not in the intersection needs deletion: + CORBA::Long * last = lstManager->get_buffer() + lstManager->length(); + for (unsigned i = 0; i < lstModule->length(); i++) { + CORBA::Long * ptr = std::find(lstManager->get_buffer(), last, (*lstModule)[i]); + if (ptr == last) { + STDLOG("Removing pres " << (*lstModule)[i] << " from OB."); + // Presentation in module but not in manager anymore: to be deleted from OB: + updateTreeViewForPresentationRemoval((*lstModule)[i]); + } + } +} + void PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event) { if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) { - updateTreeViewWithNewPresentation(event->dataId, event->presentationId); - // Deal with replace mode: presentations with invalid IDs have to be removed: - SalomeApp_Study* study = dynamic_cast(_salomeModule->application()->activeStudy()); - _PTR(Study) studyDS = study->studyDS(); - - MEDCALC::PresentationsList * lstManager = _presManager->getAllPresentations(); - MED_ORB::PresentationsList * lstModule = _salomeModule->engine()->getStudyPresentations(_CAST(Study, studyDS)->GetStudy()); - // The IDs not in the intersection needs deletion: - CORBA::Long * last = lstManager->get_buffer() + lstManager->length(); - for (unsigned i = 0; i < lstModule->length(); i++) - { - CORBA::Long * ptr = std::find(lstManager->get_buffer(), last, (*lstModule)[i]); - if (ptr == last) - { - STDLOG("Removing pres " << (*lstModule)[i] << " from OB."); - // Presentation in module but not in manager anymore: to be deleted from OB: - updateTreeViewForPresentationRemoval((*lstModule)[i]); - onPresentationSelected(-1, "", ""); // make sure param widget is hidden - } - } + if (event->dataId == -1) { + // A file has been loaded, and we want to create a default presentation (MeshView) for it + QString viewMode = getViewModePython(); + QStringList commands; + commands += QString("presentation_id = medcalc.MakeMeshView(medcalc.GetFirstMeshFromDataSource(source_id), viewMode=%1)").arg(viewMode); + commands += QString("presentation_id"); + _consoleDriver->exec(commands); + } + else { + updateTreeViewWithNewPresentation(event->dataId, event->presentationId); + _dealWithReplaceMode(); + } } else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) { updateTreeViewForPresentationRemoval(event->presentationId); @@ -770,4 +817,3 @@ PresentationController::showDockWidgets(bool isVisible) { _dockWidget->setVisible(isVisible); } - diff --git a/src/MEDCalc/gui/PresentationController.hxx b/src/MEDCalc/gui/PresentationController.hxx index 39d58a3e7..0c187e562 100644 --- a/src/MEDCalc/gui/PresentationController.hxx +++ b/src/MEDCalc/gui/PresentationController.hxx @@ -76,12 +76,12 @@ protected slots: void onPresentationSelected(int presId, const QString& presType, const QString& presName); void processWorkspaceEvent(const MEDCALC::MedEvent*); - void processPresentationEvent(const PresentationEvent* event); + void processPresentationEvent(const PresentationEvent*); private: void visualize(PresentationEvent::EventType); - void updateTreeViewWithNewPresentation(long, long); - void updateTreeViewForPresentationRemoval(long); + void updateTreeViewWithNewPresentation(long dataId, long presentationId); + void updateTreeViewForPresentationRemoval(long presId); std::string _getIconName(const std::string&); MEDWidgetHelper * findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string& type, const std::string& name); @@ -94,6 +94,8 @@ private: QString getMeshModePython(const int mode) const; QString getSliceOrientationPython(const int orient) const; + void _dealWithReplaceMode(); + private: MEDModule* _salomeModule; XmedConsoleDriver* _consoleDriver; // the same as in WorkspaceController diff --git a/src/MEDCalc/gui/PresentationEvent.hxx b/src/MEDCalc/gui/PresentationEvent.hxx index 92b8dc4f9..66868893e 100644 --- a/src/MEDCalc/gui/PresentationEvent.hxx +++ b/src/MEDCalc/gui/PresentationEvent.hxx @@ -29,6 +29,7 @@ typedef struct { EventType eventtype; MEDCALC::FieldHandler * fieldHandler; + MEDCALC::MeshHandler * meshHandler; int presentationId; int anInteger; // multi-purpose variable //int anInteger2; // multi-purpose variable diff --git a/src/MEDCalc/gui/ProcessingController.cxx b/src/MEDCalc/gui/ProcessingController.cxx index a554668d7..d78eacd61 100644 --- a/src/MEDCalc/gui/ProcessingController.cxx +++ b/src/MEDCalc/gui/ProcessingController.cxx @@ -20,6 +20,11 @@ #include "ProcessingController.hxx" #include +#include +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + #include "MEDFactoryClient.hxx" #include "MEDModule.hxx" #include "Basics_Utils.hxx" @@ -53,7 +58,7 @@ ProcessingController::createActions() STDLOG("Creating ProcessingController actions"); int processingToolbarId = _salomeModule->createTool("Processing", "ProcessingToolbar"); - int processingMenuId = _salomeModule->createMenu(tr("MENU_PROCESSING"), -1, 1); + int processingMenuId = _salomeModule->createMenu(tr("MENU_PROCESSING"), -1, -1, 12); // Change underlying mesh (note that this action creates a new field in // the workspace that corresponds to a copy of the selected field @@ -86,8 +91,17 @@ ProcessingController::OnChangeUnderlyingMesh() SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); if ( listOfSObject->size() > 0 ) { SALOMEDS::SObject_var soField = listOfSObject->at(0); - //int fieldId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID); - int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID); + std::string name(_studyEditor->getName(soField)); + if (soField->_is_nil() || name == "MEDCalc") + return; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soField->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER)) + return; + } + int fieldId = aParam->GetInt(FIELD_SERIES_ID); // _GBO_ : the dialog should not be modal, so that we can choose a // mesh in the browser. Then we have to emit a signal from the // dialog.accept, connected to a slot of the DatasourceControler @@ -142,7 +156,17 @@ ProcessingController::OnInterpolateField() SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); if ( listOfSObject->size() > 0 ) { SALOMEDS::SObject_var soField = listOfSObject->at(0); - int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID); + std::string name(_studyEditor->getName(soField)); + if (soField->_is_nil() || name == "MEDCalc") + return; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soField->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER)) + return; + } + int fieldId = aParam->GetInt(FIELD_SERIES_ID); // _GBO_ : the dialog should not be modal, so that we can choose a // mesh in the browser. Then we have to emit a signal from the // dialog.accept, connected to a slot of the DatasourceControler diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index dd59a2447..a2c442aa4 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -527,6 +527,12 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent* event) { commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(event->objectalias); commands += QString("source_id"); _consoleDriver->exec(commands); + + // Create a default presentation when loading a file + MEDCALC::MedEvent* evt = new MEDCALC::MedEvent(); + evt->type = MEDCALC::EVENT_ADD_PRESENTATION; + evt->dataId = -1; + emit workspaceSignal(evt); // forward to PresentationController } else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) { QStringList commands; diff --git a/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx b/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx index 26defc750..90a7adf8d 100644 --- a/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx +++ b/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx @@ -20,6 +20,11 @@ #include "DlgChangeUnderlyingMesh.hxx" #include +#include +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + #include #include @@ -64,9 +69,17 @@ void DlgChangeUnderlyingMesh::OnSelectMesh() { SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects(); if ( listOfSObject->size() > 0 ) { SALOMEDS::SObject_var soMesh = listOfSObject->at(0); - // _GBO_ TODO: we should test here if it is a mesh (attribute in - // the sobject) - _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID); + std::string name(_studyEditor->getName(soMesh)); + if (soMesh->_is_nil() || name == "MEDCalc") + return; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soMesh->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(MESH_ID, PT_INTEGER)) + return; + } + _meshId = aParam->GetInt(MESH_ID); const char * meshname = _studyEditor->getName(soMesh); this->ui.txtMesh->setText(QString(meshname)); } diff --git a/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx b/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx index 4ef53c6f2..7c318ba23 100644 --- a/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx +++ b/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx @@ -20,6 +20,11 @@ #include "DlgInterpolateField.hxx" #include +#include +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + #include #include #include @@ -113,9 +118,17 @@ void DlgInterpolateField::OnSelectMesh() { SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects(); if ( listOfSObject->size() > 0 ) { SALOMEDS::SObject_var soMesh = listOfSObject->at(0); - // _GBO_ TODO: we should test here if it is a mesh (attribute in - // the sobject) - _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID); + std::string name(_studyEditor->getName(soMesh)); + if (soMesh->_is_nil() || name == "MEDCalc") + return; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soMesh->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(MESH_ID, PT_INTEGER)) + return; + } + _meshId = aParam->GetInt(MESH_ID); const char * meshname = _studyEditor->getName(soMesh); this->ui.txtMesh->setText(QString(meshname)); } diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx index 3114be35e..8faec9df2 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx @@ -38,8 +38,8 @@ WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent) this, SLOT(onComboColorMapIndexChanged(int)) ); QObject::connect(_ui.comboBoxSliceOrient, SIGNAL(activated(int)), this, SLOT(onComboOrientIndexChanged(int)) ); - QObject::connect(_ui.spinBox, SIGNAL(valueChanged(int)), - this, SLOT(onSpinBoxValueChanged(int)) ); + QObject::connect(_ui.spinBox, SIGNAL(editingFinished()), + this, SLOT(onSpinBoxEditingFinished()) ); } void @@ -74,9 +74,9 @@ WidgetPresentationParameters::onComboScalarBarRangeIndexChanged(int idx) } void -WidgetPresentationParameters::onSpinBoxValueChanged(int val) +WidgetPresentationParameters::onSpinBoxEditingFinished() { - if (!_blockSig) emit spinBoxValueChanged(val); + if (!_blockSig) emit spinBoxValueChanged(_ui.spinBox->value()); } void @@ -125,7 +125,8 @@ WidgetPresentationParameters::isShown() const string WidgetPresentationParameters::getComponent() const { - if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm + if (_ui.comboBoxCompo->count() > 1 && _ui.comboBoxCompo->count() <= 3) + if (_ui.comboBoxCompo->currentIndex() == 0) // Euclidean norm return ""; return _ui.comboBoxCompo->currentText().toStdString(); @@ -141,10 +142,15 @@ WidgetPresentationParameters::setComponents(vector compos, int selecInde _ui.comboBoxCompo->show(); _ui.comboBoxCompo->clear(); - _ui.comboBoxCompo->addItem(tr("LAB_EUCLIDEAN_NORM")); + bool vectorField = (compos.size() > 1 && compos.size() <= 3); + if (vectorField) + _ui.comboBoxCompo->addItem(tr("LAB_EUCLIDEAN_NORM")); for(vector::const_iterator it = compos.begin(); it != compos.end(); ++it) _ui.comboBoxCompo->addItem(QString::fromStdString(*it)); - _ui.comboBoxCompo->setCurrentIndex(selecIndex); + if (!vectorField) + _ui.comboBoxCompo->setCurrentIndex(std::max(0, selecIndex-1)); + else + _ui.comboBoxCompo->setCurrentIndex(selecIndex); _blockSig = false; } @@ -161,9 +167,11 @@ WidgetPresentationParameters::setNbContour(int nbContour) } // Show the widget: - _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS")); + _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS").arg(MEDCALC::NB_CONTOURS_MAX)); + _ui.labelSpinBox->show(); _ui.spinBox->show(); + _ui.spinBox->setRange(1, MEDCALC::NB_CONTOURS_MAX); _ui.spinBox->setValue(nbContour); _blockSig = false; @@ -181,9 +189,10 @@ WidgetPresentationParameters::setNbSlices(int nbSlices) } // Show the widget: - _ui.labelSpinBox->setText(tr("LAB_NB_SLICES")); + _ui.labelSpinBox->setText(tr("LAB_NB_SLICES").arg(MEDCALC::NB_SLICES_MAX)); _ui.labelSpinBox->show(); _ui.spinBox->show(); + _ui.spinBox->setRange(1, MEDCALC::NB_SLICES_MAX); _ui.spinBox->setValue(nbSlices); _blockSig = false; diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx index b518e5605..a9d0d5742 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx @@ -84,7 +84,7 @@ private slots: void onComboCompoIndexChanged(int); void onComboOrientIndexChanged(int); void onComboMeshIndexChanged(int); - void onSpinBoxValueChanged(int); + void onSpinBoxEditingFinished(); private: Ui_WidgetPresentationParameters _ui; // instance of the class defined in ui_WidgetPresentationParameters.h diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui index c5557a3da..d4500e896 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui @@ -148,6 +148,9 @@ + + LAB_SPINBOX_TOOLTIP + 1 diff --git a/src/MEDCalc/test/tui/mesh_view.py b/src/MEDCalc/test/tui/mesh_view.py index 6f4f7f5f8..f7f5d9167 100644 --- a/src/MEDCalc/test/tui/mesh_view.py +++ b/src/MEDCalc/test/tui/mesh_view.py @@ -30,7 +30,7 @@ from medcalc_testutils import GetMEDFileDirTUI datafile = os.path.join(GetMEDFileDirTUI(), "smooth_surface_and_field.med") source_id = medcalc.LoadDataSource(datafile) -presentation_id = medcalc.MakeMeshView(accessField(0), MEDCALC.VIEW_MODE_REPLACE) +presentation_id = medcalc.MakeMeshView(0, MEDCALC.VIEW_MODE_REPLACE) # here the ID of the mesh directly sleep(1) medcalc.RemovePresentation(presentation_id) sleep(1) diff --git a/src/MEDCalc/tui/__init__.py b/src/MEDCalc/tui/__init__.py index 273b74a0c..71845ab46 100644 --- a/src/MEDCalc/tui/__init__.py +++ b/src/MEDCalc/tui/__init__.py @@ -35,8 +35,7 @@ import medevents from fieldproxy import newFieldProxy, FieldProxy # Input/Output -from medio import LoadDataSource -from medio import LoadImageAsDataSource +from medio import LoadDataSource, LoadImageAsDataSource, GetFirstMeshFromDataSource # Presentations from medpresentation import MakeMeshView @@ -72,4 +71,3 @@ import medconsole # Playing test scenarii from medtest import PlayQtTestingScenario from medtest import RequestSALOMETermination - diff --git a/src/MEDCalc/tui/medcorba.py b/src/MEDCalc/tui/medcorba.py index afd74692e..9288d85be 100644 --- a/src/MEDCalc/tui/medcorba.py +++ b/src/MEDCalc/tui/medcorba.py @@ -31,16 +31,19 @@ # # containerType = Name of the container factory # -componentName = "MEDFactory" -corbaModule = "MEDCALC" +factoryComponentName = "MEDFactory" +medComponentName = "MED" +#corbaModule = "MEDCALC" containerType = "FactoryServer" import salome if salome.lcc is None: salome.salome_init() pass -__import__(corbaModule) -factory = salome.lcc.FindOrLoadComponent(containerType,componentName) + +import MEDCALC # corbaModule +med_engine = salome.lcc.FindOrLoadComponent(containerType,medComponentName) +factory = salome.lcc.FindOrLoadComponent(containerType,factoryComponentName) # The factory is not the main CORBA component of the SALOME module MED # (i.e. the engine associated to the active study), but the CORBA # entry point for MED fields operations (i.e. a CORBA component diff --git a/src/MEDCalc/tui/medio.py b/src/MEDCalc/tui/medio.py index 364fbba3f..013842d04 100644 --- a/src/MEDCalc/tui/medio.py +++ b/src/MEDCalc/tui/medio.py @@ -39,3 +39,10 @@ def LoadImageAsDataSource(filename): builder.image2med(filename, medfilename) return LoadDataSource(medfilename) # + +def GetFirstMeshFromDataSource(datasource_id): + dataManager = medcalc.medcorba.factory.getDataManager() + handlerLst = dataManager.getMeshHandlerList(datasource_id) + if not len(handlerLst): + return -1 + return handlerLst[0].id diff --git a/src/MEDCalc/tui/medpresentation.py b/src/MEDCalc/tui/medpresentation.py index faa1e0eb0..3ef5c42a8 100644 --- a/src/MEDCalc/tui/medpresentation.py +++ b/src/MEDCalc/tui/medpresentation.py @@ -23,15 +23,15 @@ from medcalc.medevents import notifyGui_addPresentation, notifyGui_removePresent __manager = medcalc.medcorba.factory.getPresentationManager() -def MakeMeshView(proxy, +def MakeMeshView(meshID, viewMode=MEDCALC.VIEW_MODE_DEFAULT, meshMode=MEDCALC.MESH_MODE_DEFAULT): # Create the presentation instance in CORBA engine # The engine in turn creates the ParaView pipeline elements - params = MEDCALC.MeshViewParameters(proxy.id, meshMode) + params = MEDCALC.MeshViewParameters(meshID, meshMode) try: presentation_id = __manager.makeMeshView(params, viewMode) - notifyGui_addPresentation(proxy.id, presentation_id) + notifyGui_addPresentation(meshID, presentation_id) return presentation_id except SALOME.SALOME_Exception as e: notifyGui_error("An error occured while creating the mesh view:\n" + e.details.text) @@ -180,8 +180,12 @@ def ComputeCellAverageSize(obj): bb, nCells = obj.GetDataInformation().GetBounds(), obj.GetDataInformation().GetNumberOfCells() bb = zip(bb[::2], bb[1::2]) deltas = [x[1]-x[0] for x in bb] + ## Filter out null dimensions: + avgDelta = sum(deltas) / 3.0 + deltas = [d for d in deltas if abs(d) > 1.0e-12*avgDelta] + ## vol = reduce(lambda x,y:x*y, deltas, 1.0) - cellSize = (vol/nCells)**(1.0/3.0) # necessarily 3D in ParaView + cellSize = (vol/nCells)**(1.0/float(len(deltas))) return cellSize def GetDomainCenter(obj): @@ -219,7 +223,10 @@ def GetSliceOrigins(obj, nbSlices, normal): def SelectSourceField(obj, meshName, fieldName, discretisation): """ Properly set the AllArrays property of a MEDReader source to point to the correct field. + Setting the fieldName to void string is allowed (meaning we work on the mesh only). """ + if fieldName == "": + return tree = obj.GetProperty("FieldsTreeInfo")[::2] it = None for t in tree: -- 2.39.2