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