]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Thu, 2 Apr 2015 14:08:02 +0000 (17:08 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 2 Apr 2015 14:08:02 +0000 (17:08 +0300)
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.cpp
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 8b16a24cda7eb1339d08d4ef7a65517a53679b2d..ee2f5727bc45521eedd43078d2a510425e5250ce 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>
@@ -278,14 +280,8 @@ bool PartSet_Module::canRedo() const
 
 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
 {
-  // the display should be possible almost always, with exception of some specific cases
-
-  bool aCanDisplay = true;
-
-  if (mySketchMgr->activeSketch()) {
-    aCanDisplay = mySketchMgr->canDisplayObject(theObject);
-  }
-  return aCanDisplay;
+  // the sketch manager put the restriction to the objects display
+  return mySketchMgr->canDisplayObject(theObject);
 }
 
 bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
@@ -319,6 +315,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 +495,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 10a008fee15c704a0984a6c693dbbedf449301ed..05cf9b550dc68ebb35a7d272212e2a4899e98d69 100644 (file)
@@ -776,42 +776,45 @@ bool PartSet_SketcherMgr::canRedo() const
 bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
 {
   bool aCanDisplay = true;
-  // 1. the sketch feature should not be displayed during the sketch active operation
-  // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch 
-  // nested features can be visualized
-  CompositeFeaturePtr aSketchFeature = activeSketch();
-  if (aSketchFeature.get() != NULL) {
+
+  bool aHasActiveSketch = activeSketch().get() != NULL;
+  if (aHasActiveSketch) {
+    // 1. the sketch feature should not be displayed during the sketch active operation
+    // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch 
+    // nested features can be visualized
     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-    if (aFeature.get() != NULL && aFeature == aSketchFeature)
+    if (aFeature.get() != NULL && aFeature == activeSketch())
       aCanDisplay = false;
   }
-  // 2. For created nested feature operation do not display the created feature if
+  else { // there are no an active sketch
+    // 2. sketch sub-features should not visualized if the sketch operatio is not active
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+    if (aFeature.get() != NULL) {
+      std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+                              std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+      if (aSketchFeature.get() == NULL)
+        aCanDisplay = false;
+    }
+  }
+
+  // 3. For created nested feature operation do not display the created feature if
   // the mouse curstor leaves the OCC window.
   // The correction cases, which ignores this condition:
   // a. the property panel values modification
   // b. the popup menu activated
   // c. widget editor control
-  if (aCanDisplay) {
-    if (!isNestedCreateOperation(getCurrentOperation()))
-      return aCanDisplay;
-
+  if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
     ModuleBase_Operation* aOperation = getCurrentOperation();
     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
     ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
+    ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
     // the active widget editor should not influence here. The presentation should be visible always
     // when this widget is active.
-    if (anActiveWdg) {
-      ModuleBase_WidgetEditor* anEditorWdg = dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg);
-      if (anEditorWdg) {
-        return aCanDisplay;
-      }
+    if (!anEditorWdg && !myIsPopupMenuActive) {
+      // during a nested create operation, the feature is redisplayed only if the mouse over view
+      // of there was a value modified in the property panel after the mouse left the view
+      aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow;
     }
-    if (myIsPopupMenuActive)
-      return aCanDisplay;
-
-    // during a nested create operation, the feature is redisplayed only if the mouse over view
-    // of there was a value modified in the property panel after the mouse left the view
-    aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow;
   }
   return aCanDisplay;
 }
index be687f220730ef4e12c3b68cc3b8d75d6f978da0..ed1ff7294d3c502b16f590fcc4378fd4eebbf2f7 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>