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 : BasicGUI_WorkingPlaneDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "BasicGUI_WorkingPlaneDlg.h"
31 #include <BRepAdaptor_Surface.hxx>
36 //=================================================================================
37 // class : BasicGUI_WorkingPlaneDlg()
38 // purpose : Constructs a BasicGUI_WorkingPlaneDlg which is a child of 'parent', with the
39 // name 'name' and widget flags set to 'f'.
40 // The dialog will by default be modeless, unless you set 'modal' to
41 // TRUE to construct a modal dialog.
42 //=================================================================================
43 BasicGUI_WorkingPlaneDlg::BasicGUI_WorkingPlaneDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
44 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
46 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_WPLANE_FACE")));
47 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
49 setCaption(tr("GEOM_WPLANE_TITLE"));
51 /***************************************************************/
52 GroupConstructors->setTitle(tr("GEOM_WPLANE"));
53 RadioButton1->setPixmap(image0);
54 RadioButton2->close(TRUE);
55 RadioButton3->close(TRUE);
57 GroupWPlane = new DlgRef_1Sel_QTD(this, "GroupWPlane");
58 GroupWPlane->GroupBox1->setTitle(tr("GEOM_WPLANE_FACE"));
59 GroupWPlane->TextLabel1->setText(tr("GEOM_SELECTION"));
60 GroupWPlane->PushButton1->setPixmap(image1);
62 Layout1->addWidget(GroupWPlane, 1, 0);
63 /***************************************************************/
66 myBasicGUI = theBasicGUI;
71 //=================================================================================
72 // function : ~BasicGUI_WorkingPlaneDlg()
73 // purpose : Destroys the object and frees any allocated resources
74 //=================================================================================
75 BasicGUI_WorkingPlaneDlg::~BasicGUI_WorkingPlaneDlg()
77 // no need to delete child widgets, Qt does it all for us
81 //=================================================================================
84 //=================================================================================
85 void BasicGUI_WorkingPlaneDlg::Init()
88 myEditCurrentArgument = GroupWPlane->LineEdit1;
92 /* Filter definition */
93 myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom);
94 mySelection->AddFilter(myFaceFilter); /* filter for next selection */
96 /* signals and slots connections */
97 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
98 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
100 connect(GroupWPlane->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
101 connect(GroupWPlane->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
103 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
105 /* displays Dialog */
113 //=================================================================================
114 // function : ClickOnOk()
116 //=================================================================================
117 void BasicGUI_WorkingPlaneDlg::ClickOnOk()
119 this->ClickOnApply();
124 //=================================================================================
125 // function : ClickOnApply()
127 //=================================================================================
128 void BasicGUI_WorkingPlaneDlg::ClickOnApply()
130 QAD_Application::getDesktop()->putInfo(tr(""));
132 myBasicGUI->MakeWorkingPlane(myLoc, myDir);
138 //=================================================================================
139 // function : SelectionIntoArgument()
140 // purpose : Called when selection as changed or other case
141 //=================================================================================
142 void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument()
144 myEditCurrentArgument->setText("");
145 QString aString = "";
147 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
155 if(!myGeomBase->GetTopoFromSelection(mySelection, S))
158 BRepAdaptor_Surface surf(TopoDS::Face(S));
159 gp_Pln Plane = surf.Plane();
160 myLoc = Plane.Location();
161 myDir = Plane.Axis().Direction();
163 GroupWPlane->LineEdit1->setText(aString);
171 //=================================================================================
172 // function : SetEditCurrentArgument()
174 //=================================================================================
175 void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument()
177 GroupWPlane->LineEdit1->setFocus();
178 this->SelectionIntoArgument();
183 //=================================================================================
184 // function : LineEditReturnPressed()
186 //=================================================================================
187 void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed()
189 GEOMBase_Skeleton::LineEditReturnPressed();
194 //=================================================================================
195 // function : ActivateThisDialog()
197 //=================================================================================
198 void BasicGUI_WorkingPlaneDlg::ActivateThisDialog()
200 GEOMBase_Skeleton::ActivateThisDialog();
201 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
202 mySelection->AddFilter(myFaceFilter);
207 //=================================================================================
208 // function : enterEvent()
210 //=================================================================================
211 void BasicGUI_WorkingPlaneDlg::enterEvent(QEvent* e)
213 if(GroupConstructors->isEnabled())
215 this->ActivateThisDialog();