1 // Copyright (C) 2016-2021 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 "MEDWidgetHelperPlot3D.hxx"
21 #include "MEDPresentationPlot3D.hxx" // from component side.
22 #include "PresentationController.hxx"
24 #include <Basics_Utils.hxx>
28 MEDWidgetHelperPlot3D::MEDWidgetHelperPlot3D(const PresentationController* presController,
29 MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName,
30 WidgetPresentationParameters * paramW):
31 MEDWidgetHelper(presController, presManager, presId, presName, paramW)
34 MEDWidgetHelperPlot3D::~MEDWidgetHelperPlot3D()
37 void MEDWidgetHelperPlot3D::loadParametersFromEngine()
39 MEDWidgetHelper::loadParametersFromEngine();
40 _planeNormal[0] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_NORMAL_X.c_str());
41 _planeNormal[1] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_NORMAL_Y.c_str());
42 _planeNormal[2] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_NORMAL_Z.c_str());
43 _planePos = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationPlot3D::PROP_PLANE_POS.c_str());
44 _isPlanar = _presManager->getPresentationIntProperty(_presId, MEDPresentationPlot3D::PROP_IS_PLANAR.c_str());
47 void MEDWidgetHelperPlot3D::updateWidget(bool connect)
49 MEDWidgetHelper::updateWidget(connect);
51 _paramWidget->setNormal(_planeNormal[0], _planeNormal[1], _planeNormal[2]);
52 _paramWidget->setPlanePosition(_planePos);
54 // Connect spin boxes changes
57 QObject::connect( _paramWidget, SIGNAL(spinNormalValuesChanged(double, double, double)), this, SLOT(onPlaneNormalChanged(double, double, double)) );
58 QObject::connect( _paramWidget, SIGNAL(spinPlanePosValueChanged(double)), this, SLOT(onPlanePositionChanged(double)) );
61 _paramWidget->hidePlot3D();
64 void MEDWidgetHelperPlot3D::releaseWidget()
66 MEDWidgetHelper::releaseWidget();
68 QObject::disconnect( _paramWidget, SIGNAL(spinNormalValuesChanged(double, double, double)), this, SLOT(onPlaneNormalChanged(double, double, double)) );
69 QObject::disconnect( _paramWidget, SIGNAL(spinPlanePosValueChanged(double)), this, SLOT(onPlanePositionChanged(double)) );
72 void MEDWidgetHelperPlot3D::onPlaneNormalChanged(double normX, double normY, double normZ)
74 STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
75 PresentationEvent* event = new PresentationEvent();
76 event->eventtype = PresentationEvent::EVENT_CHANGE_NORMAL;
77 event->presentationId = _presId;
78 event->aDoubleN[0] = normX;
79 event->aDoubleN[1] = normY;
80 event->aDoubleN[2] = normZ;
82 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
85 void MEDWidgetHelperPlot3D::onPlanePositionChanged(double planePos)
87 STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged");
88 PresentationEvent* event = new PresentationEvent();
89 event->eventtype = PresentationEvent::EVENT_CHANGE_PLANE_POS;
90 event->presentationId = _presId;
91 event->aDouble3 = planePos;
93 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent