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_CompoundDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "BuildGUI_CompoundDlg.h"
30 #include "GEOMImpl_Types.hxx"
32 #include "GeometryGUI.h"
35 #include "SUIT_ResourceMgr.h"
36 #include "SUIT_Session.h"
37 #include "SalomeApp_Application.h"
38 #include "LightApp_SelectionMgr.h"
40 //=================================================================================
41 // class : BuildGUI_CompoundDlg()
42 // purpose : Constructs a BuildGUI_CompoundDlg 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_CompoundDlg::BuildGUI_CompoundDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
48 const char* name, bool modal, Qt::WindowFlags fl)
49 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
51 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_BUILD_COMPOUND")));
52 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
54 setWindowTitle(tr("GEOM_COMPOUND_TITLE"));
56 /***************************************************************/
57 GroupConstructors->setTitle(tr("GEOM_COMPOUND"));
58 RadioButton1->setIcon(image0);
59 RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
60 RadioButton2->close();
61 RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
62 RadioButton3->close();
64 GroupShapes = new Ui::DlgRef_1Sel_QTD();
65 QWidget* aGroupShapesWidget = new QWidget(this);
66 GroupShapes->setupUi(aGroupShapesWidget);
67 aGroupShapesWidget->setObjectName("GroupShapes");
69 GroupShapes->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
70 GroupShapes->TextLabel1->setText(tr("GEOM_OBJECTS"));
71 GroupShapes->PushButton1->setIcon(image1);
72 GroupShapes->LineEdit1->setReadOnly( true );
74 gridLayout1->addWidget(aGroupShapesWidget, 2, 0);
75 /***************************************************************/
77 setHelpFileName("compound.htm");
84 //=================================================================================
85 // function : ~BuildGUI_CompoundDlg()
86 // purpose : Destroys the object and frees any allocated resources
87 //=================================================================================
88 BuildGUI_CompoundDlg::~BuildGUI_CompoundDlg()
90 // no need to delete child widgets, Qt does it all for us
94 //=================================================================================
97 //=================================================================================
98 void BuildGUI_CompoundDlg::Init()
101 myEditCurrentArgument = GroupShapes->LineEdit1;
102 GroupShapes->LineEdit1->setReadOnly( true );
106 /* signals and slots connections */
107 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
108 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
109 connect(GroupShapes->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
110 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
111 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
113 globalSelection( GEOM_ALLSHAPES );
115 initName( tr( "GEOM_COMPOUND" ).toLatin1().constData() );
119 //=================================================================================
120 // function : ClickOnOk()
122 //=================================================================================
123 void BuildGUI_CompoundDlg::ClickOnOk()
125 if ( ClickOnApply() )
130 //=================================================================================
131 // function : ClickOnApply()
133 //=================================================================================
134 bool BuildGUI_CompoundDlg::ClickOnApply()
144 //=================================================================================
145 // function : SelectionIntoArgument()
146 // purpose : Called when selection as changed or other case
147 //=================================================================================
148 void BuildGUI_CompoundDlg::SelectionIntoArgument()
150 myEditCurrentArgument->setText( "" );
151 QString aString = ""; /* name of selection */
154 int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true );
158 aString = QString( "%1_objects").arg( nbSel );
160 GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myShapes, true );
161 myEditCurrentArgument->setText( aString );
166 //=================================================================================
167 // function : SetEditCurrentArgument()
169 //=================================================================================
170 void BuildGUI_CompoundDlg::SetEditCurrentArgument()
172 QPushButton* send = (QPushButton*)sender();
173 if (send != GroupShapes->PushButton1)
176 myEditCurrentArgument = GroupShapes->LineEdit1;
178 myEditCurrentArgument->setFocus();
179 SelectionIntoArgument();
183 //=================================================================================
184 // function : ActivateThisDialog()
186 //=================================================================================
187 void BuildGUI_CompoundDlg::ActivateThisDialog()
189 GEOMBase_Skeleton::ActivateThisDialog();
190 globalSelection( GEOM_ALLSHAPES );
191 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
192 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
196 //=================================================================================
197 // function : enterEvent()
199 //=================================================================================
200 void BuildGUI_CompoundDlg::enterEvent(QEvent* e)
202 if ( !GroupConstructors->isEnabled() )
203 ActivateThisDialog();
206 //=================================================================================
207 // function : createOperation
209 //=================================================================================
210 GEOM::GEOM_IOperations_ptr BuildGUI_CompoundDlg::createOperation()
212 return getGeomEngine()->GetIShapesOperations( getStudyId() );
215 //=================================================================================
216 // function : isValid
218 //=================================================================================
219 bool BuildGUI_CompoundDlg::isValid( QString& )
224 //=================================================================================
225 // function : execute
227 //=================================================================================
228 bool BuildGUI_CompoundDlg::execute( ObjectList& objects )
230 GEOM::GEOM_Object_var anObj;
232 anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeCompound( myShapes );
234 if ( !anObj->_is_nil() )
235 objects.push_back( anObj._retn() );