1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : OperationGUI_PartitionDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "OperationGUI_PartitionDlg.h"
32 //=================================================================================
33 // class : OperationGUI_PartitionDlg()
34 // purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the
35 // name 'name' and widget flags set to 'f'.
36 // The dialog will by default be modeless, unless you set 'modal' to
37 // TRUE to construct a modal dialog.
38 //=================================================================================
39 OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
40 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
42 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PARTITION")));
43 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
45 setCaption(tr("GEOM_PARTITION_TITLE"));
47 /***************************************************************/
48 GroupConstructors->setTitle(tr("GEOM_PARTITION"));
49 RadioButton1->setPixmap(image0);
50 RadioButton2->close(TRUE);
51 RadioButton3->close(TRUE);
53 GroupPoints = new DlgRef_4Sel1List_QTD(this, "GroupPoints");
54 GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION"));
55 GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
56 GroupPoints->TextLabel2->setText(tr("GEOM_TOOL_OBJECT"));
57 GroupPoints->TextLabel3->setText(tr("GEOM_RECONSTRUCTION_LIMIT"));
58 GroupPoints->TextLabel4->setText(tr("GEOM_SUPPRESS_RESULT_INSIDE"));
59 GroupPoints->TextLabel5->setText(tr("GEOM_SUPPRESS_RESULT_OUTSIDE"));
60 GroupPoints->PushButton1->setPixmap(image1);
61 GroupPoints->PushButton2->setPixmap(image1);
62 GroupPoints->PushButton3->setPixmap(image1);
63 GroupPoints->PushButton4->setPixmap(image1);
65 Layout1->addWidget(GroupPoints, 1, 0);
66 /***************************************************************/
69 myOperationGUI = theOperationGUI;
74 //=================================================================================
75 // function : ~OperationGUI_PartitionDlg()
76 // purpose : Destroys the object and frees any allocated resources
77 //=================================================================================
78 OperationGUI_PartitionDlg::~OperationGUI_PartitionDlg()
80 // no need to delete child widgets, Qt does it all for us
84 //=================================================================================
87 //=================================================================================
88 void OperationGUI_PartitionDlg::Init()
91 myEditCurrentArgument = GroupPoints->LineEdit1;
93 myOkListShapes = myOkListTools = myOkKeepShape = myOkRemoveShape = false;
95 /* type for sub shape selection */
96 GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SOLID"));
97 GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SHELL"));
98 GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_FACE"));
99 GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE"));
100 GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE"));
101 GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX"));
103 /* Current item is 'Shape' */
104 GroupPoints->ComboBox1->setCurrentItem(0);
105 myLimit = GroupPoints->ComboBox1->currentItem();
107 /* signals and slots connections */
108 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
109 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
111 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
112 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
113 connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
114 connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
116 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
117 connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
118 connect(GroupPoints->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
119 connect(GroupPoints->LineEdit4, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
121 connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
123 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
125 /* displays Dialog */
133 //=================================================================================
134 // function : ClickOnOk()
136 //=================================================================================
137 void OperationGUI_PartitionDlg::ClickOnOk()
139 this->ClickOnApply();
145 //=================================================================================
146 // function : ClickOnApply()
148 //=================================================================================
149 void OperationGUI_PartitionDlg::ClickOnApply()
151 QAD_Application::getDesktop()->putInfo(tr(""));
153 if(myOkListShapes || myOkListTools || myOkKeepShape || myOkRemoveShape) {
154 GEOM::shape_type limit;
184 limit = GEOM::VERTEX;
191 myOperationGUI->MakePartitionAndDisplay(myListShapes, myListTools, myListKeepInside, myListRemoveInside, limit);
197 //=================================================================================
198 // function : SelectionIntoArgument()
199 // purpose : Called when selection as changed or other case
200 //=================================================================================
201 void OperationGUI_PartitionDlg::SelectionIntoArgument()
203 myEditCurrentArgument->setText("");
204 QString aString = ""; /* name of selection */
206 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
208 if(myEditCurrentArgument == GroupPoints->LineEdit1)
209 myOkListShapes = false;
210 else if(myEditCurrentArgument == GroupPoints->LineEdit2)
211 myOkListTools = false;
212 else if(myEditCurrentArgument == GroupPoints->LineEdit3)
213 myOkKeepShape = false;
214 else if(myEditCurrentArgument == GroupPoints->LineEdit4)
215 myOkRemoveShape = false;
219 if(myEditCurrentArgument == GroupPoints->LineEdit1) {
220 myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
221 myEditCurrentArgument->setText(aString);
222 myOkListShapes = true;
224 else if(myEditCurrentArgument == GroupPoints->LineEdit2) {
225 myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListTools);
226 myEditCurrentArgument->setText(aString);
227 myOkListTools = true;
229 else if(myEditCurrentArgument == GroupPoints->LineEdit3) {
230 myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListRemoveInside);
231 myEditCurrentArgument->setText(aString);
232 myOkKeepShape = true;
234 else if(myEditCurrentArgument == GroupPoints->LineEdit4) {
235 myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListKeepInside);
236 myEditCurrentArgument->setText(aString);
237 myOkRemoveShape = true;
245 //=================================================================================
246 // function : SetEditCurrentArgument()
248 //=================================================================================
249 void OperationGUI_PartitionDlg::SetEditCurrentArgument()
251 QPushButton* send = (QPushButton*)sender();
253 if(send == GroupPoints->PushButton1) {
254 GroupPoints->LineEdit1->setFocus();
255 myEditCurrentArgument = GroupPoints->LineEdit1;
257 else if(send == GroupPoints->PushButton2) {
258 GroupPoints->LineEdit2->setFocus();
259 myEditCurrentArgument = GroupPoints->LineEdit2;
261 else if(send == GroupPoints->PushButton3) {
262 GroupPoints->LineEdit3->setFocus();
263 myEditCurrentArgument = GroupPoints->LineEdit3;
265 else if(send == GroupPoints->PushButton4) {
266 GroupPoints->LineEdit4->setFocus();
267 myEditCurrentArgument = GroupPoints->LineEdit4;
269 this->SelectionIntoArgument();
275 //=================================================================================
276 // function : LineEditReturnPressed()
278 //=================================================================================
279 void OperationGUI_PartitionDlg::LineEditReturnPressed()
281 QLineEdit* send = (QLineEdit*)sender();
282 if(send == GroupPoints->LineEdit1)
283 myEditCurrentArgument = GroupPoints->LineEdit1;
284 else if (send == GroupPoints->LineEdit2)
285 myEditCurrentArgument = GroupPoints->LineEdit2;
286 else if (send == GroupPoints->LineEdit3)
287 myEditCurrentArgument = GroupPoints->LineEdit3;
288 else if (send == GroupPoints->LineEdit4)
289 myEditCurrentArgument = GroupPoints->LineEdit4;
293 GEOMBase_Skeleton::LineEditReturnPressed();
298 //=================================================================================
299 // function : ActivateThisDialog()
301 //=================================================================================
302 void OperationGUI_PartitionDlg::ActivateThisDialog()
304 GEOMBase_Skeleton::ActivateThisDialog();
305 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
310 //=================================================================================
311 // function : enterEvent()
313 //=================================================================================
314 void OperationGUI_PartitionDlg::enterEvent(QEvent* e)
316 if(GroupConstructors->isEnabled())
318 this->ActivateThisDialog();
323 //=======================================================================
324 //function : ComboTextChanged
326 //=======================================================================
328 void OperationGUI_PartitionDlg::ComboTextChanged()
330 myLimit = GroupPoints->ComboBox1->currentItem();
332 bool IsEnabled = GroupPoints->ComboBox1->currentItem() < 3;
333 GroupPoints->LineEdit3->setEnabled(IsEnabled);
334 GroupPoints->LineEdit4->setEnabled(IsEnabled);
335 GroupPoints->TextLabel4->setEnabled(IsEnabled);
336 GroupPoints->TextLabel5->setEnabled(IsEnabled);
337 GroupPoints->PushButton3->setEnabled(IsEnabled);
338 GroupPoints->PushButton4->setEnabled(IsEnabled);