Salome HOME
Issue #422 - Application hangs up when apply Fillet constraint on preselected segments
authornds <natalia.donis@opencascade.com>
Thu, 2 Apr 2015 12:56:03 +0000 (15:56 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 2 Apr 2015 12:56:03 +0000 (15:56 +0300)
Do not show an editor control if the mouse is out of the viewer. So, for creation a fillet by preselection, the double value control is active

src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_WidgetEditor.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetEditor.h [new file with mode: 0644]
src/SketchPlugin/plugin-Sketch.xml

index 084ba04bf563f555f4ad9d2bad5d631d6ba55f13..68dd1322176bd6a73e83687402f769d7f0e99946 100644 (file)
@@ -239,12 +239,12 @@ void ModuleBase_Operation::activateByPreselection()
     }
   }
   // 2. ignore not obligatory widgets
-  for (; aWIt != aWidgets.constEnd(); ++aWIt) {
+  /*for (; aWIt != aWidgets.constEnd(); ++aWIt) {
     aWgt = (*aWIt);
     if (aWgt && aWgt->isObligatory())
       continue;
     aFilledWgt = aWgt;
-  }
+  }*/
 
   // 3. activate the next obligatory widget
   myPropertyPanel->activateNextWidget(aFilledWgt);
index 93c3e7271a86ea824de85398c0f4571bf0c8774a..6925ee993efa84fad1448ebf86bd84900368af51 100644 (file)
@@ -132,9 +132,6 @@ ModuleBase_ModelWidget* ModuleBase_WidgetFactory
   } else if (theType == WDG_BOOLVALUE) {
     result = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
 
-  } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
-    result = new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
-
   } else if (theType == WDG_FILE_SELECTOR) {
     result = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
 
index d10a13c9f857fa9c5c978713521a59784a5e2d18..59affd8ca2b9d21b123b38efd12a06f3dcb027ce 100644 (file)
@@ -13,6 +13,7 @@ SET(PROJECT_HEADERS
        PartSet_Validators.h
        PartSet_WidgetPoint2d.h
        PartSet_WidgetConstraintShapeSelector.h
+    PartSet_WidgetEditor.h
        PartSet_WidgetPoint2dDistance.h
        PartSet_WidgetShapeSelector.h
        PartSet_Filters.h
@@ -26,6 +27,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetSketchLabel.cpp
        PartSet_Validators.cpp
        PartSet_WidgetConstraintShapeSelector.cpp
+    PartSet_WidgetEditor.cpp
        PartSet_WidgetPoint2d.cpp
        PartSet_WidgetPoint2dDistance.cpp
        PartSet_WidgetShapeSelector.cpp
index 4c685683578f2cd490d3964e314fca495da18414..f62c677a27b352e96ede8d12f2f7b523d5b90a8b 100644 (file)
@@ -8,6 +8,7 @@
 #include <PartSet_WidgetPoint2dDistance.h>
 #include <PartSet_WidgetShapeSelector.h>
 #include <PartSet_WidgetConstraintShapeSelector.h>
+#include <PartSet_WidgetEditor.h>
 #include <PartSet_SketcherMgr.h>
 
 #include <ModuleBase_Operation.h>
@@ -63,6 +64,7 @@
 
 #include <Events_Loop.h>
 #include <Config_PropManager.h>
+#include <Config_Keywords.h>
 
 #include <StdSelect_TypeOfFace.hxx>
 #include <TopoDS_Vertex.hxx>
@@ -319,6 +321,11 @@ bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*
   return true;
 }
 
+bool PartSet_Module::isMouseOverWindow()
+{
+  return mySketchMgr->isMouseOverWindow();
+}
+
 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
 {
   ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
@@ -494,7 +501,9 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
       new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
     aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aConstraintShapeSelectorWgt;
-  }
+  } if (theType == WDG_DOUBLEVALUE_EDITOR) {
+    aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
+  } 
   return aWgt;
 }
 
