1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : BuildGUI_ShellDlg.cxx
24 // Author : Damien COQUERET
28 #include "BuildGUI_ShellDlg.h"
29 #include "GEOMImpl_Types.hxx"
31 #include "SUIT_Session.h"
32 #include "SalomeApp_Application.h"
33 #include "LightApp_SelectionMgr.h"
35 #include "TColStd_MapOfInteger.hxx"
39 //=================================================================================
40 // class : BuildGUI_ShellDlg()
41 // purpose : Constructs a BuildGUI_ShellDlg which is a child of 'parent', with the
42 // name 'name' and widget flags set to 'f'.
43 // The dialog will by default be modeless, unless you set 'modal' to
44 // TRUE to construct a modal dialog.
45 //=================================================================================
46 BuildGUI_ShellDlg::BuildGUI_ShellDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
47 const char* name, bool modal, WFlags fl)
48 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
49 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
51 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SHELL")));
52 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
54 setCaption(tr("GEOM_SHELL_TITLE"));
56 /***************************************************************/
57 GroupConstructors->setTitle(tr("GEOM_SHELL"));
58 RadioButton1->setPixmap(image0);
59 RadioButton2->close(TRUE);
60 RadioButton3->close(TRUE);
62 GroupShell = new DlgRef_1Sel_QTD(this, "GroupShell");
63 GroupShell->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
64 GroupShell->TextLabel1->setText(tr("GEOM_OBJECTS"));
65 GroupShell->PushButton1->setPixmap(image1);
66 GroupShell->LineEdit1->setReadOnly( true );
68 Layout1->addWidget(GroupShell, 2, 0);
69 /***************************************************************/
71 setHelpFileName("create_shell_page.html");
78 //=================================================================================
79 // function : ~BuildGUI_ShellDlg()
80 // purpose : Destroys the object and frees any allocated resources
81 //=================================================================================
82 BuildGUI_ShellDlg::~BuildGUI_ShellDlg()
84 // no need to delete child widgets, Qt does it all for us
88 //=================================================================================
91 //=================================================================================
92 void BuildGUI_ShellDlg::Init()
95 myEditCurrentArgument = GroupShell->LineEdit1;
96 GroupShell->LineEdit1->setReadOnly( true );
98 myOkFacesAndShells = false;
100 TColStd_MapOfInteger aMap;
101 aMap.Add(GEOM_SHELL);
103 aMap.Add(GEOM_COMPOUNDFILTER);
105 QValueList<int> aSubShapes;
106 aSubShapes.append(GEOM_FACE);
107 globalSelection( aMap, aSubShapes );
109 /* signals and slots connections */
110 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
111 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
113 connect(GroupShell->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
115 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
116 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
118 initName(tr("GEOM_SHELL"));
122 //=================================================================================
123 // function : ClickOnOk()
125 //=================================================================================
126 void BuildGUI_ShellDlg::ClickOnOk()
128 if ( ClickOnApply() )
133 //=================================================================================
134 // function : ClickOnApply()
136 //=================================================================================
137 bool BuildGUI_ShellDlg::ClickOnApply()
147 //=================================================================================
148 // function : SelectionIntoArgument()
149 // purpose : Called when selection as changed or other case
150 //=================================================================================
151 void BuildGUI_ShellDlg::SelectionIntoArgument()
153 myEditCurrentArgument->setText( "" );
156 myOkFacesAndShells = false;
157 int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true );
161 aString = QString( "%1_objects ").arg( nbSel );
163 GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myFacesAndShells, true );
164 if ( !myFacesAndShells.length() )
167 myEditCurrentArgument->setText( aString );
168 myOkFacesAndShells = true;
172 //=================================================================================
173 // function : SetEditCurrentArgument()
175 //=================================================================================
176 void BuildGUI_ShellDlg::SetEditCurrentArgument()
178 QPushButton* send = (QPushButton*)sender();
179 if (send != GroupShell->PushButton1)
182 TColStd_MapOfInteger aMap;
183 aMap.Add(GEOM_SHELL);
185 aMap.Add(GEOM_COMPOUNDFILTER);
187 QValueList<int> aSubShapes;
188 aSubShapes.append(GEOM_FACE);
189 globalSelection( aMap, aSubShapes );
191 myEditCurrentArgument = GroupShell->LineEdit1;
193 myEditCurrentArgument->setFocus();
194 SelectionIntoArgument();
198 //=================================================================================
199 // function : ActivateThisDialog()
201 //=================================================================================
202 void BuildGUI_ShellDlg::ActivateThisDialog()
204 GEOMBase_Skeleton::ActivateThisDialog();
205 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
206 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
208 TColStd_MapOfInteger aMap;
209 aMap.Add(GEOM_SHELL);
211 aMap.Add(GEOM_COMPOUNDFILTER);
213 QValueList<int> aSubShapes;
214 aSubShapes.append(GEOM_FACE);
215 globalSelection( aMap, aSubShapes );
220 //=================================================================================
221 // function : enterEvent()
223 //=================================================================================
224 void BuildGUI_ShellDlg::enterEvent(QEvent* e)
226 if ( !GroupConstructors->isEnabled() )
227 ActivateThisDialog();
230 //=================================================================================
231 // function : createOperation
233 //=================================================================================
234 GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation()
236 return getGeomEngine()->GetIShapesOperations( getStudyId() );
239 //=================================================================================
240 // function : isValid
242 //=================================================================================
243 bool BuildGUI_ShellDlg::isValid( QString& )
245 return myOkFacesAndShells;
248 //=================================================================================
249 // function : execute
251 //=================================================================================
252 bool BuildGUI_ShellDlg::execute( ObjectList& objects )
254 GEOM::GEOM_Object_var anObj;
256 anObj = GEOM::GEOM_IShapesOperations::_narrow(
257 getOperation() )->MakeShell( myFacesAndShells );
259 if ( !anObj->_is_nil() )
260 objects.push_back( anObj._retn() );