1 // Copyright (C) 2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MEDWidgetHelperSlices.hxx"
21 #include "MEDPresentationSlices.hxx" // from component side.
22 #include "PresentationController.hxx"
24 #include <Basics_Utils.hxx>
28 MEDWidgetHelperSlices::MEDWidgetHelperSlices(const PresentationController * presController,
29 MEDCALC::MEDPresentationManager_ptr presManager, int presId,
30 const std::string & presName, WidgetPresentationParameters * paramW):
31 MEDWidgetHelper(presController, presManager, presId, presName, paramW),
33 _sliceOrientation(MEDCALC::SLICE_ORIENTATION_DEFAULT)
36 MEDWidgetHelperSlices::~MEDWidgetHelperSlices()
39 void MEDWidgetHelperSlices::loadParametersFromEngine()
41 MEDWidgetHelper::loadParametersFromEngine();
42 _nbSlices = _presManager->getPresentationIntProperty(_presId, MEDPresentationSlices::PROP_NB_SLICES.c_str());
43 _sliceOrientation = static_cast<MEDCALC::SliceOrientationType>(
44 _presManager->getPresentationIntProperty(_presId, MEDPresentationSlices::PROP_SLICE_ORIENTATION.c_str()));
47 void MEDWidgetHelperSlices::updateWidget(bool connect)
49 MEDWidgetHelper::updateWidget(connect);
50 STDLOG("MEDWidgetHelperSlices::udpateWidget() nbSlices is " << _nbSlices);
52 _paramWidget->setNbSlices(_nbSlices);
53 _paramWidget->setSliceOrientation(_sliceOrientation);
55 // Connect combo box changes
58 QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
59 _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
60 QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
61 QObject::connect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
65 void MEDWidgetHelperSlices::releaseWidget()
67 MEDWidgetHelper::releaseWidget();
69 QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
70 _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
71 QObject::disconnect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
72 QObject::disconnect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
75 void MEDWidgetHelperSlices::onNbSlicesChanged(int nbSlices)
77 STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
78 PresentationEvent* event = new PresentationEvent();
79 event->eventtype = PresentationEvent::EVENT_CHANGE_NB_SLICES;
80 event->presentationId = _presId;
81 event->anInteger = nbSlices;
83 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
87 void MEDWidgetHelperSlices::onSliceOrientationChanged(int sliceOrient)
89 STDLOG("MEDWidgetHelperSlices::onSliceOrientationChanged");
90 PresentationEvent* event = new PresentationEvent();
91 event->eventtype = PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION;
92 event->presentationId = _presId;
93 event->anInteger = static_cast<int>(_paramWidget->getSliceOrientation());
95 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent