Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / HEXABLOCKGUI / MyBasicGUI_PointDlg.cxx
index 52705486728a1092d2eeb1fad385977f1d1031b2..5b65849dc8f4911ce88c757a4438f8c04af175d3 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2009-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2009-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -34,6 +34,7 @@
 #include <QRadioButton>
 #include <QMenu>
 #include <QTimer>
+#include <QVector3D>
 
 #include <gp_Pnt.hxx>
 #include <TopoDS_Shape.hxx>
@@ -115,19 +116,23 @@ MyBasicGUI_PointDlg::MyBasicGUI_PointDlg(QWidget* parent, Qt::WindowFlags fl)
     myParamCoord = new QButtonGroup(myParamGroup);
     QHBoxLayout* boxLayout = new QHBoxLayout(myParamGroup);
     boxLayout->setMargin(MARGIN); boxLayout->setSpacing(SPACING);
+
     QRadioButton* btn = new QRadioButton(tr("By Param"), myParamGroup);
     myParamCoord->addButton(btn, PARAM_VALUE);
     boxLayout->addWidget(btn);
+
     btn = new QRadioButton(tr("By Length"), myParamGroup);
     myParamCoord->addButton(btn, LENGTH_VALUE);
     boxLayout->addWidget(btn);
+
     btn = new QRadioButton(tr("By Coords"), myParamGroup);
     myParamCoord->addButton(btn, COORD_VALUE);
     boxLayout->addWidget(btn);
+
     myParamCoord->setExclusive(true);
     myParamCoord->button(PARAM_VALUE)->setChecked(true);
 
-    GroupXYZ = new DlgRef_3Spin(centralWidget());
+    GroupXYZ = new MyDlgRef_3Spin(centralWidget());
     GroupXYZ->GroupBox1->setTitle(tr("GEOM_COORDINATES"));
     GroupXYZ->TextLabel1->setText(tr("GEOM_X"));
     GroupXYZ->TextLabel2->setText(tr("GEOM_Y"));
@@ -136,7 +141,7 @@ MyBasicGUI_PointDlg::MyBasicGUI_PointDlg(QWidget* parent, Qt::WindowFlags fl)
     coordsInputValue[GEOM_POINT_EDGE] = new QVector3D(0, 0, 0);
     coordsInputValue[GEOM_POINT_SURF] = new QVector3D(0, 0, 0);
 
-    GroupOnCurve = new DlgRef_2Sel1Spin(centralWidget());
+    GroupOnCurve = new MyDlgRef_2Sel1Spin(centralWidget());
     GroupOnCurve->GroupBox1->setTitle(tr("GEOM_POINT_ON_EDGE"));
     GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE"));
     GroupOnCurve->TextLabel2->setText(tr("GEOM_START_POINT"));
@@ -144,13 +149,13 @@ MyBasicGUI_PointDlg::MyBasicGUI_PointDlg(QWidget* parent, Qt::WindowFlags fl)
     paramInputValue[PARAM_VALUE] = 0.5;
     paramInputValue[LENGTH_VALUE] = 0.5;
 
-    GroupOnSurface = new DlgRef_1Sel2Spin(centralWidget());
+    GroupOnSurface = new MyDlgRef_1Sel2Spin(centralWidget());
     GroupOnSurface->GroupBox1->setTitle(tr("GEOM_POINT_ON_FACE"));
     GroupOnSurface->TextLabel1->setText(tr("GEOM_FACE"));
     GroupOnSurface->TextLabel2->setText(tr("GEOM_UPARAMETER"));
     GroupOnSurface->TextLabel3->setText(tr("GEOM_VPARAMETER"));
 
-    GroupRefPoint = new DlgRef_1Sel3Spin(centralWidget());
+    GroupRefPoint = new MyDlgRef_1Sel3Spin(centralWidget());
     GroupRefPoint->GroupBox1->setTitle(tr("GEOM_REF_POINT"));
     GroupRefPoint->TextLabel1->setText(tr("GEOM_POINT"));
     GroupRefPoint->TextLabel2->setText(tr("GEOM_DX"));
