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 : BooleanGUI_CutDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "BooleanGUI_CutDlg.h"
32 //=================================================================================
33 // class : BooleanGUI_CutDlg()
34 // purpose : Constructs a BooleanGUI_CutDlg 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 BooleanGUI_CutDlg::BooleanGUI_CutDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_CUT")));
43 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
45 setCaption(tr("GEOM_CUT_TITLE"));
47 /***************************************************************/
48 GroupConstructors->setTitle(tr("GEOM_CUT"));
49 RadioButton1->setPixmap(image0);
50 RadioButton2->close(TRUE);
51 RadioButton3->close(TRUE);
53 GroupCut = new DlgRef_2Sel_QTD(this, "GroupCut");
54 GroupCut->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
55 GroupCut->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1"));
56 GroupCut->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2"));
57 GroupCut->PushButton1->setPixmap(image1);
58 GroupCut->PushButton2->setPixmap(image1);
60 Layout1->addWidget(GroupCut, 1, 0);
61 /***************************************************************/
64 myBooleanGUI = theBooleanGUI;
69 //=================================================================================
70 // function : ~BooleanGUI_CutDlg()
71 // purpose : Destroys the object and frees any allocated resources
72 //=================================================================================
73 BooleanGUI_CutDlg::~BooleanGUI_CutDlg()
75 /* no need to delete child widgets, Qt does it all for us */
79 //=================================================================================
82 //=================================================================================
83 void BooleanGUI_CutDlg::Init()
86 myEditCurrentArgument = GroupCut->LineEdit1;
87 myOkShape1 = myOkShape2 = false;
89 /* signals and slots connections */
90 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
91 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
93 connect(GroupCut->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
94 connect(GroupCut->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
96 connect(GroupCut->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
97 connect(GroupCut->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
99 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
101 /* displays Dialog */
109 //=================================================================================
110 // function : ClickOnOk()
112 //=================================================================================
113 void BooleanGUI_CutDlg::ClickOnOk()
115 this->ClickOnApply();
121 //=================================================================================
122 // function : ClickOnApply()
124 //=================================================================================
125 void BooleanGUI_CutDlg::ClickOnApply()
127 QAD_Application::getDesktop()->putInfo(tr(""));
129 if(myOkShape1 && myOkShape2)
130 myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 2);
136 //=================================================================================
137 // function : SelectionIntoArgument()
138 // purpose : Called when selection has changed
139 //=================================================================================
140 void BooleanGUI_CutDlg::SelectionIntoArgument()
142 myEditCurrentArgument->setText("");
143 QString aString = "";
145 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
147 if(myEditCurrentArgument == GroupCut->LineEdit1)
149 else if( myEditCurrentArgument == GroupCut->LineEdit2)
156 Standard_Boolean testResult;
157 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
159 if(!myGeomBase->GetTopoFromSelection(mySelection, S))
162 if(myEditCurrentArgument == GroupCut->LineEdit1) {
163 myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
166 GroupCut->LineEdit1->setText(aString);
169 else if(myEditCurrentArgument == GroupCut->LineEdit2) {
170 myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
173 GroupCut->LineEdit2->setText(aString);
180 //=================================================================================
181 // function : SetEditCurrentArgument()
183 //=================================================================================
184 void BooleanGUI_CutDlg::SetEditCurrentArgument()
186 QPushButton* send = (QPushButton*)sender();
188 if(send == GroupCut->PushButton1) {
189 GroupCut->LineEdit1->setFocus();
190 myEditCurrentArgument = GroupCut->LineEdit1;
192 else if(send == GroupCut->PushButton2) {
193 GroupCut->LineEdit2->setFocus();
194 myEditCurrentArgument = GroupCut->LineEdit2;
196 SelectionIntoArgument();
202 //=================================================================================
203 // function : LineEditReturnPressed()
205 //=================================================================================
206 void BooleanGUI_CutDlg::LineEditReturnPressed()
208 QLineEdit* send = (QLineEdit*)sender();
209 if(send == GroupCut->LineEdit1)
210 myEditCurrentArgument = GroupCut->LineEdit1;
211 else if(send == GroupCut->LineEdit2)
212 myEditCurrentArgument = GroupCut->LineEdit2;
216 GEOMBase_Skeleton::LineEditReturnPressed();
221 //=================================================================================
222 // function : ActivateThisDialog()
224 //=================================================================================
225 void BooleanGUI_CutDlg::ActivateThisDialog()
227 GEOMBase_Skeleton::ActivateThisDialog();
228 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
233 //=================================================================================
234 // function : enterEvent()
235 // purpose : when mouse enter onto the QWidget
236 //=================================================================================
237 void BooleanGUI_CutDlg::enterEvent(QEvent * e)
239 if(GroupConstructors->isEnabled())
241 this->ActivateThisDialog();