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_SolidDlg.cxx
25 // Author : Damien COQUERET
29 #include "BuildGUI_SolidDlg.h"
31 #include "QAD_Desktop.h"
32 #include "GEOMImpl_Types.hxx"
35 #include <qcheckbox.h>
37 //=================================================================================
38 // class : BuildGUI_SolidDlg()
39 // purpose : Constructs a BuildGUI_SolidDlg which is a child of 'parent', with the
40 // name 'name' and widget flags set to 'f'.
41 // The dialog will by default be modeless, unless you set 'modal' to
42 // TRUE to construct a modal dialog.
43 //=================================================================================
44 BuildGUI_SolidDlg::BuildGUI_SolidDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
45 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
47 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SOLID")));
48 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT")));
50 setCaption(tr("GEOM_SOLID_TITLE"));
52 /***************************************************************/
53 GroupConstructors->setTitle(tr("GEOM_SOLID"));
54 RadioButton1->setPixmap(image0);
55 RadioButton2->close(TRUE);
56 RadioButton3->close(TRUE);
58 GroupSolid = new DlgRef_1Sel1Check_QTD(this, "GroupSolid");
59 GroupSolid->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
60 GroupSolid->TextLabel1->setText(tr("GEOM_OBJECTS"));
61 GroupSolid->CheckButton1->setText(tr("GEOM_CREATE_SINGLE_SOLID"));
62 GroupSolid->PushButton1->setPixmap(image1);
63 GroupSolid->LineEdit1->setReadOnly( true );
65 Layout1->addWidget(GroupSolid, 2, 0);
66 /***************************************************************/
73 //=================================================================================
74 // function : ~BuildGUI_SolidDlg()
75 // purpose : Destroys the object and frees any allocated resources
76 //=================================================================================
77 BuildGUI_SolidDlg::~BuildGUI_SolidDlg()
79 // no need to delete child widgets, Qt does it all for us
83 //=================================================================================
86 //=================================================================================
87 void BuildGUI_SolidDlg::Init()
90 myEditCurrentArgument = GroupSolid->LineEdit1;
91 GroupSolid->LineEdit1->setReadOnly( true );
92 GroupSolid->CheckButton1->setChecked( true );
96 globalSelection( GEOM_SHELL );
98 /* signals and slots connections */
99 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
100 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
102 connect(GroupSolid->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
103 connect(GroupSolid->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(EnableNameField(bool)));
105 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
107 initName(tr("GEOM_SOLID"));
111 //=================================================================================
112 // function : ClickOnOk()
114 //=================================================================================
115 void BuildGUI_SolidDlg::ClickOnOk()
117 if ( ClickOnApply() )
121 //=================================================================================
122 // function : ClickOnApply()
124 //=================================================================================
125 bool BuildGUI_SolidDlg::ClickOnApply()
135 //=================================================================================
136 // function : SelectionIntoArgument()
137 // purpose : Called when selection as changed or other case
138 //=================================================================================
139 void BuildGUI_SolidDlg::SelectionIntoArgument()
141 myEditCurrentArgument->setText("");
142 QString aString = "";
145 int nbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aString);
149 aString = tr("%1_objects").arg(nbSel);
151 GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myShells);
152 if (!myShells.length())
155 myEditCurrentArgument->setText(aString);
159 //=================================================================================
160 // function : SetEditCurrentArgument()
162 //=================================================================================
163 void BuildGUI_SolidDlg::SetEditCurrentArgument()
165 QPushButton* send = (QPushButton*)sender();
166 if(send != GroupSolid->PushButton1)
169 globalSelection( GEOM_SHELL );
170 myEditCurrentArgument = GroupSolid->LineEdit1;
172 myEditCurrentArgument->setFocus();
173 SelectionIntoArgument();
177 //=================================================================================
178 // function : ActivateThisDialog()
180 //=================================================================================
181 void BuildGUI_SolidDlg::ActivateThisDialog()
183 GEOMBase_Skeleton::ActivateThisDialog();
184 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
185 globalSelection( GEOM_SHELL );
189 //=================================================================================
190 // function : enterEvent()
192 //=================================================================================
193 void BuildGUI_SolidDlg::enterEvent(QEvent* e)
195 if ( !GroupConstructors->isEnabled() )
196 ActivateThisDialog();
200 //=================================================================================
201 // function : EnableNameField()
203 //=================================================================================
204 void BuildGUI_SolidDlg::EnableNameField(bool toEnable)
206 this->GroupBoxName->setEnabled(toEnable);
209 //=================================================================================
210 // function : createOperation
212 //=================================================================================
213 GEOM::GEOM_IOperations_ptr BuildGUI_SolidDlg::createOperation()
215 return getGeomEngine()->GetIShapesOperations( getStudyId() );
218 //=================================================================================
219 // function : isValid
221 //=================================================================================
222 bool BuildGUI_SolidDlg::isValid( QString& )
227 //=================================================================================
228 // function : execute
230 //=================================================================================
231 bool BuildGUI_SolidDlg::execute( ObjectList& objects )
233 bool toCreateSingleSolid = GroupSolid->CheckButton1->isChecked();
235 if ( toCreateSingleSolid )
237 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow(
238 getOperation() )->MakeSolidShells( myShells );
240 if ( !anObj->_is_nil() )
241 objects.push_back( anObj._retn() );
245 for ( int i = 0, n = myShells.length(); i< n; i++ )
247 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow(
248 getOperation() )->MakeSolidShell( myShells[ i ] );
250 if ( !anObj->_is_nil() )
251 objects.push_back( anObj._retn() );