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_FaceDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "BuildGUI_FaceDlg.h"
31 #include "QAD_Desktop.h"
32 #include "GEOMImpl_Types.hxx"
35 #include <qcheckbox.h>
37 //=================================================================================
38 // class : BuildGUI_FaceDlg()
39 // purpose : Constructs a BuildGUI_FaceDlg which is a child of 'parent', with the
40 // name 'name' and widget flags set to 'f'.
41 // The dialog will by default be modeless, unless you set 'modal' to
42 // TRUE to construct a modal dialog.
43 //=================================================================================
44 BuildGUI_FaceDlg::BuildGUI_FaceDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
45 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
47 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BUILD_FACE")));
48 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
50 setCaption(tr("GEOM_FACE_TITLE"));
52 /***************************************************************/
53 GroupConstructors->setTitle(tr("GEOM_FACE"));
54 RadioButton1->setPixmap(image0);
55 RadioButton2->close(TRUE);
56 RadioButton3->close(TRUE);
58 GroupWire = new DlgRef_1Sel1Check_QTD(this, "GroupWire");
59 GroupWire->GroupBox1->setTitle(tr("GEOM_FACE_FFW"));
60 GroupWire->TextLabel1->setText(tr("GEOM_WIRES"));
61 GroupWire->CheckButton1->setText(tr("GEOM_FACE_OPT"));
62 GroupWire->PushButton1->setPixmap(image1);
64 Layout1->addWidget(GroupWire, 2, 0);
65 /***************************************************************/
72 //=================================================================================
73 // function : ~BuildGUI_FaceDlg()
74 // purpose : Destroys the object and frees any allocated resources
75 //=================================================================================
76 BuildGUI_FaceDlg::~BuildGUI_FaceDlg()
78 // no need to delete child widgets, Qt does it all for us
82 //=================================================================================
85 //=================================================================================
86 void BuildGUI_FaceDlg::Init()
89 myEditCurrentArgument = GroupWire->LineEdit1;
90 GroupWire->LineEdit1->setReadOnly( true );
92 GroupWire->CheckButton1->setChecked(TRUE);
94 globalSelection( GEOM_WIRE );
96 /* signals and slots connections */
97 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
98 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
99 connect(GroupWire->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
100 connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
101 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
103 initName(tr("GEOM_FACE"));
107 //=================================================================================
108 // function : ClickOnOk()
110 //=================================================================================
111 void BuildGUI_FaceDlg::ClickOnOk()
113 if ( ClickOnApply() )
118 //=================================================================================
119 // function : ClickOnApply()
121 //=================================================================================
122 bool BuildGUI_FaceDlg::ClickOnApply()
132 //=================================================================================
133 // function : SelectionIntoArgument()
134 // purpose : Called when selection as changed or other case
135 //=================================================================================
136 void BuildGUI_FaceDlg::SelectionIntoArgument()
138 myEditCurrentArgument->setText("");
141 int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName);
149 GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myWires);
150 if (!myWires.length())
153 aName = tr("%1_wires").arg(aNbSel);
155 myEditCurrentArgument->setText( aName );
157 myEditCurrentArgument->setText( aName );
161 //=================================================================================
162 // function : SetEditCurrentArgument()
164 //=================================================================================
165 void BuildGUI_FaceDlg::SetEditCurrentArgument()
167 QPushButton* send = (QPushButton*)sender();
168 if (send != GroupWire->PushButton1)
171 globalSelection( GEOM_WIRE );
172 myEditCurrentArgument = GroupWire->LineEdit1;
174 myEditCurrentArgument->setFocus();
175 SelectionIntoArgument();
179 //=================================================================================
180 // function : ActivateThisDialog()
182 //=================================================================================
183 void BuildGUI_FaceDlg::ActivateThisDialog()
185 GEOMBase_Skeleton::ActivateThisDialog();
186 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
187 globalSelection( GEOM_WIRE );
191 //=================================================================================
192 // function : enterEvent()
194 //=================================================================================
195 void BuildGUI_FaceDlg::enterEvent(QEvent* e)
197 if ( !GroupConstructors->isEnabled() )
198 ActivateThisDialog();
201 //=================================================================================
202 // function : createOperation
204 //=================================================================================
205 GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation()
207 return getGeomEngine()->GetIShapesOperations( getStudyId() );
210 //=================================================================================
211 // function : isValid
213 //=================================================================================
214 bool BuildGUI_FaceDlg::isValid( QString& )
216 return (myWires.length() != 0);
219 //=================================================================================
220 // function : execute
222 //=================================================================================
223 bool BuildGUI_FaceDlg::execute( ObjectList& objects )
225 GEOM::GEOM_Object_var anObj;
227 bool isPlanarWanted = GroupWire->CheckButton1->isChecked();
228 anObj = GEOM::GEOM_IShapesOperations::_narrow(
229 getOperation() )->MakeFaceWires( myWires, isPlanarWanted );
231 if ( !anObj->_is_nil() )
232 objects.push_back( anObj._retn() );