1 // Copyright (C) 2009-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MyBasicGUI_PointDlg.hxx"
22 #include <SUIT_ResourceMgr.h>
23 #include <SUIT_Session.h>
24 #include <SalomeApp_Application.h>
25 #include <LightApp_SelectionMgr.h>
27 #include <GeometryGUI.h>
30 #include "MyDlgRef.hxx"
32 #include <GEOMImpl_Types.hxx>
34 #include <QApplication>
35 #include <QButtonGroup>
36 #include <QHBoxLayout>
38 #include <QRadioButton>
43 #include <TopoDS_Shape.hxx>
44 #include <TopAbs_ShapeEnum.hxx>
46 #include <BRep_Tool.hxx>
48 #include <TColStd_IndexedMapOfInteger.hxx>
49 #include <TopTools_IndexedMapOfShape.hxx>
52 #include <VTKViewer_ViewModel.h>
53 #include <SUIT_MessageBox.h>
54 #include <SUIT_OverrideCursor.h>
55 #include <SalomeApp_Tools.h>
56 #include <SalomeApp_Study.h>
58 #include "HEXABLOCKGUI_DocumentModel.hxx"
59 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
60 #include "HEXABLOCKGUI_DocumentItem.hxx"
61 #include "HEXABLOCKGUI_SalomeTools.hxx"
62 #include "HEXABLOCKGUI.hxx"
66 #define LENGTH_VALUE 2
68 #define GEOM_POINT_XYZ 0
69 #define GEOM_POINT_REF 1
70 #define GEOM_POINT_EDGE 2
71 #define GEOM_POINT_INTINT 3
72 #define GEOM_POINT_SURF 4
77 using namespace HEXABLOCK::GUI;
79 Q_DECLARE_METATYPE(QModelIndex);
80 Q_DECLARE_METATYPE(HEXABLOCK::GUI::HexaTreeRole);
82 enum { SelectEdge, SelectWire };
84 //=================================================================================
85 // class : MyBasicGUI_PointDlg()
86 // purpose : Constructs a MyBasicGUI_PointDlg which is a child of 'parent', with the
87 // name 'name' and widget flags set to 'f'.
88 // The dialog will by default be modeless, unless you set 'modal' to
89 // TRUE to construct a modal dialog.
90 //=================================================================================
91 MyBasicGUI_PointDlg::MyBasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
92 bool modal, Qt::WindowFlags fl)
93 : MyGEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
96 _patternDataSelectionModel(0),
101 _selectionMutex(false)
103 QWidget* w = centralWidget();
104 QString objectName = w->objectName();
105 QString className = w->metaObject()->className();
106 MESSAGE("* centralWidget() " << w );
107 MESSAGE("* centralWidget()->objectName() is "<< objectName.toStdString() ); //toStdString()
108 MESSAGE("* centralWidget()->metaObject()->className() is "<< className.toStdString() );
110 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
111 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT")));
112 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_EDGE")));
113 QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
114 QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_REF")));
115 QPixmap image4 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_LINES")));
116 QPixmap image5 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POINT_FACE")));
117 QPixmap image6 (aResMgr->loadPixmap("GEOM", tr("ICO_LINE")));
118 QPixmap image7 (aResMgr->loadPixmap("GEOM", tr("ICO_WIRE")));
120 // setWindowTitle(tr("GEOM_POINT_TITLE"));
121 setWindowTitle( tr("Vertex Association") );
122 setMinimumWidth(260);
127 mainFrame()->GroupConstructors->setTitle(tr("GEOM_POINTS"));
128 mainFrame()->RadioButton1->setIcon(image0);
129 mainFrame()->RadioButton2->setIcon(image3);
130 mainFrame()->RadioButton3->setIcon(image1);
131 mainFrame()->RadioButton4->show();
132 mainFrame()->RadioButton4->setIcon(image4);
133 mainFrame()->RadioButton5->show();
134 mainFrame()->RadioButton5->setIcon(image5);
136 myParamGroup = new QGroupBox(centralWidget());
137 myParamCoord = new QButtonGroup(myParamGroup);
138 QHBoxLayout* boxLayout = new QHBoxLayout(myParamGroup);
139 boxLayout->setMargin(MARGIN); boxLayout->setSpacing(SPACING);
140 QRadioButton* btn = new QRadioButton(tr("GEOM_PARAM_VALUE"), myParamGroup);
141 myParamCoord->addButton(btn, PARAM_VALUE);
142 boxLayout->addWidget(btn);
143 btn = new QRadioButton(tr("GEOM_LENGTH_VALUE"), myParamGroup);
144 myParamCoord->addButton(btn, LENGTH_VALUE);
145 boxLayout->addWidget(btn);
146 btn = new QRadioButton(tr("GEOM_COORD_VALUE"), myParamGroup);
147 myParamCoord->addButton(btn, COORD_VALUE);
148 boxLayout->addWidget(btn);
149 myParamCoord->setExclusive(true);
150 myParamCoord->button(PARAM_VALUE)->setChecked(true);
152 GroupXYZ = new DlgRef_3Spin(centralWidget());
153 GroupXYZ->GroupBox1->setTitle(tr("GEOM_COORDINATES"));
154 GroupXYZ->TextLabel1->setText(tr("GEOM_X"));
155 GroupXYZ->TextLabel2->setText(tr("GEOM_Y"));
156 GroupXYZ->TextLabel3->setText(tr("GEOM_Z"));
158 GroupOnCurve = new DlgRef_2Sel1Spin(centralWidget());
159 GroupOnCurve->GroupBox1->setTitle(tr("GEOM_POINT_ON_EDGE"));
160 GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE"));
161 GroupOnCurve->TextLabel2->setText(tr("GEOM_START_POINT"));
162 GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
163 GroupOnCurve->PushButton1->setIcon(image2);
164 GroupOnCurve->PushButton2->setIcon(image2);
166 GroupOnSurface = new DlgRef_1Sel2Spin(centralWidget());
167 GroupOnSurface->GroupBox1->setTitle(tr("GEOM_POINT_ON_FACE"));
168 GroupOnSurface->TextLabel1->setText(tr("GEOM_FACE"));
169 GroupOnSurface->TextLabel2->setText(tr("GEOM_UPARAMETER"));
170 GroupOnSurface->TextLabel3->setText(tr("GEOM_VPARAMETER"));
171 GroupOnSurface->PushButton1->setIcon(image2);
173 GroupRefPoint = new DlgRef_1Sel3Spin(centralWidget());
174 GroupRefPoint->GroupBox1->setTitle(tr("GEOM_REF_POINT"));
175 GroupRefPoint->TextLabel1->setText(tr("GEOM_POINT"));
176 GroupRefPoint->PushButton1->setIcon(image2);
177 GroupRefPoint->TextLabel2->setText(tr("GEOM_DX"));
178 GroupRefPoint->TextLabel3->setText(tr("GEOM_DY"));
179 GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ"));
181 /* popup menu for line intersect buttons */
182 myBtnPopup = new QMenu(this);
183 QIcon ico_line = QIcon(image6);
184 QIcon ico_wire = QIcon(image7);
185 myActions[myBtnPopup->addAction(ico_line, tr("GEOM_EDGE"))] = SelectEdge;
186 myActions[myBtnPopup->addAction(ico_wire, tr("GEOM_WIRE"))] = SelectWire;
188 GroupLineIntersection = new DlgRef_2Sel(centralWidget());
189 GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION"));
190 GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1"));
191 GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2"));
192 GroupLineIntersection->PushButton1->setIcon(image2);
193 GroupLineIntersection->PushButton1->setMenu(myBtnPopup);
194 GroupLineIntersection->PushButton2->setIcon(image2);
195 GroupLineIntersection->PushButton2->setMenu(myBtnPopup);
196 GroupLineIntersection->LineEdit2->setEnabled(false);
198 myCoordGrp = new QGroupBox(tr("GEOM_COORDINATES_RES"), centralWidget());
199 QGridLayout* myCoordGrpLayout = new QGridLayout(myCoordGrp);
200 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_X"), myCoordGrp), 0, 0);
201 myX = new QLineEdit(myCoordGrp);
202 myCoordGrpLayout->addWidget(myX, 0, 1);
203 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Y"), myCoordGrp), 1, 0);
204 myY = new QLineEdit(myCoordGrp);
205 myCoordGrpLayout->addWidget(myY, 1, 1);
206 myCoordGrpLayout->addWidget(new QLabel(tr("GEOM_Z"), myCoordGrp), 2, 0);
207 myZ = new QLineEdit(myCoordGrp);
208 myCoordGrpLayout->addWidget(myZ, 2, 1);
210 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
211 layout->setMargin(0); layout->setSpacing(6);
212 layout->addWidget(myParamGroup);
213 layout->addWidget(GroupXYZ);
214 layout->addWidget(GroupOnCurve);
215 layout->addWidget(GroupOnSurface);
216 layout->addWidget(GroupRefPoint);
217 layout->addWidget(GroupLineIntersection);
218 layout->addWidget(myCoordGrp);
221 myX->setReadOnly(true);
222 myY->setReadOnly(true);
223 myZ->setReadOnly(true);
225 myX->setEnabled(false);
226 myY->setEnabled(false);
227 myZ->setEnabled(false);
229 QPalette aPal = myX->palette();
230 aPal.setColor(QPalette::Disabled, QPalette::Text, QColor(0, 0, 0));
231 myX->setPalette(aPal);
232 myY->setPalette(aPal);
233 myZ->setPalette(aPal);
235 setHelpFileName("gui_asso_quad_to_geom.html#associate-to-a-vertex-of-the-geometry");/*"create_point_page.html"*/
246 //=================================================================================
247 // function : ~MyBasicGUI_PointDlg()
248 // purpose : Destructor
249 //=================================================================================
250 MyBasicGUI_PointDlg::~MyBasicGUI_PointDlg()
258 //=================================================================================
261 //=================================================================================
262 void MyBasicGUI_PointDlg::Init()
264 MESSAGE("MyBasicGUI_PointDlg::Init() ");
266 GroupOnCurve->LineEdit1->setReadOnly(true);
267 GroupOnCurve->LineEdit2->setReadOnly(true);
268 GroupOnSurface->LineEdit1->setReadOnly(true);
269 GroupRefPoint->LineEdit1->setReadOnly(true);
270 GroupLineIntersection->LineEdit1->setReadOnly(true);
271 GroupLineIntersection->LineEdit2->setReadOnly(true);
272 GroupLineIntersection->LineEdit1->setEnabled(true);
273 GroupLineIntersection->LineEdit2->setEnabled(false);
277 myRefPoint.nullify();
280 myNeedType = TopAbs_VERTEX;
282 myEditCurrentArgument = 0;
284 /* Get setting of step value from file configuration */
285 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
286 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
288 /* min, max, step and decimals for spin boxes */
289 initSpinBox(GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
290 initSpinBox(GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision");
291 initSpinBox(GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision");
292 GroupXYZ->SpinBox_DX->setValue(0.0);
293 GroupXYZ->SpinBox_DY->setValue(0.0);
294 GroupXYZ->SpinBox_DZ->setValue(0.0);
296 initSpinBox(GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
297 initSpinBox(GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision");
298 initSpinBox(GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision");
299 GroupRefPoint->SpinBox_DX->setValue(0.0);
300 GroupRefPoint->SpinBox_DY->setValue(0.0);
301 GroupRefPoint->SpinBox_DZ->setValue(0.0);
305 initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision");
306 GroupOnCurve->SpinBox_DX->setValue(0.5);
308 initSpinBox(GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision");
309 GroupOnSurface->SpinBox_DX->setValue(0.5);
310 initSpinBox(GroupOnSurface->SpinBox_DY, 0., 1., step, "parametric_precision");
311 GroupOnSurface->SpinBox_DY->setValue(0.5);
313 MESSAGE("MyBasicGUI_PointDlg::Init() : myGeomGUI " << myGeomGUI);
314 /* signals and slots connections */
316 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
317 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
319 //connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
320 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
322 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
324 connect(myParamCoord, SIGNAL(buttonClicked(int)), this, SLOT(ClickParamCoord(int)));
326 connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
327 connect(GroupOnCurve->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
328 connect(GroupOnSurface->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
329 connect(GroupLineIntersection->PushButton1, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
330 connect(GroupLineIntersection->PushButton2, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
332 connect(myBtnPopup, SIGNAL(triggered(QAction*)), this, SLOT(onBtnPopup(QAction*)));
334 connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
335 connect(GroupOnSurface->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
336 connect(GroupOnSurface->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
337 connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
338 connect(GroupXYZ->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
339 connect(GroupXYZ->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
340 connect(GroupRefPoint->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
341 connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
342 connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
345 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
347 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
348 this, SLOT(SelectionIntoArgument()));
351 initName(tr("GEOM_VERTEX"));
353 ConstructorsClicked(0);
356 //=================================================================================
357 // function : SetDoubleSpinBoxStep()
358 // purpose : Double spin box management
359 //=================================================================================
360 void MyBasicGUI_PointDlg::SetDoubleSpinBoxStep(double step)
362 GroupOnCurve->SpinBox_DX->setSingleStep(step);
363 GroupXYZ->SpinBox_DX->setSingleStep(step);
364 GroupXYZ->SpinBox_DY->setSingleStep(step);
365 GroupXYZ->SpinBox_DZ->setSingleStep(step);
366 GroupRefPoint->SpinBox_DX->setSingleStep(step);
367 GroupRefPoint->SpinBox_DY->setSingleStep(step);
368 GroupRefPoint->SpinBox_DZ->setSingleStep(step);
372 //=================================================================================
373 // function : ConstructorsClicked()
374 // purpose : Radio button management
375 //=================================================================================
376 void MyBasicGUI_PointDlg::ConstructorsClicked(int constructorId)
378 // HEXABLOCKGUI::currentOccView->raise();
379 // HEXABLOCKGUI::currentOccView->setFocus();
380 MESSAGE("MyBasicGUI_PointDlg::ConstructorsClicked("<< constructorId << ")");
381 switch (constructorId) {
384 globalSelection(); // close local contexts, if any
385 myNeedType = TopAbs_VERTEX;
386 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
388 GroupRefPoint->hide();
389 GroupOnCurve->hide();
390 GroupLineIntersection->hide();
391 GroupOnSurface->hide();
393 myParamGroup->hide();
399 globalSelection(); // close local contexts, if any
400 myNeedType = TopAbs_VERTEX;
401 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
403 myEditCurrentArgument = GroupRefPoint->LineEdit1;
404 //myEditCurrentArgument->setText("");
405 //myRefPoint.nullify();
406 GroupRefPoint->PushButton1->setDown(true);
407 myParamGroup->hide();
409 GroupOnCurve->hide();
410 GroupLineIntersection->hide();
411 GroupOnSurface->hide();
412 GroupRefPoint->show();
416 case GEOM_POINT_EDGE:
418 globalSelection(); // close local contexts, if any
419 myNeedType = TopAbs_EDGE;
420 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
422 myEditCurrentArgument = GroupOnCurve->LineEdit1;
423 // myEditCurrentArgument->setText("");
425 // myRefPoint.nullify();
426 GroupOnCurve->PushButton1->setDown(true);
427 GroupRefPoint->hide();
428 GroupLineIntersection->hide();
429 GroupOnSurface->hide();
430 myParamGroup->show();
431 myParamCoord->button(LENGTH_VALUE)->show();
432 myParamCoord->button(PARAM_VALUE)->setChecked(true);
433 GroupOnCurve->show();
435 updateParamCoord(false);
438 case GEOM_POINT_INTINT:
440 globalSelection(); // close local contexts, if any
441 myNeedType = TopAbs_EDGE;
442 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
444 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
445 // GroupLineIntersection->LineEdit1->setText("");
446 // GroupLineIntersection->LineEdit2->setText("");
447 GroupLineIntersection->LineEdit1->setEnabled(true);
448 GroupLineIntersection->LineEdit2->setEnabled(false);
449 // myLine1.nullify();
450 // myLine2.nullify();
451 GroupLineIntersection->PushButton1->setDown(true);
452 GroupLineIntersection->PushButton2->setDown(false);
453 myParamGroup->hide();
455 GroupRefPoint->hide();
456 GroupOnCurve->hide();
457 GroupOnSurface->hide();
459 GroupLineIntersection->show();
462 case GEOM_POINT_SURF:
464 globalSelection(); // close local contexts, if any
465 myNeedType = TopAbs_FACE;
466 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
468 myEditCurrentArgument = GroupOnSurface->LineEdit1;
469 //myEditCurrentArgument->setText("");
471 GroupOnSurface->PushButton1->setDown(true);
472 GroupRefPoint->hide();
473 GroupOnCurve->hide();
474 GroupLineIntersection->hide();
475 myParamGroup->show();
476 myParamCoord->button(LENGTH_VALUE)->hide();
477 myParamCoord->button(PARAM_VALUE)->setChecked(true);
478 GroupOnSurface->show();
480 updateParamCoord(false);
489 QTimer::singleShot(50, this, SLOT(updateSize()));
491 SelectionIntoArgument();
494 //=================================================================================
495 // function : ClickOnOk()
497 //=================================================================================
498 void MyBasicGUI_PointDlg::ClickOnOk()
500 setIsApplyAndClose(true);
505 //=================================================================================
506 // function : ClickOnApply()
508 //=================================================================================
509 bool MyBasicGUI_PointDlg::ClickOnApply()
515 ConstructorsClicked(getConstructorId());
521 //=================================================================================
522 // function : SelectionIntoArgument()
523 // purpose : Called when selection as changed (for constructors not using local context)
524 //=================================================================================
525 void MyBasicGUI_PointDlg::SelectionIntoArgument()
527 MESSAGE("MyBasicGUI_PointDlg::SelectionIntoArgument() myGeomGUI : "<< myGeomGUI);
529 GEOM::GeomObjPtr aSelectedObject = getSelected(myNeedType);
531 if (!aSelectedObject || !GEOMBase::GetShape(aSelectedObject.get(), aShape) || aShape.IsNull())
535 const int id = getConstructorId();
537 if ((id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF)
538 && myEditCurrentArgument != 0)
540 myEditCurrentArgument->setText("");
545 if (myEditCurrentArgument == GroupOnCurve->LineEdit1)
547 else if (myEditCurrentArgument == GroupOnCurve->LineEdit2)
548 myRefPoint.nullify();
550 else if (id == GEOM_POINT_INTINT) {
551 myEditCurrentArgument->setText("");
552 if (myEditCurrentArgument == GroupLineIntersection->LineEdit1)
554 else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2)
558 QString aName = GEOMBase::GetName(aSelectedObject.get());
560 if (id == GEOM_POINT_XYZ) {
561 gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
562 GroupXYZ->SpinBox_DX->setValue(aPnt.X());
563 GroupXYZ->SpinBox_DY->setValue(aPnt.Y());
564 GroupXYZ->SpinBox_DZ->setValue(aPnt.Z());
566 else if (id == GEOM_POINT_REF) {
567 myRefPoint = aSelectedObject;
568 GroupRefPoint->LineEdit1->setText(aName);
570 else if (id == GEOM_POINT_EDGE) {
571 myEditCurrentArgument->setText(aName);
572 if (myEditCurrentArgument == GroupOnCurve->LineEdit1) {
573 myEdge = aSelectedObject;
574 if (myEdge && !myRefPoint) {
575 GroupOnCurve->PushButton2->click();
578 else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) {
579 myRefPoint = aSelectedObject;
580 if (myRefPoint && !myEdge) {
581 GroupOnCurve->PushButton1->click();
585 else if (id == GEOM_POINT_INTINT) {
586 myEditCurrentArgument->setText(aName);
587 if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) {
588 myLine1 = aSelectedObject;
590 GroupLineIntersection->PushButton2->setMenu(0);
591 GroupLineIntersection->PushButton2->click();
592 GroupLineIntersection->PushButton2->setDown(true);
593 GroupLineIntersection->PushButton2->setMenu(myBtnPopup);
596 else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) {
597 myLine2 = aSelectedObject;
599 GroupLineIntersection->PushButton1->setMenu(0);
600 GroupLineIntersection->PushButton1->click();
601 GroupLineIntersection->PushButton1->setDown(true);
602 GroupLineIntersection->PushButton1->setMenu(myBtnPopup);
606 else if (id == GEOM_POINT_SURF) {
607 myFace = aSelectedObject;
608 GroupOnSurface->LineEdit1->setText(aName);
613 displayPreview(true);
617 //=================================================================================
618 // function : SetEditCurrentArgument()
620 //=================================================================================
621 void MyBasicGUI_PointDlg::SetEditCurrentArgument()
623 QPushButton* send = (QPushButton*)sender();
625 if (send == GroupRefPoint->PushButton1) {
626 GroupRefPoint->LineEdit1->setFocus();
627 myEditCurrentArgument = GroupRefPoint->LineEdit1;
628 globalSelection(); // close local contexts, if any
629 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
631 else if (send == GroupOnCurve->PushButton1) {
632 GroupOnCurve->LineEdit1->setFocus();
633 myEditCurrentArgument = GroupOnCurve->LineEdit1;
634 globalSelection(); // close local contexts, if any
635 myNeedType = TopAbs_EDGE;
636 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
637 GroupOnCurve->PushButton2->setDown(false);
638 GroupOnCurve->LineEdit1->setEnabled(true);
639 GroupOnCurve->LineEdit2->setEnabled(false);
641 else if (send == GroupOnCurve->PushButton2) {
642 GroupOnCurve->LineEdit2->setFocus();
643 myEditCurrentArgument = GroupOnCurve->LineEdit2;
644 globalSelection(); // close local contexts, if any
645 myNeedType = TopAbs_VERTEX;
646 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
647 GroupOnCurve->PushButton1->setDown(false);
648 GroupOnCurve->LineEdit2->setEnabled(true);
649 GroupOnCurve->LineEdit1->setEnabled(false);
651 else if (send == GroupOnSurface->PushButton1)
653 GroupOnSurface->LineEdit1->setFocus();
654 myEditCurrentArgument = GroupOnSurface->LineEdit1;
655 globalSelection(); // close local contexts, if any
656 localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE);
658 else if (send == GroupLineIntersection->PushButton1) {
659 GroupLineIntersection->LineEdit1->setFocus();
660 myEditCurrentArgument = GroupLineIntersection->LineEdit1;
661 GroupLineIntersection->PushButton2->setDown(false);
662 GroupLineIntersection->LineEdit1->setEnabled(true);
663 GroupLineIntersection->LineEdit2->setEnabled(false);
665 else if (send == GroupLineIntersection->PushButton2) {
666 GroupLineIntersection->LineEdit2->setFocus();
667 myEditCurrentArgument = GroupLineIntersection->LineEdit2;
668 GroupLineIntersection->PushButton1->setDown(false);
669 GroupLineIntersection->LineEdit1->setEnabled(false);
670 GroupLineIntersection->LineEdit2->setEnabled(true);
674 if ((send == GroupLineIntersection->PushButton1 ||
675 send == GroupLineIntersection->PushButton2) && !myBusy)
676 SelectionIntoArgument();
680 //=================================================================================
681 // function : enterEvent()
682 // purpose : to reactivate this dialog box when mouse enter onto the window
683 //=================================================================================
684 void MyBasicGUI_PointDlg::enterEvent(QEvent*)
686 MESSAGE( "MyBasicGUI_PointDlg::enterEvent() ");
687 if (!mainFrame()->GroupConstructors->isEnabled())
688 ActivateThisDialog();
692 //=================================================================================
693 // function : ActivateThisDialog()
695 //=================================================================================
696 void MyBasicGUI_PointDlg::ActivateThisDialog()
698 MESSAGE( "MyBasicGUI_PointDlg::ActivateThisDialog() ");
699 MyGEOMBase_Skeleton::ActivateThisDialog();
702 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
703 this, SLOT(SelectionIntoArgument()));
705 ConstructorsClicked(getConstructorId());
709 //=================================================================================
710 // function : DeactivateActiveDialog()
711 // purpose : public slot to deactivate if active
712 //=================================================================================
713 void MyBasicGUI_PointDlg::DeactivateActiveDialog()
715 MESSAGE( "MyBasicGUI_PointDlg::DeactivateActiveDialog() ");
716 // myGeomGUI->SetState(-1);
717 MyGEOMBase_Skeleton::DeactivateActiveDialog();
721 //=================================================================================
722 // function : ValueChangedInSpinBox()
724 //=================================================================================
725 void MyBasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
727 displayPreview(true);
730 //=================================================================================
731 // function : CheckBoxClicked()
732 // purpose : Check Boxes Management
733 //=================================================================================
734 void MyBasicGUI_PointDlg::CheckBoxClicked(int State)
736 displayPreview(true);
740 //=================================================================================
741 // funcion : getParameter()
743 //=================================================================================
744 double MyBasicGUI_PointDlg::getParameter() const
746 return GroupOnCurve->SpinBox_DX->value();
750 //=================================================================================
751 // funcion : getUParameter()
753 //=================================================================================
754 double MyBasicGUI_PointDlg::getUParameter() const
756 return GroupOnSurface->SpinBox_DX->value();
760 //=================================================================================
761 // funcion : getVParameter()
763 //=================================================================================
764 double MyBasicGUI_PointDlg::getVParameter() const
766 return GroupOnSurface->SpinBox_DY->value();
770 //=================================================================================
771 // function : OnPointSelected
773 //=================================================================================
774 void MyBasicGUI_PointDlg::OnPointSelected(const gp_Pnt& thePnt)
776 if (getConstructorId() == GEOM_POINT_XYZ) {
777 GroupXYZ->SpinBox_DX->setValue(thePnt.X());
778 GroupXYZ->SpinBox_DY->setValue(thePnt.Y());
779 GroupXYZ->SpinBox_DZ->setValue(thePnt.Z());
781 displayPreview(true);
785 //=================================================================================
786 // function : createOperation
788 //=================================================================================
789 GEOM::GEOM_IOperations_ptr MyBasicGUI_PointDlg::createOperation()
791 return myGeomGUI->GetGeomGen()->GetIBasicOperations(getStudyId());
794 //=================================================================================
795 // function : isValid
797 //=================================================================================
798 bool MyBasicGUI_PointDlg::isValid(QString& msg)
801 switch (getConstructorId()) {
802 case GEOM_POINT_XYZ :
803 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
804 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
805 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
808 ok = GroupRefPoint->SpinBox_DX->isValid(msg, !IsPreview()) &&
809 GroupRefPoint->SpinBox_DY->isValid(msg, !IsPreview()) &&
810 GroupRefPoint->SpinBox_DZ->isValid(msg, !IsPreview()) &&
813 case GEOM_POINT_EDGE:
814 if (myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE)
815 ok = GroupOnCurve->SpinBox_DX->isValid(msg, !IsPreview());
817 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
818 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
819 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
822 case GEOM_POINT_INTINT:
823 ok = myLine1 && myLine2;
825 case GEOM_POINT_SURF:
826 if (myParamCoord->checkedId() == PARAM_VALUE)
827 ok = GroupOnSurface->SpinBox_DX->isValid(msg, !IsPreview()) &&
828 GroupOnSurface->SpinBox_DY->isValid(msg, !IsPreview());
830 ok = GroupXYZ->SpinBox_DX->isValid(msg, !IsPreview()) &&
831 GroupXYZ->SpinBox_DY->isValid(msg, !IsPreview()) &&
832 GroupXYZ->SpinBox_DZ->isValid(msg, !IsPreview());
841 //=================================================================================
842 // function : execute
844 //=================================================================================
845 bool MyBasicGUI_PointDlg::execute(ObjectList& objects)
849 GEOM::GEOM_Object_var anObj;
850 QStringList aParameters;
852 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow(getOperation());
854 switch (getConstructorId()) {
855 case GEOM_POINT_XYZ :
857 double x = GroupXYZ->SpinBox_DX->value();
858 double y = GroupXYZ->SpinBox_DY->value();
859 double z = GroupXYZ->SpinBox_DZ->value();
861 aParameters << GroupXYZ->SpinBox_DX->text();
862 aParameters << GroupXYZ->SpinBox_DY->text();
863 aParameters << GroupXYZ->SpinBox_DZ->text();
865 anObj = anOper->MakePointXYZ(x, y, z);
869 case GEOM_POINT_REF :
871 double dx = GroupRefPoint->SpinBox_DX->value();
872 double dy = GroupRefPoint->SpinBox_DY->value();
873 double dz = GroupRefPoint->SpinBox_DZ->value();
875 aParameters << GroupRefPoint->SpinBox_DX->text();
876 aParameters << GroupRefPoint->SpinBox_DY->text();
877 aParameters << GroupRefPoint->SpinBox_DZ->text();
879 anObj = anOper->MakePointWithReference(myRefPoint.get(), dx, dy, dz);
883 case GEOM_POINT_EDGE :
885 if (myParamCoord->checkedId() == PARAM_VALUE) {
886 anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter());
887 aParameters<<GroupOnCurve->SpinBox_DX->text();
889 else if (myParamCoord->checkedId() == LENGTH_VALUE) {
890 anObj = anOper->MakePointOnCurveByLength(myEdge.get(), getParameter(), myRefPoint.get());
891 aParameters<<GroupOnCurve->SpinBox_DX->text();
893 else if (myParamCoord->checkedId() == COORD_VALUE) {
894 double x = GroupXYZ->SpinBox_DX->value();
895 double y = GroupXYZ->SpinBox_DY->value();
896 double z = GroupXYZ->SpinBox_DZ->value();
898 aParameters << GroupXYZ->SpinBox_DX->text();
899 aParameters << GroupXYZ->SpinBox_DY->text();
900 aParameters << GroupXYZ->SpinBox_DZ->text();
902 anObj = anOper->MakePointOnCurveByCoord(myEdge.get(), x, y, z);
907 case GEOM_POINT_INTINT :
908 anObj = anOper->MakePointOnLinesIntersection(myLine1.get(), myLine2.get());
909 if (!anObj->_is_nil()) {
910 QString aName = getNewObjectName();
911 if (anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex"))
912 initName(tr("GEOM_COMPOUND"));
913 else if (anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound"))
914 initName(tr("GEOM_VERTEX"));
918 case GEOM_POINT_SURF :
920 if (myParamCoord->checkedId() == PARAM_VALUE) {
921 anObj = anOper->MakePointOnSurface(myFace.get(), getUParameter(), getVParameter());
922 aParameters<<GroupOnSurface->SpinBox_DX->text();
923 aParameters<<GroupOnSurface->SpinBox_DY->text();
925 double x = GroupXYZ->SpinBox_DX->value();
926 double y = GroupXYZ->SpinBox_DY->value();
927 double z = GroupXYZ->SpinBox_DZ->value();
929 aParameters << GroupXYZ->SpinBox_DX->text();
930 aParameters << GroupXYZ->SpinBox_DY->text();
931 aParameters << GroupXYZ->SpinBox_DZ->text();
933 anObj = anOper->MakePointOnSurfaceByCoord(myFace.get(), x, y, z);
940 const int id = getConstructorId();
941 if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ ||
942 id == GEOM_POINT_REF ||
943 id == GEOM_POINT_EDGE ||
944 id == GEOM_POINT_SURF)) {
945 anObj->SetParameters(aParameters.join(":").toLatin1().constData());
948 if (id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF) {
950 if (GEOMBase::GetShape(anObj, aShape) && !aShape.IsNull() &&
951 aShape.ShapeType() == TopAbs_VERTEX) {
952 gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
953 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
954 int aPrecision = resMgr->integerValue("Geometry", "length_precision", 6);
955 myX->setText(DlgRef::PrintDoubleValue(aPnt.X(), aPrecision));
956 myY->setText(DlgRef::PrintDoubleValue(aPnt.Y(), aPrecision));
957 myZ->setText(DlgRef::PrintDoubleValue(aPnt.Z(), aPrecision));
966 if (!anObj->_is_nil()) {
967 objects.push_back(anObj._retn());
973 //=================================================================================
974 // function : addSubshapeToStudy
975 // purpose : virtual method to add new SubObjects if local selection
976 //=================================================================================
977 void MyBasicGUI_PointDlg::addSubshapesToStudy()
979 switch (getConstructorId()) {
981 GEOMBase::PublishSubObject(myRefPoint.get());
983 case GEOM_POINT_EDGE:
984 GEOMBase::PublishSubObject(myEdge.get());
986 case GEOM_POINT_INTINT:
987 GEOMBase::PublishSubObject(myLine1.get());
988 GEOMBase::PublishSubObject(myLine2.get());
990 case GEOM_POINT_SURF:
991 GEOMBase::PublishSubObject(myFace.get());
998 //=================================================================================
999 // function : ClickParamCoord()
1001 //=================================================================================
1002 void MyBasicGUI_PointDlg::ClickParamCoord(int id)
1004 updateParamCoord(true);
1005 displayPreview(true);
1008 //=================================================================================
1009 // function : updateParamCoord
1011 //=================================================================================
1012 void MyBasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
1014 bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
1015 bool isLength = myParamCoord->checkedId() == LENGTH_VALUE;
1017 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1018 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
1020 const int id = getConstructorId();
1021 if (id == GEOM_POINT_EDGE) {
1022 GroupOnCurve->TextLabel2->setVisible(isLength);
1023 GroupOnCurve->PushButton2->setVisible(isLength);
1024 GroupOnCurve->LineEdit2->setVisible(isLength);
1025 GroupOnCurve->TextLabel3->setVisible(isParam || isLength);
1026 GroupOnCurve->SpinBox_DX->setVisible(isParam || isLength);
1028 initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
1029 GroupOnCurve->SpinBox_DX->setValue(0.5);
1030 GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
1033 initSpinBox(GroupOnCurve->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
1034 GroupOnCurve->SpinBox_DX->setValue(0.0);
1035 GroupOnCurve->TextLabel3->setText(tr("GEOM_LENGTH"));
1038 else if (id == GEOM_POINT_SURF) {
1039 GroupOnSurface->TextLabel2->setShown(isParam);
1040 GroupOnSurface->TextLabel3->setShown(isParam);
1041 GroupOnSurface->SpinBox_DX->setShown(isParam);
1042 GroupOnSurface->SpinBox_DY->setShown(isParam);
1045 GroupXYZ->setShown(!isParam && !isLength);
1048 QTimer::singleShot(50, this, SLOT(updateSize()));
1051 //=================================================================================
1052 // function : onBtnPopup()
1054 //=================================================================================
1055 void MyBasicGUI_PointDlg::onBtnPopup(QAction* a)
1057 globalSelection(); // close local contexts, if any
1058 myNeedType = myActions[a] == SelectEdge ? TopAbs_EDGE : TopAbs_WIRE;
1059 localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
1062 //=================================================================================
1063 // function : updateSize
1064 // purpose : adjust dialog size to minimum
1065 //=================================================================================
1066 void MyBasicGUI_PointDlg::updateSize()
1068 qApp->processEvents();
1070 resize(minimumSizeHint());
1083 void MyBasicGUI_PointDlg::setDocumentModel( HEXABLOCK::GUI::DocumentModel* m)
1088 void MyBasicGUI_PointDlg::setPatternDataSelectionModel( HEXABLOCK::GUI::PatternDataSelectionModel* s)
1090 _patternDataSelectionModel = s;
1093 void MyBasicGUI_PointDlg::_initInputWidget()
1096 // QVBoxLayout* mainLayout = new QVBoxLayout( centralWidget() );
1097 // setLayout( mainLayout );
1098 // QHBoxLayout* up = new QHBoxLayout( centralWidget() );
1099 // QVBoxLayout* down = new QVBoxLayout( centralWidget() );
1101 // QGroupBox *GroupBoxName = new QGroupBox(centralWidget());
1102 // GroupBoxName->setObjectName(QString::fromUtf8("GroupBoxName"));
1103 // GroupBoxName->setTitle("Vertex");
1104 // QHBoxLayout *hboxLayout1 = new QHBoxLayout(GroupBoxName);
1105 // hboxLayout1->setSpacing(6);
1106 // hboxLayout1->setContentsMargins(9, 9, 9, 9);
1107 // hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
1108 // QLabel *NameLabel = new QLabel(GroupBoxName);
1109 // NameLabel->setObjectName(QString::fromUtf8("NameLabel"));
1110 // NameLabel->setWordWrap(false);
1111 // NameLabel->setText( "Name : " );
1112 // hboxLayout1->addWidget( NameLabel );
1113 // mainFrame()->_vertex_le = new QLineEdit( GroupBoxName );
1114 // mainFrame()->_vertex_le->setObjectName(QString::fromUtf8("mainFrame()->_vertex_le"));
1115 // hboxLayout1->addWidget(mainFrame()->_vertex_le);
1117 // layout()->addWidget( GroupBoxName );
1122 QValidator *validator = new QRegExpValidator(rx, this);
1124 // setProperty( "HexaWidgetType", QVariant::fromValue(HEXABLOCK::GUI::VERTEX_TREE) );
1125 // installEventFilter(this);
1127 mainFrame()->_vertex_le->setProperty( "HexaWidgetType", QVariant::fromValue(HEXABLOCK::GUI::VERTEX_TREE) );
1128 mainFrame()->_vertex_le->installEventFilter(this);
1129 mainFrame()->_vertex_le->setValidator( validator );
1132 void MyBasicGUI_PointDlg::_initViewManager()
1134 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1135 _mgr = dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1136 _vtkVm = anApp->getViewManager( SVTK_Viewer::Type(), true );
1137 _occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true );
1138 SUIT_ViewManager* activeVm = anApp->activeViewManager();
1139 onWindowActivated ( activeVm );
1143 // bool MyBasicGUI_PointDlg::_onSelectionChanged( const QItemSelection& sel, QLineEdit* le )
1145 // MESSAGE("HexaBaseDialog::_onSelectionChanged(const QItemSelection& sel, QLineEdit* le)");
1146 // MESSAGE("* le is "<< le->objectName().toStdString() );
1147 // QModelIndexList l = sel.indexes();
1148 // if ( l.count() == 0 ) return false;
1150 // //type from selection (first)
1151 // QModelIndex selected = l[0];
1152 // int selType = selected.data(HEXABLOCK::GUI::HEXA_TREE_ROLE).toInt();
1155 // QVariant v = le->property("HexaWidgetType");
1156 // if ( !v.isValid() ) return false;
1157 // HexaWidgetType wType = v.value<HexaWidgetType>();
1159 // // check selection compatibility between selection and widget
1160 // if ( selType != wType ){
1161 // MESSAGE("* bad selection : " << selType << " is not " << wType );
1162 // SUIT_MessageBox::information( 0,
1164 // tr("Bad selection type: please select a %1").arg( _strHexaWidgetType[wType]) );
1168 // //fill the lineEdit if selection is OK
1169 // le->setText( selected.data().toString() );// name
1170 // le->setProperty("QModelIndex", QVariant::fromValue(selected) );
1177 void MyBasicGUI_PointDlg::onSelectionChanged( const QItemSelection& sel, const QItemSelection& unsel )
1179 MESSAGE( "HexaBaseDialog::onSelectionChanged(){" );
1180 QString className = metaObject()->className();
1181 MESSAGE( "* I am : " << className.toStdString() );
1182 MESSAGE( "* sender is : " << sender() );
1183 QItemSelectionModel* selector = dynamic_cast<QItemSelectionModel*>(sender());
1184 MESSAGE( "* selector : " << selector);
1186 foreach( const QModelIndex& isel, sel.indexes() ){
1187 MESSAGE("* selected : " << isel.data().toString().toStdString());
1189 foreach( const QModelIndex& iunsel, unsel.indexes() ){
1190 MESSAGE("* unselected : " << iunsel.data().toString().toStdString());
1192 if ( _selectionMutex ) return;
1193 if ( _currentObj != mainFrame()->_vertex_le ) return;
1197 QModelIndexList l = sel.indexes();
1198 if ( l.count() != 0 ){
1199 //type from selection (first)
1200 QModelIndex selected = l[0];
1201 int selType = selected.data(HEXABLOCK::GUI::HEXA_TREE_ROLE).toInt();
1202 // check selection compatibility between selection and widget
1203 if ( selType == HEXABLOCK::GUI::VERTEX_TREE ){
1204 mainFrame()->_vertex_le->setText( selected.data().toString() );// name
1205 mainFrame()->_vertex_le->setProperty("QModelIndex", QVariant::fromValue(selected) );
1208 _patternDataSelectionModel->clearSelection();
1209 MESSAGE("* bad selection : " << selType << " is not " << HEXABLOCK::GUI::VERTEX_TREE );
1210 SUIT_MessageBox::information( 0,
1212 tr("Bad selection type: please select a %1").arg( "VERTEX" ) );
1219 void MyBasicGUI_PointDlg::onWindowActivated(SUIT_ViewManager* vm)
1221 MESSAGE( "getConstructorId()"<< getConstructorId() );
1222 SUIT_ViewWindow* v = vm->getActiveView();
1223 QString vmType = vm->getType();
1224 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){
1225 mainFrame()->_vertex_le->setFocus();
1226 } else if ( vmType == OCCViewer_Viewer::Type() ){
1227 // lines_lw->setFocus();
1228 // ConstructorsClicked(0);
1229 MESSAGE( "getConstructorId()"<< getConstructorId() );
1230 ConstructorsClicked( getConstructorId() );
1236 bool MyBasicGUI_PointDlg::eventFilter(QObject *obj, QEvent *event)
1239 if ( (event->type() != QEvent::FocusIn)
1240 or (obj != mainFrame()->_vertex_le) ){
1241 return MyGEOMBase_Skeleton::eventFilter(obj, event);
1244 MESSAGE("MyBasicGUI_PointDlg::eventFilter{");
1247 QModelIndex vxIndex;
1250 // HEXABLOCKGUI::currentVtkView->raise();
1251 _patternDataSelectionModel->setVertexSelection();
1253 vxVariant = mainFrame()->_vertex_le->property("QModelIndex");
1254 if ( !vxVariant.isValid() ) {
1255 return MyGEOMBase_Skeleton::eventFilter(obj, event);
1257 vxIndex = vxVariant.value<QModelIndex>();
1258 _selectionMutex = true;
1259 MESSAGE("* selecting the element : " << vxIndex.data().toString().toStdString());
1260 MESSAGE("* _patternDataSelectionModel : " << _patternDataSelectionModel );
1261 _patternDataSelectionModel->select( vxIndex, QItemSelectionModel::Clear );
1262 _patternDataSelectionModel->select( vxIndex, QItemSelectionModel::Select );
1263 _selectionMutex = false;
1269 void MyBasicGUI_PointDlg::hideEvent ( QHideEvent * event )
1271 MESSAGE("MyBasicGUI_PointDlg::hideEvent(){");
1272 disconnect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
1273 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1274 disconnect( HEXABLOCKGUI::selectionMgr() , SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) );
1275 disconnect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
1276 disconnect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
1277 _documentModel->allowEdition();
1278 DeactivateActiveDialog();
1279 MyGEOMBase_Skeleton::hideEvent( event );
1283 void MyBasicGUI_PointDlg::showEvent( QShowEvent * event )
1285 MESSAGE("MyBasicGUI_PointDlg::showEvent(){");
1286 _documentModel->disallowEdition();
1287 // _patternDataSelectionModel->clearSelection();
1288 connect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
1289 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
1290 connect( _mgr, SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) );
1291 connect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
1292 connect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
1295 SalomeApp_Application* app = (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() );
1297 MESSAGE( "XXXXXXXXXXX myGeomGUI => " << myGeomGUI );
1298 if ( !myGeomGUI && app )
1299 myGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
1301 MESSAGE( "YYYYYYYYYYYYY myGeomGUI => " << myGeomGUI );
1303 ActivateThisDialog();
1304 MyGEOMBase_Skeleton::showEvent ( event );
1311 bool MyBasicGUI_PointDlg::onAccept( const bool publish, const bool useTransaction )
1313 MESSAGE("MyBasicGUI_PointDlg::onAccept()");
1315 GEOM::GEOM_Object_ptr newVertex;
1316 QString newVertexEntry;
1317 QString newVertexName;
1318 QString newVertexBrep;
1322 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1323 if ( !appStudy ) return false;
1324 _PTR(Study) aStudy = appStudy->studyDS();
1326 bool aLocked = (_PTR(AttributeStudyProperties) (aStudy->GetProperties()))->IsLocked();
1328 MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
1329 SUIT_MessageBox::warning ( (QWidget*)SUIT_Session::session()->activeApplication()->desktop(),
1330 QObject::tr("WRN_WARNING"),
1331 QObject::tr("WRN_STUDY_LOCKED"),
1332 QObject::tr("BUT_OK") );
1337 if ( !isValid( msg ) ) {
1342 erasePreview( false );
1344 bool result = false;
1347 if ( ( !publish && !useTransaction ) || openCommand() ) {
1348 SUIT_OverrideCursor wc;
1349 SUIT_Session::session()->activeApplication()->putInfo( "" );
1351 if ( !execute( objects ) || !getOperation()->IsDone() ) {
1357 addSubshapesToStudy(); // add Subshapes if local selection
1358 const int nbObjs = objects.size();
1359 QStringList anEntryList;
1361 for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
1362 GEOM::GEOM_Object_var obj=*it;
1364 QString aName = getNewObjectName();
1366 if (aName.isEmpty())
1367 aName = getPrefix(obj);
1369 // Try to find a unique name
1370 aName = GEOMBase::GetDefaultName(aName, extractPrefix());
1372 // Don't check name uniqueness in case of numerous objects
1373 aName = aName + "_" + QString::number(aNumber++);
1376 // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
1377 if ( aName.isEmpty() )
1378 aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
1380 anEntryList << addInStudy( obj, aName.toLatin1().constData() );
1383 newVertexEntry = anEntryList[0];
1384 TopoDS_Shape aShape;
1385 GEOMBase::GetShape( newVertex, aShape );
1386 if ( !aShape.IsNull() ){
1387 MESSAGE("!aShape.IsNull()");
1388 newVertexName = GEOMBase::GetName( newVertex );
1389 MESSAGE("newVertexName "<< newVertexName.toStdString());
1390 newVertexBrep = HEXABLOCK::GUI::shape2string( aShape ).c_str();
1394 display( obj, false );
1395 #ifdef WITHGENERICOBJ
1396 // obj has been published in study. Its refcount has been incremented.
1397 // It is safe to decrement its refcount
1398 // so that it will be destroyed when the entry in study will be removed
1403 // asv : fix of PAL6454. If publish==false, then the original shape
1404 // was modified, and need to be re-cached in GEOM_Client before redisplay
1405 // clearShapeBuffer( obj );
1406 // withChildren=true, updateView=false
1407 redisplay( obj, true, false );
1414 if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) {
1415 if( LightApp_Application* aLightApp = dynamic_cast<LightApp_Application*>( anApp ) ){
1416 aLightApp->browseObjects( anEntryList, isApplyAndClose(), isOptimizedBrowsing() );
1418 anApp->putInfo( QObject::tr("GEOM_PRP_DONE") );
1427 catch( const SALOME::SALOME_Exception& e ) {
1428 SalomeApp_Tools::QtCatchCorbaException( e );
1435 SUIT_OverrideCursor wc;
1436 if ( !_documentModel ) return false;
1437 if ( !_patternDataSelectionModel ) return false;
1438 const HEXABLOCK::GUI::PatternDataModel* patternDataModel = dynamic_cast<const HEXABLOCK::GUI::PatternDataModel*>( _patternDataSelectionModel->model() );
1439 if ( !patternDataModel ) return false;
1442 QVariant v = mainFrame()->_vertex_le->property("QModelIndex");
1443 if ( !v.isValid() ) return false;
1444 QModelIndex iVertex = patternDataModel->mapToSource( v.value<QModelIndex>() );
1446 if ( iVertex.isValid() ){
1447 HEXABLOCK::GUI::DocumentModel::GeomObj aPoint;
1448 aPoint.name = newVertexName;
1449 aPoint.entry = newVertexEntry;
1450 aPoint.brep = newVertexBrep;
1451 MESSAGE(" aPoint.name" << aPoint.name.toStdString() );
1452 MESSAGE(" aPoint.entry" << aPoint.entry.toStdString() );
1453 MESSAGE(" aPoint.brep" << aPoint.brep.toStdString() );
1454 _documentModel->addAssociation( iVertex, aPoint );
1455 // to select/highlight result
1456 // _patternDataSelectionModel->clearSelection();
1457 // mainFrame()->_vertex_le->setFocus();
1459 // globalSelection();
1460 // localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
1461 _patternDataSelectionModel->select( patternDataModel->mapFromSource(iVertex), QItemSelectionModel::Clear );
1462 _patternDataSelectionModel->select( patternDataModel->mapFromSource(iVertex), QItemSelectionModel::Select );
1466 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE VERTEX ASSOCIATION" ) );