]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Add presentation in datasource tree
authorCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 5 Aug 2015 13:31:50 +0000 (15:31 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 5 Aug 2015 13:31:50 +0000 (15:31 +0200)
12 files changed:
idl/MEDEventListener.idl
src/MEDCalc/cmp/MEDPresentation.cxx
src/MEDCalc/cmp/MEDPresentation.hxx
src/MEDCalc/gui/DatasourceController.cxx
src/MEDCalc/gui/DatasourceController.hxx
src/MEDCalc/gui/MED_images.ts
src/MEDCalc/gui/MED_msg_en.ts
src/MEDCalc/gui/MED_msg_fr.ts
src/MEDCalc/res/CMakeLists.txt
src/MEDCalc/res/pqAppIcon16.png [new file with mode: 0644]
src/MEDCalc/tui/medevents.py
src/MEDCalc/tui/medpresentation.py

index 5d4df921144f774aab9be6d041387e48b72dd102..5eb198e8264ad9970ef7b3e7b000e22638a0ae8f 100644 (file)
@@ -41,6 +41,7 @@ module MEDCALC
     MedEventType  type;
     long          dataId;
     string        filename;
+    long          presentationId;
   };
 
   interface MEDEventListener: SALOME::GenericObj {
index 7c129c23c2034f13fb634605b17eca4f60501d1d..b389d5884ab6f23c55a55bd524161b7b43908e9d 100644 (file)
 #include <PyInterp_Utils.h>
 #include <iostream>
 
+MEDPresentation::MEDPresentation(MEDCALC::FieldHandler* fieldHdl, std::string name)
+    : _fieldHandler(fieldHdl), _pipeline(0), _display(0), _properties()
+{
+  setProperty("name", name);
+}
+
 void MEDPresentation::generatePipeline()
 {
   // Might be more complicated in the future:
index ef1bdf7910b1db8edf0daac6d9d10abacf72148e..6fb01555a9545924ab4bc3476331976bf1f7ed25 100644 (file)
@@ -46,9 +46,7 @@ public:
 
 protected:
 
-  MEDPresentation(MEDCALC::FieldHandler* fieldHdl):
-    _fieldHandler(fieldHdl), _pipeline(0), _display(0), _properties()
-  {}
+  MEDPresentation(MEDCALC::FieldHandler* fieldHdl, std::string name);
 
   void generatePipeline();
   virtual void internalGeneratePipeline() = 0;
@@ -74,7 +72,7 @@ class MEDCALC_EXPORT MEDPresentationScalarMap :  public MEDPresentation
 {
 public:
   MEDPresentationScalarMap(MEDCALC::FieldHandler* fieldHdl, bool wireframe) :
-    MEDPresentation(fieldHdl),
+    MEDPresentation(fieldHdl, "MEDPresentationScalarMap"),
     _isWireframe(wireframe)
   {}
   virtual ~MEDPresentationScalarMap() {}
index 4d7bc8b8e27ce7bbacad5bbb903b10a386c43503..386fa5e2d1bea47fc9164f873d8149d9bbc8b559 100644 (file)
@@ -40,7 +40,9 @@
 // Datasource controller
 // ==============================================================
 //
-DatasourceController::DatasourceController(StandardApp_Module * salomeModule) {
+DatasourceController::DatasourceController(StandardApp_Module * salomeModule)
+  : _fieldSeriesEntries()
+{
   STDLOG("Creating a DatasourceController");
   _salomeModule = salomeModule;
   _studyEditor = new SALOME_AppStudyEditor(_salomeModule->getApp());
@@ -150,7 +152,6 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH
   _studyEditor->setIcon(soDatasource,tr("ICO_DATASOURCE").toStdString().c_str());
   _studyEditor->setParameterInt(soDatasource,OBJECT_ID,datasourceHandler->id);
 
-
   // We can add the meshes as children of the datasource
   MEDCALC::MeshHandlerList * meshHandlerList =
     MEDFactoryClient::getDataManager()->getMeshList(datasourceHandler->id);
@@ -171,6 +172,7 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH
     for(CORBA::ULong iFieldseries=0; iFieldseries<fieldseriesHandlerList->length(); iFieldseries++) {
       MEDCALC::FieldseriesHandler fieldseriesHandler = (*fieldseriesHandlerList)[iFieldseries];
       SALOMEDS::SObject_var soFieldseries = _studyEditor->newObject(soMesh);
+      _fieldSeriesEntries[fieldseriesHandler.id] = soFieldseries->GetID();
 
       std::string label(fieldseriesHandler.name);
       label +=" ("+std::string(XmedDataObject::mapTypeOfFieldLabel[fieldseriesHandler.type])+")";
@@ -179,23 +181,33 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH
       _studyEditor->setIcon(soFieldseries,tr("ICO_DATASOURCE_FIELD").toStdString().c_str());
       _studyEditor->setParameterInt(soFieldseries,OBJECT_ID,fieldseriesHandler.id);
       _studyEditor->setParameterBool(soFieldseries,OBJECT_IS_IN_WORKSPACE,false);
-      //std::cout << "soFieldseries.GetIOR(): " << soFieldseries._retn()->GetIOR() << std::endl;
-      //std::cout << _studyEditor->findObject(soFieldseries._retn()->GetIOR())->GetIOR() << std::endl;
-      std::cout << "soFieldseries.GetName(): " << soFieldseries._retn()->GetName() << std::endl;
-
     }
   }
 }
 
 void
-DatasourceController::updateTreeViewWithNewPresentation(long presentationId)
+DatasourceController::updateTreeViewWithNewPresentation(long fieldId, long presentationId)
 {
   if (presentationId < 0) {
+    std::cerr << "Unknown presentation\n";
     return;
   }
 
-  std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name");
+  if (_fieldSeriesEntries.find(fieldId) == _fieldSeriesEntries.end()) {
+    std::cerr << "Field not found\n";
+    return;
+  }
+  std::string entry = _fieldSeriesEntries[fieldId];
+  SALOMEDS::SObject_ptr soFieldseries = _studyEditor->findObject(entry.c_str());
+  if (soFieldseries->IsNull()) {
+    std::cerr << "Entry not found\n";
+    return;
+  }
 
+  std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name");
+  SALOMEDS::SObject_var soPresentation = _studyEditor->newObject(soFieldseries);
+  _studyEditor->setName(soPresentation, tr(name.c_str()).toStdString().c_str());
+  _studyEditor->setIcon(soPresentation, tr("ICO_MED_PRESENTATION").toStdString().c_str());
 }
 
 void DatasourceController::OnAddDatasource()
@@ -584,7 +596,7 @@ DatasourceController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
     _salomeModule->updateObjBrowser(true);
   }
   else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
-    this->updateTreeViewWithNewPresentation(event->dataId);
+    this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
     _salomeModule->updateObjBrowser(true);
   }
 }
