Salome HOME
Merge branch 'V9_9_BR'
[modules/med.git] / src / MEDCalc / gui / MEDWidgetHelperStreamLines.cxx
1 // Copyright (C) 2016-2022  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "MEDWidgetHelperStreamLines.hxx"
21 #include "MEDPresentationStreamLines.hxx"  // from component side.
22 #include "PresentationController.hxx"
23
24 #include <Basics_Utils.hxx>
25
26 #include <sstream>
27
28 MEDWidgetHelperStreamLines::MEDWidgetHelperStreamLines(const PresentationController* presController,
29                            MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
30                            WidgetPresentationParameters * paramW):
31   MEDWidgetHelper(presController, presManager, presId, presName, paramW)
32   {}
33
34 MEDWidgetHelperStreamLines::~MEDWidgetHelperStreamLines()
35 {}
36
37 void MEDWidgetHelperStreamLines::loadParametersFromEngine()
38 {
39   MEDWidgetHelper::loadParametersFromEngine();
40   _intDirType = static_cast<MEDCALC::IntegrationDirType>(
41         _presManager->getPresentationIntProperty(_presId, MEDPresentationStreamLines::PROP_INTEGR_DIR_TYPE.c_str()));
42 }
43
44 void MEDWidgetHelperStreamLines::updateWidget(bool connect)
45 {
46   MEDWidgetHelper::updateWidget(connect);
47
48   _paramWidget->setIntegrationDir(_intDirType);
49
50   // Connect spin boxes changes
51   if (connect)
52   {
53     QObject::connect( _paramWidget, SIGNAL(comboIntegrDirIndexChanged(int)), this, SLOT(onIntegrDirTypeChanged(int)) );
54   }
55 }
56
57 void MEDWidgetHelperStreamLines::releaseWidget()
58 {
59   MEDWidgetHelper::releaseWidget();
60
61   QObject::disconnect( _paramWidget, SIGNAL(comboIntegrDirIndexChanged(int)), this, SLOT(onIntegrDirTypeChanged(int)) );
62 }
63
64 void MEDWidgetHelperStreamLines::onIntegrDirTypeChanged(int index)
65 {
66   STDLOG("MEDWidgetHelperStreamLines::onIntegrDirTypeChanged");
67   PresentationEvent* event = new PresentationEvent();
68   event->eventtype = PresentationEvent::EVENT_CHANGE_INTEGR_DIR;
69   event->presentationId = _presId;
70   event->anInteger = static_cast<int>(_paramWidget->getIntegrationDir());
71
72   emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
73 }
74