1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : MeasureGUI_GetNonBlocksDlg.cxx
26 #include "MeasureGUI_GetNonBlocksDlg.h"
31 #include <GeometryGUI.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
37 #include <SalomeApp_Tools.h>
39 //=================================================================================
40 // class : MeasureGUI_GetNonBlocksDlg()
41 // purpose : Constructs a MeasureGUI_GetNonBlocksDlg which is a child of 'parent',
42 // with the name 'name' and widget flags set to 'f'.
43 // The dialog will by default be modeless, unless you set 'modal' to
44 // true to construct a modal dialog.
45 //=================================================================================
46 MeasureGUI_GetNonBlocksDlg::MeasureGUI_GetNonBlocksDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
47 : GEOMBase_Skeleton(theGeometryGUI, parent, false)
49 QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GETNONBLOCKS")));
50 QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
52 setWindowTitle(tr("GEOM_GETNONBLOCKS_TITLE"));
54 /***************************************************************/
55 mainFrame()->GroupConstructors->setTitle(tr("GEOM_GETNONBLOCKS"));
56 mainFrame()->RadioButton1->setIcon(image0);
57 mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
58 mainFrame()->RadioButton2->close();
59 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
60 mainFrame()->RadioButton3->close();
62 myGrp = new DlgRef_1Sel (centralWidget());
63 myGrp->GroupBox1->setTitle(tr("GEOM_GETNONBLOCKS"));
64 myGrp->TextLabel1->setText(tr("GEOM_OBJECT"));
65 myGrp->PushButton1->setIcon(image1);
66 myGrp->LineEdit1->setReadOnly(true);
68 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
69 layout->setMargin(0); layout->setSpacing(6);
70 layout->addWidget(myGrp);
72 /***************************************************************/
74 myHelpFileName = "get_non_blocks_page.html";
80 //=================================================================================
81 // function : ~MeasureGUI_GetNonBlocksDlg()
82 // purpose : Destroys the object and frees any allocated resources
83 //=================================================================================
84 MeasureGUI_GetNonBlocksDlg::~MeasureGUI_GetNonBlocksDlg()
88 //=================================================================================
91 //=================================================================================
92 void MeasureGUI_GetNonBlocksDlg::Init()
94 showOnlyPreviewControl();
97 myEditCurrentArgument = myGrp->LineEdit1;
99 /* signals and slots connections */
100 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
101 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
103 connect(myGrp->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
104 connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
106 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
107 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
109 //initName(tr("GEOM_NONBLOCKS"));
110 mainFrame()->ResultName->setText(tr("GEOM_NONBLOCKS"));
112 SelectionIntoArgument();
115 //=================================================================================
116 // function : ClickOnOk()
118 //=================================================================================
119 void MeasureGUI_GetNonBlocksDlg::ClickOnOk()
125 //=================================================================================
126 // function : ClickOnApply()
128 //=================================================================================
129 bool MeasureGUI_GetNonBlocksDlg::ClickOnApply()
138 //=================================================================================
139 // function : SelectionIntoArgument()
140 // purpose : Called when selection as changed or other case
141 //=================================================================================
142 void MeasureGUI_GetNonBlocksDlg::SelectionIntoArgument()
145 myObj = GEOM::GEOM_Object::_nil();
147 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
148 SALOME_ListIO aSelList;
149 aSelMgr->selectedObjects(aSelList);
151 if (aSelList.Extent() != 1) {
156 GEOM::GEOM_Object_var aSelectedObject =
157 GEOMBase::ConvertIOinGEOMObject(aSelList.First());
159 if (aSelectedObject->_is_nil()) {
164 myObj = aSelectedObject;
168 //=================================================================================
169 // function : SetEditCurrentArgument()
171 //=================================================================================
172 void MeasureGUI_GetNonBlocksDlg::SetEditCurrentArgument()
174 myGrp->LineEdit1->setFocus();
175 myEditCurrentArgument = myGrp->LineEdit1;
176 SelectionIntoArgument();
179 //=================================================================================
180 // function : LineEditReturnPressed()
182 //=================================================================================
183 void MeasureGUI_GetNonBlocksDlg::LineEditReturnPressed()
185 QLineEdit* send = (QLineEdit*)sender();
186 if (send == myGrp->LineEdit1) {
187 myEditCurrentArgument = myGrp->LineEdit1;
188 GEOMBase_Skeleton::LineEditReturnPressed();
192 //=================================================================================
193 // function : ActivateThisDialog()
195 //=================================================================================
196 void MeasureGUI_GetNonBlocksDlg::ActivateThisDialog()
198 GEOMBase_Skeleton::ActivateThisDialog();
200 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
201 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
207 //=================================================================================
208 // function : processObject()
209 // purpose : Fill dialog fields in accordance with myObj
210 //=================================================================================
211 void MeasureGUI_GetNonBlocksDlg::processObject()
213 if (myObj->_is_nil()) {
217 myGrp->LineEdit1->setText(GEOMBase::GetName(myObj));
223 //=================================================================================
224 // function : enterEvent()
226 //=================================================================================
227 void MeasureGUI_GetNonBlocksDlg::enterEvent (QEvent*)
229 if (!mainFrame()->GroupConstructors->isEnabled())
230 ActivateThisDialog();
233 //=================================================================================
234 // function : createOperation
236 //=================================================================================
237 GEOM::GEOM_IOperations_ptr MeasureGUI_GetNonBlocksDlg::createOperation()
239 return getGeomEngine()->GetIBlocksOperations(getStudyId());
242 //=================================================================================
243 // function : isValid
245 //=================================================================================
246 bool MeasureGUI_GetNonBlocksDlg::isValid (QString&)
248 return !myObj->_is_nil();
251 //=================================================================================
252 // function : execute
254 //=================================================================================
255 bool MeasureGUI_GetNonBlocksDlg::execute (ObjectList& objects)
257 GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation());
258 GEOM::GEOM_Object_var aNonQuads;
259 GEOM::GEOM_Object_var anObj = anOper->GetNonBlocks(myObj, aNonQuads);
260 //mainFrame()->ResultName->setText(tr("GEOM_NONBLOCKS"));
262 if (!anObj->_is_nil())
263 objects.push_back(anObj._retn());
264 if (!aNonQuads->_is_nil())
265 objects.push_back(aNonQuads._retn());
270 //================================================================
271 // Function : getFather
272 // Purpose : Get father object for object to be added in study
273 // ( called with addInStudy method )
274 //================================================================
275 GEOM::GEOM_Object_ptr MeasureGUI_GetNonBlocksDlg::getFather (GEOM::GEOM_Object_ptr)