index 09ecdc140c80e164131e65698bbc526f4441f953..0ec0a180669c4ee54be8c18e0d843f29fc27934c 100644 (file)
@@ -102,11 +102,12 @@ private:
   void visualize(DatasourceEvent::EventType);
   void addDatasource(const char* filename);
   void updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler*);
-  void updateTreeViewWithNewPresentation(long presentationId);
+  void updateTreeViewWithNewPresentation(long fieldId, long presentationId);
 
 private:
   StandardApp_Module * _salomeModule;
   SALOME_AppStudyEditor * _studyEditor;
+  std::map<long, std::string> _fieldSeriesEntries;
 
   DlgChangeUnderlyingMesh * _dlgChangeUnderlyingMesh;
   DlgInterpolateField * _dlgInterpolateField;
index 95df2d88ea93448ade731663f3e9ee1625c5c40d..86476bca17d3632b6d012cf7d81bf66060d4c100 100644 (file)
@@ -3,6 +3,10 @@
 <TS version="2.0" language="en_US">
   <context>
     <name>@default</name>
+    <message>
+      <source>ICO_MED_PRESENTATION</source>
+      <translation>pqAppIcon16.png</translation>
+    </message>
     <message>
       <source>ICO_IMPORT_MED</source>
       <translation>datasource_add.png</translation>
index bb06235c7f11139ba802b168d92c0c5185959c46..3f12bcf9b7d099fce3a061cf024ba5c1fc578cc0 100644 (file)
@@ -3,6 +3,10 @@
 <TS version="2.0">
   <context>
     <name>DatasourceController</name>
