Salome HOME
[MEDCalc] : better slices + more error handling when invalid params
[modules/med.git] / src / MEDCalc / gui / PresentationController.cxx
index fe19f432e5bcf20d9862fb08e3d7a854d804409f..3b8e9e21948bf30037e5f25ae397e76f5138f393 100644 (file)
@@ -33,7 +33,7 @@
 #include "MEDPresentationSlices.hxx"
 #include "MEDPresentationPointSprite.hxx"
 #include "MEDPresentationVectorField.hxx"
-//#include "MEDPresentationDeflectionShape.hxx"
+#include "MEDPresentationDeflectionShape.hxx"
 
 #include "MEDWidgetHelperMeshView.hxx"
 #include "MEDWidgetHelperScalarMap.hxx"
@@ -41,7 +41,7 @@
 #include "MEDWidgetHelperSlices.hxx"
 #include "MEDWidgetHelperPointSprite.hxx"
 #include "MEDWidgetHelperVectorField.hxx"
-//#include "MEDWidgetHelperDeflectionShape.hxx"
+#include "MEDWidgetHelperDeflectionShape.hxx"
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
@@ -242,21 +242,21 @@ PresentationController::createActions()
 
   label   = tr("LAB_DELETE_PRESENTATION");
   tooltip = tr("TIP_DELETE_PRESENTATION");
-  icon    = tr(_getIconName("ICO_DELETE_PRESENTATION").c_str());
+  icon    = tr("ICO_DELETE_PRESENTATION");
   actionId = _salomeModule->createStandardAction(label,this, SLOT(onDeletePresentation()),icon,tooltip);
   //  _salomeModule->createTool(actionId, presentationToolbarId);
   //  _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
 
-  //
-  // Actions for popup menu only
-  //
   // Low level PARAVIS dump
   label = tr("LAB_PARAVIS_DUMP");
-  //icon  = tr("ICO_DATASOURCE_EXPAND_FIELD");
+  tooltip = tr("TIP_PARAVIS_DUMP");
   actionId = _salomeModule->createStandardAction(label,this,SLOT(onParavisDump()),"");
-  _salomeModule->addActionInPopupMenu(actionId);
+  _salomeModule->createMenu(actionId, presentationMenuId);
 
+  //
+  // Actions for popup menu only
+  //
 
 }
 
@@ -484,6 +484,10 @@ PresentationController::processPresentationEvent(const PresentationEvent* event)
   QString scalarBarRange = getScalarBarRangePython();
   MEDCALC::FieldHandler* fieldHandler = event->fieldHandler;
   QStringList commands;
+
+  // [ABN] using event mechanism for all this is awkward? TODO: direct implementation in each
+  // 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");
@@ -513,13 +517,13 @@ PresentationController::processPresentationEvent(const PresentationEvent* event)
               .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
       commands += QString("presentation_id");
   }
+    else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
+      commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)")
+          .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap);
+      commands += QString("presentation_id");
+  }
 
-  //  else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
-  //    commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-  //    commands += QString("presentation_id");
 
-  // [ABN] using event mechanism for this is awkward? TODO: direct implementation in each
-  // dedicated widget helper class?
   else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COMPONENT ) {
       std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
       commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
@@ -592,6 +596,8 @@ PresentationController::findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager
     wh = new MEDWidgetHelperVectorField(this, _presManager, presId, name, _widgetPresentationParameters);
   else if (type == MEDPresentationPointSprite::TYPE_NAME)
     wh = new MEDWidgetHelperPointSprite(this, _presManager, presId, name, _widgetPresentationParameters);
+  else if (type == MEDPresentationDeflectionShape::TYPE_NAME)
+    wh = new MEDWidgetHelperDeflectionShape(this, _presManager, presId, name, _widgetPresentationParameters);
   else
     {
       const char * msg ="findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!";
@@ -642,9 +648,9 @@ PresentationController::onParavisDump()
         continue;
 
       std::string dump(_presManager->getParavisDump(presId));
-      std::cerr << "#====== ParaVis dump =============== " << std::endl;
+      std::cerr << "#====== ParaVis dump (presentation "  << presId << ") =====" << std::endl;
       std::cerr << dump;
-      std::cerr << "#====== End of ParaVis dump ======== " << std::endl;
+      std::cerr << "#====== End of ParaVis dump =============== " << std::endl;
 
       break; // stop at the first one
   }
@@ -749,6 +755,8 @@ PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
   }
   else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
       updateTreeViewForPresentationRemoval(event->presentationId);
+      // Hide parameter widget if necessary:
+      onPresentationSelected(-1, "", "");
   }
   else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
       // Update parameter widget if shown: