1 // Copyright (C) 2007-2016 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_2Sel1Spin2Check(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);
135 GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
136 GroupOnCurve->CheckButton1->setText(tr("GEOM_TAKE_ORIENTATION_INTO_ACCOUNT"));
137 GroupOnCurve->CheckButton2->setAttribute( Qt::WA_DeleteOnClose );
138 GroupOnCurve->CheckButton2->close();
140 GroupOnSurface = new DlgRef_1Sel2Spin(centralWidget());
141 GroupOnSurface->GroupBox1->setTitle(tr("GEOM_POINT_ON_FACE"));
142 GroupOnSurface->TextLabel1->setText(tr("GEOM_FACE"));
143 GroupOnSurface->TextLabel2->setText(tr("GEOM_UPARAMETER"));
144 GroupOnSurface->TextLabel3->setText(tr("GEOM_VPARAMETER"));
145 GroupOnSurface->PushButton1->setIcon(image2);
147 GroupRefPoint = new DlgRef_1Sel3Spin(centralWidget());
148 GroupRefPoint->GroupBox1->setTitle(tr("GEOM_REF_POINT"));
149 GroupRefPoint->TextLabel1->setText(tr("GEOM_POINT"));
150 GroupRefPoint->PushButton1->setIcon(image2);
151 GroupRefPoint->TextLabel2->setText(tr("GEOM_DX"));
152 GroupRefPoint->TextLabel3->setText(tr("GEOM_DY"));
153 GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ"));
155 /* popup menu for line intersect buttons */
156 QIcon ico_line = QIcon(image6);
157 QIcon ico_wire = QIcon(image7);
159 GroupLineIntersection = new DlgRef_2Sel(centralWidget());
160 GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION"));
161 GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1"));
162 GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2"));
163 GroupLineIntersection->PushButton1->setIcon(image2);
164 GroupLineIntersection->PushButton2->setIcon(image2);
165 GroupLineIntersection->LineEdit2->setEnabled(false);
167 myCoordGrp = new QGroupBox(tr("GEOM_COORDINATES_RES"), centralWidget());
168 QGridLayout* myCoordGrpLayout = new QGridLayout(myCoordGrp);
169 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_X"), myCoordGrp), 0, 0);
170 myX = new QLineEdit(myCoordGrp);
171 myCoordGrpLayout->addWidget(myX, 0, 1);
172 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Y"), myCoordGrp), 1, 0);
173 myY = new QLineEdit(myCoordGrp);
174 myCoordGrpLayout->addWidget(myY, 1, 1);
175 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Z"), myCoordGrp), 2, 0);
176 myZ = new QLineEdit(myCoordGrp);
177 myCoordGrpLayout->addWidget(myZ, 2, 1);
179 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
180 layout->setMargin(0); layout->setSpacing(6);
181 layout->addWidget(myParamGroup);
182 layout->addWidget(GroupXYZ);
183 layout->addWidget(GroupOnCurve);
184 layout->addWidget(GroupOnSurface);
185 layout->addWidget(GroupRefPoint);
186 layout->addWidget(GroupLineIntersection);
187 layout->addWidget(myCoordGrp);
189 myX->setReadOnly(true);
190 myY->setReadOnly(true);
191 myZ->setReadOnly(true);
193 myX->setEnabled(false);
194 myY->setEnabled(false);
195 myZ->setEnabled(false);
197 QPalette aPal = myX->palette();
198 aPal.setColor(QPalette::Disabled, QPalette::Text, QColor(0, 0, 0));
199 myX->setPalette(aPal);
200 myY->setPalette(aPal);
201 myZ->setPalette(aPal);
203 setHelpFileName("create_point_page.html");
209 //=================================================================================
210 // function : ~BasicGUI_PointDlg()
211 // purpose : Destructor
212 //=================================================================================
213 BasicGUI_PointDlg::~BasicGUI_PointDlg()
218 //=================================================================================
221 //=================================================================================
222 void BasicGUI_PointDlg::Init()
224 GroupOnCurve->LineEdit1->setReadOnly(true);
225 GroupOnCurve->LineEdit2->setReadOnly(true);
226 GroupOnSurface->LineEdit1->setReadOnly(true);
227 GroupRefPoint->LineEdit1->setReadOnly(true);
228 GroupLineIntersection->LineEdit1->setReadOnly(true);
229 GroupLineIntersection->LineEdit2->setReadOnly(true);
230 GroupLineIntersection->LineEdit1->setEnabled(true);
231 GroupLineIntersection->LineEdit2->setEnabled(false);
235 myRefPoint.nullify();
238 myNeedType = TopAbs_VERTEX;
240 myEditCurrentArgument = 0;
242 /* Get setting of step value from file configuration */
243 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
244 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
246 /* min, max, step and decimals for spin boxes */
247 initSpinBox(GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
248 initSpinBox(GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision");
249 initSpinBox(GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision");
250 GroupXYZ->SpinBox_DX->setValue(0.0);
251 GroupXYZ->SpinBox_DY->setValue(0.0);
252 GroupXYZ->SpinBox_DZ->setValue(0.0);
254 initSpinBox(GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
255 initSpinBox(GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision");
256 initSpinBox(GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision");
257 GroupRefPoint->SpinBox_DX->setValue(0.0);
258 GroupRefPoint->SpinBox_DY->setValue(0.0);
259 GroupRefPoint->SpinBox_DZ->setValue(0.0);
263 initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision");
264 GroupOnCurve->SpinBox_DX->setValue(0.5);
265 GroupOnCurve->CheckButton1->setChecked(true);
267 initSpinBox(GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision");
268 GroupOnSurface->SpinBox_DX->setValue(0.5);
269 initSpinBox(GroupOnSurface->SpinBox_DY, 0., 1., step, "parametric_precision");
270 GroupOnSurface->SpinBox_DY->setValue(0.5);
272 /* signals and slots connections */
273 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
274 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
276 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
277 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
279 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
281 connect(myParamCoord, SIGNAL(buttonClicked(int)), this, SLOT(ClickParamCoord(int)));
283 connect(GroupOnCurve->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CheckBoxClicked()));
285 connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
286 connect(GroupOnCurve->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
287 connect(GroupOnSurface->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
288 connect(GroupLineIntersection->PushButton1, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
289 connect(GroupLineIntersection->PushButton2, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
291 connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
292 connect(GroupOnSurface->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
293 connect(GroupOnSurface->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
294 connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
295 connect(GroupXYZ->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
296 connect(GroupXYZ->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
297 connect(GroupRefPoint->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
298 connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
299 connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
301 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
303 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
304 this, SLOT(SelectionIntoArgument()));
306 initName(tr("GEOM_VERTEX"));
308 ConstructorsClicked(0);
311 //=================================================================================
312 // function : SetDoubleSpinBoxStep()
313 // purpose : Double spin box management
314 //=================================================================================
315 void BasicGUI_PointDlg::SetDoubleSpinBoxStep(double step)
317 GroupOnCurve->SpinBox_DX->setSingleStep(step);
318 GroupXYZ->SpinBox_DX->setSingleStep(step);
319 GroupXYZ->SpinBox_DY->setSingleStep(step);
320 GroupXYZ->SpinBox_DZ->setSingleStep(step);
321 GroupRefPoint->SpinBox_DX->setSingleStep(step);
322 GroupRefPoint->SpinBox_DY->setSingleStep(step);
323 GroupRefPoint->SpinBox_DZ->setSingleStep(step);
327 //=================================================================================
328 // function : ConstructorsClicked()
329 // purpose : Radio button management
330 //=================================================================================
331 void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
333 switch (constructorId) {
336 globalSelection(); // close local contexts, if any
337 myNeedType = TopAbs_VERTEX;
338 localSelection(myNeedType);
340 GroupRefPoint->hide();
341 GroupOnCurve->hide();
342 GroupLineIntersection->hide();
343 GroupOnSurface->hide();
345 myParamGroup->hide();
351 globalSelection(); // close local contexts, if any
352 myNeedType = TopAbs_VERTEX;
353 localSelection(myNeedType);
355 myEditCurrentArgument = GroupRefPoint->LineEdit1;
356 myEditCurrentArgument->setText("");
357 myRefPoint.nullify();
358 GroupRefPoint->PushButton1->setDown(true);
359 myParamGroup->hide();
361 GroupOnCurve->hide();
362 GroupLineIntersection->hide();
363 GroupOnSurface->hide();
364 GroupRefPoint->show();
368 case GEOM_POINT_EDGE:
370 globalSelection(); // close local contexts, if any
371 myNeedType = TopAbs_EDGE;
372 localSelection(myNeedType);
374 myEditCurrentArgument = GroupOnCurve->LineEdit1;
375 myEditCurrentArgument->setText("");
377 myRefPoint.nullify();
378 GroupOnCurve->PushButton1->setDown(true);
379 GroupRefPoint->hide();
380 GroupLineIntersection->hide();
381 GroupOnSurface->hide();
382 myParamGroup->show();
383 myParamCoord->button(LENGTH_VALUE)->show();
384 myParamCoord->button(PARAM_VALUE)->setChecked(true);
385 GroupOnCurve->show();
387 updateParamCoord(false);
390 case GEOM_POINT_INTINT:
392 globalSelection(); // close local contexts, if any
393 std::list<int> needTypes;
394 needTypes.push_back( TopAbs_EDGE ), needTypes.push_back( TopAbs_WIRE );
395 localSelection(needTypes );
397 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
398 GroupLineIntersection->LineEdit1->setText("");
399 GroupLineIntersection->LineEdit2->setText("");
400 GroupLineIntersection->LineEdit1->setEnabled(true);
401 GroupLineIntersection->LineEdit2->setEnabled(false);
404 GroupLineIntersection->PushButton1->setDown(true);
405 GroupLineIntersection->PushButton2->setDown(false);
406 myParamGroup->hide();
408 GroupRefPoint->hide();
409 GroupOnCurve->hide();
410 GroupOnSurface->hide();
412 GroupLineIntersection->show();
415 case GEOM_POINT_SURF:
417 globalSelection(); // close local contexts, if any
418 myNeedType = TopAbs_FACE;
419 localSelection(myNeedType);
421 myEditCurrentArgument = GroupOnSurface->LineEdit1;
422 myEditCurrentArgument->setText("");
424 GroupOnSurface->PushButton1->setDown(true);
425 GroupRefPoint->hide();
426 GroupOnCurve->hide();
427 GroupLineIntersection->hide();
428 myParamGroup->show();
429 myParamCoord->button(LENGTH_VALUE)->hide();
430 myParamCoord->button(PARAM_VALUE)->setChecked(true);
431 GroupOnSurface->show();
433 updateParamCoord(false);
442 QTimer::singleShot(50, this, SLOT(updateSize()));
444 SelectionIntoArgument();
447 //=================================================================================
448 // function : ClickOnOk()
450 //=================================================================================
451 void BasicGUI_PointDlg::ClickOnOk()
453 setIsApplyAndClose(true);
458 //=================================================================================
459 // function : ClickOnApply()
461 //=================================================================================
462 bool BasicGUI_PointDlg::ClickOnApply()
468 ConstructorsClicked(getConstructorId());
473 //=================================================================================
474 // function : SelectionIntoArgument()
475 // purpose : Called when selection as changed (for constructors not using local context)
476 //=================================================================================
477 void BasicGUI_PointDlg::SelectionIntoArgument()
480 const int id = getConstructorId();
482 if ((id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF)
483 && myEditCurrentArgument != 0)
485 myEditCurrentArgument->setText("");
490 if (myEditCurrentArgument == GroupOnCurve->LineEdit1)
492 else if (myEditCurrentArgument == GroupOnCurve->LineEdit2)
493 myRefPoint.nullify();
495 else if (id == GEOM_POINT_INTINT) {
496 myEditCurrentArgument->setText("");
497 if (myEditCurrentArgument == GroupLineIntersection->LineEdit1)
499 else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2)
503 GEOM::GeomObjPtr aSelectedObject;
504 if (id == GEOM_POINT_INTINT) {
505 QList<TopAbs_ShapeEnum> needTypes;
506 needTypes << TopAbs_EDGE, needTypes << TopAbs_WIRE;
507 aSelectedObject= getSelected(needTypes);
510 aSelectedObject= getSelected(myNeedType);
512 if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) {
513 QString aName = GEOMBase::GetName(aSelectedObject.get());
515 if (id == GEOM_POINT_XYZ) {
516 gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
517 GroupXYZ->SpinBox_DX->setValue(aPnt.X());
518 GroupXYZ->SpinBox_DY->setValue(aPnt.Y());
519 GroupXYZ->SpinBox_DZ->setValue(aPnt.Z());
521 else if (id == GEOM_POINT_REF) {
522 myRefPoint = aSelectedObject;
523 GroupRefPoint->LineEdit1->setText(aName);
525 else if (id == GEOM_POINT_EDGE) {
526 myEditCurrentArgument->setText(aName);
527 if (myEditCurrentArgument == GroupOnCurve->LineEdit1) {
528 myEdge = aSelectedObject;
529 if (myEdge && !myRefPoint) {
530 GroupOnCurve->PushButton2->click();
533 else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) {
534 myRefPoint = aSelectedObject;
535 if (myRefPoint && !myEdge) {
536 GroupOnCurve->PushButton1->click();
540 else if (id == GEOM_POINT_INTINT) {
541 myEditCurrentArgument->setText(aName);
542 if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) {
543 myLine1 = aSelectedObject;
544 if (myLine1 && !myLine2) {
545 GroupLineIntersection->PushButton2->click();
548 else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) {
549 myLine2 = aSelectedObject;
550 if (myLine2 && !myLine1) {
551 GroupLineIntersection->PushButton1->click();
555 else if (id == GEOM_POINT_SURF) {
556 myFace = aSelectedObject;
557 GroupOnSurface->LineEdit1->setText(aName);
562 displayPreview(true);
566 //=================================================================================
567 // function : SetEditCurrentArgument()
569 //=================================================================================
570 void BasicGUI_PointDlg::SetEditCurrentArgument()
572 QPushButton* send = (QPushButton*)sender();
574 if (send == GroupRefPoint->PushButton1) {
575 GroupRefPoint->LineEdit1->setFocus();
576 myEditCurrentArgument = GroupRefPoint->LineEdit1;
577 globalSelection(); // close local contexts, if any
578 localSelection(TopAbs_VERTEX);
580 else if (send == GroupOnCurve->PushButton1) {
581 GroupOnCurve->LineEdit1->setFocus();
582 myEditCurrentArgument = GroupOnCurve->LineEdit1;
583 globalSelection(); // close local contexts, if any
584 myNeedType = TopAbs_EDGE;
585 localSelection(myNeedType);
586 GroupOnCurve->PushButton2->setDown(false);
587 GroupOnCurve->LineEdit1->setEnabled(true);
588 GroupOnCurve->LineEdit2->setEnabled(false);
590 else if (send == GroupOnCurve->PushButton2) {
591 GroupOnCurve->LineEdit2->setFocus();
592 myEditCurrentArgument = GroupOnCurve->LineEdit2;
593 globalSelection(); // close local contexts, if any
594 myNeedType = TopAbs_VERTEX;
595 localSelection(myNeedType);
596 GroupOnCurve->PushButton1->setDown(false);
597 GroupOnCurve->LineEdit2->setEnabled(true);
598 GroupOnCurve->LineEdit1->setEnabled(false);
600 else if (send == GroupOnSurface->PushButton1)
602 GroupOnSurface->LineEdit1->setFocus();
603 myEditCurrentArgument = GroupOnSurface->LineEdit1;
604 globalSelection(); // close local contexts, if any
605 localSelection(TopAbs_FACE);
607 else if (send == GroupLineIntersection->PushButton1) {
608 GroupLineIntersection->LineEdit1->setFocus();
609 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
610 GroupLineIntersection->PushButton2->setDown(false);
611 GroupLineIntersection->LineEdit1->setEnabled(true);
612 GroupLineIntersection->LineEdit2->setEnabled(false);
614 else if (send == GroupLineIntersection->PushButton2) {
615 GroupLineIntersection->LineEdit2->setFocus();
616 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
617 GroupLineIntersection->PushButton1->setDown(false);
618 GroupLineIntersection->LineEdit1->setEnabled(false);
619 GroupLineIntersection->LineEdit2->setEnabled(true);
623 // if ((send == GroupLineIntersection->PushButton1 ||
624 // send == GroupLineIntersection->PushButton2) && !myBusy)
625 // SelectionIntoArgument();
629 //=================================================================================
630 // function : enterEvent()
631 // purpose : to reactivate this dialog box when mouse enter onto the window
632 //=================================================================================
633 void BasicGUI_PointDlg::enterEvent(QEvent*)
635 if (!mainFrame()->GroupConstructors->isEnabled())
636 ActivateThisDialog();
640 //=================================================================================
641 // function : ActivateThisDialog()
643 //=================================================================================
644 void BasicGUI_PointDlg::ActivateThisDialog()
646 GEOMBase_Skeleton::ActivateThisDialog();
648 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
649 this, SLOT(SelectionIntoArgument()));
651 ConstructorsClicked(getConstructorId());
655 //=================================================================================
656 // function : DeactivateActiveDialog()
657 // purpose : public slot to deactivate if active
658 //=================================================================================
659 void BasicGUI_PointDlg::DeactivateActiveDialog()
661 // myGeomGUI->SetState(-1);
662 GEOMBase_Skeleton::DeactivateActiveDialog();
666 //=================================================================================
667 // function : ValueChangedInSpinBox()
669 //=================================================================================
670 void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
672 displayPreview(true);
675 //=================================================================================
676 // function : CheckBoxClicked()
677 // purpose : Check Boxes Management
678 //=================================================================================
679 void BasicGUI_PointDlg::CheckBoxClicked()
681 displayPreview(true);
685 //=================================================================================
686 // function : getParameter()
688 //=================================================================================
689 double BasicGUI_PointDlg::getParameter() const
691 return GroupOnCurve->SpinBox_DX->value();
695 //=================================================================================
696 // function : getUParameter()
698 //=================================================================================
699 double BasicGUI_PointDlg::getUParameter() const
701 return GroupOnSurface->SpinBox_DX->value();
705 //=================================================================================
706 // function : getVParameter()
708 //=================================================================================
709 double BasicGUI_PointDlg::getVParameter() const
711 return GroupOnSurface->SpinBox_DY->value();
715 //=================================================================================
716 // function : OnPointSelected
718 //=================================================================================
719 void BasicGUI_PointDlg::OnPointSelected(const gp_Pnt& thePnt)
721 if (getConstructorId() == GEOM_POINT_XYZ) {
722 GroupXYZ->SpinBox_DX->setValue(thePnt.X());
723 GroupXYZ->SpinBox_DY->setValue(thePnt.Y());
724 GroupXYZ->SpinBox_DZ->setValue(thePnt.Z());
726 displayPreview(true);
730 //=================================================================================
731 // function : createOperation
733 //=================================================================================
734 GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
736 return myGeomGUI->GetGeomGen()->GetIBasicOperations();
739 //=================================================================================
740 // function : isValid
742 //=================================================================================
743 bool BasicGUI_PointDlg::isValid(QString& msg)
746 switch (getConstructorId()) {
747 case GEOM_POINT_XYZ :
748 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
749 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
750 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
753 ok = GroupRefPoint->SpinBox_DX->isValid(msg, !IsPreview()) &&
754 GroupRefPoint->SpinBox_DY->isValid(msg, !IsPreview()) &&
755 GroupRefPoint->SpinBox_DZ->isValid(msg, !IsPreview()) &&
758 case GEOM_POINT_EDGE:
759 if (myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE)
760 ok = GroupOnCurve->SpinBox_DX->isValid(msg, !IsPreview());
762 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
763 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
764 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
767 case GEOM_POINT_INTINT:
768 ok = myLine1 && myLine2;
770 case GEOM_POINT_SURF:
771 if (myParamCoord->checkedId() == PARAM_VALUE)
772 ok = GroupOnSurface->SpinBox_DX->isValid(msg, !IsPreview()) &&
773 GroupOnSurface->SpinBox_DY->isValid(msg, !IsPreview());
775 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
776 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
777 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
786 //=================================================================================
787 // function : execute
789 //=================================================================================
790 bool BasicGUI_PointDlg::execute(ObjectList& objects)
794 GEOM::GEOM_Object_var anObj;
795 QStringList aParameters;
797 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow(getOperation());
799 switch (getConstructorId()) {
800 case GEOM_POINT_XYZ :
802 double x = GroupXYZ->SpinBox_DX->value();
803 double y = GroupXYZ->SpinBox_DY->value();
804 double z = GroupXYZ->SpinBox_DZ->value();
806 aParameters << GroupXYZ->SpinBox_DX->text();
807 aParameters << GroupXYZ->SpinBox_DY->text();
808 aParameters << GroupXYZ->SpinBox_DZ->text();
810 anObj = anOper->MakePointXYZ(x, y, z);
814 case GEOM_POINT_REF :
816 double dx = GroupRefPoint->SpinBox_DX->value();
817 double dy = GroupRefPoint->SpinBox_DY->value();
818 double dz = GroupRefPoint->SpinBox_DZ->value();
820 aParameters << GroupRefPoint->SpinBox_DX->text();
821 aParameters << GroupRefPoint->SpinBox_DY->text();
822 aParameters << GroupRefPoint->SpinBox_DZ->text();
824 anObj = anOper->MakePointWithReference(myRefPoint.get(), dx, dy, dz);
828 case GEOM_POINT_EDGE :
830 if (myParamCoord->checkedId() == PARAM_VALUE) {
831 bool isUseOrientation = GroupOnCurve->CheckButton1->isChecked();
833 anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter(), isUseOrientation);
834 aParameters<<GroupOnCurve->SpinBox_DX->text();
836 else if (myParamCoord->checkedId() == LENGTH_VALUE) {
837 anObj = anOper->MakePointOnCurveByLength(myEdge.get(), getParameter(), myRefPoint.get());
838 aParameters<<GroupOnCurve->SpinBox_DX->text();
840 else if (myParamCoord->checkedId() == COORD_VALUE) {
841 double x = GroupXYZ->SpinBox_DX->value();
842 double y = GroupXYZ->SpinBox_DY->value();
843 double z = GroupXYZ->SpinBox_DZ->value();
845 aParameters << GroupXYZ->SpinBox_DX->text();
846 aParameters << GroupXYZ->SpinBox_DY->text();
847 aParameters << GroupXYZ->SpinBox_DZ->text();
849 anObj = anOper->MakePointOnCurveByCoord(myEdge.get(), x, y, z);
854 case GEOM_POINT_INTINT :
855 anObj = anOper->MakePointOnLinesIntersection(myLine1.get(), myLine2.get());
856 if (!anObj->_is_nil()) {
857 QString aName = getNewObjectName();
858 if (anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex"))
859 initName(tr("GEOM_COMPOUND"));
860 else if (anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound"))
861 initName(tr("GEOM_VERTEX"));
865 case GEOM_POINT_SURF :
867 if (myParamCoord->checkedId() == PARAM_VALUE) {
868 anObj = anOper->MakePointOnSurface(myFace.get(), getUParameter(), getVParameter());
869 aParameters<<GroupOnSurface->SpinBox_DX->text();
870 aParameters<<GroupOnSurface->SpinBox_DY->text();
872 double x = GroupXYZ->SpinBox_DX->value();
873 double y = GroupXYZ->SpinBox_DY->value();
874 double z = GroupXYZ->SpinBox_DZ->value();
876 aParameters << GroupXYZ->SpinBox_DX->text();
877 aParameters << GroupXYZ->SpinBox_DY->text();
878 aParameters << GroupXYZ->SpinBox_DZ->text();
880 anObj = anOper->MakePointOnSurfaceByCoord(myFace.get(), x, y, z);
887 const int id = getConstructorId();
888 if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ ||
889 id == GEOM_POINT_REF ||
890 id == GEOM_POINT_EDGE ||
891 id == GEOM_POINT_SURF)) {
892 anObj->SetParameters(aParameters.join(":").toUtf8().constData());
895 if (id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF) {
897 if (GEOMBase::GetShape(anObj, aShape) && !aShape.IsNull() &&
898 aShape.ShapeType() == TopAbs_VERTEX) {
899 gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
900 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
901 int aPrecision = resMgr->integerValue("Geometry", "length_precision", 6);
902 myX->setText(DlgRef::PrintDoubleValue(aPnt.X(), aPrecision));
903 myY->setText(DlgRef::PrintDoubleValue(aPnt.Y(), aPrecision));
904 myZ->setText(DlgRef::PrintDoubleValue(aPnt.Z(), aPrecision));
913 if (!anObj->_is_nil()) {
914 objects.push_back(anObj._retn());
920 //=================================================================================
921 // function : addSubshapeToStudy
922 // purpose : virtual method to add new SubObjects if local selection
923 //=================================================================================
924 void BasicGUI_PointDlg::addSubshapesToStudy()
926 switch (getConstructorId()) {
928 GEOMBase::PublishSubObject(myRefPoint.get());
930 case GEOM_POINT_EDGE:
931 GEOMBase::PublishSubObject(myEdge.get());
933 case GEOM_POINT_INTINT:
934 GEOMBase::PublishSubObject(myLine1.get());
935 GEOMBase::PublishSubObject(myLine2.get());
937 case GEOM_POINT_SURF:
938 GEOMBase::PublishSubObject(myFace.get());
945 //=================================================================================
946 // function : getSourceObjects
947 // purpose : virtual method to get source objects
948 //=================================================================================
949 QList<GEOM::GeomObjPtr> BasicGUI_PointDlg::getSourceObjects()
951 QList<GEOM::GeomObjPtr> res;
952 res << myRefPoint << myEdge << myLine1 << myLine2 << myFace;
956 //=================================================================================
957 // function : ClickParamCoord()
959 //=================================================================================
960 void BasicGUI_PointDlg::ClickParamCoord(int id)
962 updateParamCoord(true);
963 displayPreview(true);
966 //=================================================================================
967 // function : updateParamCoord
969 //=================================================================================
970 void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
972 bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
973 bool isLength = myParamCoord->checkedId() == LENGTH_VALUE;
975 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
976 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
978 const int id = getConstructorId();
979 if (id == GEOM_POINT_EDGE) {
980 GroupOnCurve->TextLabel2->setVisible(isLength);
981 GroupOnCurve->PushButton2->setVisible(isLength);
982 GroupOnCurve->LineEdit2->setVisible(isLength);
983 GroupOnCurve->TextLabel3->setVisible(isParam || isLength);
984 GroupOnCurve->SpinBox_DX->setVisible(isParam || isLength);
985 GroupOnCurve->CheckButton1->setVisible(isParam);
987 initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
988 GroupOnCurve->SpinBox_DX->setValue(0.5);
989 GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
992 initSpinBox(GroupOnCurve->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
993 GroupOnCurve->SpinBox_DX->setValue(0.0);
994 GroupOnCurve->TextLabel3->setText(tr("GEOM_LENGTH"));
997 else if (id == GEOM_POINT_SURF) {
998 GroupOnSurface->TextLabel2->setVisible(isParam);
999 GroupOnSurface->TextLabel3->setVisible(isParam);
1000 GroupOnSurface->SpinBox_DX->setVisible(isParam);
1001 GroupOnSurface->SpinBox_DY->setVisible(isParam);
1004 GroupXYZ->setVisible(!isParam && !isLength);
1007 QTimer::singleShot(50, this, SLOT(updateSize()));
1010 //=================================================================================
1011 // function : updateSize
1012 // purpose : adjust dialog size to minimum
1013 //=================================================================================
1014 void BasicGUI_PointDlg::updateSize()
1016 qApp->processEvents();
1018 resize(minimumSizeHint());