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"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
37 #include <qcheckbox.h>
42 //=================================================================================
43 // class : BuildGUI_FaceDlg()
44 // purpose : Constructs a BuildGUI_FaceDlg which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // TRUE to construct a modal dialog.
48 //=================================================================================
49 BuildGUI_FaceDlg::BuildGUI_FaceDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
50 const char* name, bool modal, WFlags fl)
51 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
52 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
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 setCaption(tr("GEOM_FACE_TITLE"));
59 /***************************************************************/
60 GroupConstructors->setTitle(tr("GEOM_FACE"));
61 RadioButton1->setPixmap(image0);
62 RadioButton2->close(TRUE);
63 RadioButton3->close(TRUE);
65 GroupWire = new DlgRef_1Sel1Check_QTD(this, "GroupWire");
66 GroupWire->GroupBox1->setTitle(tr("GEOM_FACE_FFW"));
67 GroupWire->TextLabel1->setText(tr("GEOM_WIRES"));
68 GroupWire->CheckButton1->setText(tr("GEOM_FACE_OPT"));
69 GroupWire->PushButton1->setPixmap(image1);
71 Layout1->addWidget(GroupWire, 2, 0);
72 /***************************************************************/
74 setHelpFileName("face.htm");
81 //=================================================================================
82 // function : ~BuildGUI_FaceDlg()
83 // purpose : Destroys the object and frees any allocated resources
84 //=================================================================================
85 BuildGUI_FaceDlg::~BuildGUI_FaceDlg()
87 // no need to delete child widgets, Qt does it all for us
91 //=================================================================================
94 //=================================================================================
95 void BuildGUI_FaceDlg::Init()
98 myEditCurrentArgument = GroupWire->LineEdit1;
99 GroupWire->LineEdit1->setReadOnly( true );
101 GroupWire->CheckButton1->setChecked(TRUE);
103 globalSelection( GEOM_WIRE );
105 /* signals and slots connections */
106 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
107 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
108 connect(GroupWire->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
109 connect(GroupWire->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_FACE"));
117 //=================================================================================
118 // function : ClickOnOk()
120 //=================================================================================
121 void BuildGUI_FaceDlg::ClickOnOk()
123 if ( ClickOnApply() )
128 //=================================================================================
129 // function : ClickOnApply()
131 //=================================================================================
132 bool BuildGUI_FaceDlg::ClickOnApply()
142 //=================================================================================
143 // function : SelectionIntoArgument()
144 // purpose : Called when selection as changed or other case
145 //=================================================================================
146 void BuildGUI_FaceDlg::SelectionIntoArgument()
148 myEditCurrentArgument->setText("");
151 int aNbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aName);
159 GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myWires);
160 if (!myWires.length())
163 aName = tr("%1_wires").arg(aNbSel);
165 myEditCurrentArgument->setText( aName );
167 myEditCurrentArgument->setText( aName );
171 //=================================================================================
172 // function : SetEditCurrentArgument()
174 //=================================================================================
175 void BuildGUI_FaceDlg::SetEditCurrentArgument()
177 QPushButton* send = (QPushButton*)sender();
178 if (send != GroupWire->PushButton1)
181 globalSelection( GEOM_WIRE );
182 myEditCurrentArgument = GroupWire->LineEdit1;
184 myEditCurrentArgument->setFocus();
185 SelectionIntoArgument();
189 //=================================================================================
190 // function : ActivateThisDialog()
192 //=================================================================================
193 void BuildGUI_FaceDlg::ActivateThisDialog()
195 GEOMBase_Skeleton::ActivateThisDialog();
196 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
197 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
198 globalSelection( GEOM_WIRE );
202 //=================================================================================
203 // function : enterEvent()
205 //=================================================================================
206 void BuildGUI_FaceDlg::enterEvent(QEvent* e)
208 if ( !GroupConstructors->isEnabled() )
209 ActivateThisDialog();
212 //=================================================================================
213 // function : createOperation
215 //=================================================================================
216 GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation()
218 return getGeomEngine()->GetIShapesOperations( getStudyId() );
221 //=================================================================================
222 // function : isValid
224 //=================================================================================
225 bool BuildGUI_FaceDlg::isValid( QString& )
227 return (myWires.length() != 0);
230 //=================================================================================
231 // function : execute
233 //=================================================================================
234 bool BuildGUI_FaceDlg::execute( ObjectList& objects )
236 GEOM::GEOM_Object_var anObj;
238 bool isPlanarWanted = GroupWire->CheckButton1->isChecked();
239 anObj = GEOM::GEOM_IShapesOperations::_narrow(
240 getOperation() )->MakeFaceWires( myWires, isPlanarWanted );
242 if ( !anObj->_is_nil() )
243 objects.push_back( anObj._retn() );