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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : BuildGUI_ShellDlg.cxx
25 // Author : Damien COQUERET
29 #include "BuildGUI_ShellDlg.h"
30 #include "GEOMImpl_Types.hxx"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
36 #include "TColStd_MapOfInteger.hxx"
40 //=================================================================================
41 // class : BuildGUI_ShellDlg()
42 // purpose : Constructs a BuildGUI_ShellDlg which is a child of 'parent', with the
43 // name 'name' and widget flags set to 'f'.
44 // The dialog will by default be modeless, unless you set 'modal' to
45 // TRUE to construct a modal dialog.
46 //=================================================================================
47 BuildGUI_ShellDlg::BuildGUI_ShellDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
48 const char* name, bool modal, WFlags fl)
49 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
50 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
52 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SHELL")));
53 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
55 setCaption(tr("GEOM_SHELL_TITLE"));
57 /***************************************************************/
58 GroupConstructors->setTitle(tr("GEOM_SHELL"));
59 RadioButton1->setPixmap(image0);
60 RadioButton2->close(TRUE);
61 RadioButton3->close(TRUE);
63 GroupShell = new DlgRef_1Sel_QTD(this, "GroupShell");
64 GroupShell->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
65 GroupShell->TextLabel1->setText(tr("GEOM_OBJECTS"));
66 GroupShell->PushButton1->setPixmap(image1);
67 GroupShell->LineEdit1->setReadOnly( true );
69 Layout1->addWidget(GroupShell, 2, 0);
70 /***************************************************************/
72 setHelpFileName("shell.htm");
79 //=================================================================================
80 // function : ~BuildGUI_ShellDlg()
81 // purpose : Destroys the object and frees any allocated resources
82 //=================================================================================
83 BuildGUI_ShellDlg::~BuildGUI_ShellDlg()
85 // no need to delete child widgets, Qt does it all for us
89 //=================================================================================
92 //=================================================================================
93 void BuildGUI_ShellDlg::Init()
96 myEditCurrentArgument = GroupShell->LineEdit1;
97 GroupShell->LineEdit1->setReadOnly( true );
99 myOkFacesAndShells = false;
101 TColStd_MapOfInteger aMap;
102 aMap.Add(GEOM_SHELL);
104 globalSelection( aMap );
106 /* signals and slots connections */
107 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
108 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
110 connect(GroupShell->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
112 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
113 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
115 initName(tr("GEOM_SHELL"));
119 //=================================================================================
120 // function : ClickOnOk()
122 //=================================================================================
123 void BuildGUI_ShellDlg::ClickOnOk()
125 if ( ClickOnApply() )
130 //=================================================================================
131 // function : ClickOnApply()
133 //=================================================================================
134 bool BuildGUI_ShellDlg::ClickOnApply()
144 //=================================================================================
145 // function : SelectionIntoArgument()
146 // purpose : Called when selection as changed or other case
147 //=================================================================================
148 void BuildGUI_ShellDlg::SelectionIntoArgument()
150 myEditCurrentArgument->setText( "" );
153 myOkFacesAndShells = false;
154 int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true );
158 aString = QString( "%1_objects ").arg( nbSel );
160 GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myFacesAndShells, true );
161 if ( !myFacesAndShells.length() )
164 myEditCurrentArgument->setText( aString );
165 myOkFacesAndShells = true;
169 //=================================================================================
170 // function : SetEditCurrentArgument()
172 //=================================================================================
173 void BuildGUI_ShellDlg::SetEditCurrentArgument()
175 QPushButton* send = (QPushButton*)sender();
176 if (send != GroupShell->PushButton1)
179 TColStd_MapOfInteger aMap;
180 aMap.Add(GEOM_SHELL);
182 globalSelection( aMap );
183 myEditCurrentArgument = GroupShell->LineEdit1;
185 myEditCurrentArgument->setFocus();
186 SelectionIntoArgument();
190 //=================================================================================
191 // function : ActivateThisDialog()
193 //=================================================================================
194 void BuildGUI_ShellDlg::ActivateThisDialog()
196 GEOMBase_Skeleton::ActivateThisDialog();
197 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
198 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
199 TColStd_MapOfInteger aMap;
200 aMap.Add(GEOM_SHELL);
202 globalSelection( aMap );
206 //=================================================================================
207 // function : enterEvent()
209 //=================================================================================
210 void BuildGUI_ShellDlg::enterEvent(QEvent* e)
212 if ( !GroupConstructors->isEnabled() )
213 ActivateThisDialog();
216 //=================================================================================
217 // function : createOperation
219 //=================================================================================
220 GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation()
222 return getGeomEngine()->GetIShapesOperations( getStudyId() );
225 //=================================================================================
226 // function : isValid
228 //=================================================================================
229 bool BuildGUI_ShellDlg::isValid( QString& )
231 return myOkFacesAndShells;
234 //=================================================================================
235 // function : execute
237 //=================================================================================
238 bool BuildGUI_ShellDlg::execute( ObjectList& objects )
240 GEOM::GEOM_Object_var anObj;
242 anObj = GEOM::GEOM_IShapesOperations::_narrow(
243 getOperation() )->MakeShell( myFacesAndShells );
245 if ( !anObj->_is_nil() )
246 objects.push_back( anObj._retn() );