Case: create a contour, select any vertex, detach it from a line. Call distance and select the equal points of detached lines. Previous result: no active control, waiting for user click. Current result: the flyout attribute is initialized with a default value, the focus is on the value control.
}
}
+bool GeomAPI_AISObject::isEmptyDistanceGeometry()
+{
+ bool anEmpty = false;
+
+ Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull()) {
+ Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
+ if (!aDimAIS.IsNull()) {
+ anEmpty = !aDimAIS->IsValid();
+ }
+ }
+
+ return anEmpty;
+}
+
void GeomAPI_AISObject::createRadius(std::shared_ptr<GeomAPI_Circ> theCircle,
std::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
double theRadius)
std::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
std::shared_ptr<GeomAPI_Pln> thePlane, double theDistance);
+ /**
+ * Returns validity of the AIS distance. It is invalid if set measured geometry is not valid,
+ * e.g. the distance points are equal.
+ * \return a boolean result
+ */
+ GEOMAPI_EXPORT
+ bool isEmptyDistanceGeometry();
+
/** \brief Creates AIS_RadiusDimension object
* \param[in] theCircle the radius is created for this circle
* \param[in] theFlyoutPoint the flyout of dimension
PartSet_WidgetEditor.h
PartSet_WidgetMultiSelector.h
PartSet_WidgetPoint2dDistance.h
+ PartSet_WidgetPoint2DFlyout.h
PartSet_WidgetShapeSelector.h
PartSet_WidgetFileSelector.h
PartSet_Filters.h
PartSet_WidgetPoint2d.cpp
PartSet_WidgetPoint2dAngle.cpp
PartSet_WidgetPoint2dDistance.cpp
+ PartSet_WidgetPoint2DFlyout.cpp
PartSet_WidgetShapeSelector.cpp
PartSet_WidgetFileSelector.cpp
PartSet_Filters.cpp
#include "PartSet_Tools.h"
#include "PartSet_WidgetPoint2d.h"
#include "PartSet_WidgetPoint2dDistance.h"
+#include "PartSet_WidgetPoint2DFlyout.h"
#include "PartSet_WidgetShapeSelector.h"
#include "PartSet_WidgetPoint2dAngle.h"
#include "PartSet_WidgetMultiSelector.h"
aPointWgt->setSketch(mySketchMgr->activeSketch());
connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
aWgt = aPointWgt;
+ } else if (theType == "sketch-2dpoint_flyout_selector") {
+ PartSet_WidgetPoint2DFlyout* aPointWgt = new PartSet_WidgetPoint2DFlyout(theParent, aWorkshop,
+ theWidgetApi, theParentId);
+ aPointWgt->setSketch(mySketchMgr->activeSketch());
+ connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
+ aWgt = aPointWgt;
} else if (theType == "point2ddistance") {
PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent,
aWorkshop, theWidgetApi, theParentId);
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetPoint2D.cpp
+// Created: 25 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#include "PartSet_WidgetPoint2DFlyout.h"
+
+#include <XGUI_Workshop.h>
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_Displayer.h>
+
+#include <Config_WidgetAPI.h>
+#include <Config_Keywords.h>
+
+#include <QWidget>
+
+
+PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : PartSet_WidgetPoint2D(theParent, theWorkshop, theData, theParentId)
+{
+ myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false);
+}
+
+bool PartSet_WidgetPoint2DFlyout::focusTo()
+{
+ bool aCanAcceptFocus = true;
+ if (myIsInternal && isComputedDefault()) {
+ AISObjectPtr anObject = workshop()->displayer()->getAISObject(feature());
+ aCanAcceptFocus = anObject.get() && !anObject->isEmptyDistanceGeometry();
+ }
+ if (aCanAcceptFocus)
+ aCanAcceptFocus = PartSet_WidgetPoint2D::focusTo();
+ return aCanAcceptFocus;
+}
+
+XGUI_Workshop* PartSet_WidgetPoint2DFlyout::workshop() const
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+ return aConnector->workshop();
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: PartSet_WidgetPoint2dFlyout.h
+// Created: 14 Oct 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef PartSet_WidgetPoint2DFlyout_H
+#define PartSet_WidgetPoint2DFlyout_H
+
+#include "PartSet.h"
+#include <PartSet_WidgetPoint2D.h>
+
+class XGUI_Workshop;
+
+/**\class PartSet_WidgetPoint2DFlyout
+ * \ingroup Modules
+ * \brief Implementation of usual point 2d widget with a condition that it can not accept the focus
+ * when the AIS presentation is not visualized in the viewer.
+ */
+class PARTSET_EXPORT PartSet_WidgetPoint2DFlyout : public PartSet_WidgetPoint2D
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theWorkshop a current workshop
+ /// \param theData the widget configuation. The attribute of the model widget is obtained from
+ /// \param theParentId is Id of a parent of the current attribute
+ PartSet_WidgetPoint2DFlyout(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId);
+ /// Destructor
+ virtual ~PartSet_WidgetPoint2DFlyout() {};
+
+ /// Activates the editor control only in case if the mouse over the OCC window, otherwise
+ /// set focus to the usual double value control
+ /// \return the state whether the widget can accept the focus
+ virtual bool focusTo();
+
+private:
+ //! Returns workshop
+ XGUI_Workshop* workshop() const;
+
+private:
+ bool myIsInternal; /// an XML internal state
+};
+
+#endif
/// \theObject a result object
void setConstraintWith(const ObjectPtr& theObject);
+protected:
ModuleBase_IWorkshop* myWorkshop;
+
+private:
PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP
QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
<validator id="GeomValidators_ShapeType" parameters="vertex,line"/>
</sketch_shape_selector>
- <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
+ <sketch-2dpoint_flyout_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed" min="0">
<validator id="GeomValidators_Positive"/>
<shape_selector id="ConstraintEntityA" label="Line" tooltip="Select an line" shape_types="edge" >
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
- <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
+ <sketch-2dpoint_flyout_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<doublevalue_editor label="Value" tooltip="Length" id="ConstraintValue" default="computed">
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
shape_types="edge">
<validator id="GeomValidators_ShapeType" parameters="circle"/>
</shape_selector>
- <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
+ <sketch-2dpoint_flyout_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed">
<validator id="GeomValidators_Positive"/>
</doublevalue_editor>
<validator id="PartSet_DifferentObjects"/>
<validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
</shape_selector>
- <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
+ <sketch-2dpoint_flyout_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
<doublevalue_editor label="Value" tooltip="Angle" id="ConstraintValue" default="computed" min="0" max="180" />
<validator id="PartSet_AngleSelection"/>
</feature>
return;
}
}
- isFoundWidget = (*anIt) == theWidget;
+ isFoundWidget = isFoundWidget || (*anIt) == theWidget;
}
activateWidget(NULL);
}
emit widgetActivated(theWidget);
} else if (!isEditingMode()) {
emit noMoreWidgets();
+ setFocusOnOkButton();
}
}