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_FaceDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "BuildGUI_FaceDlg.h"
30 #include "GEOMImpl_Types.hxx"
31 #include "TColStd_MapOfInteger.hxx"
33 #include "GeometryGUI.h"
36 #include "SUIT_ResourceMgr.h"
37 #include "SUIT_Session.h"
38 #include "SalomeApp_Application.h"
39 #include "LightApp_SelectionMgr.h"
43 //=================================================================================
44 // class : BuildGUI_FaceDlg()
45 // purpose : Constructs a BuildGUI_FaceDlg which is a child of 'parent', with the
46 // name 'name' and widget flags set to 'f'.
47 // The dialog will by default be modeless, unless you set 'modal' to
48 // TRUE to construct a modal dialog.
49 //=================================================================================
50 BuildGUI_FaceDlg::BuildGUI_FaceDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
51 const char* name, bool modal, Qt::WindowFlags fl)
52 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
54 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_BUILD_FACE")));
55 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
57 setWindowTitle(tr("GEOM_FACE_TITLE"));
59 /***************************************************************/
60 GroupConstructors->setTitle(tr("GEOM_FACE"));
61 RadioButton1->setIcon(image0);
62 RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
63 RadioButton2->close();
64 RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
65 RadioButton3->close();
67 GroupWire = new Ui::DlgRef_1Sel1Check_QTD();
68 QWidget* aGroupWireWidget = new QWidget(this);
69 GroupWire->setupUi(aGroupWireWidget);
70 aGroupWireWidget->setObjectName("GroupWire");
72 GroupWire->GroupBox1->setTitle(tr("GEOM_FACE_FFW"));
73 GroupWire->TextLabel1->setText(tr("GEOM_OBJECTS"));
74 GroupWire->CheckButton1->setText(tr("GEOM_FACE_OPT"));
75 GroupWire->PushButton1->setIcon(image1);
77 gridLayout1->addWidget(aGroupWireWidget, 2, 0);
78 /***************************************************************/
80 setHelpFileName("face.htm");
87 //=================================================================================
88 // function : ~BuildGUI_FaceDlg()
89 // purpose : Destroys the object and frees any allocated resources
90 //=================================================================================
91 BuildGUI_FaceDlg::~BuildGUI_FaceDlg()
93 // no need to delete child widgets, Qt does it all for us
97 //=================================================================================
100 //=================================================================================
101 void BuildGUI_FaceDlg::Init()
104 myEditCurrentArgument = GroupWire->LineEdit1;
105 GroupWire->LineEdit1->setReadOnly( true );
107 GroupWire->CheckButton1->setChecked(TRUE);
109 TColStd_MapOfInteger aMap;
110 aMap.Add( GEOM_EDGE );
111 aMap.Add( GEOM_WIRE );
112 globalSelection( aMap );
114 /* signals and slots connections */
115 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
116 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
117 connect(GroupWire->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
118 connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
119 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
120 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
122 initName(tr("GEOM_FACE").toStdString().c_str());
126 //=================================================================================
127 // function : ClickOnOk()
129 //=================================================================================
130 void BuildGUI_FaceDlg::ClickOnOk()
132 if ( ClickOnApply() )
137 //=================================================================================
138 // function : ClickOnApply()
140 //=================================================================================
141 bool BuildGUI_FaceDlg::ClickOnApply()
151 //=================================================================================
152 // function : SelectionIntoArgument()
153 // purpose : Called when selection as changed or other case
154 //=================================================================================
155 void BuildGUI_FaceDlg::SelectionIntoArgument()
157 myEditCurrentArgument->setText("");
160 int aNbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aName);
168 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myWires);
169 if (!myWires.length())
172 aName = tr("%1_objects").arg(aNbSel);
174 myEditCurrentArgument->setText( aName );
176 myEditCurrentArgument->setText( aName );
180 //=================================================================================
181 // function : SetEditCurrentArgument()
183 //=================================================================================
184 void BuildGUI_FaceDlg::SetEditCurrentArgument()
186 QPushButton* send = (QPushButton*)sender();
187 if (send != GroupWire->PushButton1)
190 TColStd_MapOfInteger aMap;
191 aMap.Add( GEOM_EDGE );
192 aMap.Add( GEOM_WIRE );
193 globalSelection( aMap );
195 myEditCurrentArgument = GroupWire->LineEdit1;
197 myEditCurrentArgument->setFocus();
198 SelectionIntoArgument();
202 //=================================================================================
203 // function : ActivateThisDialog()
205 //=================================================================================
206 void BuildGUI_FaceDlg::ActivateThisDialog()
208 GEOMBase_Skeleton::ActivateThisDialog();
209 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
210 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
211 TColStd_MapOfInteger aMap;
212 aMap.Add( GEOM_EDGE );
213 aMap.Add( GEOM_WIRE );
214 globalSelection( aMap );
218 //=================================================================================
219 // function : enterEvent()
221 //=================================================================================
222 void BuildGUI_FaceDlg::enterEvent(QEvent* e)
224 if ( !GroupConstructors->isEnabled() )
225 ActivateThisDialog();
228 //=================================================================================
229 // function : createOperation
231 //=================================================================================
232 GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation()
234 return getGeomEngine()->GetIShapesOperations( getStudyId() );
237 //=================================================================================
238 // function : isValid
240 //=================================================================================
241 bool BuildGUI_FaceDlg::isValid( QString& )
243 return (myWires.length() != 0);
246 //=================================================================================
247 // function : execute
249 //=================================================================================
250 bool BuildGUI_FaceDlg::execute( ObjectList& objects )
252 GEOM::GEOM_Object_var anObj;
254 bool isPlanarWanted = GroupWire->CheckButton1->isChecked();
255 anObj = GEOM::GEOM_IShapesOperations::_narrow(
256 getOperation() )->MakeFaceWires( myWires, isPlanarWanted );
258 if ( !anObj->_is_nil() )
259 objects.push_back( anObj._retn() );