Salome HOME
9041727f379e86d046b6fd52daff30268987dd0d
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2DFlyout.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetPoint2D.cpp
4 // Created:     25 Apr 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #include "PartSet_WidgetPoint2DFlyout.h"
8
9 #include "ModuleBase_WidgetValidator.h"
10 #include "ModuleBase_ViewerPrs.h"
11
12 #include <XGUI_Workshop.h>
13 #include <XGUI_ModuleConnector.h>
14 #include <XGUI_Displayer.h>
15
16 #include <Config_WidgetAPI.h>
17 #include <Config_Keywords.h>
18
19 #include <QWidget>
20
21
22 PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent,
23                                                          ModuleBase_IWorkshop* theWorkshop,
24                                                          const Config_WidgetAPI* theData)
25  : PartSet_WidgetPoint2D(theParent, theWorkshop, theData)
26 {
27   myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop);
28 }
29
30 bool PartSet_WidgetPoint2DFlyout::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
31                                                const bool theToValidate)
32 {
33   PartSet_WidgetPoint2D::setSelection(theValues, theToValidate);
34   // true value should be returned to set this control as processed the selection
35   // to move focus to the next control if it is filled by preselection
36   return true;
37 }
38
39 bool PartSet_WidgetPoint2DFlyout::isValidSelectionCustom(
40                                       const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
41 {
42   return false;
43 }
44
45 bool PartSet_WidgetPoint2DFlyout::useSelectedShapes() const
46 {
47   return false;
48 }
49
50 bool PartSet_WidgetPoint2DFlyout::focusTo()
51 {
52   bool aCanAcceptFocus = true;
53   if (isInternal() && isComputedDefault()) {
54     AISObjectPtr anObject = workshop()->displayer()->getAISObject(feature());
55     aCanAcceptFocus = anObject.get() && !anObject->isEmptyDistanceGeometry();
56   }
57   if (aCanAcceptFocus)
58     aCanAcceptFocus = PartSet_WidgetPoint2D::focusTo();
59   return aCanAcceptFocus;
60 }
61
62 XGUI_Workshop* PartSet_WidgetPoint2DFlyout::workshop() const
63 {
64   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
65   return aConnector->workshop();
66 }