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::udpateWidget()
49 MEDWidgetHelper::udpateWidget();
50 STDLOG("MEDWidgetHelperSlices::udpateWidget() nbSlices is " << _nbSlices);
52 // _paramWidget->setNbSlices(_nbSlices); // TODO: uncomment when ready to deal with slice number
53 _paramWidget->setSliceOrientation(_sliceOrientation);
55 // Connect combo box changes
56 QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
57 _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
58 QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
59 QObject::connect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
62 void MEDWidgetHelperSlices::releaseWidget()
64 MEDWidgetHelper::releaseWidget();
66 QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)),
67 _presController, SIGNAL(presentationSignal(const PresentationEvent *)) );
68 QObject::disconnect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) );
69 QObject::disconnect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) );
72 void MEDWidgetHelperSlices::onNbSlicesChanged(int nbSlices)
74 STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
75 PresentationEvent* event = new PresentationEvent();
76 event->eventtype = PresentationEvent::EVENT_CHANGE_NB_SLICES;
77 event->presentationId = _presId;
78 event->anInteger = nbSlices;
80 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
84 void MEDWidgetHelperSlices::onSliceOrientationChanged(int sliceOrient)
86 STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
87 PresentationEvent* event = new PresentationEvent();
88 event->eventtype = PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION;
89 event->presentationId = _presId;
90 event->anInteger = static_cast<int>(_paramWidget->getSliceOrientation());
92 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent