]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
[MEDCalc] Manage color maps
authorCédric Aguerre <cedric.aguerre@edf.fr>
Thu, 25 Feb 2016 09:54:17 +0000 (10:54 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Thu, 25 Feb 2016 09:54:17 +0000 (10:54 +0100)
12 files changed:
src/MEDCalc/cmp/MEDPresentation.cxx
src/MEDCalc/cmp/MEDPresentation.hxx
src/MEDCalc/cmp/MEDPresentationScalarMap.cxx
src/MEDCalc/gui/MEDModule.cxx
src/MEDCalc/gui/MEDModule.hxx
src/MEDCalc/gui/MED_msg_en.ts
src/MEDCalc/gui/PresentationController.cxx
src/MEDCalc/gui/PresentationController.hxx
src/MEDCalc/gui/WorkspaceController.cxx
src/MEDCalc/gui/WorkspaceController.hxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx

index 4ae979910bedb179ffda55514cc88cd5be935621..09ce776ae2783a1dd1de570c90d44d526d1d7a0c 100644 (file)
@@ -124,3 +124,12 @@ MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode)
   cmd += std::string("__view1.ResetCamera();");
   return cmd;
 }
+
+std::string
+MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap)
+{
+  switch(colorMap) {
+  case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "Blue to Red Rainbow";
+  case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "Cool to Warm";
+  }
+}
index 480723a980f782d272673d4b599c909f59caba2a..f9abab44bb41f26c5c824d17deea9d3ae7f9b0ba 100644 (file)
@@ -50,11 +50,14 @@ protected:
 
   MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name);
   std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode);
+  std::string getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap);
 
   virtual void internalGeneratePipeline() = 0;
   PyObject * getPythonObjectFromMain(const char * var);
   void pushInternal(PyObject * obj, PyObject * disp = NULL);
 
+  MEDPresentation::TypeID getID() { return _fieldHandlerId; }
+
 private:
 
   void generatePipeline(); // reserved to friend class MEDPresentationManager
index 58a99a55317fe99fb814ddbbe304e45f901f2f6f..17e9916e94a3a4b706de2245883df88edece8b1d 100644 (file)
@@ -13,6 +13,8 @@ MEDPresentationScalarMap::internalGeneratePipeline()
   cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
   cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
   cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
+  cmd += std::string("__lut = pvs.GetColorTransferFunction('")+_fieldName+std::string("');");
+  cmd += std::string("__lut.ApplyPreset('")+getColorMapCommand(_params.colorMap)+std::string("',True);");
   cmd += std::string("pvs.Render();");
 
   //std::cerr << "Python command:" << std::endl;
index 7d5770b6de890c25a4b72dcd82d6401e42c8e732..f5f091420b6fecf4bc6c22a566b280089ec6ee49 100644 (file)
@@ -272,3 +272,9 @@ MEDModule::getSelectedViewMode()
 {
   return _presentationController->getSelectedViewMode();
 }
+
+MEDCALC::MEDPresentationColorMap
+MEDModule::getSelectedColorMap()
+{
+  return _presentationController->getSelectedColorMap();
+}
index b0853c61d33c0114ca49194595911f94b8d10955..97cf198888537d13565a975a5dc2c1d53ca5ca18 100644 (file)
@@ -75,6 +75,7 @@ public:
                             const QString& rule="client='ObjectBrowser'");
 
   MEDCALC::MEDPresentationViewMode getSelectedViewMode();
+  MEDCALC::MEDPresentationColorMap getSelectedColorMap();
 
   inline SALOME_AppStudyEditor* getStudyEditor() { return _studyEditor; }
 
index 251b402abcbb8abf615f83a0d1601c4243076881..ba14c9e84e0614681c6dc7ae0a91d1a1aefa087c 100644 (file)
       <source>LAB_COLOR_MAP</source>
       <translation>Color map:</translation>
     </message>
-    <message>
-      <source>LAB_BLUE_TO_RED</source>
-      <translation>Blue to red rainbow</translation>
-    </message>
-    <message>
-      <source>LAB_COOL_TO_WARM</source>
-      <translation>Cool to warm</translation>
-    </message>
   </context>
   <context>
     <name>DlgAlias</name>
       <source>LAB_VIEW_MODE_SPLIT_VIEW</source>
       <translation>Split</translation>
     </message>
+    <message>
+      <source>LAB_BLUE_TO_RED</source>
+      <translation>Blue to red rainbow</translation>
+    </message>
+    <message>
+      <source>LAB_COOL_TO_WARM</source>
+      <translation>Cool to warm</translation>
+    </message>
   </context>
 </TS>
index bd2b83058a3f70aed3e794b612cf050852534493..b6cbe19c191845f3d93b35d4c651b6ddc1d75ff9 100644 (file)
@@ -145,6 +145,12 @@ PresentationController::getSelectedViewMode()
   return _widgetPresentationParameters->getViewMode();
 }
 
+MEDCALC::MEDPresentationColorMap
+PresentationController::getSelectedColorMap()
+{
+  return _widgetPresentationParameters->getColorMap();
+}
+
 void
 PresentationController::visualize(PresentationEvent::EventType eventType)
 {
index c4a1dacc7be6c4686e1749456d6b5e837849f73c..19384c52f96104c10852da7310325b2f32f07fba 100644 (file)
@@ -58,6 +58,7 @@ public:
   void createActions();
 
   MEDCALC::MEDPresentationViewMode getSelectedViewMode();
+  MEDCALC::MEDPresentationColorMap getSelectedColorMap();
 
 signals:
   void presentationSignal(const PresentationEvent*);
index 5458ecb727f5f8bd8360ae13ca0771ad5f630bea..ec6f3e2b29da43915b5f2a076c54f4460b1d1e51 100644 (file)
@@ -458,17 +458,6 @@ void WorkspaceController::_viewItemList(QStringList itemNameIdList) {
   _consoleDriver->exec(commands);
 }
 
-QString
-WorkspaceController::_getViewMode() {
-  MEDCALC::MEDPresentationViewMode viewMode = _salomeModule->getSelectedViewMode();
-  switch(viewMode) {
-  case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
-  case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
-  case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
-  case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
-  }
-}
-
 /**
  * This slot can process the event coming from the
  * DatasourceController. The connection between the datasource signal
@@ -527,6 +516,29 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent* event) {
     STDLOG("The event "<<event->eventtype<<" is not implemented yet");
   }
 }
+
+QString
+WorkspaceController::_getViewMode()
+{
+  MEDCALC::MEDPresentationViewMode viewMode = _salomeModule->getSelectedViewMode();
+  switch(viewMode) {
+  case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
+  case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
+  case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
+  case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
+  }
+}
+
+QString
+WorkspaceController::_getColorMap()
+{
+  MEDCALC::MEDPresentationColorMap colorMap = _salomeModule->getSelectedColorMap();
+  switch(colorMap) {
+  case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW";
+  case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "MEDCALC.COLOR_MAP_COOL_TO_WARM";
+  }
+}
+
 /**
  * This slot can process the event coming from the
  * DatasourceController. The connection between the datasource signal
@@ -553,10 +565,10 @@ void WorkspaceController::processPresentationEvent(const PresentationEvent* even
     QString viewMode = _getViewMode();
     //QString displayedInfo = ; // from PresentationController combobox
     //QString scalarBarRange = ; // from PresentationController spinbox
-    //QString colorMap = ; // from PresentationController combobox
+    QString colorMap = _getColorMap();
     MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
     QStringList commands;
-    commands += QString("medcalc.MakeScalarMap(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
     _consoleDriver->exec(commands);
   }
   else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
index 876ae6eab53876cff520e48e0e447b76452bf54c..b53c73db5fe2003deaf70e95f425e807c81b0a02 100644 (file)
@@ -78,6 +78,7 @@ private:
   void _removeItemList(QStringList itemNameIdList);
   void _viewItemList(QStringList itemNameIdList);
   QString _getViewMode();
+  QString _getColorMap();
 
 private:
   XmedConsoleDriver* _consoleDriver;
index 08823ca73b2ef3f282c93ad2f7d4362a0987a29a..37e41391af0a423487ae7945bfedf804b8c37af2 100644 (file)
@@ -53,8 +53,14 @@ WidgetPresentationParameters::getScalarBarMaxVal()
   return this->ui.doubleSpinBoxMaxVal->value();
 }
 
-std::string
+MEDCALC::MEDPresentationColorMap
 WidgetPresentationParameters::getColorMap()
 {
-  return this->ui.comboBoxColorMap->currentText().toStdString();
+  QString colorMap = this->ui.comboBoxColorMap->currentText();
+  if (colorMap == tr("LAB_BLUE_TO_RED")) {
+    return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW;
+  }
+  else if (colorMap == tr("LAB_COOL_TO_WARM")) {
+    return MEDCALC::COLOR_MAP_COOL_TO_WARM;
+  }
 }
index a8a97141622d6155c5506d0cb42a32f5c65d2cec..b605b03af06dba1e8dd04fd948f7f1ce14dbe38c 100644 (file)
@@ -20,7 +20,7 @@ public:
   double getScalarBarTimestep();
   double getScalarBarMinVal();
   double getScalarBarMaxVal();
-  std::string getColorMap();
+  MEDCALC::MEDPresentationColorMap getColorMap();
 
  private:
   Ui_WidgetPresentationParameters ui; // instance of the class defined in ui_WidgetPresentationParameters.h