+    <message>
+      <source>MEDPresentationScalarMap</source>
+      <translation>Scalar Map</translation>
+    </message>
     <message>
       <location filename="MEDCALC/gui/DatasourceController.cxx" line="45"/>
       <source>LAB_ADD_DATA_SOURCE</source>
index 7ff258e3477ee47257983a3f4db6629bf40f632a..c8d917f5be4c753a5fd6be7e5065580be34c4043 100644 (file)
@@ -3,6 +3,10 @@
 <TS version="2.0">
   <context>
     <name>DatasourceController</name>
+    <message>
+      <source>MEDPresentationScalarMap</source>
+      <translation>Carte scalaire</translation>
+    </message>
     <message>
       <location filename="MEDCALC/gui/DatasourceController.cxx" line="45"/>
       <source>LAB_ADD_DATA_SOURCE</source>
index 87f6ab69fe5549752620b8081dd0565162e7bc68..fb78aa13cafb0a5bd6e0851e4c5d1872098b70e4 100644 (file)
@@ -36,5 +36,6 @@ SET(MED_RESOURCES_FILES
   MEDCalc_small.png
   workspace_clean.png
   workspace_save.png
+  pqAppIcon16.png
   )
 INSTALL(FILES ${MED_RESOURCES_FILES} DESTINATION ${SALOME_MED_INSTALL_RES_DATA})
diff --git a/src/MEDCalc/res/pqAppIcon16.png b/src/MEDCalc/res/pqAppIcon16.png
new file mode 100644 (file)
index 0000000..38713ca
Binary files /dev/null and b/src/MEDCalc/res/pqAppIcon16.png differ
index 2feb1645d3f7aa388579badd44fe53dbcf909e06..96ad59ed41b49bf677f1a27b0ad8ea27f51bea0e 100644 (file)
@@ -83,8 +83,8 @@ connectEventListener()
 # that they could be used in another context than the FieldProxy instances
 import MEDCALC
 
-def __notifyGui(eventType, dataId=-1, filename=""):
-  medEvent = MEDCALC.MedEvent(eventType, dataId, filename)
+def __notifyGui(eventType, dataId=-1, filename="", presentationId=-1):
+  medEvent = MEDCALC.MedEvent(eventType, dataId, filename, presentationId)
   if not eventListenerIsRunning(): return
 
   # Notify the GUI of the update event
@@ -97,21 +97,21 @@ def notifyGui_updateField(fieldId):
   meta-data have changed so it could update the gui
   presentations of this field.
   """
-  __notifyGui(MEDCALC.EVENT_UPDATE_FIELD,fieldId)
+  __notifyGui(MEDCALC.EVENT_UPDATE_FIELD, dataId=fieldId)
 #
 
 def notifyGui_putInWorkspace(fieldId):
-  __notifyGui(MEDCALC.EVENT_PUT_IN_WORKSPACE,fieldId)
+  __notifyGui(MEDCALC.EVENT_PUT_IN_WORKSPACE, dataId=fieldId)
 #
 def notifyGui_removeFromWorkspace(fieldId):
-  __notifyGui(MEDCALC.EVENT_REMOVE_FROM_WORKSPACE, fieldId)
+  __notifyGui(MEDCALC.EVENT_REMOVE_FROM_WORKSPACE, dataId=fieldId)
 
 def notifyGui_cleanWorkspace():
   __notifyGui(MEDCALC.EVENT_CLEAN_WORKSPACE)
 #
 def notifyGui_addDatasource(filename):
-  __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, -1, filename)
+  __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, filename=filename)
 #
-def notifyGui_addPresentation(presentation_id):
-  __notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, presentation_id)
+def notifyGui_addPresentation(fieldId, presId):
+  __notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, dataId=fieldId, presentationId=presId)
 #
index fad2d9680eba58c39e90721b0cbf545d6abdff0a..0395826b586f6d214a8a72bfd7147bb567ae0f44 100644 (file)
@@ -33,7 +33,7 @@ def MakeScalarMap(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE):
 
   params = MEDCALC.ScalarMapParameters(proxy.id, viewMode)
   presentation_id = __manager.makeScalarMap(params)
-  notifyGui_addPresentation(presentation_id)
+  notifyGui_addPresentation(proxy.id, presentation_id)
 #
 
 def MakeIsoSurface():