#include "MEDPresentationManager_i.hxx"
#include "XmedConsoleDriver.hxx"
-#include "MEDWidgetHelperScalarMap.hxx"
+#include "MEDPresentationMeshView.hxx"
#include "MEDPresentationScalarMap.hxx"
+#include "MEDPresentationContour.hxx"
+#include "MEDPresentationSlices.hxx"
+#include "MEDPresentationPointSprite.hxx"
+#include "MEDPresentationVectorField.hxx"
+#include "MEDPresentationDeflectionShape.hxx"
+
+#include "MEDWidgetHelperMeshView.hxx"
+#include "MEDWidgetHelperScalarMap.hxx"
+#include "MEDWidgetHelperContour.hxx"
+#include "MEDWidgetHelperSlices.hxx"
+#include "MEDWidgetHelperPointSprite.hxx"
+#include "MEDWidgetHelperVectorField.hxx"
+#include "MEDWidgetHelperDeflectionShape.hxx"
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
MEDCALC::MEDPresentationManager_ptr PresentationController::_presManager;
PresentationController::PresentationController(MEDModule* salomeModule) :
- _salomeModule(salomeModule),
- _consoleDriver(0),
- _studyEditor(salomeModule->getStudyEditor()),
- _presHelperMap(),
- _currentWidgetHelper(0)
+ _salomeModule(salomeModule),
+ _consoleDriver(0),
+ _studyEditor(salomeModule->getStudyEditor()),
+ _presHelperMap(),
+ _currentWidgetHelper(0)
{
STDLOG("Creating a PresentationController");
// Retrieve MEDFactory to get MEDPresentationManager (sometimes GUI needs to talk to the engine directly)
if ( ! _presManager ) {
_presManager = MEDFactoryClient::getFactory()->getPresentationManager();
- }
+ }
// Connect to the click in the object browser
connect(salomeModule, SIGNAL( presentationSelected(int , const QString&, const QString&) ),
- this, SLOT(onPresentationSelected(int , const QString&, const QString&) ) );
+ this, SLOT(onPresentationSelected(int , const QString&, const QString&) ) );
}
PresentationController::~PresentationController()
// Read value from preferences and suffix name to select icon theme
int theme = mgr->integerValue("MEDCalc", "icons");
if (theme == 0) {
- return name + "_MODERN";
+ return name + "_MODERN";
} else if (theme == 1) {
- return name + "_CLASSIC";
+ return name + "_CLASSIC";
}
return name + "_DEFAULT";
}
int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar");
int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1);
+ label = tr("LAB_PRESENTATION_MESH_VIEW");
+ tooltip = tr("TIP_PRESENTATION_MESH_VIEW");
+ QString icon = tr(_getIconName("ICO_PRESENTATION_MESH_VIEW").c_str());
+ int actionId;
+ actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeMeshView()),icon,tooltip);
+ _salomeModule->createTool(actionId, presentationToolbarId);
+ _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+ _salomeModule->createMenu(actionId, presentationMenuId);
+
label = tr("LAB_PRESENTATION_SCALAR_MAP");
tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
- QString icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
- int actionId;
+ icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeScalarMap()),icon,tooltip);
_salomeModule->createTool(actionId, presentationToolbarId);
_salomeModule->action(actionId)->setIconVisibleInMenu(true);
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->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
+ //
}
-MEDCALC::MEDPresentationViewMode
+MEDCALC::ViewModeType
PresentationController::getSelectedViewMode() const
{
if (_salomeModule->action(OPTIONS_VIEW_MODE_REPLACE_ID)->isChecked()) {
- return MEDCALC::VIEW_MODE_REPLACE;
+ return MEDCALC::VIEW_MODE_REPLACE;
}
else if (_salomeModule->action(OPTIONS_VIEW_MODE_OVERLAP_ID)->isChecked()) {
- return MEDCALC::VIEW_MODE_OVERLAP;
+ return MEDCALC::VIEW_MODE_OVERLAP;
}
else if (_salomeModule->action(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID)->isChecked()) {
- return MEDCALC::VIEW_MODE_NEW_LAYOUT;
+ return MEDCALC::VIEW_MODE_NEW_LAYOUT;
}
else if (_salomeModule->action(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID)->isChecked()) {
- return MEDCALC::VIEW_MODE_SPLIT_VIEW;
+ return MEDCALC::VIEW_MODE_SPLIT_VIEW;
}
// Should not happen
STDLOG("Strange!! No matching view mode found - returning VIEW_MODE_REPLACE.");
return MEDCALC::VIEW_MODE_REPLACE;
}
-MEDCALC::MEDPresentationColorMap
+MEDCALC::ColorMapType
PresentationController::getSelectedColorMap() const
{
return _widgetPresentationParameters->getColorMap();
}
-MEDCALC::MEDPresentationScalarBarRange
+MEDCALC::ScalarBarRangeType
PresentationController::getSelectedScalarBarRange() const
{
return _widgetPresentationParameters->getScalarBarRange();
// 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; i<listOfSObject->size(); i++) {
- SALOMEDS::SObject_var soField = listOfSObject->at(i);
- int fieldId = getIntParamFromStudyEditor(soField, FIELD_ID);
- if (fieldId < 0) // is it a field serie ?
- {
- 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)
- 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;
- }
+ SALOMEDS::SObject_var soField = listOfSObject->at(i);
+ int fieldId = getIntParamFromStudyEditor(soField, FIELD_ID);
+ if (fieldId < 0) // is it a field serie ?
+ {
+ 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)
+ 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;
+ }
- MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
- if (! fieldHandler) {
- QMessageBox::warning(_salomeModule->getApp()->desktop(),
- tr("Operation not allowed"),
- tr("No field is defined"));
- return;
- }
+ MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
+ if (! fieldHandler) {
+ QMessageBox::warning(_salomeModule->getApp()->desktop(),
+ tr("Operation not allowed"),
+ tr("No field is defined"));
+ return;
+ }
- PresentationEvent* event = new PresentationEvent();
- event->eventtype = eventType;
- event->fieldHandler = fieldHandler;
- emit presentationSignal(event); // --> processPresentationEvent()
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = eventType;
+ event->fieldHandler = fieldHandler;
+ emit presentationSignal(event); // --> processPresentationEvent()
}
}
+void
+PresentationController::onVisualizeMeshView()
+{
+ this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW);
+}
+
void
PresentationController::onVisualizeScalarMap()
{
// For each object, emit a signal to the workspace to request pres deletion
for (int i=0; i<listOfSObject->size(); i++) {
- SALOMEDS::SObject_var soPres = listOfSObject->at(i);
- 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.
- if ( presId < 0 )
- continue;
-
- PresentationEvent* event = new PresentationEvent();
- event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
- event->presentationId = presId;
- emit presentationSignal(event); // --> processPresentationEvent()
+ SALOMEDS::SObject_var soPres = listOfSObject->at(i);
+ 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.
+ if ( presId < 0 )
+ continue;
+
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
+ event->presentationId = presId;
+ emit presentationSignal(event); // --> processPresentationEvent()
}
}
QString
PresentationController::getViewModePython() const
{
- MEDCALC::MEDPresentationViewMode viewMode = getSelectedViewMode();
+ MEDCALC::ViewModeType viewMode = 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";
+ 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";
}
return QString();
}
QString
PresentationController::getColorMapPython() const
{
- MEDCALC::MEDPresentationColorMap colorMap = getSelectedColorMap();
+ MEDCALC::ColorMapType colorMap = 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";
+ 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";
}
return QString();
}
QString
PresentationController::getScalarBarRangePython() const
{
- MEDCALC::MEDPresentationScalarBarRange colorMap = getSelectedScalarBarRange();
- switch(colorMap) {
- case MEDCALC::SCALAR_BAR_ALL_TIMESTEPS: return "MEDCALC.SCALAR_BAR_ALL_TIMESTEPS";
- case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP: return "MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP";
- }
- return QString();
+ MEDCALC::ScalarBarRangeType colorMap = getSelectedScalarBarRange();
+ switch(colorMap) {
+ case MEDCALC::SCALAR_BAR_ALL_TIMESTEPS: return "MEDCALC.SCALAR_BAR_ALL_TIMESTEPS";
+ case MEDCALC::SCALAR_BAR_CURRENT_TIMESTEP: return "MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP";
+ }
+ return QString();
+}
+
+QString
+PresentationController::getMeshModePython(const int mode) const
+{
+ MEDCALC::MeshModeType mod = static_cast<MEDCALC::MeshModeType>(mode);
+ switch(mod) {
+ case MEDCALC::MESH_MODE_WIREFRAME: return "MEDCALC.MESH_MODE_WIREFRAME";
+ case MEDCALC::MESH_MODE_SURFACE: return "MEDCALC.MESH_MODE_SURFACE";
+ case MEDCALC::MESH_MODE_SURFACE_EDGES: return "MEDCALC.MESH_MODE_SURFACE_EDGES";
+ }
+ return QString();
+}
+
+QString
+PresentationController::getSliceOrientationPython(const int orientation) const
+{
+ MEDCALC::SliceOrientationType orient = static_cast<MEDCALC::SliceOrientationType>(orientation);
+ switch(orient) {
+ case MEDCALC::SLICE_NORMAL_TO_X: return "MEDCALC.SLICE_NORMAL_TO_X";
+ case MEDCALC::SLICE_NORMAL_TO_Y: return "MEDCALC.SLICE_NORMAL_TO_Y";
+ case MEDCALC::SLICE_NORMAL_TO_Z: return "MEDCALC.SLICE_NORMAL_TO_Z";
+ case MEDCALC::SLICE_NORMAL_TO_XY: return "MEDCALC.SLICE_NORMAL_TO_XY";
+ case MEDCALC::SLICE_NORMAL_TO_XZ: return "MEDCALC.SLICE_NORMAL_TO_XZ";
+ case MEDCALC::SLICE_NORMAL_TO_YZ: return "MEDCALC.SLICE_NORMAL_TO_YZ";
+ case MEDCALC::SLICE_NORMAL_TO_XYZ: return "MEDCALC.SLICE_NORMAL_TO_XYZ";
+ }
+ return QString();
}
std::string
{
std::map<int, MEDWidgetHelper *>::const_iterator it =_presHelperMap.find(presId);
if (it != _presHelperMap.end())
- return (*it).second->getPythonTag();
+ return (*it).second->getPythonTag();
return "UNKNOWN";
}
void
PresentationController::processPresentationEvent(const PresentationEvent* event) {
// --> Send commands to SALOME Python console
- if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
- QString viewMode = getViewModePython();
- //QString displayedComponent = ; // from PresentationController combobox
- //QString scalarBarRange = ; // from PresentationController spinbox
- QString colorMap = getColorMapPython();
- MEDCALC::FieldHandler* fieldHandler = event->fieldHandler;
- QStringList commands;
- commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
- commands += QString("presentation_id");
- _consoleDriver->exec(commands);
- }
-// else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
-// QString viewMode = getViewModePython();
-// MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
-// QStringList commands;
-// commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-// commands += QString("presentation_id");
-// _consoleDriver->exec(commands);
-// }
-// else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
-// QString viewMode = getViewModePython();
-// MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
-// QStringList commands;
-// commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-// commands += QString("presentation_id");
-// _consoleDriver->exec(commands);
-// }
-// else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
-// QString viewMode = getViewModePython();
-// MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
-// QStringList commands;
-// commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-// commands += QString("presentation_id");
-// _consoleDriver->exec(commands);
-// }
-// else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
-// QString viewMode = getViewModePython();
-// MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
-// QStringList commands;
-// commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-// commands += QString("presentation_id");
-// _consoleDriver->exec(commands);
-// }
-// else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
-// QString viewMode = getViewModePython();
-// MEDCALC::FieldHandler* fieldHandler = event->_fieldHandler;
-// QStringList commands;
-// commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
-// commands += QString("presentation_id");
-// _consoleDriver->exec(commands);
-// }
-
- // [ABN] using event mechanism for this is awkward? TODO: direct implementation in each
+ QString viewMode = getViewModePython();
+ QString colorMap = getColorMapPython();
+ 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");
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
+ commands += QString("presentation_id = medcalc.MakeScalarMap(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_CONTOUR ) {
+ commands += QString("presentation_id = medcalc.MakeContour(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_SLICES ) {
+ commands += QString("presentation_id = medcalc.MakeSlices(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_VECTOR_FIELD ) {
+ commands += QString("presentation_id = medcalc.MakeVectorField(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_POINT_SPRITE ) {
+ commands += QString("presentation_id = medcalc.MakePointSprite(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), 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_CHANGE_COMPONENT ) {
std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
- QStringList commands;
commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
commands += QString("params.displayedComponent = '%1'").arg(QString::fromStdString(event->aString));
commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
- _consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COLORMAP ) {
std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
- QStringList commands;
commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
commands += QString("params.colorMap = %1").arg(getColorMapPython());
commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
- _consoleDriver->exec(commands);
- }
+ }
else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_TIME_RANGE ) {
std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
- QStringList commands;
commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
commands += QString("params.scalarBarRange = %1").arg(getScalarBarRangePython());
commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
- _consoleDriver->exec(commands);
}
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NB_CONTOUR ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetContourParameters(%2)").arg(event->presentationId);
+ commands += QString("params.nbContours = %1").arg(event->anInteger);
+ commands += QString("medcalc.UpdateContour(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_MESH_MODE ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetMeshViewParameters(%2)").arg(event->presentationId);
+ commands += QString("params.mode = %1").arg(getMeshModePython(event->anInteger));
+ commands += QString("medcalc.UpdateMeshView(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NB_SLICES ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId);
+ commands += QString("params.nbSlices = %1").arg(event->anInteger);
+ commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId);
+ }
+ else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION ) {
+ std::string typ = getPresTypeFromWidgetHelper(event->presentationId);
+ commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId);
+ commands += QString("params.orientation = %1").arg(getSliceOrientationPython(event->anInteger));
+ commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId);
+ }
+
else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
- QStringList commands;
commands += QString("medcalc.RemovePresentation(%1)").arg(event->presentationId);
- _consoleDriver->exec(commands);
}
else {
- STDLOG("The event "<<event->eventtype<<" is not implemented yet");
+ STDLOG("The event "<<event->eventtype<<" is not implemented yet");
}
+ _consoleDriver->exec(commands);
}
MEDWidgetHelper *
std::map<int, MEDWidgetHelper *>::const_iterator it =_presHelperMap.find(presId);
if (it != _presHelperMap.end())
return (*it).second;
- MEDWidgetHelper * wh;
- if (type == MEDPresentationScalarMap::TYPE_NAME)
+ MEDWidgetHelper * wh = 0;
+ if (type == MEDPresentationMeshView::TYPE_NAME)
+ wh = new MEDWidgetHelperMeshView(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationScalarMap::TYPE_NAME)
wh = new MEDWidgetHelperScalarMap(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationContour::TYPE_NAME)
+ wh = new MEDWidgetHelperContour(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationSlices::TYPE_NAME)
+ wh = new MEDWidgetHelperSlices(this, _presManager, presId, name, _widgetPresentationParameters);
+ else if (type == MEDPresentationVectorField::TYPE_NAME)
+ 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
{
-// case PRES_CONTOUR:
-//// break;
-// case PRES_DEFLECTION:
-//// break;
-// case PRES_VECTOR_FIELD:
-// // break;
-// case PRES_POINT_SPRITE:
-// // break;
-// case PRES_POINT_SPRITE:
-// // break;
-// default:
- STDLOG("findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!");
-
- }
+ const char * msg ="findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!";
+ STDLOG(msg);
+ }
_presHelperMap[presId] = wh;
return wh;
}
_presManager->activateView(presId);
// Update widgets parameters
_currentWidgetHelper = findOrCreateWidgetHelper(_presManager, presId, presType.toStdString(), presName.toStdString());
- _currentWidgetHelper->udpateWidget();
+ _currentWidgetHelper->updateWidget(true);
}
}
// For the first object only, request the dump
for (int i=0; i<listOfSObject->size(); i++) {
- SALOMEDS::SObject_var soPres = listOfSObject->at(i);
- 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.
- if ( presId < 0 )
- continue;
-
- std::string dump(_presManager->getParavisDump(presId));
- std::cerr << "#====== ParaVis dump =============== " << std::endl;
- std::cerr << dump;
- std::cerr << "#====== End of ParaVis dump ======== " << std::endl;
-
- break; // stop at the first one
+ SALOMEDS::SObject_var soPres = listOfSObject->at(i);
+ 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.
+ if ( presId < 0 )
+ continue;
+
+ std::string dump(_presManager->getParavisDump(presId));
+ std::cerr << "#====== ParaVis dump (presentation " << presId << ") =====" << std::endl;
+ std::cerr << dump;
+ std::cerr << "#====== End of ParaVis dump =============== " << std::endl;
+
+ break; // stop at the first one
}
}
PresentationController::updateTreeViewWithNewPresentation(long fieldId, long presentationId)
{
if (presentationId < 0) {
- std::cerr << "Unknown presentation\n";
- return;
+ std::cerr << "Unknown presentation\n";
+ return;
}
- std::string name(MEDFactoryClient::getPresentationManager()->getPresentationStringProperty(presentationId, MEDPresentation::PROP_NAME.c_str()));
+ std::string name(_presManager->getPresentationStringProperty(presentationId, MEDPresentation::PROP_NAME.c_str()));
std::string type = name;
std::string icon = std::string("ICO_") + type;
icon = _getIconName(icon);
oss.str().c_str(), type.c_str(),ico.c_str(), presentationId);
- MEDCALC::MEDPresentationViewMode 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;
- }
+ // 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;
+ // }
// update Object browser
_salomeModule->getApp()->updateObjectBrowser(true);
PresentationController::updateTreeViewForPresentationRemoval(long presentationId)
{
if (presentationId < 0) {
- std::cerr << "Unknown presentation\n";
- return;
+ std::cerr << "Unknown presentation\n";
+ return;
}
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
{
if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
- this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
+ updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
+ // Deal with replace mode: presentations with invalid IDs have to be removed:
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_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
+ }
+ }
}
else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
- this->updateTreeViewForPresentationRemoval(event->presentationId);
+ updateTreeViewForPresentationRemoval(event->presentationId);
+ // Hide parameter widget if necessary:
+ onPresentationSelected(-1, "", "");
+ }
+ else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
+ // Update parameter widget if shown:
+ if(_currentWidgetHelper)
+ _currentWidgetHelper->updateWidget(false);
}
}