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
29 #include "BuildGUI_ShellDlg.h"
31 #include "QAD_Desktop.h"
32 #include "GEOMImpl_Types.hxx"
34 //=================================================================================
35 // class : BuildGUI_ShellDlg()
36 // purpose : Constructs a BuildGUI_ShellDlg which is a child of 'parent', with the
37 // name 'name' and widget flags set to 'f'.
38 // The dialog will by default be modeless, unless you set 'modal' to
39 // TRUE to construct a modal dialog.
40 //=================================================================================
41 BuildGUI_ShellDlg::BuildGUI_ShellDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
42 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
44 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SHELL")));
45 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT")));
47 setCaption(tr("GEOM_SHELL_TITLE"));
49 /***************************************************************/
50 GroupConstructors->setTitle(tr("GEOM_SHELL"));
51 RadioButton1->setPixmap(image0);
52 RadioButton2->close(TRUE);
53 RadioButton3->close(TRUE);
55 GroupShell = new DlgRef_1Sel_QTD(this, "GroupShell");
56 GroupShell->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
57 GroupShell->TextLabel1->setText(tr("GEOM_OBJECTS"));
58 GroupShell->PushButton1->setPixmap(image1);
59 GroupShell->LineEdit1->setReadOnly( true );
61 Layout1->addWidget(GroupShell, 2, 0);
62 /***************************************************************/
69 //=================================================================================
70 // function : ~BuildGUI_ShellDlg()
71 // purpose : Destroys the object and frees any allocated resources
72 //=================================================================================
73 BuildGUI_ShellDlg::~BuildGUI_ShellDlg()
75 // no need to delete child widgets, Qt does it all for us
79 //=================================================================================
82 //=================================================================================
83 void BuildGUI_ShellDlg::Init()
86 myEditCurrentArgument = GroupShell->LineEdit1;
87 GroupShell->LineEdit1->setReadOnly( true );
89 myOkFacesAndShells = false;
91 TColStd_MapOfInteger aMap;
94 globalSelection( aMap );
96 /* signals and slots connections */
97 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
98 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
100 connect(GroupShell->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
102 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
104 initName(tr("GEOM_SHELL"));
108 //=================================================================================
109 // function : ClickOnOk()
111 //=================================================================================
112 void BuildGUI_ShellDlg::ClickOnOk()
114 if ( ClickOnApply() )
119 //=================================================================================
120 // function : ClickOnApply()
122 //=================================================================================
123 bool BuildGUI_ShellDlg::ClickOnApply()
133 //=================================================================================
134 // function : SelectionIntoArgument()
135 // purpose : Called when selection as changed or other case
136 //=================================================================================
137 void BuildGUI_ShellDlg::SelectionIntoArgument()
139 myEditCurrentArgument->setText( "" );
142 myOkFacesAndShells = false;
143 int nbSel = GEOMBase::GetNameOfSelectedIObjects( mySelection, aString, true );
147 aString = QString( "%1_objects ").arg( nbSel );
149 GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myFacesAndShells, true );
150 if ( !myFacesAndShells.length() )
153 myEditCurrentArgument->setText( aString );
154 myOkFacesAndShells = true;
158 //=================================================================================
159 // function : SetEditCurrentArgument()
161 //=================================================================================
162 void BuildGUI_ShellDlg::SetEditCurrentArgument()
164 QPushButton* send = (QPushButton*)sender();
165 if (send != GroupShell->PushButton1)
168 TColStd_MapOfInteger aMap;
169 aMap.Add(GEOM_SHELL);
171 globalSelection( aMap );
172 myEditCurrentArgument = GroupShell->LineEdit1;
174 myEditCurrentArgument->setFocus();
175 SelectionIntoArgument();
179 //=================================================================================
180 // function : ActivateThisDialog()
182 //=================================================================================
183 void BuildGUI_ShellDlg::ActivateThisDialog()
185 GEOMBase_Skeleton::ActivateThisDialog();
186 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
187 TColStd_MapOfInteger aMap;
188 aMap.Add(GEOM_SHELL);
190 globalSelection( aMap );
194 //=================================================================================
195 // function : enterEvent()
197 //=================================================================================
198 void BuildGUI_ShellDlg::enterEvent(QEvent* e)
200 if ( !GroupConstructors->isEnabled() )
201 ActivateThisDialog();
204 //=================================================================================
205 // function : createOperation
207 //=================================================================================
208 GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation()
210 return getGeomEngine()->GetIShapesOperations( getStudyId() );
213 //=================================================================================
214 // function : isValid
216 //=================================================================================
217 bool BuildGUI_ShellDlg::isValid( QString& )
219 return myOkFacesAndShells;
222 //=================================================================================
223 // function : execute
225 //=================================================================================
226 bool BuildGUI_ShellDlg::execute( ObjectList& objects )
228 GEOM::GEOM_Object_var anObj;
230 anObj = GEOM::GEOM_IShapesOperations::_narrow(
231 getOperation() )->MakeShell( myFacesAndShells );
233 if ( !anObj->_is_nil() )
234 objects.push_back( anObj._retn() );