1 // Copyright (C) 2007-2022 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>
35 //=================================================================================
36 // class : EntityGUI_IsolineDlg
38 //=================================================================================
39 EntityGUI_IsolineDlg::EntityGUI_IsolineDlg (GeometryGUI *theGeometryGUI,
43 : GEOMBase_Skeleton (theGeometryGUI, parent, modal, fl),
46 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_ISOLINE")));
47 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
48 QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_ISOLINE_V")));
50 setWindowTitle(tr("GEOM_ISOLINE_TITLE"));
52 /***************************************************************/
54 mainFrame()->GroupConstructors->setTitle(tr("GEOM_ISOLINE"));
55 mainFrame()->RadioButton1->setIcon(image0);
56 mainFrame()->RadioButton2->close();
57 mainFrame()->RadioButton3->close();
60 myGroup = new DlgRef_3Radio1Sel1Spin(centralWidget());
61 myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
62 myGroup->TextLabel1->setText(tr("GEOM_FACE"));
63 myGroup->PushButton1->setIcon(image1);
64 myGroup->LineEdit1->setReadOnly(true);
65 myGroup->RadioButton1->setIcon(image0);
66 myGroup->RadioButton2->setIcon(image2);
67 myGroup->RadioButton1->setText(tr("GEOM_ISOLINE_U"));
68 myGroup->RadioButton2->setText(tr("GEOM_ISOLINE_V"));
69 myGroup->RadioButton3->hide();
70 myGroup->TextLabel2->setText(tr("GEOM_PARAMETER"));
72 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
73 layout->setMargin(0); layout->setSpacing(6);
74 layout->addWidget(myGroup);
76 myRBGroup = new QButtonGroup( this );
77 myRBGroup->addButton( myGroup->RadioButton1, 0 );
78 myRBGroup->addButton( myGroup->RadioButton2, 1 );
80 setHelpFileName("create_isoline_page.html");
85 //=================================================================================
86 // function : ~EntityGUI_IsolineDlg()
88 //=================================================================================
89 EntityGUI_IsolineDlg::~EntityGUI_IsolineDlg()
93 //=================================================================================
96 //=================================================================================
97 void EntityGUI_IsolineDlg::Init()
99 /* min, max, step and decimals for spin box */
100 initSpinBox(myGroup->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
101 myGroup->SpinBox_DX->setValue(0.5);
102 myGroup->RadioButton1->setChecked(true);
104 initName(mainFrame()->GroupConstructors->title());
106 connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditFace()));
107 connect(myGroup->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
109 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
110 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
111 this, SLOT(SelectionIntoArgument()));
113 /* signals and slots connections */
114 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
115 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
116 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
117 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
118 connect(myRBGroup, SIGNAL(buttonClicked(int)), this, SLOT(TypeChanged(int)));
120 myGroup->PushButton1->click();
121 SelectionIntoArgument();
125 //=================================================================================
126 // function : SelectionIntoArgument
127 // purpose : Called when selection is changed
128 //=================================================================================
129 void EntityGUI_IsolineDlg::SelectionIntoArgument()
131 myGroup->LineEdit1->setText("");
134 GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_SHAPE );
137 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
138 if (aShape.ShapeType() == TopAbs_FACE) {
139 QString aName = GEOMBase::GetName( aSelectedObject.get() );
140 myGroup->LineEdit1->setText( aName );
143 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
144 myGeomGUI->getApp()->selectionMgr()->clearSelected();
145 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
146 this, SLOT(SelectionIntoArgument()));
148 myFace = aSelectedObject;
152 displayPreview(true);
155 //=================================================================================
156 // function : ActivateThisDialog
158 //=================================================================================
159 void EntityGUI_IsolineDlg::ActivateThisDialog()
161 GEOMBase_Skeleton::ActivateThisDialog();
163 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
164 this, SLOT( SelectionIntoArgument() ) );
166 SelectionIntoArgument();
169 //=================================================================================
170 // function : enterEvent()
172 //=================================================================================
173 void EntityGUI_IsolineDlg::enterEvent (QEvent*)
175 if (!mainFrame()->GroupConstructors->isEnabled())
176 ActivateThisDialog();
179 //=================================================================================
180 // function : TypeChanged
182 //=================================================================================
183 void EntityGUI_IsolineDlg::TypeChanged(int)
185 displayPreview(true);
188 //=================================================================================
189 // function : createOperation
191 //=================================================================================
192 GEOM::GEOM_IOperations_ptr EntityGUI_IsolineDlg::createOperation()
194 return myGeomGUI->GetGeomGen()->GetICurvesOperations();
197 //=================================================================================
198 // function : isValid
200 //=================================================================================
201 bool EntityGUI_IsolineDlg::isValid (QString& /*msg*/)
206 //=================================================================================
207 // function : execute
209 //=================================================================================
210 bool EntityGUI_IsolineDlg::execute (ObjectList& objects)
212 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
213 GEOM::GEOM_Object_var anObj = anOper->MakeIsoline
214 (myFace.get(), myGroup->RadioButton1->isChecked(), myGroup->SpinBox_DX->value());
216 if (!anObj->_is_nil())
217 objects.push_back(anObj._retn());
222 //=================================================================================
223 // function : addSubshapesToStudy()
224 // purpose : Double spin box management
225 //=================================================================================
226 void EntityGUI_IsolineDlg::addSubshapesToStudy()
228 GEOMBase::PublishSubObject(myFace.get());
231 //=================================================================================
232 // function : SetDoubleSpinBoxStep()
233 // purpose : Double spin box management
234 //=================================================================================
235 void EntityGUI_IsolineDlg::SetDoubleSpinBoxStep (double step)
237 myGroup->SpinBox_DX->setSingleStep(step);
240 //=================================================================================
241 // function : ClickOnOk()
243 //=================================================================================
244 void EntityGUI_IsolineDlg::ClickOnOk()
246 setIsApplyAndClose( true );
252 //=================================================================================
253 // function : ClickOnApply()
255 //=================================================================================
256 bool EntityGUI_IsolineDlg::ClickOnApply()
262 // activate selection and connect selection manager
263 myGroup->PushButton1->click();
267 //=================================================================================
268 // function : SetEditFace
270 //=================================================================================
271 void EntityGUI_IsolineDlg::SetEditFace()
273 myGroup->LineEdit1->setFocus();
274 myGroup->PushButton1->setDown(true);
277 //=================================================================================
278 // function : ValueChangedInSpinBox
280 //=================================================================================
281 void EntityGUI_IsolineDlg::ValueChangedInSpinBox(double /*newValue*/)
283 displayPreview(true);
286 //=================================================================================
287 // function : getSourceObjects
288 // purpose : virtual method to get source objects
289 //=================================================================================
290 QList<GEOM::GeomObjPtr> EntityGUI_IsolineDlg::getSourceObjects()
292 QList<GEOM::GeomObjPtr> res;