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_CommonDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "BooleanGUI_CommonDlg.h"
32 //=================================================================================
33 // class : BooleanGUI_CommonDlg()
34 // purpose : Constructs a BooleanGUI_CommonDlg 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_CommonDlg::BooleanGUI_CommonDlg(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_COMMON")));
43 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
45 setCaption(tr("GEOM_COMMON_TITLE"));
47 /***************************************************************/
48 GroupConstructors->setTitle(tr("GEOM_COMMON"));
49 RadioButton1->setPixmap(image0);
50 RadioButton2->close(TRUE);
51 RadioButton3->close(TRUE);
53 GroupCommon = new DlgRef_2Sel_QTD(this, "GroupCommon");
54 GroupCommon->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
55 GroupCommon->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1"));
56 GroupCommon->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2"));
57 GroupCommon->PushButton1->setPixmap(image1);
58 GroupCommon->PushButton2->setPixmap(image1);
60 Layout1->addWidget(GroupCommon, 1, 0);
61 /***************************************************************/
64 myBooleanGUI = theBooleanGUI;
69 //=================================================================================
70 // function : ~BooleanGUI_CommonDlg()
71 // purpose : Destroys the object and frees any allocated resources
72 //=================================================================================
73 BooleanGUI_CommonDlg::~BooleanGUI_CommonDlg()
75 /* no need to delete child widgets, Qt does it all for us */
80 //=================================================================================
83 //=================================================================================
84 void BooleanGUI_CommonDlg::Init()
87 myEditCurrentArgument = GroupCommon->LineEdit1;
88 myOkShape1 = myOkShape2 = false;
90 /* signals and slots connections */
91 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
92 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
94 connect(GroupCommon->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
95 connect(GroupCommon->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
97 connect(GroupCommon->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
98 connect(GroupCommon->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
100 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
102 /* displays Dialog */
110 //=================================================================================
111 // function : ClickOnOk()
113 //=================================================================================
114 void BooleanGUI_CommonDlg::ClickOnOk()
116 this->ClickOnApply();
122 //=================================================================================
123 // function : ClickOnApply()
125 //=================================================================================
126 void BooleanGUI_CommonDlg::ClickOnApply()
128 QAD_Application::getDesktop()->putInfo(tr(""));
130 if(myOkShape1 && myOkShape2)
131 myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 1);
137 //=================================================================================
138 // function : SelectionIntoArgument()
139 // purpose : Called when selection has changed
140 //=================================================================================
141 void BooleanGUI_CommonDlg::SelectionIntoArgument()
143 myEditCurrentArgument->setText("");
144 QString aString = "";
146 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
148 if(myEditCurrentArgument == GroupCommon->LineEdit1)
150 else if( myEditCurrentArgument == GroupCommon->LineEdit2)
157 Standard_Boolean testResult;
158 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
160 if(!myGeomBase->GetTopoFromSelection(mySelection, S))
163 if(myEditCurrentArgument == GroupCommon->LineEdit1) {
164 myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
167 GroupCommon->LineEdit1->setText(aString);
170 else if(myEditCurrentArgument == GroupCommon->LineEdit2) {
171 myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
174 GroupCommon->LineEdit2->setText(aString);
181 //=================================================================================
182 // function : SetEditCurrentArgument()
184 //=================================================================================
185 void BooleanGUI_CommonDlg::SetEditCurrentArgument()
187 QPushButton* send = (QPushButton*)sender();
189 if(send == GroupCommon->PushButton1) {
190 GroupCommon->LineEdit1->setFocus();
191 myEditCurrentArgument = GroupCommon->LineEdit1;
193 else if(send == GroupCommon->PushButton2) {
194 GroupCommon->LineEdit2->setFocus();
195 myEditCurrentArgument = GroupCommon->LineEdit2;
197 SelectionIntoArgument();
204 //=================================================================================
205 // function : LineEditReturnPressed()
207 //=================================================================================
208 void BooleanGUI_CommonDlg::LineEditReturnPressed()
210 QLineEdit* send = (QLineEdit*)sender();
211 if(send == GroupCommon->LineEdit1)
212 myEditCurrentArgument = GroupCommon->LineEdit1;
213 else if(send == GroupCommon->LineEdit2)
214 myEditCurrentArgument = GroupCommon->LineEdit2;
218 GEOMBase_Skeleton::LineEditReturnPressed();
223 //=================================================================================
224 // function : ActivateThisDialog()
226 //=================================================================================
227 void BooleanGUI_CommonDlg::ActivateThisDialog()
229 GEOMBase_Skeleton::ActivateThisDialog();
230 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
235 //=================================================================================
236 // function : enterEvent()
237 // purpose : when mouse enter onto the QWidget
238 //=================================================================================
239 void BooleanGUI_CommonDlg::enterEvent(QEvent * e)
241 if (GroupConstructors->isEnabled())
243 this->ActivateThisDialog();