1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #include "PartSet_WidgetPoint2DFlyout.h"
22 #include "ModuleBase_WidgetValidator.h"
23 #include "ModuleBase_ViewerPrs.h"
25 #include <XGUI_Workshop.h>
26 #include <XGUI_ModuleConnector.h>
27 #include <XGUI_Displayer.h>
29 #include <Config_WidgetAPI.h>
30 #include <Config_Keywords.h>
35 PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent,
36 ModuleBase_IWorkshop* theWorkshop,
37 const Config_WidgetAPI* theData)
38 : PartSet_WidgetPoint2D(theParent, theWorkshop, theData)
40 myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop);
43 bool PartSet_WidgetPoint2DFlyout::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
44 const bool theToValidate)
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
52 bool PartSet_WidgetPoint2DFlyout::isValidSelectionCustom(
53 const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
58 bool PartSet_WidgetPoint2DFlyout::useSelectedShapes() const
63 bool PartSet_WidgetPoint2DFlyout::focusTo()
65 bool aCanAcceptFocus = true;
66 if (isInternal() && isComputedDefault()) {
67 AISObjectPtr anObject = workshop()->displayer()->getAISObject(feature());
68 aCanAcceptFocus = anObject.get() && !anObject->isEmptyDistanceGeometry();
71 aCanAcceptFocus = PartSet_WidgetPoint2D::focusTo();
72 return aCanAcceptFocus;
75 XGUI_Workshop* PartSet_WidgetPoint2DFlyout::workshop() const
77 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
78 return aConnector->workshop();