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 "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
37 #include <qcheckbox.h>
39 //=================================================================================
40 // class : BuildGUI_CompoundDlg()
41 // purpose : Constructs a BuildGUI_CompoundDlg 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_CompoundDlg::BuildGUI_CompoundDlg(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_COMPOUND")));
52 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
54 setCaption(tr("GEOM_COMPOUND_TITLE"));
56 /***************************************************************/
57 GroupConstructors->setTitle(tr("GEOM_COMPOUND"));
58 RadioButton1->setPixmap(image0);
59 RadioButton2->close(TRUE);
60 RadioButton3->close(TRUE);
62 GroupShapes = new DlgRef_1Sel_QTD(this, "GroupShapes");
63 GroupShapes->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
64 GroupShapes->TextLabel1->setText(tr("GEOM_OBJECTS"));
65 GroupShapes->PushButton1->setPixmap(image1);
66 GroupShapes->LineEdit1->setReadOnly( true );
68 Layout1->addWidget(GroupShapes, 2, 0);
69 /***************************************************************/
71 setHelpFileName("create_compound_page.html");
78 //=================================================================================
79 // function : ~BuildGUI_CompoundDlg()
80 // purpose : Destroys the object and frees any allocated resources
81 //=================================================================================
82 BuildGUI_CompoundDlg::~BuildGUI_CompoundDlg()
84 // no need to delete child widgets, Qt does it all for us
88 //=================================================================================
91 //=================================================================================
92 void BuildGUI_CompoundDlg::Init()
95 myEditCurrentArgument = GroupShapes->LineEdit1;
96 GroupShapes->LineEdit1->setReadOnly( true );
100 GroupBoxPublish->show();
102 /* signals and slots connections */
103 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
104 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
105 connect(GroupShapes->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
106 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
107 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
109 globalSelection( GEOM_ALLSHAPES );
111 initName( tr( "GEOM_COMPOUND" ) );
115 //=================================================================================
116 // function : ClickOnOk()
118 //=================================================================================
119 void BuildGUI_CompoundDlg::ClickOnOk()
121 if ( ClickOnApply() )
126 //=================================================================================
127 // function : ClickOnApply()
129 //=================================================================================
130 bool BuildGUI_CompoundDlg::ClickOnApply()
140 //=================================================================================
141 // function : SelectionIntoArgument()
142 // purpose : Called when selection as changed or other case
143 //=================================================================================
144 void BuildGUI_CompoundDlg::SelectionIntoArgument()
146 myEditCurrentArgument->setText( "" );
147 QString aString = ""; /* name of selection */
150 int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true );
154 aString = QString( "%1_objects").arg( nbSel );
156 GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myShapes, true );
157 myEditCurrentArgument->setText( aString );
162 //=================================================================================
163 // function : SetEditCurrentArgument()
165 //=================================================================================
166 void BuildGUI_CompoundDlg::SetEditCurrentArgument()
168 QPushButton* send = (QPushButton*)sender();
169 if (send != GroupShapes->PushButton1)
172 myEditCurrentArgument = GroupShapes->LineEdit1;
174 myEditCurrentArgument->setFocus();
175 SelectionIntoArgument();
179 //=================================================================================
180 // function : ActivateThisDialog()
182 //=================================================================================
183 void BuildGUI_CompoundDlg::ActivateThisDialog()
185 GEOMBase_Skeleton::ActivateThisDialog();
186 globalSelection( GEOM_ALLSHAPES );
187 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
188 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
192 //=================================================================================
193 // function : enterEvent()
195 //=================================================================================
196 void BuildGUI_CompoundDlg::enterEvent(QEvent* e)
198 if ( !GroupConstructors->isEnabled() )
199 ActivateThisDialog();
202 //=================================================================================
203 // function : createOperation
205 //=================================================================================
206 GEOM::GEOM_IOperations_ptr BuildGUI_CompoundDlg::createOperation()
208 return getGeomEngine()->GetIShapesOperations( getStudyId() );
211 //=================================================================================
212 // function : isValid
214 //=================================================================================
215 bool BuildGUI_CompoundDlg::isValid( QString& )
220 //=================================================================================
221 // function : execute
223 //=================================================================================
224 bool BuildGUI_CompoundDlg::execute( ObjectList& objects )
226 GEOM::GEOM_Object_var anObj;
228 anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeCompound( myShapes );
230 if ( !anObj->_is_nil() )
231 objects.push_back( anObj._retn() );
236 //=================================================================================
237 // function : restoreSubShapes
239 //=================================================================================
240 void BuildGUI_CompoundDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
241 SALOMEDS::SObject_ptr theSObject)
243 if (CheckBoxRestoreSS->isChecked()) {
244 // empty list of arguments means that all arguments should be restored
245 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/false);