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_ShellDlg.cxx
25 // Author : Damien COQUERET
30 #include "BuildGUI_ShellDlg.h"
33 #include "QAD_Desktop.h"
35 //=================================================================================
36 // class : BuildGUI_ShellDlg()
37 // purpose : Constructs a BuildGUI_ShellDlg 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 BuildGUI_ShellDlg::BuildGUI_ShellDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
43 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
45 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SHELL")));
46 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT")));
48 setCaption(tr("GEOM_SHELL_TITLE"));
50 /***************************************************************/
51 GroupConstructors->setTitle(tr("GEOM_SHELL"));
52 RadioButton1->setPixmap(image0);
53 RadioButton2->close(TRUE);
54 RadioButton3->close(TRUE);
56 GroupShell = new DlgRef_1Sel_QTD(this, "GroupShell");
57 GroupShell->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
58 GroupShell->TextLabel1->setText(tr("GEOM_OBJECTS"));
59 GroupShell->PushButton1->setPixmap(image1);
61 Layout1->addWidget(GroupShell, 1, 0);
62 /***************************************************************/
65 myBuildGUI = theBuildGUI;
70 //=================================================================================
71 // function : ~BuildGUI_ShellDlg()
72 // purpose : Destroys the object and frees any allocated resources
73 //=================================================================================
74 BuildGUI_ShellDlg::~BuildGUI_ShellDlg()
76 // no need to delete child widgets, Qt does it all for us
80 //=================================================================================
83 //=================================================================================
84 void BuildGUI_ShellDlg::Init()
87 myEditCurrentArgument = GroupShell->LineEdit1;
88 myOkListShapes = false;
90 myFaceFilter = new GEOM_ShapeTypeFilter(TopAbs_FACE, myGeom);
91 /* Filter for the next selection */
92 mySelection->AddFilter(myFaceFilter) ;
94 /* signals and slots connections */
95 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
96 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
98 connect(GroupShell->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
100 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
102 /* displays Dialog */
110 //=================================================================================
111 // function : ClickOnOk()
113 //=================================================================================
114 void BuildGUI_ShellDlg::ClickOnOk()
116 this->ClickOnApply();
122 //=================================================================================
123 // function : ClickOnApply()
125 //=================================================================================
126 void BuildGUI_ShellDlg::ClickOnApply()
128 QAD_Application::getDesktop()->putInfo(tr(""));
131 myBuildGUI->MakeShellAndDisplay(myListShapes);
136 //=================================================================================
137 // function : SelectionIntoArgument()
138 // purpose : Called when selection as changed or other case
139 //=================================================================================
140 void BuildGUI_ShellDlg::SelectionIntoArgument()
142 myEditCurrentArgument->setText("");
143 QString aString = "";
145 myOkListShapes = false;
146 int nbSel = mySelection->IObjectCount();
150 aString = tr("%1_objects").arg(nbSel);
152 myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
153 myEditCurrentArgument->setText(aString);
154 myOkListShapes = true;
160 //=================================================================================
161 // function : SetEditCurrentArgument()
163 //=================================================================================
164 void BuildGUI_ShellDlg::SetEditCurrentArgument()
166 mySelection->ClearFilters();
167 GroupShell->LineEdit1->setFocus();
168 mySelection->AddFilter(myFaceFilter);
169 this->SelectionIntoArgument();
174 //=================================================================================
175 // function : ActivateThisDialog()
177 //=================================================================================
178 void BuildGUI_ShellDlg::ActivateThisDialog()
180 GEOMBase_Skeleton::ActivateThisDialog();
181 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
182 mySelection->AddFilter(myFaceFilter);
187 //=================================================================================
188 // function : enterEvent()
190 //=================================================================================
191 void BuildGUI_ShellDlg::enterEvent(QEvent* e)
193 if(GroupConstructors->isEnabled())
195 this->ActivateThisDialog();