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_WireDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "BuildGUI_WireDlg.h"
30 #include "QAD_Desktop.h"
31 #include "GEOMImpl_Types.hxx"
33 //=================================================================================
34 // class : BuildGUI_WireDlg()
35 // purpose : Constructs a BuildGUI_WireDlg 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_WireDlg::BuildGUI_WireDlg(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_WIRE")));
44 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
46 setCaption(tr("GEOM_WIRE_TITLE"));
48 /***************************************************************/
49 GroupConstructors->setTitle(tr("GEOM_WIRE"));
50 RadioButton1->setPixmap(image0);
51 RadioButton2->close(TRUE);
52 RadioButton3->close(TRUE);
54 GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints");
55 GroupPoints->GroupBox1->setTitle(tr("GEOM_WIRE_CONNECT"));
56 GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
57 GroupPoints->PushButton1->setPixmap(image1);
58 GroupPoints->LineEdit1->setReadOnly( true );
60 Layout1->addWidget(GroupPoints, 2, 0);
61 /***************************************************************/
68 //=================================================================================
69 // function : ~BuildGUI_WireDlg()
70 // purpose : Destroys the object and frees any allocated resources
71 //=================================================================================
72 BuildGUI_WireDlg::~BuildGUI_WireDlg()
74 // no need to delete child widgets, Qt does it all for us
78 //=================================================================================
81 //=================================================================================
82 void BuildGUI_WireDlg::Init()
85 myEditCurrentArgument = GroupPoints->LineEdit1;
86 GroupPoints->LineEdit1->setReadOnly( true );
88 myOkEdgesAndWires = false;
90 TColStd_MapOfInteger aMap;
93 globalSelection( aMap );
95 /* signals and slots connections */
96 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
97 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
98 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
99 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
101 initName(tr("GEOM_WIRE"));
105 //=================================================================================
106 // function : ClickOnOk()
108 //=================================================================================
109 void BuildGUI_WireDlg::ClickOnOk()
111 if ( ClickOnApply() )
116 //=================================================================================
117 // function : ClickOnApply()
119 //=================================================================================
120 bool BuildGUI_WireDlg::ClickOnApply()
130 //=================================================================================
131 // function : SelectionIntoArgument()
132 // purpose : Called when selection as changed or other case
133 //=================================================================================
134 void BuildGUI_WireDlg::SelectionIntoArgument()
136 myEditCurrentArgument->setText("");
137 QString aString = ""; /* name of selection */
139 myOkEdgesAndWires = false;
140 int nbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aString);
145 aString = tr("%1_objects").arg(nbSel);
147 GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myEdgesAndWires);
148 if (!myEdgesAndWires.length())
151 myEditCurrentArgument->setText(aString);
152 myOkEdgesAndWires = true;
156 //=================================================================================
157 // function : SetEditCurrentArgument()
159 //=================================================================================
160 void BuildGUI_WireDlg::SetEditCurrentArgument()
162 QPushButton* send = (QPushButton*)sender();
163 if (send != GroupPoints->PushButton1)
166 TColStd_MapOfInteger aMap;
169 globalSelection( aMap );
170 myEditCurrentArgument = GroupPoints->LineEdit1;
172 myEditCurrentArgument->setFocus();
173 SelectionIntoArgument();
177 //=================================================================================
178 // function : ActivateThisDialog()
180 //=================================================================================
181 void BuildGUI_WireDlg::ActivateThisDialog()
183 GEOMBase_Skeleton::ActivateThisDialog();
184 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
185 TColStd_MapOfInteger aMap;
188 globalSelection( aMap );
192 //=================================================================================
193 // function : enterEvent()
195 //=================================================================================
196 void BuildGUI_WireDlg::enterEvent(QEvent* e)
198 if ( !GroupConstructors->isEnabled() )
199 ActivateThisDialog();
202 //=================================================================================
203 // function : createOperation
205 //=================================================================================
206 GEOM::GEOM_IOperations_ptr BuildGUI_WireDlg::createOperation()
208 return getGeomEngine()->GetIShapesOperations( getStudyId() );
211 //=================================================================================
212 // function : isValid
214 //=================================================================================
215 bool BuildGUI_WireDlg::isValid( QString& )
217 return myOkEdgesAndWires;
220 //=================================================================================
221 // function : execute
223 //=================================================================================
224 bool BuildGUI_WireDlg::execute( ObjectList& objects )
226 GEOM::GEOM_Object_var anObj;
228 anObj = GEOM::GEOM_IShapesOperations::_narrow(
229 getOperation() )->MakeWire( myEdgesAndWires );
231 if ( !anObj->_is_nil() )
232 objects.push_back( anObj._retn() );