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 : MeasureGUI_NormaleDlg.cxx
25 // Author : Julia DOROVSKIKH
29 #include "MeasureGUI_NormaleDlg.h"
31 #include "SUIT_Session.h"
32 #include "SalomeApp_Application.h"
33 #include "LightApp_SelectionMgr.h"
37 #include "GEOMImpl_Types.hxx"
39 #include "utilities.h"
41 //=================================================================================
42 // class : MeasureGUI_NormaleDlg()
43 // purpose : Constructs a MeasureGUI_NormaleDlg which is a child of 'parent', with the
44 // name 'name' and widget flags set to 'f'.
45 // The dialog will by default be modeless, unless you set 'modal' to
46 // TRUE to construct a modal dialog.
47 //=================================================================================
48 MeasureGUI_NormaleDlg::MeasureGUI_NormaleDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
49 const char* name, bool modal, WFlags fl)
50 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
51 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
53 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
54 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_NORMALE")));
55 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
57 setCaption(tr("GEOM_NORMALE_TITLE"));
59 /***************************************************************/
60 GroupConstructors->setTitle(tr("GEOM_NORMALE"));
61 RadioButton1->setPixmap(image0);
62 RadioButton2->close(TRUE);
63 RadioButton3->close(TRUE);
65 GroupArgs = new DlgRef_2Sel_QTD (this, "GroupArgs");
66 GroupArgs->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
68 GroupArgs->TextLabel1->setText(tr("GEOM_FACE"));
69 GroupArgs->TextLabel2->setText(tr("GEOM_POINT"));
71 GroupArgs->PushButton1->setPixmap(image1);
72 GroupArgs->PushButton2->setPixmap(image1);
74 Layout1->addWidget(GroupArgs, 2, 0);
75 /***************************************************************/
77 setHelpFileName("using_measurement_tools_page.html#normale_anchor");
82 //=================================================================================
83 // function : ~MeasureGUI_NormaleDlg()
84 // purpose : Destroys the object and frees any allocated resources
85 //=================================================================================
86 MeasureGUI_NormaleDlg::~MeasureGUI_NormaleDlg()
88 // no need to delete child widgets, Qt does it all for us
91 //=================================================================================
94 //=================================================================================
95 void MeasureGUI_NormaleDlg::Init()
98 GroupArgs->LineEdit1->setReadOnly(true);
99 GroupArgs->LineEdit2->setReadOnly(true);
101 myFace = GEOM::GEOM_Object::_nil();
102 myPoint = GEOM::GEOM_Object::_nil();
104 myEditCurrentArgument = GroupArgs->LineEdit1;
105 globalSelection(GEOM_FACE);
107 /* signals and slots connections */
108 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
109 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
111 connect(GroupArgs->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
112 connect(GroupArgs->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
114 connect(GroupArgs->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
115 connect(GroupArgs->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
117 connect(myGeomGUI->getApp()->selectionMgr(),
118 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
120 initName(tr("GEOM_VECTOR_NORMALE"));
122 //ConstructorsClicked(0);
123 SelectionIntoArgument();
125 /* displays Dialog */
130 //=================================================================================
131 // function : ClickOnOk()
133 //=================================================================================
134 void MeasureGUI_NormaleDlg::ClickOnOk()
140 //=================================================================================
141 // function : ClickOnApply()
143 //=================================================================================
144 bool MeasureGUI_NormaleDlg::ClickOnApply()
153 //=================================================================================
154 // function : SelectionIntoArgument()
155 // purpose : Called when selection as changed or other case
156 //=================================================================================
157 void MeasureGUI_NormaleDlg::SelectionIntoArgument()
160 myEditCurrentArgument->setText("");
162 if (myEditCurrentArgument == GroupArgs->LineEdit1) {
163 myFace = GEOM::GEOM_Object::_nil();
165 else if (myEditCurrentArgument == GroupArgs->LineEdit2) {
166 myPoint = GEOM::GEOM_Object::_nil();
169 if (IObjectCount() != 1)
173 Standard_Boolean testResult = Standard_False;
174 GEOM::GEOM_Object_var aSelectedObject =
175 GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult);
180 if (myEditCurrentArgument == GroupArgs->LineEdit1) {
181 myFace = aSelectedObject;
183 else if (myEditCurrentArgument == GroupArgs->LineEdit2) {
184 myPoint = aSelectedObject;
187 myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
192 //=================================================================================
193 // function : LineEditReturnPressed()
195 //=================================================================================
196 void MeasureGUI_NormaleDlg::LineEditReturnPressed()
198 QLineEdit* send = (QLineEdit*)sender();
199 if (send == GroupArgs->LineEdit1 ||
200 send == GroupArgs->LineEdit2)
202 myEditCurrentArgument = send;
203 GEOMBase_Skeleton::LineEditReturnPressed();
207 //=================================================================================
208 // function : SetEditCurrentArgument()
210 //=================================================================================
211 void MeasureGUI_NormaleDlg::SetEditCurrentArgument()
213 QPushButton* send = (QPushButton*)sender();
215 if (send == GroupArgs->PushButton1) {
216 myEditCurrentArgument = GroupArgs->LineEdit1;
217 globalSelection(GEOM_FACE);
219 else if (send == GroupArgs->PushButton2) {
220 myEditCurrentArgument = GroupArgs->LineEdit2;
221 globalSelection(GEOM_POINT);
224 myEditCurrentArgument->setFocus();
225 SelectionIntoArgument();
228 //=================================================================================
229 // function : ActivateThisDialog()
231 //=================================================================================
232 void MeasureGUI_NormaleDlg::ActivateThisDialog()
234 GEOMBase_Skeleton::ActivateThisDialog();
236 SelectionIntoArgument();
239 //=================================================================================
240 // function : enterEvent()
242 //=================================================================================
243 void MeasureGUI_NormaleDlg::enterEvent (QEvent* e)
245 if (!GroupConstructors->isEnabled())
246 ActivateThisDialog();
249 //=================================================================================
250 // function : createOperation
252 //=================================================================================
253 GEOM::GEOM_IOperations_ptr MeasureGUI_NormaleDlg::createOperation()
255 return getGeomEngine()->GetIMeasureOperations(getStudyId());
258 //=================================================================================
259 // function : isValid
261 //=================================================================================
262 bool MeasureGUI_NormaleDlg::isValid (QString&)
264 //return !CORBA::is_nil(myFace) && !CORBA::is_nil(myPoint);
265 return !CORBA::is_nil(myFace);
268 //=================================================================================
269 // function : execute
271 //=================================================================================
272 bool MeasureGUI_NormaleDlg::execute (ObjectList& objects)
274 GEOM::GEOM_Object_var anObj =
275 GEOM::GEOM_IMeasureOperations::_narrow(getOperation())->GetNormal(myFace, myPoint);
277 if (!anObj->_is_nil())
278 objects.push_back(anObj._retn());