1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "PartSet_WidgetPoint2DFlyout.h"
23 #include "ModuleBase_WidgetValidator.h"
24 #include "ModuleBase_ViewerPrs.h"
26 #include <XGUI_Workshop.h>
27 #include <XGUI_ModuleConnector.h>
28 #include <XGUI_Displayer.h>
30 #include <Config_WidgetAPI.h>
31 #include <Config_Keywords.h>
36 PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent,
37 ModuleBase_IWorkshop* theWorkshop,
38 const Config_WidgetAPI* theData)
39 : PartSet_WidgetPoint2D(theParent, theWorkshop, theData)
41 myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop);
44 bool PartSet_WidgetPoint2DFlyout::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
45 const bool theToValidate)
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
53 bool PartSet_WidgetPoint2DFlyout::isValidSelectionCustom(
54 const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
59 bool PartSet_WidgetPoint2DFlyout::useSelectedShapes() const
64 bool PartSet_WidgetPoint2DFlyout::focusTo()
66 bool aCanAcceptFocus = true;
67 if (isInternal() && isComputedDefault()) {
68 AISObjectPtr anObject = workshop()->displayer()->getAISObject(feature());
69 aCanAcceptFocus = anObject.get() && !anObject->isEmptyDistanceGeometry();
72 aCanAcceptFocus = PartSet_WidgetPoint2D::focusTo();
73 return aCanAcceptFocus;
76 XGUI_Workshop* PartSet_WidgetPoint2DFlyout::workshop() const
78 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
79 return aConnector->workshop();