From 3de6476971b64b3a36c0c520e502a150fc5d1e88 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Mon, 18 Apr 2016 13:43:00 +0200 Subject: [PATCH] [MEDCalc] View mode in a dedicated toolbar --- src/MEDCalc/gui/PresentationController.cxx | 60 +++++++++++++++++-- .../dialogs/WidgetPresentationParameters.cxx | 20 ------- .../dialogs/WidgetPresentationParameters.hxx | 1 - .../dialogs/WidgetPresentationParameters.ui | 59 +++++------------- 4 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx index edeeb576c..b727b6b4c 100644 --- a/src/MEDCalc/gui/PresentationController.cxx +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -37,6 +37,12 @@ #include #include +static const int OPTIONS_VIEW_MODE_ID = 943; +static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944; +static const int OPTIONS_VIEW_MODE_OVERLAP_ID = 945; +static const int OPTIONS_VIEW_MODE_NEW_LAYOUT_ID = 946; +static const int OPTIONS_VIEW_MODE_SPLIT_VIEW_ID = 947; + PresentationController::PresentationController(MEDModule* salomeModule) { STDLOG("Creating a PresentationController"); @@ -84,12 +90,44 @@ PresentationController::createActions() { STDLOG("Creating PresentationController actions"); + // View Mode + int viewModeToolbarId = _salomeModule->createTool("View Mode", "ViewModeToolbar"); + QtxActionGroup* ag = _salomeModule->createActionGroup(OPTIONS_VIEW_MODE_ID, true); + ag->setText("View mode"); + ag->setUsesDropDown(true); + QString label = tr("LAB_VIEW_MODE_REPLACE"); + QString tooltip = tr("TIP_VIEW_MODE_REPLACE"); + QAction* a = _salomeModule->createAction(OPTIONS_VIEW_MODE_REPLACE_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + a->setChecked(true); + ag->add(a); + + label = tr("LAB_VIEW_MODE_OVERLAP"); + tooltip = tr("TIP_VIEW_MODE_OVERLAP"); + a = _salomeModule->createAction(OPTIONS_VIEW_MODE_OVERLAP_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + ag->add(a); + + label = tr("LAB_VIEW_MODE_NEW_LAYOUT"); + tooltip = tr("TIP_VIEW_MODE_NEW_LAYOUT"); + a = _salomeModule->createAction(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + ag->add(a); + + label = tr("LAB_VIEW_MODE_SPLIT_VIEW"); + tooltip = tr("TIP_VIEW_MODE_SPLIT_VIEW"); + a = _salomeModule->createAction(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + ag->add(a); + + _salomeModule->createTool(OPTIONS_VIEW_MODE_ID, viewModeToolbarId); + + // Presentations int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar"); int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1); - // Presentations - QString label = tr("LAB_PRESENTATION_SCALAR_MAP"); - QString tooltip = tr("TIP_PRESENTATION_SCALAR_MAP"); + label = tr("LAB_PRESENTATION_SCALAR_MAP"); + tooltip = tr("TIP_PRESENTATION_SCALAR_MAP"); QString icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str()); int actionId; actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeScalarMap()),icon,tooltip); @@ -141,7 +179,21 @@ PresentationController::createActions() MEDCALC::MEDPresentationViewMode PresentationController::getSelectedViewMode() { - return _widgetPresentationParameters->getViewMode(); + if (_salomeModule->action(OPTIONS_VIEW_MODE_REPLACE_ID)->isChecked()) { + return MEDCALC::VIEW_MODE_REPLACE; + } + else if (_salomeModule->action(OPTIONS_VIEW_MODE_OVERLAP_ID)->isChecked()) { + return MEDCALC::VIEW_MODE_OVERLAP; + } + else if (_salomeModule->action(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID)->isChecked()) { + return MEDCALC::VIEW_MODE_NEW_LAYOUT; + } + else if (_salomeModule->action(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID)->isChecked()) { + 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 diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx index d314cfa35..380784b02 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx @@ -26,26 +26,6 @@ WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent) ui.setupUi(this); // To be done first } -MEDCALC::MEDPresentationViewMode -WidgetPresentationParameters::getViewMode() { - QString viewMode = this->ui.comboBoxViewMode->currentText(); - if (viewMode == tr("LAB_VIEW_MODE_REPLACE")) { - return MEDCALC::VIEW_MODE_REPLACE; - } - else if (viewMode == tr("LAB_VIEW_MODE_OVERLAP")) { - return MEDCALC::VIEW_MODE_OVERLAP; - } - else if (viewMode == tr("LAB_VIEW_MODE_NEW_LAYOUT")) { - return MEDCALC::VIEW_MODE_NEW_LAYOUT; - } - else if (viewMode == tr("LAB_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; -} - std::string WidgetPresentationParameters::getField() { diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx index 0f8815759..b6dd8d365 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx @@ -36,7 +36,6 @@ public: WidgetPresentationParameters(QWidget* parent = 0); virtual ~WidgetPresentationParameters() {} - MEDCALC::MEDPresentationViewMode getViewMode(); std::string getField(); std::string getScalarBarRange(); double getScalarBarTimestep(); diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui index 00882636e..f3feece34 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui @@ -7,7 +7,7 @@ 0 0 404 - 230 + 200 @@ -20,14 +20,14 @@ Form - + LAB_FIELD - + @@ -36,7 +36,7 @@ - + false @@ -49,14 +49,14 @@ - + false - + false @@ -69,14 +69,14 @@ - + false - + false @@ -89,21 +89,21 @@ - + false - + LAB_COLOR_MAP - + @@ -117,38 +117,7 @@ - - - - LAB_VIEW_MODE - - - - - - - - LAB_VIEW_MODE_REPLACE - - - - - LAB_VIEW_MODE_OVERLAP - - - - - LAB_VIEW_MODE_NEW_LAYOUT - - - - - LAB_VIEW_MODE_SPLIT_VIEW - - - - - + true @@ -170,14 +139,14 @@ - + LAB_SCALARBAR - + true -- 2.39.2