index 5264352dc98b0563d12877f826f862cce2cd67dd..904175b1336c7d35bbe085e15cca25fd17995a8d 100644 (file)
@@ -107,6 +107,10 @@ public:
   /// \return true if items are added and there is no necessity to provide standard menu
   virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
 
+  /// Returns whether the mouse enter the viewer's window
+  /// \return true if items are added and there is no necessity to provide standard menu
+  bool isMouseOverWindow();
+
 public slots:
   /// SLOT, that is called by no more widget signal emitted by property panel
   /// Set a specific flag to restart the sketcher operation
index aad09ef0fda92803c1694ca56c514e79711aad5b..6f30ea45a915a0dd0f9b3f06c95733a3da5f4c0a 100644 (file)
@@ -102,6 +102,8 @@ public:
   /// \return a boolean value
   static bool isDistanceOperation(ModuleBase_Operation* theOperation);
 
+  bool isMouseOverWindow() { return myIsMouseOverWindow; }
+
   /// Returns current Sketch feature/ Returns NULL if there is no launched sketch operation
   CompositeFeaturePtr activeSketch() const { return myCurrentSketch; }
 
diff --git a/src/PartSet/PartSet_WidgetEditor.cpp b/src/PartSet/PartSet_WidgetEditor.cpp
new file mode 100644 (file)
index 0000000..66ed150
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetShapeSelector.cpp
+// Created:     27 Nov 2014
+// Author:      Vitaly Smetannikov
+
+#include "PartSet_WidgetEditor.h"
+#include "PartSet_Module.h"
+
+#include <ModuleBase_IWorkshop.h>
+
+#include <Config_WidgetAPI.h>
+
+#include <QWidget>
+
+PartSet_WidgetEditor::PartSet_WidgetEditor(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+                                           const Config_WidgetAPI* theData,
+                                           const std::string& theParentId)
+ : ModuleBase_WidgetEditor(theParent, theData, theParentId), myWorkshop(theWorkshop)
+{
+}
+
+bool PartSet_WidgetEditor::focusTo()
+{
+  PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+  if (aModule->isMouseOverWindow())
+    return ModuleBase_WidgetDoubleValue::focusTo();
+  else {
+    ModuleBase_WidgetEditor::focusTo();
+  }
+}
diff --git a/src/PartSet/PartSet_WidgetEditor.h b/src/PartSet/PartSet_WidgetEditor.h
new file mode 100644 (file)
index 0000000..a4f6111
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetShapeSelector.h
+// Created:     27 Nov 2014
+// Author:      Vitaly Smetannikov
+
+
+#ifndef PartSet_WidgetEditor_H
+#define PartSet_WidgetEditor_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_WidgetEditor.h>
+
+class ModuleBase_IWorkshop;
+
+/**
+* \ingroup Modules
+* Customosation of ModuleBase_WidgetEditor in order to do not show the editor value if the mouse
+* cursor is not over the OCC window
+*/
+class PARTSET_EXPORT PartSet_WidgetEditor : public ModuleBase_WidgetEditor
+{
+Q_OBJECT
+ public:
+  /// Constructor
+  /// \param theParent the parent object
+  /// \param theWorkshop instance of workshop interface
+  /// \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_WidgetEditor(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+                       const Config_WidgetAPI* theData, const std::string& theParentId);
+
+  virtual ~PartSet_WidgetEditor() {}
+
+  /// 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:
+  ModuleBase_IWorkshop* myWorkshop; // the current workshop
+};
+
+#endif
\ No newline at end of file
index caeb92d8d45f78528ad6fc4854d353f8f49fb901..f2bce5f32c89d4c47fcb6adccf7b9319ddf56be4 100644 (file)
             label="Last object" tooltip="Select line or arc" shape_types="edge">
         </sketch_constraint_shape_selector>
 
-        <doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" default="1" min="0" obligatory="0">
+        <doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0">
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
       </feature>