@@ -170,7 +175,7 @@ MyBasicGUI_PointDlg::MyBasicGUI_PointDlg(QWidget* parent, Qt::WindowFlags fl)
     action_line2_edge = myBtnPopup2->addAction(ico_line, tr("GEOM_EDGE"));
     action_line2_wire = myBtnPopup2->addAction(ico_wire, tr("GEOM_WIRE"));
 
-    GroupLineIntersection = new DlgRef_2Sel(centralWidget());
+    GroupLineIntersection = new MyDlgRef_2Sel(centralWidget());
     GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION"));
     GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1"));
     GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2"));
@@ -671,9 +676,9 @@ void MyBasicGUI_PointDlg::onUpdateResults(const QString& data)
         return;
     }
     gp_Pnt pnt = BRep_Tool::Pnt(vertex);
-    myX->setText(DlgRef::PrintDoubleValue(pnt.X(), 6));
-    myY->setText(DlgRef::PrintDoubleValue(pnt.Y(), 6));
-    myZ->setText(DlgRef::PrintDoubleValue(pnt.Z(), 6));
+    myX->setText(MyDlgRef::PrintDoubleValue(pnt.X(), 6));
+    myY->setText(MyDlgRef::PrintDoubleValue(pnt.Y(), 6));
+    myZ->setText(MyDlgRef::PrintDoubleValue(pnt.Z(), 6));
 }
 
 TopoDS_Vertex MyBasicGUI_PointDlg::computeGeomVertex(bool preview)
@@ -964,13 +969,13 @@ void MyBasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
         }
     }
     else if (id == GEOM_POINT_SURF) {
-        GroupOnSurface->TextLabel2->setShown(isParam);
-        GroupOnSurface->TextLabel3->setShown(isParam);
-        GroupOnSurface->SpinBox_DX->setShown(isParam);
-        GroupOnSurface->SpinBox_DY->setShown(isParam);
+        GroupOnSurface->TextLabel2->setVisible(isParam);
+        GroupOnSurface->TextLabel3->setVisible(isParam);
+        GroupOnSurface->SpinBox_DX->setVisible(isParam);
+        GroupOnSurface->SpinBox_DY->setVisible(isParam);
     }
 
-    GroupXYZ->setShown(!isParam && !isLength);
+    GroupXYZ->setVisible(!isParam && !isLength);
 }
 
 //=================================================================================
@@ -1058,9 +1063,23 @@ void MyBasicGUI_PointDlg::clear()
 void MyBasicGUI_PointDlg::onWindowActivated(SUIT_ViewManager* vm)
 {
     QString vmType = vm->getType();
-    if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){
-        mainFrame()->_vertex_le->setFocus();
-    } else if ( vmType == OCCViewer_Viewer::Type() ){
-        // ...
+    if ( ((vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type())) &&
+            !mainFrame()->RadioButton4->isChecked() &&
+        !myParamCoord->button(LENGTH_VALUE)->isChecked() ){
+      // VSR 2020-04-06 bos #17637
+      // next line is commented out to prevent resetting focus when mouse enters the view
+      //mainFrame()->_vertex_le->setFocus();
+    }
+    else if ( vmType == OCCViewer_Viewer::Type() ){
+        if (mainFrame()->RadioButton1->isChecked())
+            // Make the field "Vertex of the model" lose the focus
+            mainFrame()->RadioButton1->click();
+        else if (mainFrame()->RadioButton2->isChecked())
+            GroupRefPoint->LineEdit1->setFocus();
+        else if (mainFrame()->RadioButton3->isChecked() &&
+                !myParamCoord->button(LENGTH_VALUE)->isChecked())
+            GroupOnCurve->LineEdit1->setFocus();
+        else if (mainFrame()->RadioButton5->isChecked())
+            GroupOnSurface->LineEdit1->setFocus();
     }
 }