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