1 // Copyright (C) 2007-2015 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>
34 //=================================================================================
35 // class : EntityGUI_IsolineDlg
37 //=================================================================================
38 EntityGUI_IsolineDlg::EntityGUI_IsolineDlg (GeometryGUI *theGeometryGUI,
42 : GEOMBase_Skeleton (theGeometryGUI, parent, modal, fl),
45 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_ISOLINE")));
46 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
47 QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_ISOLINE_V")));
49 setWindowTitle(tr("GEOM_ISOLINE_TITLE"));
51 /***************************************************************/
53 mainFrame()->GroupConstructors->setTitle(tr("GEOM_ISOLINE"));
54 mainFrame()->RadioButton1->setIcon(image0);
55 mainFrame()->RadioButton2->close();
56 mainFrame()->RadioButton3->close();
59 myGroup = new DlgRef_3Radio1Sel1Spin(centralWidget());
60 myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
61 myGroup->TextLabel1->setText(tr("GEOM_FACE"));
62 myGroup->PushButton1->setIcon(image1);
63 myGroup->LineEdit1->setReadOnly(true);
64 myGroup->RadioButton1->setIcon(image0);
65 myGroup->RadioButton2->setIcon(image2);
66 myGroup->RadioButton1->setText(tr("GEOM_ISOLINE_U"));
67 myGroup->RadioButton2->setText(tr("GEOM_ISOLINE_V"));
68 myGroup->RadioButton3->hide();
69 myGroup->TextLabel2->setText(tr("GEOM_PARAMETER"));
71 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
72 layout->setMargin(0); layout->setSpacing(6);
73 layout->addWidget(myGroup);
75 myRBGroup = new QButtonGroup( this );
76 myRBGroup->addButton( myGroup->RadioButton1, 0 );
77 myRBGroup->addButton( myGroup->RadioButton2, 1 );
79 setHelpFileName("create_isoline_page.html");
84 //=================================================================================
85 // function : ~EntityGUI_IsolineDlg()
87 //=================================================================================
88 EntityGUI_IsolineDlg::~EntityGUI_IsolineDlg()
92 //=================================================================================
95 //=================================================================================
96 void EntityGUI_IsolineDlg::Init()
98 /* min, max, step and decimals for spin box */
99 initSpinBox(myGroup->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
100 myGroup->SpinBox_DX->setValue(0.5);
101 myGroup->RadioButton1->setChecked(true);
103 initName(mainFrame()->GroupConstructors->title());
105 connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditFace()));
106 connect(myGroup->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
108 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
109 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
110 this, SLOT(SelectionIntoArgument()));
112 /* signals and slots connections */
113 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
114 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
115 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
116 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
117 connect(myRBGroup, SIGNAL(buttonClicked(int)), this, SLOT(TypeChanged(int)));
119 myGroup->PushButton1->click();
120 SelectionIntoArgument();
124 //=================================================================================
125 // function : SelectionIntoArgument
126 // purpose : Called when selection is changed
127 //=================================================================================
128 void EntityGUI_IsolineDlg::SelectionIntoArgument()
130 myGroup->LineEdit1->setText("");
133 GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_SHAPE );
136 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
137 if (aShape.ShapeType() == TopAbs_FACE) {
138 QString aName = GEOMBase::GetName( aSelectedObject.get() );
139 myGroup->LineEdit1->setText( aName );
142 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
143 myGeomGUI->getApp()->selectionMgr()->clearSelected();
144 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
145 this, SLOT(SelectionIntoArgument()));
147 myFace = aSelectedObject;
151 displayPreview(true);
154 //=================================================================================
155 // function : ActivateThisDialog
157 //=================================================================================
158 void EntityGUI_IsolineDlg::ActivateThisDialog()
160 GEOMBase_Skeleton::ActivateThisDialog();
162 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
163 this, SLOT( SelectionIntoArgument() ) );
165 SelectionIntoArgument();
168 //=================================================================================
169 // function : enterEvent()
171 //=================================================================================
172 void EntityGUI_IsolineDlg::enterEvent (QEvent*)
174 if (!mainFrame()->GroupConstructors->isEnabled())
175 ActivateThisDialog();
178 //=================================================================================
179 // function : TypeChanged
181 //=================================================================================
182 void EntityGUI_IsolineDlg::TypeChanged(int)
184 displayPreview(true);
187 //=================================================================================
188 // function : createOperation
190 //=================================================================================
191 GEOM::GEOM_IOperations_ptr EntityGUI_IsolineDlg::createOperation()
193 return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
196 //=================================================================================
197 // function : isValid
199 //=================================================================================
200 bool EntityGUI_IsolineDlg::isValid (QString& msg)
205 //=================================================================================
206 // function : execute
208 //=================================================================================
209 bool EntityGUI_IsolineDlg::execute (ObjectList& objects)
211 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
212 GEOM::GEOM_Object_var anObj = anOper->MakeIsoline
213 (myFace.get(), myGroup->RadioButton1->isChecked(), myGroup->SpinBox_DX->value());
215 if (!anObj->_is_nil())
216 objects.push_back(anObj._retn());
221 //=================================================================================
222 // function : addSubshapesToStudy()
223 // purpose : Double spin box management
224 //=================================================================================
225 void EntityGUI_IsolineDlg::addSubshapesToStudy()
227 GEOMBase::PublishSubObject(myFace.get());
230 //=================================================================================
231 // function : SetDoubleSpinBoxStep()
232 // purpose : Double spin box management
233 //=================================================================================
234 void EntityGUI_IsolineDlg::SetDoubleSpinBoxStep (double step)
236 myGroup->SpinBox_DX->setSingleStep(step);
239 //=================================================================================
240 // function : ClickOnOk()
242 //=================================================================================
243 void EntityGUI_IsolineDlg::ClickOnOk()
245 setIsApplyAndClose( true );
251 //=================================================================================
252 // function : ClickOnApply()
254 //=================================================================================
255 bool EntityGUI_IsolineDlg::ClickOnApply()
261 // activate selection and connect selection manager
262 myGroup->PushButton1->click();
266 //=================================================================================
267 // function : SetEditFace
269 //=================================================================================
270 void EntityGUI_IsolineDlg::SetEditFace()
272 myGroup->LineEdit1->setFocus();
273 myGroup->PushButton1->setDown(true);
276 //=================================================================================
277 // function : ValueChangedInSpinBox
279 //=================================================================================
280 void EntityGUI_IsolineDlg::ValueChangedInSpinBox(double newValue)
282 displayPreview(true);