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 : BuildGUI_FaceDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "BuildGUI_FaceDlg.h"
32 //=================================================================================
33 // class : BuildGUI_FaceDlg()
34 // purpose : Constructs a BuildGUI_FaceDlg 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 BuildGUI_FaceDlg::BuildGUI_FaceDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, 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_BUILD_FACE")));
43 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
45 setCaption(tr("GEOM_FACE_TITLE"));
47 /***************************************************************/
48 GroupConstructors->setTitle(tr("GEOM_FACE"));
49 RadioButton1->setPixmap(image0);
50 RadioButton2->close(TRUE);
51 RadioButton3->close(TRUE);
53 GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints");
54 GroupPoints->GroupBox1->setTitle(tr("GEOM_FACE_FFW"));
55 GroupPoints->TextLabel1->setText(tr("GEOM_WIRES"));
56 GroupPoints->CheckButton1->setText(tr("GEOM_FACE_OPT"));
57 GroupPoints->PushButton1->setPixmap(image1);
59 Layout1->addWidget(GroupPoints, 1, 0);
60 /***************************************************************/
63 myBuildGUI = theBuildGUI;
68 //=================================================================================
69 // function : ~BuildGUI_FaceDlg()
70 // purpose : Destroys the object and frees any allocated resources
71 //=================================================================================
72 BuildGUI_FaceDlg::~BuildGUI_FaceDlg()
74 // no need to delete child widgets, Qt does it all for us
78 //=================================================================================
81 //=================================================================================
82 void BuildGUI_FaceDlg::Init()
85 myEditCurrentArgument = GroupPoints->LineEdit1;
86 GroupPoints->CheckButton1->setChecked(TRUE);
88 myOkListShapes = false;
90 myWireFilter = new GEOM_ShapeTypeFilter(TopAbs_WIRE, myGeom);
91 mySelection->AddFilter(myWireFilter); /* first filter used */
93 /* signals and slots connections */
94 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
95 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
96 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
97 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
98 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
100 /* displays Dialog */
108 //=================================================================================
109 // function : ClickOnOk()
111 //=================================================================================
112 void BuildGUI_FaceDlg::ClickOnOk()
114 this->ClickOnApply();
120 //=================================================================================
121 // function : ClickOnApply()
123 //=================================================================================
124 void BuildGUI_FaceDlg::ClickOnApply()
126 QAD_Application::getDesktop()->putInfo(tr(""));
128 myBuildGUI->MakeFaceAndDisplay(myListShapes, GroupPoints->CheckButton1->isChecked());
133 //=================================================================================
134 // function : SelectionIntoArgument()
135 // purpose : Called when selection as changed or other case
136 //=================================================================================
137 void BuildGUI_FaceDlg::SelectionIntoArgument()
139 myEditCurrentArgument->setText("");
140 QString aString = ""; /* name of selection */
142 myOkListShapes = false;
143 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
147 aString = tr("%1_objects").arg(nbSel);
149 myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
151 myEditCurrentArgument->setText(aString);
152 myOkListShapes = true;
158 //=================================================================================
159 // function : SetEditCurrentArgument()
161 //=================================================================================
162 void BuildGUI_FaceDlg::SetEditCurrentArgument()
164 GroupPoints->LineEdit1->setFocus();
165 mySelection->ClearFilters();
166 mySelection->AddFilter(myWireFilter);
167 this->SelectionIntoArgument();
172 //=================================================================================
173 // function : ActivateThisDialog()
175 //=================================================================================
176 void BuildGUI_FaceDlg::ActivateThisDialog()
178 GEOMBase_Skeleton::ActivateThisDialog();
179 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
180 mySelection->AddFilter(myWireFilter);
185 //=================================================================================
186 // function : enterEvent()
188 //=================================================================================
189 void BuildGUI_FaceDlg::enterEvent(QEvent* e)
191 if (GroupConstructors->isEnabled())
193 this->ActivateThisDialog();