]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
The flyout widget should not accept the focus if the corresponded presentation is...
authornds <nds@opencascade.com>
Wed, 14 Oct 2015 11:01:24 +0000 (14:01 +0300)
committernds <nds@opencascade.com>
Wed, 14 Oct 2015 11:01:57 +0000 (14:01 +0300)
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.

src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAPI/GeomAPI_AISObject.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2DFlyout.cpp [new file with mode: 0755]
src/PartSet/PartSet_WidgetPoint2DFlyout.h [new file with mode: 0755]
src/PartSet/PartSet_WidgetPoint2d.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_PropertyPanel.cpp

index 30879add3d8743dd85afcbcfbe43b979a5ef439d..bd8892987095df14e38c193c0814f0d4835b9cb1 100644 (file)
@@ -141,6 +141,21 @@ void GeomAPI_AISObject::createDistance(std::shared_ptr<GeomAPI_Pnt> theStartPoin
   }
 }
 
+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)
index 6d0a3f2e5187b66c3a7344e565b86a406ddcd2a9..a3c0c23cefa13115b2d735c0fb480725b6cbb500 100644 (file)
@@ -49,6 +49,14 @@ class GeomAPI_AISObject : public GeomAPI_Interface
                       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
index 0db713356e0ec54a8ba83343e567399160c1aa78..350924e1f5bee3d03736244da490efa7a5ce68ea 100644 (file)
@@ -19,6 +19,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetEditor.h
        PartSet_WidgetMultiSelector.h
        PartSet_WidgetPoint2dDistance.h
+       PartSet_WidgetPoint2DFlyout.h
        PartSet_WidgetShapeSelector.h
        PartSet_WidgetFileSelector.h
        PartSet_Filters.h
@@ -43,6 +44,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetPoint2d.cpp
        PartSet_WidgetPoint2dAngle.cpp
        PartSet_WidgetPoint2dDistance.cpp
+       PartSet_WidgetPoint2DFlyout.cpp
        PartSet_WidgetShapeSelector.cpp
        PartSet_WidgetFileSelector.cpp
        PartSet_Filters.cpp
index ae090a39ed3af7ddfdf4482d28589224916ee133..a20479f8cbc70524c11d1c2e0dc863d9608e0429 100755 (executable)
@@ -6,6 +6,7 @@
 #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"
@@ -630,6 +631,12 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
     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);
diff --git a/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp b/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp
new file mode 100755 (executable)
index 0000000..61c2aba
--- /dev/null
@@ -0,0 +1,44 @@
+// 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();
+}
diff --git a/src/PartSet/PartSet_WidgetPoint2DFlyout.h b/src/PartSet/PartSet_WidgetPoint2DFlyout.h
new file mode 100755 (executable)
index 0000000..3c294d3
--- /dev/null
@@ -0,0 +1,48 @@
+// 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
index c85ad2082c2c81906cda79fbe3cdc421c5173b5b..88ae9ac2e21209e66ddfe771a9d56e9634683ba3 100644 (file)
@@ -138,7 +138,10 @@ private slots:
    /// \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
index 3a926c248a25e25499ac8ccdf458740f40a43970..381d4fb8099783476fd1198724f88df7e9d462fe 100644 (file)
@@ -70,7 +70,7 @@
           <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"/>
@@ -85,7 +85,7 @@
         <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>
@@ -99,7 +99,7 @@
             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>
index 1df3582db947ace423990953b47e01a4c0cf14d1..637521cb7a5103fa0fa896dc95c81f36130df86b 100644 (file)
@@ -177,7 +177,7 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
         return;
       }
     }
-    isFoundWidget = (*anIt) == theWidget;
+    isFoundWidget = isFoundWidget || (*anIt) == theWidget;
   }
   activateWidget(NULL);
 }
@@ -207,6 +207,7 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
     emit widgetActivated(theWidget);
   } else if (!isEditingMode()) {
     emit noMoreWidgets();
+    setFocusOnOkButton();
   }
 }