1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
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 // GEOM GEOMGUI : GUI for Geometry component
21 // File : EntityGUI_IsolineDlg.cxx
23 #include "EntityGUI_IsolineDlg.h"
24 #include <GeometryGUI.h>
28 #include <SUIT_Session.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SalomeApp_Application.h>
31 #include <LightApp_SelectionMgr.h>
33 #include <QButtonGroup>
36 //=================================================================================
37 // class : EntityGUI_IsolineDlg
39 //=================================================================================
40 EntityGUI_IsolineDlg::EntityGUI_IsolineDlg (GeometryGUI *theGeometryGUI,
44 : GEOMBase_Skeleton (theGeometryGUI, parent, modal, fl),
47 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_ISOLINE")));
48 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
49 QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_ISOLINE_V")));
51 setWindowTitle(tr("GEOM_ISOLINE_TITLE"));
53 /***************************************************************/
55 mainFrame()->GroupConstructors->setTitle(tr("GEOM_ISOLINE"));
56 mainFrame()->RadioButton1->setIcon(image0);
57 mainFrame()->RadioButton2->close();
58 mainFrame()->RadioButton3->close();
61 myGroup = new DlgRef_3Radio1Sel1Spin(centralWidget());
62 myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
63 myGroup->TextLabel1->setText(tr("GEOM_FACE"));
64 myGroup->PushButton1->setIcon(image1);
65 myGroup->LineEdit1->setReadOnly(true);
66 myGroup->RadioButton1->setIcon(image0);
67 myGroup->RadioButton2->setIcon(image2);
68 myGroup->RadioButton1->setText(tr("GEOM_ISOLINE_U"));
69 myGroup->RadioButton2->setText(tr("GEOM_ISOLINE_V"));
70 myGroup->RadioButton3->hide();
71 myGroup->TextLabel2->setText(tr("GEOM_PARAMETER"));
73 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
74 layout->setMargin(0); layout->setSpacing(6);
75 layout->addWidget(myGroup);
77 myRBGroup = new QButtonGroup( this );
78 myRBGroup->addButton( myGroup->RadioButton1, 0 );
79 myRBGroup->addButton( myGroup->RadioButton2, 1 );
81 setHelpFileName("create_isoline_page.html");
86 //=================================================================================
87 // function : ~EntityGUI_IsolineDlg()
89 //=================================================================================
90 EntityGUI_IsolineDlg::~EntityGUI_IsolineDlg()
94 //=================================================================================
97 //=================================================================================
98 void EntityGUI_IsolineDlg::Init()
100 /* min, max, step and decimals for spin box */
101 initSpinBox(myGroup->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
102 myGroup->SpinBox_DX->setValue(0.5);
103 myGroup->RadioButton1->setChecked(true);
105 initName(mainFrame()->GroupConstructors->title());
107 connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditFace()));
108 connect(myGroup->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
110 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
111 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
112 this, SLOT(SelectionIntoArgument()));
114 /* signals and slots connections */
115 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
116 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
117 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
118 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
119 connect(myRBGroup, SIGNAL(buttonClicked(int)), this, SLOT(TypeChanged(int)));
121 myGroup->PushButton1->click();
122 SelectionIntoArgument();
126 //=================================================================================
127 // function : SelectionIntoArgument
128 // purpose : Called when selection is changed
129 //=================================================================================
130 void EntityGUI_IsolineDlg::SelectionIntoArgument()
132 myGroup->LineEdit1->setText("");
135 GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_SHAPE );
138 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
139 if (aShape.ShapeType() == TopAbs_FACE) {
140 QString aName = GEOMBase::GetName( aSelectedObject.get() );
141 myGroup->LineEdit1->setText( aName );
144 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
145 myGeomGUI->getApp()->selectionMgr()->clearSelected();
146 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
147 this, SLOT(SelectionIntoArgument()));
149 myFace = aSelectedObject;
153 displayPreview(true);
156 //=================================================================================
157 // function : ActivateThisDialog
159 //=================================================================================
160 void EntityGUI_IsolineDlg::ActivateThisDialog()
162 GEOMBase_Skeleton::ActivateThisDialog();
164 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
165 this, SLOT( SelectionIntoArgument() ) );
167 SelectionIntoArgument();
170 //=================================================================================
171 // function : enterEvent()
173 //=================================================================================
174 void EntityGUI_IsolineDlg::enterEvent (QEvent*)
176 if (!mainFrame()->GroupConstructors->isEnabled())
177 ActivateThisDialog();
180 //=================================================================================
181 // function : TypeChanged
183 //=================================================================================
184 void EntityGUI_IsolineDlg::TypeChanged(int)
186 displayPreview(true);
189 //=================================================================================
190 // function : createOperation
192 //=================================================================================
193 GEOM::GEOM_IOperations_ptr EntityGUI_IsolineDlg::createOperation()
195 return myGeomGUI->GetGeomGen()->GetICurvesOperations();
198 //=================================================================================
199 // function : isValid
201 //=================================================================================
202 bool EntityGUI_IsolineDlg::isValid (QString& msg)
207 //=================================================================================
208 // function : execute
210 //=================================================================================
211 bool EntityGUI_IsolineDlg::execute (ObjectList& objects)
213 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
214 GEOM::GEOM_Object_var anObj = anOper->MakeIsoline
215 (myFace.get(), myGroup->RadioButton1->isChecked(), myGroup->SpinBox_DX->value());
217 if (!anObj->_is_nil())
218 objects.push_back(anObj._retn());
223 //=================================================================================
224 // function : addSubshapesToStudy()
225 // purpose : Double spin box management
226 //=================================================================================
227 void EntityGUI_IsolineDlg::addSubshapesToStudy()
229 GEOMBase::PublishSubObject(myFace.get());
232 //=================================================================================
233 // function : SetDoubleSpinBoxStep()
234 // purpose : Double spin box management
235 //=================================================================================
236 void EntityGUI_IsolineDlg::SetDoubleSpinBoxStep (double step)
238 myGroup->SpinBox_DX->setSingleStep(step);
241 //=================================================================================
242 // function : ClickOnOk()
244 //=================================================================================
245 void EntityGUI_IsolineDlg::ClickOnOk()
247 setIsApplyAndClose( true );
253 //=================================================================================
254 // function : ClickOnApply()
256 //=================================================================================
257 bool EntityGUI_IsolineDlg::ClickOnApply()
263 // activate selection and connect selection manager
264 myGroup->PushButton1->click();
268 //=================================================================================
269 // function : SetEditFace
271 //=================================================================================
272 void EntityGUI_IsolineDlg::SetEditFace()
274 myGroup->LineEdit1->setFocus();
275 myGroup->PushButton1->setDown(true);
278 //=================================================================================
279 // function : ValueChangedInSpinBox
281 //=================================================================================
282 void EntityGUI_IsolineDlg::ValueChangedInSpinBox(double newValue)
284 displayPreview(true);
287 //=================================================================================
288 // function : getSourceObjects
289 // purpose : virtual method to get source objects
290 //=================================================================================
291 QList<GEOM::GeomObjPtr> EntityGUI_IsolineDlg::getSourceObjects()
293 QList<GEOM::GeomObjPtr> res;