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_WireDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "BuildGUI_WireDlg.h"
30 #include "GEOMImpl_Types.hxx"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
36 #include "TColStd_MapOfInteger.hxx"
40 //=================================================================================
41 // class : BuildGUI_WireDlg()
42 // purpose : Constructs a BuildGUI_WireDlg 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_WireDlg::BuildGUI_WireDlg(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_WIRE")));
53 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
55 setCaption(tr("GEOM_WIRE_TITLE"));
57 /***************************************************************/
58 GroupConstructors->setTitle(tr("GEOM_WIRE"));
59 RadioButton1->setPixmap(image0);
60 RadioButton2->close(TRUE);
61 RadioButton3->close(TRUE);
63 GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints");
64 GroupPoints->GroupBox1->setTitle(tr("GEOM_WIRE_CONNECT"));
65 GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
66 GroupPoints->PushButton1->setPixmap(image1);
67 GroupPoints->LineEdit1->setReadOnly( true );
69 Layout1->addWidget(GroupPoints, 2, 0);
70 /***************************************************************/
72 setHelpFileName("wire.htm");
79 //=================================================================================
80 // function : ~BuildGUI_WireDlg()
81 // purpose : Destroys the object and frees any allocated resources
82 //=================================================================================
83 BuildGUI_WireDlg::~BuildGUI_WireDlg()
85 // no need to delete child widgets, Qt does it all for us
89 //=================================================================================
92 //=================================================================================
93 void BuildGUI_WireDlg::Init()
96 myEditCurrentArgument = GroupPoints->LineEdit1;
97 GroupPoints->LineEdit1->setReadOnly( true );
99 myOkEdgesAndWires = false;
101 TColStd_MapOfInteger aMap;
104 globalSelection( aMap );
106 /* signals and slots connections */
107 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
108 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
109 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
110 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
111 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
113 initName(tr("GEOM_WIRE"));
117 //=================================================================================
118 // function : ClickOnOk()
120 //=================================================================================
121 void BuildGUI_WireDlg::ClickOnOk()
123 if ( ClickOnApply() )
128 //=================================================================================
129 // function : ClickOnApply()
131 //=================================================================================
132 bool BuildGUI_WireDlg::ClickOnApply()
142 //=================================================================================
143 // function : SelectionIntoArgument()
144 // purpose : Called when selection as changed or other case
145 //=================================================================================
146 void BuildGUI_WireDlg::SelectionIntoArgument()
148 myEditCurrentArgument->setText("");
149 QString aString = ""; /* name of selection */
151 myOkEdgesAndWires = false;
152 int nbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aString);
157 aString = tr("%1_objects").arg(nbSel);
159 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myEdgesAndWires);
160 if (!myEdgesAndWires.length())
163 myEditCurrentArgument->setText(aString);
164 myOkEdgesAndWires = true;
168 //=================================================================================
169 // function : SetEditCurrentArgument()
171 //=================================================================================
172 void BuildGUI_WireDlg::SetEditCurrentArgument()
174 QPushButton* send = (QPushButton*)sender();
175 if (send != GroupPoints->PushButton1)
178 TColStd_MapOfInteger aMap;
181 globalSelection( aMap );
182 myEditCurrentArgument = GroupPoints->LineEdit1;
184 myEditCurrentArgument->setFocus();
185 SelectionIntoArgument();
189 //=================================================================================
190 // function : ActivateThisDialog()
192 //=================================================================================
193 void BuildGUI_WireDlg::ActivateThisDialog()
195 GEOMBase_Skeleton::ActivateThisDialog();
196 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
197 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
198 TColStd_MapOfInteger aMap;
201 globalSelection( aMap );
205 //=================================================================================
206 // function : enterEvent()
208 //=================================================================================
209 void BuildGUI_WireDlg::enterEvent(QEvent* e)
211 if ( !GroupConstructors->isEnabled() )
212 ActivateThisDialog();
215 //=================================================================================
216 // function : createOperation
218 //=================================================================================
219 GEOM::GEOM_IOperations_ptr BuildGUI_WireDlg::createOperation()
221 return getGeomEngine()->GetIShapesOperations( getStudyId() );
224 //=================================================================================
225 // function : isValid
227 //=================================================================================
228 bool BuildGUI_WireDlg::isValid( QString& )
230 return myOkEdgesAndWires;
233 //=================================================================================
234 // function : execute
236 //=================================================================================
237 bool BuildGUI_WireDlg::execute( ObjectList& objects )
239 GEOM::GEOM_Object_var anObj;
241 anObj = GEOM::GEOM_IShapesOperations::_narrow(
242 getOperation() )->MakeWire( myEdgesAndWires );
244 if ( !anObj->_is_nil() )
245 objects.push_back( anObj._retn() );