1 // Copyright (C) 2016-2024 CEA, EDF
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 "MEDWidgetHelperCutSegment.hxx"
21 #include "MEDPresentationCutSegment.hxx" // from component side.
22 #include "PresentationController.hxx"
24 #include <Basics_Utils.hxx>
28 MEDWidgetHelperCutSegment::MEDWidgetHelperCutSegment(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 MEDWidgetHelperCutSegment::~MEDWidgetHelperCutSegment()
37 void MEDWidgetHelperCutSegment::loadParametersFromEngine()
39 MEDWidgetHelper::loadParametersFromEngine();
40 _point1[0] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT1_X.c_str());
41 _point1[1] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT1_Y.c_str());
42 _point1[2] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT1_Z.c_str());
43 _point2[0] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT2_X.c_str());
44 _point2[1] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT2_Y.c_str());
45 _point2[2] = _presManager->getPresentationDoubleProperty(_presId, MEDPresentationCutSegment::PROP_POINT2_Z.c_str());
48 void MEDWidgetHelperCutSegment::updateWidget(bool connect)
50 MEDWidgetHelper::updateWidget(connect);
52 _paramWidget->setCutPoint1(_point1[0], _point1[1], _point1[2]);
53 _paramWidget->setCutPoint2(_point2[0], _point2[1], _point2[2]);
55 // Connect spin boxes changes
58 QObject::connect( _paramWidget, SIGNAL(spinCutPoint1ValuesChanged(double, double, double)), this, SLOT(onCutPoint1Changed(double, double, double)) );
59 QObject::connect( _paramWidget, SIGNAL(spinCutPoint2ValuesChanged(double, double, double)), this, SLOT(onCutPoint2Changed(double, double, double)) );
63 void MEDWidgetHelperCutSegment::releaseWidget()
65 MEDWidgetHelper::releaseWidget();
67 QObject::disconnect( _paramWidget, SIGNAL(spinCutPoint1ValuesChanged(double, double, double)), this, SLOT(onCutPoint1Changed(double, double, double)) );
68 QObject::disconnect( _paramWidget, SIGNAL(spinCutPoint2ValuesChanged(double, double, double)), this, SLOT(onCutPoint2Changed(double, double, double)) );
71 void MEDWidgetHelperCutSegment::onCutPoint1Changed(double x, double y, double z)
73 STDLOG("MEDWidgetHelperCutSegment::onCutPoint1Changed");
74 PresentationEvent* event = new PresentationEvent();
75 event->eventtype = PresentationEvent::EVENT_CHANGE_CUT_POINT1;
76 event->presentationId = _presId;
77 event->aDoubleP1[0] = x;
78 event->aDoubleP1[1] = y;
79 event->aDoubleP1[2] = z;
81 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent
84 void MEDWidgetHelperCutSegment::onCutPoint2Changed(double x, double y, double z)
86 STDLOG("MEDWidgetHelperCutSegment::onCutPoint2Changed");
87 PresentationEvent* event = new PresentationEvent();
88 event->eventtype = PresentationEvent::EVENT_CHANGE_CUT_POINT2;
89 event->presentationId = _presId;
90 event->aDoubleP2[0] = x;
91 event->aDoubleP2[1] = y;
92 event->aDoubleP2[2] = z;
94 emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent