Salome HOME
The flyout widget should not accept the focus if the corresponded presentation is...
[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 <XGUI_Workshop.h>
10 #include <XGUI_ModuleConnector.h>
11 #include <XGUI_Displayer.h>
12
13 #include <Config_WidgetAPI.h>
14 #include <Config_Keywords.h>
15
16 #include <QWidget>
17
18
19 PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent, 
20                                                          ModuleBase_IWorkshop* theWorkshop,
21                                                          const Config_WidgetAPI* theData,
22                                                          const std::string& theParentId)
23  : PartSet_WidgetPoint2D(theParent, theWorkshop, theData, theParentId)
24 {
25   myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false);
26 }
27
28 bool PartSet_WidgetPoint2DFlyout::focusTo()
29 {
30   bool aCanAcceptFocus = true;
31   if (myIsInternal && isComputedDefault()) {
32     AISObjectPtr anObject = workshop()->displayer()->getAISObject(feature());
33     aCanAcceptFocus = anObject.get() && !anObject->isEmptyDistanceGeometry();
34   }
35   if (aCanAcceptFocus)
36     aCanAcceptFocus = PartSet_WidgetPoint2D::focusTo();
37   return aCanAcceptFocus;
38 }
39
40 XGUI_Workshop* PartSet_WidgetPoint2DFlyout::workshop() const
41 {
42   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
43   return aConnector->workshop();
44 }