]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1042 Sometimes when setting distance constraints, the input field is not displayed...
authornds <nds@opencascade.com>
Thu, 10 Dec 2015 08:14:52 +0000 (11:14 +0300)
committernds <nds@opencascade.com>
Thu, 10 Dec 2015 08:14:52 +0000 (11:14 +0300)
Code correction: moving the sketch functionality in the sketch manager.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index 68d855a482e3be39151f115695395d68b4b13817..f919207faef7460c4d1c8b10e68a4fbdef6a69c6 100755 (executable)
@@ -473,77 +473,11 @@ void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* the
   anOpMgr->onKeyReleased(theEvent);
 }
 
-#include <XGUI_SalomeConnector.h>
 void PartSet_Module::onOperationActivatedByPreselection()
 {
   if (!mySketchReentrantMgr->canBeCommittedByPreselection())
     return;
-
-  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-  if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
-    // Set final definitions if they are necessary
-    //propertyPanelDefined(aOperation);
-    /// Commit sketcher operations automatically
-    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                                                            (anOperation);
-    if (aFOperation) {
-      if (PartSet_SketcherMgr::isDistanceOperation(aFOperation)) {
-        // Activate dimension value editing on double click
-        ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
-        QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
-        // Find corresponded widget to activate value editing
-        foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
-          if (aWgt->attributeID() == "ConstraintValue") {
-            FeaturePtr aFeature = aFOperation->feature();
-            // the featue should be displayed in order to find the AIS text position,
-            // the place where the editor will be shown
-            aFeature->setDisplayed(true);
-            /// the execute is necessary to perform in the feature compute for flyout position
-            aFeature->execute();
-
-            Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
-            Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-
-            PartSet_WidgetEditor* anEditor = dynamic_cast<PartSet_WidgetEditor*>(aWgt);
-            if (anEditor) {
-              int aX = 0, anY = 0;
-              XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
-              XGUI_Workshop* aWorkshop = aConnector->workshop();
-              XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-              AISObjectPtr anAIS = aDisplayer->getAISObject(aFeature);
-              Handle(AIS_InteractiveObject) anAISIO;
-              if (anAIS.get() != NULL) {
-                anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
-              }
-              if (anAIS.get() != NULL) {
-                Handle(AIS_InteractiveObject) anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
-
-                if (!anAISIO.IsNull()) {
-                  Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAISIO);
-                  if (!aDim.IsNull()) {
-                    gp_Pnt aPosition = aDim->GetTextPosition();
-
-                    ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-                    Handle(V3d_View) aView = aViewer->activeView();
-                    int aCX, aCY;
-                    aView->Convert(aPosition.X(), aPosition.Y(), aPosition.Z(), aCX, aCY);
-
-                    QWidget* aViewPort = aViewer->activeViewPort();
-                    QPoint aGlPoint = aViewPort->mapToGlobal(QPoint(aCX, aCY));
-                    aX = aGlPoint.x();
-                    anY = aGlPoint.y();
-                  }
-                }
-                anEditor->setCursorPosition(aX, anY);
-                anEditor->showPopupEditor(false);
-              }
-            }
-          }
-        }
-      }
-    }
-    anOperation->commit();
-  }
+  mySketchMgr->operationActivatedByPreselection();
 }
 
 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
index c308eea3aa9fa022d706757907ce2d8b83c329c8..f46ae2c610f04c151366fb7afc77b04864114dac 100755 (executable)
@@ -68,6 +68,7 @@
 
 //#include <AIS_DimensionSelectionMode.hxx>
 #include <AIS_Shape.hxx>
+#include <AIS_Dimension.hxx>
 
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
@@ -972,6 +973,76 @@ void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
   }
 }
 
+void PartSet_SketcherMgr::operationActivatedByPreselection()
+{
+  ModuleBase_Operation* anOperation = getCurrentOperation();
+  if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
+    // Set final definitions if they are necessary
+    //propertyPanelDefined(aOperation);
+    /// Commit sketcher operations automatically
+    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                                            (anOperation);
+    if (aFOperation) {
+      if (PartSet_SketcherMgr::isDistanceOperation(aFOperation)) {
+        // Activate dimension value editing on double click
+        ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
+        QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+        // Find corresponded widget to activate value editing
+        foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+          if (aWgt->attributeID() == "ConstraintValue") {
+            FeaturePtr aFeature = aFOperation->feature();
+            // the featue should be displayed in order to find the AIS text position,
+            // the place where the editor will be shown
+            aFeature->setDisplayed(true);
+            /// the execute is necessary to perform in the feature compute for flyout position
+            aFeature->execute();
+
+            Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+            Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
+            PartSet_WidgetEditor* anEditor = dynamic_cast<PartSet_WidgetEditor*>(aWgt);
+            if (anEditor) {
+              int aX = 0, anY = 0;
+
+              ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+              XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+              XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+              AISObjectPtr anAIS = aDisplayer->getAISObject(aFeature);
+              Handle(AIS_InteractiveObject) anAISIO;
+              if (anAIS.get() != NULL) {
+                anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
+              }
+              if (anAIS.get() != NULL) {
+                Handle(AIS_InteractiveObject) anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
+
+                if (!anAISIO.IsNull()) {
+                  Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAISIO);
+                  if (!aDim.IsNull()) {
+                    gp_Pnt aPosition = aDim->GetTextPosition();
+
+                    ModuleBase_IViewer* aViewer = aWorkshop->viewer();
+                    Handle(V3d_View) aView = aViewer->activeView();
+                    int aCX, aCY;
+                    aView->Convert(aPosition.X(), aPosition.Y(), aPosition.Z(), aCX, aCY);
+
+                    QWidget* aViewPort = aViewer->activeViewPort();
+                    QPoint aGlPoint = aViewPort->mapToGlobal(QPoint(aCX, aCY));
+                    aX = aGlPoint.x();
+                    anY = aGlPoint.y();
+                  }
+                }
+                anEditor->setCursorPosition(aX, anY);
+                anEditor->showPopupEditor(false);
+              }
+            }
+          }
+        }
+      }
+    }
+    anOperation->commit();
+  }
+}
+
 bool PartSet_SketcherMgr::canUndo() const
 {
   return isNestedCreateOperation(getCurrentOperation());
index 5d31e7d4a1c3adebeac65e9e2ff16bf66bfde58f..71ba10312df149bec88947b6d5bb2cb2e3536c80 100644 (file)
@@ -133,6 +133,10 @@ public:
   /// \param theOperation a committed operation
   void commitNestedSketch(ModuleBase_Operation* theOperation);
 
+  /// Commit the operation if it is possible. If the operation is dimention constraint,
+  /// it gives widget editor to input dimention value
+  void operationActivatedByPreselection();
+
   /// Returns True if there are available Undos and the sketch manager allows undo
   /// \return the boolean result
   bool canUndo() const;