Salome HOME
updated copyright message
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2DFlyout.cpp
1 // Copyright (C) 2014-2023  CEA, EDF
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "PartSet_WidgetPoint2DFlyout.h"
21
22 #include "ModuleBase_WidgetValidator.h"
23 #include "ModuleBase_ViewerPrs.h"
24
25 #include <XGUI_Workshop.h>
26 #include <XGUI_ModuleConnector.h>
27 #include <XGUI_Displayer.h>
28
29 #include <Config_WidgetAPI.h>
30 #include <Config_Keywords.h>
31
32 #include <QWidget>
33
34
35 PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent,
36                                                          ModuleBase_IWorkshop* theWorkshop,
37                                                          const Config_WidgetAPI* theData)
38  : PartSet_WidgetPoint2D(theParent, theWorkshop, theData)
39 {
40   myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop);
41 }
42
43 bool PartSet_WidgetPoint2DFlyout::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
44                                                const bool theToValidate)
45 {
46   PartSet_WidgetPoint2D::setSelection(theValues, theToValidate);
47   // true value should be returned to set this control as processed the selection
48   // to move focus to the next control if it is filled by preselection
49   return true;
50 }
51
52 bool PartSet_WidgetPoint2DFlyout::isValidSelectionCustom(
53                                       const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
54 {
55   return false;
56 }
57
58 bool PartSet_WidgetPoint2DFlyout::useSelectedShapes() const
59 {
60   return false;
61 }
62
63 bool PartSet_WidgetPoint2DFlyout::focusTo()
64 {
65   bool aCanAcceptFocus = true;
66   if (isInternal() && isComputedDefault()) {
67     AISObjectPtr anObject = workshop()->displayer()->getAISObject(feature());
68     aCanAcceptFocus = anObject.get() && !anObject->isEmptyDistanceGeometry();
69   }
70   if (aCanAcceptFocus)
71     aCanAcceptFocus = PartSet_WidgetPoint2D::focusTo();
72   return aCanAcceptFocus;
73 }
74
75 XGUI_Workshop* PartSet_WidgetPoint2DFlyout::workshop() const
76 {
77   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
78   return aConnector->workshop();
79 }