1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : BasicGUI_PointDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "BasicGUI_PointDlg.h"
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_Session.h>
31 #include <SalomeApp_Application.h>
32 #include <LightApp_SelectionMgr.h>
34 #include <GeometryGUI.h>
39 #include <GEOMImpl_Types.hxx>
41 #include <QApplication>
42 #include <QButtonGroup>
43 #include <QHBoxLayout>
45 #include <QRadioButton>
51 #include <TopoDS_Shape.hxx>
52 #include <TopAbs_ShapeEnum.hxx>
54 #include <BRep_Tool.hxx>
56 #include <TColStd_IndexedMapOfInteger.hxx>
57 #include <TopTools_IndexedMapOfShape.hxx>
61 #define LENGTH_VALUE 2
63 #define GEOM_POINT_XYZ 0
64 #define GEOM_POINT_REF 1
65 #define GEOM_POINT_EDGE 2
66 #define GEOM_POINT_INTINT 3
67 #define GEOM_POINT_SURF 4
72 //=================================================================================
73 // class : BasicGUI_PointDlg()
74 // purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
75 // name 'name' and widget flags set to 'f'.
76 // The dialog will by default be modeless, unless you set 'modal' to
77 // TRUE to construct a modal dialog.
78 //=================================================================================
79 BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
80 bool modal, Qt::WindowFlags fl)
81 : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
84 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
85 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT")));
86 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_EDGE")));
87 QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
88 QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_REF")));
89 QPixmap image4 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_LINES")));
90 QPixmap image5 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_FACE")));
91 QPixmap image6 (aResMgr->loadPixmap("GEOM", tr("ICO_LINE")));
92 QPixmap image7 (aResMgr->loadPixmap("GEOM", tr("ICO_WIRE")));
94 setWindowTitle(tr("GEOM_POINT_TITLE"));
96 /***************************************************************/
97 mainFrame()->GroupConstructors->setTitle(tr("GEOM_POINTS"));
98 mainFrame()->RadioButton1->setIcon(image0);
99 mainFrame()->RadioButton2->setIcon(image3);
100 mainFrame()->RadioButton3->setIcon(image1);
101 mainFrame()->RadioButton4->show();
102 mainFrame()->RadioButton4->setIcon(image4);
103 mainFrame()->RadioButton5->show();
104 mainFrame()->RadioButton5->setIcon(image5);
106 myParamGroup = new QGroupBox(centralWidget());
107 myParamCoord = new QButtonGroup(myParamGroup);
108 QHBoxLayout* boxLayout = new QHBoxLayout(myParamGroup);
109 boxLayout->setMargin(MARGIN); boxLayout->setSpacing(SPACING);
110 QRadioButton* btn = new QRadioButton(tr("GEOM_PARAM_VALUE"), myParamGroup);
111 myParamCoord->addButton(btn, PARAM_VALUE);
112 boxLayout->addWidget(btn);
113 btn = new QRadioButton(tr("GEOM_LENGTH_VALUE"), myParamGroup);
114 myParamCoord->addButton(btn, LENGTH_VALUE);
115 boxLayout->addWidget(btn);
116 btn = new QRadioButton(tr("GEOM_COORD_VALUE"), myParamGroup);
117 myParamCoord->addButton(btn, COORD_VALUE);
118 boxLayout->addWidget(btn);
119 myParamCoord->setExclusive(true);
120 myParamCoord->button(PARAM_VALUE)->setChecked(true);
122 GroupXYZ = new DlgRef_3Spin(centralWidget());
123 GroupXYZ->GroupBox1->setTitle(tr("GEOM_COORDINATES"));
124 GroupXYZ->TextLabel1->setText(tr("GEOM_X"));
125 GroupXYZ->TextLabel2->setText(tr("GEOM_Y"));
126 GroupXYZ->TextLabel3->setText(tr("GEOM_Z"));
128 GroupOnCurve = new DlgRef_2Sel1Spin(centralWidget());
129 GroupOnCurve->GroupBox1->setTitle(tr("GEOM_POINT_ON_EDGE"));
130 GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE"));
131 GroupOnCurve->TextLabel2->setText(tr("GEOM_START_POINT"));
132 GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
133 GroupOnCurve->PushButton1->setIcon(image2);
134 GroupOnCurve->PushButton2->setIcon(image2);
136 GroupOnSurface = new DlgRef_1Sel2Spin(centralWidget());
137 GroupOnSurface->GroupBox1->setTitle(tr("GEOM_POINT_ON_FACE"));
138 GroupOnSurface->TextLabel1->setText(tr("GEOM_FACE"));
139 GroupOnSurface->TextLabel2->setText(tr("GEOM_UPARAMETER"));
140 GroupOnSurface->TextLabel3->setText(tr("GEOM_VPARAMETER"));
141 GroupOnSurface->PushButton1->setIcon(image2);
143 GroupRefPoint = new DlgRef_1Sel3Spin(centralWidget());
144 GroupRefPoint->GroupBox1->setTitle(tr("GEOM_REF_POINT"));
145 GroupRefPoint->TextLabel1->setText(tr("GEOM_POINT"));
146 GroupRefPoint->PushButton1->setIcon(image2);
147 GroupRefPoint->TextLabel2->setText(tr("GEOM_DX"));
148 GroupRefPoint->TextLabel3->setText(tr("GEOM_DY"));
149 GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ"));
151 /* popup menu for line intersect buttons */
152 QIcon ico_line = QIcon(image6);
153 QIcon ico_wire = QIcon(image7);
155 GroupLineIntersection = new DlgRef_2Sel(centralWidget());
156 GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION"));
157 GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1"));
158 GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2"));
159 GroupLineIntersection->PushButton1->setIcon(image2);
160 GroupLineIntersection->PushButton2->setIcon(image2);
161 GroupLineIntersection->LineEdit2->setEnabled(false);
163 myCoordGrp = new QGroupBox(tr("GEOM_COORDINATES_RES"), centralWidget());
164 QGridLayout* myCoordGrpLayout = new QGridLayout(myCoordGrp);
165 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_X"), myCoordGrp), 0, 0);
166 myX = new QLineEdit(myCoordGrp);
167 myCoordGrpLayout->addWidget(myX, 0, 1);
168 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Y"), myCoordGrp), 1, 0);
169 myY = new QLineEdit(myCoordGrp);
170 myCoordGrpLayout->addWidget(myY, 1, 1);
171 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Z"), myCoordGrp), 2, 0);
172 myZ = new QLineEdit(myCoordGrp);
173 myCoordGrpLayout->addWidget(myZ, 2, 1);
175 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
176 layout->setMargin(0); layout->setSpacing(6);
177 layout->addWidget(myParamGroup);
178 layout->addWidget(GroupXYZ);
179 layout->addWidget(GroupOnCurve);
180 layout->addWidget(GroupOnSurface);
181 layout->addWidget(GroupRefPoint);
182 layout->addWidget(GroupLineIntersection);
183 layout->addWidget(myCoordGrp);
185 myX->setReadOnly(true);
186 myY->setReadOnly(true);
187 myZ->setReadOnly(true);
189 myX->setEnabled(false);
190 myY->setEnabled(false);
191 myZ->setEnabled(false);
193 QPalette aPal = myX->palette();
194 aPal.setColor(QPalette::Disabled, QPalette::Text, QColor(0, 0, 0));
195 myX->setPalette(aPal);
196 myY->setPalette(aPal);
197 myZ->setPalette(aPal);
199 setHelpFileName("create_point_page.html");
205 //=================================================================================
206 // function : ~BasicGUI_PointDlg()
207 // purpose : Destructor
208 //=================================================================================
209 BasicGUI_PointDlg::~BasicGUI_PointDlg()
214 //=================================================================================
217 //=================================================================================
218 void BasicGUI_PointDlg::Init()
220 GroupOnCurve->LineEdit1->setReadOnly(true);
221 GroupOnCurve->LineEdit2->setReadOnly(true);
222 GroupOnSurface->LineEdit1->setReadOnly(true);
223 GroupRefPoint->LineEdit1->setReadOnly(true);
224 GroupLineIntersection->LineEdit1->setReadOnly(true);
225 GroupLineIntersection->LineEdit2->setReadOnly(true);
226 GroupLineIntersection->LineEdit1->setEnabled(true);
227 GroupLineIntersection->LineEdit2->setEnabled(false);
231 myRefPoint.nullify();
234 myNeedType = TopAbs_VERTEX;
236 myEditCurrentArgument = 0;
238 /* Get setting of step value from file configuration */
239 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
240 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
242 /* min, max, step and decimals for spin boxes */
243 initSpinBox(GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
244 initSpinBox(GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision");
245 initSpinBox(GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision");
246 GroupXYZ->SpinBox_DX->setValue(0.0);
247 GroupXYZ->SpinBox_DY->setValue(0.0);
248 GroupXYZ->SpinBox_DZ->setValue(0.0);
250 initSpinBox(GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
251 initSpinBox(GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision");
252 initSpinBox(GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision");
253 GroupRefPoint->SpinBox_DX->setValue(0.0);
254 GroupRefPoint->SpinBox_DY->setValue(0.0);
255 GroupRefPoint->SpinBox_DZ->setValue(0.0);
259 initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision");
260 GroupOnCurve->SpinBox_DX->setValue(0.5);
262 initSpinBox(GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision");
263 GroupOnSurface->SpinBox_DX->setValue(0.5);
264 initSpinBox(GroupOnSurface->SpinBox_DY, 0., 1., step, "parametric_precision");
265 GroupOnSurface->SpinBox_DY->setValue(0.5);
267 /* signals and slots connections */
268 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
269 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
271 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
272 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
274 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
276 connect(myParamCoord, SIGNAL(buttonClicked(int)), this, SLOT(ClickParamCoord(int)));
278 connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
279 connect(GroupOnCurve->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
280 connect(GroupOnSurface->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
281 connect(GroupLineIntersection->PushButton1, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
282 connect(GroupLineIntersection->PushButton2, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
284 connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
285 connect(GroupOnSurface->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
286 connect(GroupOnSurface->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
287 connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
288 connect(GroupXYZ->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
289 connect(GroupXYZ->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
290 connect(GroupRefPoint->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
291 connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
292 connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
294 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
296 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
297 this, SLOT(SelectionIntoArgument()));
299 initName(tr("GEOM_VERTEX"));
301 ConstructorsClicked(0);
304 //=================================================================================
305 // function : SetDoubleSpinBoxStep()
306 // purpose : Double spin box management
307 //=================================================================================
308 void BasicGUI_PointDlg::SetDoubleSpinBoxStep(double step)
310 GroupOnCurve->SpinBox_DX->setSingleStep(step);
311 GroupXYZ->SpinBox_DX->setSingleStep(step);
312 GroupXYZ->SpinBox_DY->setSingleStep(step);
313 GroupXYZ->SpinBox_DZ->setSingleStep(step);
314 GroupRefPoint->SpinBox_DX->setSingleStep(step);
315 GroupRefPoint->SpinBox_DY->setSingleStep(step);
316 GroupRefPoint->SpinBox_DZ->setSingleStep(step);
320 //=================================================================================
321 // function : ConstructorsClicked()
322 // purpose : Radio button management
323 //=================================================================================
324 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
326 switch (constructorId) {
329 globalSelection(); // close local contexts, if any
330 myNeedType = TopAbs_VERTEX;
331 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
333 GroupRefPoint->hide();
334 GroupOnCurve->hide();
335 GroupLineIntersection->hide();
336 GroupOnSurface->hide();
338 myParamGroup->hide();
344 globalSelection(); // close local contexts, if any
345 myNeedType = TopAbs_VERTEX;
346 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
348 myEditCurrentArgument = GroupRefPoint->LineEdit1;
349 myEditCurrentArgument->setText("");
350 myRefPoint.nullify();
351 GroupRefPoint->PushButton1->setDown(true);
352 myParamGroup->hide();
354 GroupOnCurve->hide();
355 GroupLineIntersection->hide();
356 GroupOnSurface->hide();
357 GroupRefPoint->show();
361 case GEOM_POINT_EDGE:
363 globalSelection(); // close local contexts, if any
364 myNeedType = TopAbs_EDGE;
365 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
367 myEditCurrentArgument = GroupOnCurve->LineEdit1;
368 myEditCurrentArgument->setText("");
370 myRefPoint.nullify();
371 GroupOnCurve->PushButton1->setDown(true);
372 GroupRefPoint->hide();
373 GroupLineIntersection->hide();
374 GroupOnSurface->hide();
375 myParamGroup->show();
376 myParamCoord->button(LENGTH_VALUE)->show();
377 myParamCoord->button(PARAM_VALUE)->setChecked(true);
378 GroupOnCurve->show();
380 updateParamCoord(false);
383 case GEOM_POINT_INTINT:
385 globalSelection(); // close local contexts, if any
386 std::list<int> needTypes;
387 needTypes.push_back( TopAbs_EDGE ), needTypes.push_back( TopAbs_WIRE );
388 localSelection(GEOM::GEOM_Object::_nil(), needTypes );
390 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
391 GroupLineIntersection->LineEdit1->setText("");
392 GroupLineIntersection->LineEdit2->setText("");
393 GroupLineIntersection->LineEdit1->setEnabled(true);
394 GroupLineIntersection->LineEdit2->setEnabled(false);
397 GroupLineIntersection->PushButton1->setDown(true);
398 GroupLineIntersection->PushButton2->setDown(false);
399 myParamGroup->hide();
401 GroupRefPoint->hide();
402 GroupOnCurve->hide();
403 GroupOnSurface->hide();
405 GroupLineIntersection->show();
408 case GEOM_POINT_SURF:
410 globalSelection(); // close local contexts, if any
411 myNeedType = TopAbs_FACE;
412 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
414 myEditCurrentArgument = GroupOnSurface->LineEdit1;
415 myEditCurrentArgument->setText("");
417 GroupOnSurface->PushButton1->setDown(true);
418 GroupRefPoint->hide();
419 GroupOnCurve->hide();
420 GroupLineIntersection->hide();
421 myParamGroup->show();
422 myParamCoord->button(LENGTH_VALUE)->hide();
423 myParamCoord->button(PARAM_VALUE)->setChecked(true);
424 GroupOnSurface->show();
426 updateParamCoord(false);
435 QTimer::singleShot(50, this, SLOT(updateSize()));
437 SelectionIntoArgument();
440 //=================================================================================
441 // function : ClickOnOk()
443 //=================================================================================
444 void BasicGUI_PointDlg::ClickOnOk()
446 setIsApplyAndClose(true);
451 //=================================================================================
452 // function : ClickOnApply()
454 //=================================================================================
455 bool BasicGUI_PointDlg::ClickOnApply()
461 ConstructorsClicked(getConstructorId());
466 //=================================================================================
467 // function : SelectionIntoArgument()
468 // purpose : Called when selection as changed (for constructors not using local context)
469 //=================================================================================
470 void BasicGUI_PointDlg::SelectionIntoArgument()
473 const int id = getConstructorId();
475 if ((id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF)
476 && myEditCurrentArgument != 0)
478 myEditCurrentArgument->setText("");
483 if (myEditCurrentArgument == GroupOnCurve->LineEdit1)
485 else if (myEditCurrentArgument == GroupOnCurve->LineEdit2)
486 myRefPoint.nullify();
488 else if (id == GEOM_POINT_INTINT) {
489 myEditCurrentArgument->setText("");
490 if (myEditCurrentArgument == GroupLineIntersection->LineEdit1)
492 else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2)
496 GEOM::GeomObjPtr aSelectedObject;
497 if (id == GEOM_POINT_INTINT) {
498 QList<TopAbs_ShapeEnum> needTypes;
499 needTypes << TopAbs_EDGE, needTypes << TopAbs_WIRE;
500 aSelectedObject= getSelected(needTypes);
503 aSelectedObject= getSelected(myNeedType);
505 if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) {
506 QString aName = GEOMBase::GetName(aSelectedObject.get());
508 if (id == GEOM_POINT_XYZ) {
509 gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
510 GroupXYZ->SpinBox_DX->setValue(aPnt.X());
511 GroupXYZ->SpinBox_DY->setValue(aPnt.Y());
512 GroupXYZ->SpinBox_DZ->setValue(aPnt.Z());
514 else if (id == GEOM_POINT_REF) {
515 myRefPoint = aSelectedObject;
516 GroupRefPoint->LineEdit1->setText(aName);
518 else if (id == GEOM_POINT_EDGE) {
519 myEditCurrentArgument->setText(aName);
520 if (myEditCurrentArgument == GroupOnCurve->LineEdit1) {
521 myEdge = aSelectedObject;
522 if (myEdge && !myRefPoint) {
523 GroupOnCurve->PushButton2->click();
526 else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) {
527 myRefPoint = aSelectedObject;
528 if (myRefPoint && !myEdge) {
529 GroupOnCurve->PushButton1->click();
533 else if (id == GEOM_POINT_INTINT) {
534 myEditCurrentArgument->setText(aName);
535 if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) {
536 myLine1 = aSelectedObject;
537 if (myLine1 && !myLine2) {
538 GroupLineIntersection->PushButton2->click();
541 else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) {
542 myLine2 = aSelectedObject;
543 if (myLine2 && !myLine1) {
544 GroupLineIntersection->PushButton1->click();
548 else if (id == GEOM_POINT_SURF) {
549 myFace = aSelectedObject;
550 GroupOnSurface->LineEdit1->setText(aName);
555 displayPreview(true);
559 //=================================================================================
560 // function : SetEditCurrentArgument()
562 //=================================================================================
563 void BasicGUI_PointDlg::SetEditCurrentArgument()
565 QPushButton* send = (QPushButton*)sender();
567 if (send == GroupRefPoint->PushButton1) {
568 GroupRefPoint->LineEdit1->setFocus();
569 myEditCurrentArgument = GroupRefPoint->LineEdit1;
570 globalSelection(); // close local contexts, if any
571 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
573 else if (send == GroupOnCurve->PushButton1) {
574 GroupOnCurve->LineEdit1->setFocus();
575 myEditCurrentArgument = GroupOnCurve->LineEdit1;
576 globalSelection(); // close local contexts, if any
577 myNeedType = TopAbs_EDGE;
578 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
579 GroupOnCurve->PushButton2->setDown(false);
580 GroupOnCurve->LineEdit1->setEnabled(true);
581 GroupOnCurve->LineEdit2->setEnabled(false);
583 else if (send == GroupOnCurve->PushButton2) {
584 GroupOnCurve->LineEdit2->setFocus();
585 myEditCurrentArgument = GroupOnCurve->LineEdit2;
586 globalSelection(); // close local contexts, if any
587 myNeedType = TopAbs_VERTEX;
588 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
589 GroupOnCurve->PushButton1->setDown(false);
590 GroupOnCurve->LineEdit2->setEnabled(true);
591 GroupOnCurve->LineEdit1->setEnabled(false);
593 else if (send == GroupOnSurface->PushButton1)
595 GroupOnSurface->LineEdit1->setFocus();
596 myEditCurrentArgument = GroupOnSurface->LineEdit1;
597 globalSelection(); // close local contexts, if any
598 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE);
600 else if (send == GroupLineIntersection->PushButton1) {
601 GroupLineIntersection->LineEdit1->setFocus();
602 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
603 GroupLineIntersection->PushButton2->setDown(false);
604 GroupLineIntersection->LineEdit1->setEnabled(true);
605 GroupLineIntersection->LineEdit2->setEnabled(false);
607 else if (send == GroupLineIntersection->PushButton2) {
608 GroupLineIntersection->LineEdit2->setFocus();
609 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
610 GroupLineIntersection->PushButton1->setDown(false);
611 GroupLineIntersection->LineEdit1->setEnabled(false);
612 GroupLineIntersection->LineEdit2->setEnabled(true);
616 // if ((send == GroupLineIntersection->PushButton1 ||
617 // send == GroupLineIntersection->PushButton2) && !myBusy)
618 // SelectionIntoArgument();
622 //=================================================================================
623 // function : enterEvent()
624 // purpose : to reactivate this dialog box when mouse enter onto the window
625 //=================================================================================
626 void BasicGUI_PointDlg::enterEvent(QEvent*)
628 if (!mainFrame()->GroupConstructors->isEnabled())
629 ActivateThisDialog();
633 //=================================================================================
634 // function : ActivateThisDialog()
636 //=================================================================================
637 void BasicGUI_PointDlg::ActivateThisDialog()
639 GEOMBase_Skeleton::ActivateThisDialog();
641 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
642 this, SLOT(SelectionIntoArgument()));
644 ConstructorsClicked(getConstructorId());
648 //=================================================================================
649 // function : DeactivateActiveDialog()
650 // purpose : public slot to deactivate if active
651 //=================================================================================
652 void BasicGUI_PointDlg::DeactivateActiveDialog()
654 // myGeomGUI->SetState(-1);
655 GEOMBase_Skeleton::DeactivateActiveDialog();
659 //=================================================================================
660 // function : ValueChangedInSpinBox()
662 //=================================================================================
663 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
665 displayPreview(true);
668 //=================================================================================
669 // function : CheckBoxClicked()
670 // purpose : Check Boxes Management
671 //=================================================================================
672 void BasicGUI_PointDlg::CheckBoxClicked(int State)
674 displayPreview(true);
678 //=================================================================================
679 // funcion : getParameter()
681 //=================================================================================
682 double BasicGUI_PointDlg::getParameter() const
684 return GroupOnCurve->SpinBox_DX->value();
688 //=================================================================================
689 // funcion : getUParameter()
691 //=================================================================================
692 double BasicGUI_PointDlg::getUParameter() const
694 return GroupOnSurface->SpinBox_DX->value();
698 //=================================================================================
699 // funcion : getVParameter()
701 //=================================================================================
702 double BasicGUI_PointDlg::getVParameter() const
704 return GroupOnSurface->SpinBox_DY->value();
708 //=================================================================================
709 // function : OnPointSelected
711 //=================================================================================
712 void BasicGUI_PointDlg::OnPointSelected(const gp_Pnt& thePnt)
714 if (getConstructorId() == GEOM_POINT_XYZ) {
715 GroupXYZ->SpinBox_DX->setValue(thePnt.X());
716 GroupXYZ->SpinBox_DY->setValue(thePnt.Y());
717 GroupXYZ->SpinBox_DZ->setValue(thePnt.Z());
719 displayPreview(true);
723 //=================================================================================
724 // function : createOperation
726 //=================================================================================
727 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
729 return myGeomGUI->GetGeomGen()->GetIBasicOperations(getStudyId());
732 //=================================================================================
733 // function : isValid
735 //=================================================================================
736 bool BasicGUI_PointDlg::isValid(QString& msg)
739 switch (getConstructorId()) {
740 case GEOM_POINT_XYZ :
741 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
742 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
743 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
746 ok = GroupRefPoint->SpinBox_DX->isValid(msg, !IsPreview()) &&
747 GroupRefPoint->SpinBox_DY->isValid(msg, !IsPreview()) &&
748 GroupRefPoint->SpinBox_DZ->isValid(msg, !IsPreview()) &&
751 case GEOM_POINT_EDGE:
752 if (myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE)
753 ok = GroupOnCurve->SpinBox_DX->isValid(msg, !IsPreview());
755 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
756 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
757 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
760 case GEOM_POINT_INTINT:
761 ok = myLine1 && myLine2;
763 case GEOM_POINT_SURF:
764 if (myParamCoord->checkedId() == PARAM_VALUE)
765 ok = GroupOnSurface->SpinBox_DX->isValid(msg, !IsPreview()) &&
766 GroupOnSurface->SpinBox_DY->isValid(msg, !IsPreview());
768 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
769 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
770 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
779 //=================================================================================
780 // function : execute
782 //=================================================================================
783 bool BasicGUI_PointDlg::execute(ObjectList& objects)
787 GEOM::GEOM_Object_var anObj;
788 QStringList aParameters;
790 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow(getOperation());
792 switch (getConstructorId()) {
793 case GEOM_POINT_XYZ :
795 double x = GroupXYZ->SpinBox_DX->value();
796 double y = GroupXYZ->SpinBox_DY->value();
797 double z = GroupXYZ->SpinBox_DZ->value();
799 aParameters << GroupXYZ->SpinBox_DX->text();
800 aParameters << GroupXYZ->SpinBox_DY->text();
801 aParameters << GroupXYZ->SpinBox_DZ->text();
803 anObj = anOper->MakePointXYZ(x, y, z);
807 case GEOM_POINT_REF :
809 double dx = GroupRefPoint->SpinBox_DX->value();
810 double dy = GroupRefPoint->SpinBox_DY->value();
811 double dz = GroupRefPoint->SpinBox_DZ->value();
813 aParameters << GroupRefPoint->SpinBox_DX->text();
814 aParameters << GroupRefPoint->SpinBox_DY->text();
815 aParameters << GroupRefPoint->SpinBox_DZ->text();
817 anObj = anOper->MakePointWithReference(myRefPoint.get(), dx, dy, dz);
821 case GEOM_POINT_EDGE :
823 if (myParamCoord->checkedId() == PARAM_VALUE) {
824 anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter());
825 aParameters<<GroupOnCurve->SpinBox_DX->text();
827 else if (myParamCoord->checkedId() == LENGTH_VALUE) {
828 anObj = anOper->MakePointOnCurveByLength(myEdge.get(), getParameter(), myRefPoint.get());
829 aParameters<<GroupOnCurve->SpinBox_DX->text();
831 else if (myParamCoord->checkedId() == COORD_VALUE) {
832 double x = GroupXYZ->SpinBox_DX->value();
833 double y = GroupXYZ->SpinBox_DY->value();
834 double z = GroupXYZ->SpinBox_DZ->value();
836 aParameters << GroupXYZ->SpinBox_DX->text();
837 aParameters << GroupXYZ->SpinBox_DY->text();
838 aParameters << GroupXYZ->SpinBox_DZ->text();
840 anObj = anOper->MakePointOnCurveByCoord(myEdge.get(), x, y, z);
845 case GEOM_POINT_INTINT :
846 anObj = anOper->MakePointOnLinesIntersection(myLine1.get(), myLine2.get());
847 if (!anObj->_is_nil()) {
848 QString aName = getNewObjectName();
849 if (anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex"))
850 initName(tr("GEOM_COMPOUND"));
851 else if (anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound"))
852 initName(tr("GEOM_VERTEX"));
856 case GEOM_POINT_SURF :
858 if (myParamCoord->checkedId() == PARAM_VALUE) {
859 anObj = anOper->MakePointOnSurface(myFace.get(), getUParameter(), getVParameter());
860 aParameters<<GroupOnSurface->SpinBox_DX->text();
861 aParameters<<GroupOnSurface->SpinBox_DY->text();
863 double x = GroupXYZ->SpinBox_DX->value();
864 double y = GroupXYZ->SpinBox_DY->value();
865 double z = GroupXYZ->SpinBox_DZ->value();
867 aParameters << GroupXYZ->SpinBox_DX->text();
868 aParameters << GroupXYZ->SpinBox_DY->text();
869 aParameters << GroupXYZ->SpinBox_DZ->text();
871 anObj = anOper->MakePointOnSurfaceByCoord(myFace.get(), x, y, z);
878 const int id = getConstructorId();
879 if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ ||
880 id == GEOM_POINT_REF ||
881 id == GEOM_POINT_EDGE ||
882 id == GEOM_POINT_SURF)) {
883 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
886 if (id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF) {
888 if (GEOMBase::GetShape(anObj, aShape) && !aShape.IsNull() &&
889 aShape.ShapeType() == TopAbs_VERTEX) {
890 gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
891 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
892 int aPrecision = resMgr->integerValue("Geometry", "length_precision", 6);
893 myX->setText(DlgRef::PrintDoubleValue(aPnt.X(), aPrecision));
894 myY->setText(DlgRef::PrintDoubleValue(aPnt.Y(), aPrecision));
895 myZ->setText(DlgRef::PrintDoubleValue(aPnt.Z(), aPrecision));
904 if (!anObj->_is_nil()) {
905 objects.push_back(anObj._retn());
911 //=================================================================================
912 // function : addSubshapeToStudy
913 // purpose : virtual method to add new SubObjects if local selection
914 //=================================================================================
915 void BasicGUI_PointDlg::addSubshapesToStudy()
917 switch (getConstructorId()) {
919 GEOMBase::PublishSubObject(myRefPoint.get());
921 case GEOM_POINT_EDGE:
922 GEOMBase::PublishSubObject(myEdge.get());
924 case GEOM_POINT_INTINT:
925 GEOMBase::PublishSubObject(myLine1.get());
926 GEOMBase::PublishSubObject(myLine2.get());
928 case GEOM_POINT_SURF:
929 GEOMBase::PublishSubObject(myFace.get());
936 //=================================================================================
937 // function : getSourceObjects
938 // purpose : virtual method to get source objects
939 //=================================================================================
940 QList<GEOM::GeomObjPtr> BasicGUI_PointDlg::getSourceObjects()
942 QList<GEOM::GeomObjPtr> res;
943 res << myRefPoint << myEdge << myLine1 << myLine2 << myFace;
947 //=================================================================================
948 // function : ClickParamCoord()
950 //=================================================================================
951 void BasicGUI_PointDlg::ClickParamCoord(int id)
953 updateParamCoord(true);
954 displayPreview(true);
957 //=================================================================================
958 // function : updateParamCoord
960 //=================================================================================
961 void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
963 bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
964 bool isLength = myParamCoord->checkedId() == LENGTH_VALUE;
966 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
967 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
969 const int id = getConstructorId();
970 if (id == GEOM_POINT_EDGE) {
971 GroupOnCurve->TextLabel2->setVisible(isLength);
972 GroupOnCurve->PushButton2->setVisible(isLength);
973 GroupOnCurve->LineEdit2->setVisible(isLength);
974 GroupOnCurve->TextLabel3->setVisible(isParam || isLength);
975 GroupOnCurve->SpinBox_DX->setVisible(isParam || isLength);
977 initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
978 GroupOnCurve->SpinBox_DX->setValue(0.5);
979 GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
982 initSpinBox(GroupOnCurve->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
983 GroupOnCurve->SpinBox_DX->setValue(0.0);
984 GroupOnCurve->TextLabel3->setText(tr("GEOM_LENGTH"));
987 else if (id == GEOM_POINT_SURF) {
988 GroupOnSurface->TextLabel2->setShown(isParam);
989 GroupOnSurface->TextLabel3->setShown(isParam);
990 GroupOnSurface->SpinBox_DX->setShown(isParam);
991 GroupOnSurface->SpinBox_DY->setShown(isParam);
994 GroupXYZ->setShown(!isParam && !isLength);
997 QTimer::singleShot(50, this, SLOT(updateSize()));
1000 //=================================================================================
1001 // function : updateSize
1002 // purpose : adjust dialog size to minimum
1003 //=================================================================================
1004 void BasicGUI_PointDlg::updateSize()
1006 qApp->processEvents();
1008 resize(minimumSizeHint());