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_CompoundDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "BuildGUI_CompoundDlg.h"
30 #include "QAD_Desktop.h"
31 #include "GEOMImpl_Types.hxx"
33 //=================================================================================
34 // class : BuildGUI_CompoundDlg()
35 // purpose : Constructs a BuildGUI_CompoundDlg which is a child of 'parent', with the
36 // name 'name' and widget flags set to 'f'.
37 // The dialog will by default be modeless, unless you set 'modal' to
38 // TRUE to construct a modal dialog.
39 //=================================================================================
40 BuildGUI_CompoundDlg::BuildGUI_CompoundDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
41 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
43 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BUILD_COMPOUND")));
44 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
46 setCaption(tr("GEOM_COMPOUND_TITLE"));
48 /***************************************************************/
49 GroupConstructors->setTitle(tr("GEOM_COMPOUND"));
50 RadioButton1->setPixmap(image0);
51 RadioButton2->close(TRUE);
52 RadioButton3->close(TRUE);
54 GroupShapes = new DlgRef_1Sel_QTD(this, "GroupShapes");
55 GroupShapes->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
56 GroupShapes->TextLabel1->setText(tr("GEOM_OBJECTS"));
57 GroupShapes->PushButton1->setPixmap(image1);
58 GroupShapes->LineEdit1->setReadOnly( true );
60 Layout1->addWidget(GroupShapes, 2, 0);
61 /***************************************************************/
68 //=================================================================================
69 // function : ~BuildGUI_CompoundDlg()
70 // purpose : Destroys the object and frees any allocated resources
71 //=================================================================================
72 BuildGUI_CompoundDlg::~BuildGUI_CompoundDlg()
74 // no need to delete child widgets, Qt does it all for us
78 //=================================================================================
81 //=================================================================================
82 void BuildGUI_CompoundDlg::Init()
85 myEditCurrentArgument = GroupShapes->LineEdit1;
86 GroupShapes->LineEdit1->setReadOnly( true );
90 /* signals and slots connections */
91 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
92 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
93 connect(GroupShapes->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
94 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
96 globalSelection( GEOM_ALLSHAPES );
98 initName( tr( "GEOM_COMPOUND" ) );
102 //=================================================================================
103 // function : ClickOnOk()
105 //=================================================================================
106 void BuildGUI_CompoundDlg::ClickOnOk()
108 if ( ClickOnApply() )
113 //=================================================================================
114 // function : ClickOnApply()
116 //=================================================================================
117 bool BuildGUI_CompoundDlg::ClickOnApply()
127 //=================================================================================
128 // function : SelectionIntoArgument()
129 // purpose : Called when selection as changed or other case
130 //=================================================================================
131 void BuildGUI_CompoundDlg::SelectionIntoArgument()
133 myEditCurrentArgument->setText( "" );
134 QString aString = ""; /* name of selection */
137 int nbSel = GEOMBase::GetNameOfSelectedIObjects( mySelection, aString, true );
141 aString = QString( "%1_objects").arg( nbSel );
143 GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myShapes, true );
144 myEditCurrentArgument->setText( aString );
149 //=================================================================================
150 // function : SetEditCurrentArgument()
152 //=================================================================================
153 void BuildGUI_CompoundDlg::SetEditCurrentArgument()
155 QPushButton* send = (QPushButton*)sender();
156 if (send != GroupShapes->PushButton1)
159 myEditCurrentArgument = GroupShapes->LineEdit1;
161 myEditCurrentArgument->setFocus();
162 SelectionIntoArgument();
166 //=================================================================================
167 // function : ActivateThisDialog()
169 //=================================================================================
170 void BuildGUI_CompoundDlg::ActivateThisDialog()
172 GEOMBase_Skeleton::ActivateThisDialog();
173 globalSelection( GEOM_ALLSHAPES );
174 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
178 //=================================================================================
179 // function : enterEvent()
181 //=================================================================================
182 void BuildGUI_CompoundDlg::enterEvent(QEvent* e)
184 if ( !GroupConstructors->isEnabled() )
185 ActivateThisDialog();
188 //=================================================================================
189 // function : createOperation
191 //=================================================================================
192 GEOM::GEOM_IOperations_ptr BuildGUI_CompoundDlg::createOperation()
194 return getGeomEngine()->GetIShapesOperations( getStudyId() );
197 //=================================================================================
198 // function : isValid
200 //=================================================================================
201 bool BuildGUI_CompoundDlg::isValid( QString& )
206 //=================================================================================
207 // function : execute
209 //=================================================================================
210 bool BuildGUI_CompoundDlg::execute( ObjectList& objects )
212 GEOM::GEOM_Object_var anObj;
214 anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeCompound( myShapes );
216 if ( !anObj->_is_nil() )
217 objects.push_back( anObj._retn() );