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_SolidDlg.cxx
25 // Author : Damien COQUERET
29 #include "BuildGUI_SolidDlg.h"
30 #include "GEOMImpl_Types.hxx"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
37 #include <qcheckbox.h>
40 //=================================================================================
41 // class : BuildGUI_SolidDlg()
42 // purpose : Constructs a BuildGUI_SolidDlg 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_SolidDlg::BuildGUI_SolidDlg(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_SOLID")));
53 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
55 setCaption(tr("GEOM_SOLID_TITLE"));
57 /***************************************************************/
58 GroupConstructors->setTitle(tr("GEOM_SOLID"));
59 RadioButton1->setPixmap(image0);
60 RadioButton2->close(TRUE);
61 RadioButton3->close(TRUE);
63 GroupSolid = new DlgRef_1Sel1Check_QTD(this, "GroupSolid");
64 GroupSolid->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
65 GroupSolid->TextLabel1->setText(tr("GEOM_OBJECTS"));
66 GroupSolid->CheckButton1->setText(tr("GEOM_CREATE_SINGLE_SOLID"));
67 GroupSolid->PushButton1->setPixmap(image1);
68 GroupSolid->LineEdit1->setReadOnly( true );
70 Layout1->addWidget(GroupSolid, 2, 0);
71 /***************************************************************/
73 setHelpFileName("solid.htm");
80 //=================================================================================
81 // function : ~BuildGUI_SolidDlg()
82 // purpose : Destroys the object and frees any allocated resources
83 //=================================================================================
84 BuildGUI_SolidDlg::~BuildGUI_SolidDlg()
86 // no need to delete child widgets, Qt does it all for us
90 //=================================================================================
93 //=================================================================================
94 void BuildGUI_SolidDlg::Init()
97 myEditCurrentArgument = GroupSolid->LineEdit1;
98 GroupSolid->LineEdit1->setReadOnly( true );
99 GroupSolid->CheckButton1->setChecked( true );
103 globalSelection( GEOM_SHELL );
105 /* signals and slots connections */
106 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
107 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
109 connect(GroupSolid->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
110 connect(GroupSolid->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(EnableNameField(bool)));
112 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
113 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
115 initName(tr("GEOM_SOLID"));
119 //=================================================================================
120 // function : ClickOnOk()
122 //=================================================================================
123 void BuildGUI_SolidDlg::ClickOnOk()
125 if ( ClickOnApply() )
129 //=================================================================================
130 // function : ClickOnApply()
132 //=================================================================================
133 bool BuildGUI_SolidDlg::ClickOnApply()
143 //=================================================================================
144 // function : SelectionIntoArgument()
145 // purpose : Called when selection as changed or other case
146 //=================================================================================
147 void BuildGUI_SolidDlg::SelectionIntoArgument()
149 myEditCurrentArgument->setText("");
150 QString aString = "";
153 int nbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aString);
157 aString = tr("%1_objects").arg(nbSel);
159 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myShells);
160 if (!myShells.length())
163 myEditCurrentArgument->setText(aString);
167 //=================================================================================
168 // function : SetEditCurrentArgument()
170 //=================================================================================
171 void BuildGUI_SolidDlg::SetEditCurrentArgument()
173 QPushButton* send = (QPushButton*)sender();
174 if(send != GroupSolid->PushButton1)
177 globalSelection( GEOM_SHELL );
178 myEditCurrentArgument = GroupSolid->LineEdit1;
180 myEditCurrentArgument->setFocus();
181 SelectionIntoArgument();
185 //=================================================================================
186 // function : ActivateThisDialog()
188 //=================================================================================
189 void BuildGUI_SolidDlg::ActivateThisDialog()
191 GEOMBase_Skeleton::ActivateThisDialog();
192 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
193 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
194 globalSelection( GEOM_SHELL );
198 //=================================================================================
199 // function : enterEvent()
201 //=================================================================================
202 void BuildGUI_SolidDlg::enterEvent(QEvent* e)
204 if ( !GroupConstructors->isEnabled() )
205 ActivateThisDialog();
209 //=================================================================================
210 // function : EnableNameField()
212 //=================================================================================
213 void BuildGUI_SolidDlg::EnableNameField(bool toEnable)
215 this->GroupBoxName->setEnabled(toEnable);
218 //=================================================================================
219 // function : createOperation
221 //=================================================================================
222 GEOM::GEOM_IOperations_ptr BuildGUI_SolidDlg::createOperation()
224 return getGeomEngine()->GetIShapesOperations( getStudyId() );
227 //=================================================================================
228 // function : isValid
230 //=================================================================================
231 bool BuildGUI_SolidDlg::isValid( QString& )
236 //=================================================================================
237 // function : execute
239 //=================================================================================
240 bool BuildGUI_SolidDlg::execute( ObjectList& objects )
242 bool toCreateSingleSolid = GroupSolid->CheckButton1->isChecked();
244 if ( toCreateSingleSolid )
246 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow(
247 getOperation() )->MakeSolidShells( myShells );
249 if ( !anObj->_is_nil() )
250 objects.push_back( anObj._retn() );
254 for ( int i = 0, n = myShells.length(); i< n; i++ )
256 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow(
257 getOperation() )->MakeSolidShell( myShells[ i ] );
259 if ( !anObj->_is_nil() )
260 objects.push_back( anObj._retn() );