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 : GeometryGUI_FuseDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_FuseDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Desktop.h"
35 //=================================================================================
36 // class : GeometryGUI_FuseDlg()
37 // purpose : Constructs a GeometryGUI_FuseDlg which is a child of 'parent', with the
38 // name 'name' and widget flags set to 'f'.
39 // The dialog will by default be modeless, unless you set 'modal' to
40 // TRUE to construct a modal dialog.
41 //=================================================================================
42 GeometryGUI_FuseDlg::GeometryGUI_FuseDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
43 :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
45 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_FUSE")));
46 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
48 setCaption(tr("GEOM_FUSE_TITLE"));
50 /***************************************************************/
51 GroupConstructors->setTitle(tr("GEOM_FUSE"));
52 RadioButton1->setPixmap(image0);
53 RadioButton2->close(TRUE);
54 RadioButton3->close(TRUE);
56 GroupFuse = new GeometryGUI_2Sel_QTD(this, "GroupFuse");
57 GroupFuse->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
58 GroupFuse->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1"));
59 GroupFuse->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2"));
60 GroupFuse->PushButton1->setPixmap(image1);
61 GroupFuse->PushButton2->setPixmap(image1);
63 Layout1->addWidget(GroupFuse, 1, 0);
64 /***************************************************************/
71 //=================================================================================
72 // function : ~GeometryGUI_FuseDlg()
73 // purpose : Destroys the object and frees any allocated resources
74 //=================================================================================
75 GeometryGUI_FuseDlg::~GeometryGUI_FuseDlg()
77 /* no need to delete child widgets, Qt does it all for us */
81 //=================================================================================
84 //=================================================================================
85 void GeometryGUI_FuseDlg::Init(SALOME_Selection* Sel)
88 myEditCurrentArgument = GroupFuse->LineEdit1;
92 myOkShape1 = myOkShape2 = false;
94 /* signals and slots connections */
95 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
96 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
98 connect(GroupFuse->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
99 connect(GroupFuse->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
101 connect(GroupFuse->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
102 connect(GroupFuse->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
104 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument()));
106 /* displays Dialog */
114 //=================================================================================
115 // function : ClickOnOk()
117 //=================================================================================
118 void GeometryGUI_FuseDlg::ClickOnOk()
120 this->ClickOnApply();
126 //=================================================================================
127 // function : ClickOnApply()
129 //=================================================================================
130 void GeometryGUI_FuseDlg::ClickOnApply()
132 myGeomGUI->GetDesktop()->putInfo(tr(""));
134 if(myOkShape1 && myOkShape2)
135 myGeomGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 3);
141 //=================================================================================
142 // function : SelectionIntoArgument()
143 // purpose : Called when selection has changed
144 //=================================================================================
145 void GeometryGUI_FuseDlg::SelectionIntoArgument()
147 myEditCurrentArgument->setText("");
148 QString aString = "";
150 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString);
152 if(myEditCurrentArgument == GroupFuse->LineEdit1)
154 else if( myEditCurrentArgument == GroupFuse->LineEdit2)
161 Standard_Boolean testResult;
162 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
164 if(!myGeomGUI->GetTopoFromSelection(mySelection, S))
167 if(myEditCurrentArgument == GroupFuse->LineEdit1) {
168 myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult);
172 GroupFuse->LineEdit1->setText(aString);
175 else if(myEditCurrentArgument == GroupFuse->LineEdit2) {
176 myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult);
180 GroupFuse->LineEdit2->setText(aString);
187 //=================================================================================
188 // function : SetEditCurrentArgument()
190 //=================================================================================
191 void GeometryGUI_FuseDlg::SetEditCurrentArgument()
193 QPushButton* send = (QPushButton*)sender();
195 if(send == GroupFuse->PushButton1) {
196 GroupFuse->LineEdit1->setFocus();
197 myEditCurrentArgument = GroupFuse->LineEdit1;
199 else if(send == GroupFuse->PushButton2) {
200 GroupFuse->LineEdit2->setFocus();
201 myEditCurrentArgument = GroupFuse->LineEdit2;
203 SelectionIntoArgument();
209 //=================================================================================
210 // function : LineEditReturnPressed()
212 //=================================================================================
213 void GeometryGUI_FuseDlg::LineEditReturnPressed()
215 QLineEdit* send = (QLineEdit*)sender();
216 if(send == GroupFuse->LineEdit1)
217 myEditCurrentArgument = GroupFuse->LineEdit1;
218 else if(send == GroupFuse->LineEdit2)
219 myEditCurrentArgument = GroupFuse->LineEdit2;
223 GeometryGUI_Skeleton::LineEditReturnPressed();
228 //=================================================================================
229 // function : ActivateThisDialog()
231 //=================================================================================
232 void GeometryGUI_FuseDlg::ActivateThisDialog()
234 GeometryGUI_Skeleton::ActivateThisDialog();
235 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
240 //=================================================================================
241 // function : enterEvent()
242 // purpose : when mouse enter onto the QWidget
243 //=================================================================================
244 void GeometryGUI_FuseDlg::enterEvent(QEvent* e)
246 if (GroupConstructors->isEnabled())
248 this->ActivateThisDialog();