]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue 1302 Restricting preselection to the first argument only
authornds <nds@opencascade.com>
Fri, 11 Mar 2016 08:38:08 +0000 (11:38 +0300)
committernds <nds@opencascade.com>
Fri, 11 Mar 2016 08:38:08 +0000 (11:38 +0300)
12 files changed:
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_OperationFeature.h
src/ModuleBase/ModuleBase_WidgetEditor.cpp
src/ModuleBase/ModuleBase_WidgetEditor.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 294d0f037812315cf2085d3c4c9cbb70b89d4b94..c460480fdaabbab81ad64db869900ee7c9f81c9b 100755 (executable)
@@ -331,15 +331,15 @@ bool ModuleBase_OperationFeature::commit()
   return false;
 }
 
-void ModuleBase_OperationFeature::activateByPreselection(ModuleBase_IWorkshop* theWorkshop)
+ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection(
+                                              const std::string& theGreedAttributeId)
 {
+  ModuleBase_ModelWidget* aWidget = 0;
   if (myPreSelection.empty())
-    return;
-
+    return aWidget;
+  // equal vertices should not be used here
   ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection);
 
-  std::string aGreedAttributeId = ModuleBase_Tools::findGreedAttribute(theWorkshop, myFeature);
-
   ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel();
   ModuleBase_ModelWidget* aFilledWgt = 0;
   if (aPropertyPanel) {
@@ -347,23 +347,18 @@ void ModuleBase_OperationFeature::activateByPreselection(ModuleBase_IWorkshop* t
     QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
     ModuleBase_ModelWidget* aWgt = 0;
     if (!aWidgets.empty()) {
-      if (!aGreedAttributeId.empty()) {
+      if (!theGreedAttributeId.empty()) {
         // set preselection to greed widget
         for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
           aWgt = (*aWIt);
-          if (aWgt->attributeID() == aGreedAttributeId) {
+          if (aWgt->attributeID() == theGreedAttributeId) {
             aPropertyPanel->setPreselectionWidget(aWgt);
             aWgt->setSelection(myPreSelection, true);
             aPropertyPanel->setPreselectionWidget(NULL);
+            aFilledWgt = aWgt;
             break;
           }
         }
-        // activate first not greed widget
-        std::string aFirstAttributeId = aWidgets.front()->attributeID();
-        if (aFirstAttributeId == aGreedAttributeId) // activate next widget after greeded
-          aFilledWgt = aWidgets.front();
-        else
-          aFilledWgt = NULL; // activate first widget of the panel
       }
       else {
         bool isSet = false;
@@ -387,18 +382,11 @@ void ModuleBase_OperationFeature::activateByPreselection(ModuleBase_IWorkshop* t
       // it is better to perform it not in setSelection of each widget, but do it here,
       // after the preselection is processed
       ModuleBase_ModelWidget::updateObject(myFeature);
-
-      // 3. a signal should be emitted before the next widget activation
-      // because, the activation of the next widget will give a focus to the widget. As a result
-      // the value of the widget is initialized. And commit may happens until the value is entered.
-      if (aFilledWgt)
-        emit activatedByPreselection();
     }
   }
-  // 4. activate the next obligatory widget
-  aPropertyPanel->activateNextWidget(aFilledWgt);
-
   clearPreselection();
+
+  return aFilledWgt;
 }
 
 void ModuleBase_OperationFeature::setParentFeature(CompositeFeaturePtr theParent)
index c2411b8841c217e385aac9398afe09d614b7d9ab..2d1844d131abb30a5abe536eda018224628fdfdf 100755 (executable)
@@ -105,8 +105,10 @@ Q_OBJECT
   /// \return Currently installed property panel
   //ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
 
-  /// Activates widgets by preselection if it is accepted. Emits signal if the activation is correct
-  virtual void activateByPreselection(ModuleBase_IWorkshop* theWorkshop);
+  /// Activates widgets by preselection if it is accepted.
+  /// \param theGreeAttributeId a greed attribute id if there is in the current feature
+  /// \return last filled widget
+  virtual ModuleBase_ModelWidget* activateByPreselection(const std::string& theGreedAttributeId);
 
   /// If the operation works with feature which is sub-feature of another one
   /// then this variable has to be initialised by parent feature 
@@ -124,10 +126,6 @@ Q_OBJECT
   /// \return theFeature a feature
   FeaturePtr previousCurrentFeature();
 
-signals:
-  /// The operation is filled with existing preselection
-  void activatedByPreselection(); 
-
  public slots:
   /// Starts operation
   /// Public slot. Verifies whether operation can be started and starts operation.
index b5dee0c4d8430f7bd80556a926e846ccfcdfc349..3adc21b0d452e653b5a0c32ed4665bdfb3caca70 100644 (file)
@@ -43,8 +43,10 @@ ModuleBase_WidgetEditor::~ModuleBase_WidgetEditor()
 {
 }
 
-void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText)
+bool ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText)
 {
+  bool isValueAccepted = false;
+
   QDialog aDlg(QApplication::desktop(), Qt::FramelessWindowHint);
   QHBoxLayout* aLay = new QHBoxLayout(&aDlg);
   aLay->setContentsMargins(2, 2, 2, 2);
@@ -70,15 +72,17 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText)
     aPoint = QPoint(myXPosition, myYPosition);
 
   aDlg.move(aPoint);
-  aDlg.exec();
-
-  outText = anEditor->text();
-  bool isDouble;
-  double aValue = outText.toDouble(&isDouble);
-  if (isDouble) {
-    outValue = aValue;
-    outText = ""; // return empty string, if it's can be converted to a double
+  isValueAccepted = aDlg.exec() == QDialog::Accepted;
+  if (isValueAccepted) {
+    outText = anEditor->text();
+    bool isDouble;
+    double aValue = outText.toDouble(&isDouble);
+    if (isDouble) {
+      outValue = aValue;
+      outText = ""; // return empty string, if it's can be converted to a double
+    }
   }
+  return isValueAccepted;
 }
 
 bool ModuleBase_WidgetEditor::focusTo()
@@ -87,8 +91,9 @@ bool ModuleBase_WidgetEditor::focusTo()
   return true;
 }
 
-void ModuleBase_WidgetEditor::showPopupEditor(const bool theSendSignals)
+bool ModuleBase_WidgetEditor::showPopupEditor(const bool theSendSignals)
 {
+  bool isValueAccepted = false;
   // we need to emit the focus in event manually in order to save the widget as an active
   // in the property panel before the mouse leave event happens in the viewer. The module
   // ask an active widget and change the feature visualization if the widget is not the current one.
@@ -103,23 +108,27 @@ void ModuleBase_WidgetEditor::showPopupEditor(const bool theSendSignals)
   if (mySpinBox->hasVariable())
     aText = mySpinBox->text();
 
-  editedValue(aValue, aText);
-  if (aText.isEmpty()) {
-    ModuleBase_Tools::setSpinValue(mySpinBox, aValue);
-  } else {
-    ModuleBase_Tools::setSpinText(mySpinBox, aText);
-  }
-  if (theSendSignals) {
-    emit valuesChanged();
-    // the focus leaves the control automatically by the Enter/Esc event
-    // it is processed in operation manager
-    //emit focusOutWidget(this);
-
-    if (!myIsEditing)
-      emit enterClicked(this);
+  isValueAccepted = editedValue(aValue, aText);
+  if (isValueAccepted) {
+    if (aText.isEmpty()) {
+      ModuleBase_Tools::setSpinValue(mySpinBox, aValue);
+    } else {
+      ModuleBase_Tools::setSpinText(mySpinBox, aText);
+    }
+    if (theSendSignals) {
+      emit valuesChanged();
+      // the focus leaves the control automatically by the Enter/Esc event
+      // it is processed in operation manager
+      //emit focusOutWidget(this);
+    }
+    else
+      storeValue();
   }
-  else
-    storeValue();
+
+  if (theSendSignals && !myIsEditing)
+    emit enterClicked(this);
+
+  return isValueAccepted;
 }
 
 void ModuleBase_WidgetEditor::setCursorPosition(const int theX, const int theY)
index db9dd1cc422f65dbef5030a98a11c92daeadd860..049188026867a320f4b08caff602ebfb513dbe02 100644 (file)
@@ -44,12 +44,17 @@ Q_OBJECT
   /// Shous popup window under cursor for data editing
   /// \param theSendSignals a flag whether the signals should be sent or the value
   /// is to be applyed directly
-  void showPopupEditor(const bool theSendSignals = true);
+  /// \return true if the editor value is accepted
+  bool showPopupEditor(const bool theSendSignals = true);
 
   void setCursorPosition(const int theX, const int theY);
 
 private:
-   void editedValue(double& outValue, QString& outText);
+  /// Show editor
+  /// \param theOutValue a result value
+  /// \param theOutText a result text
+  /// \return true if the editor value is accepted
+  bool editedValue(double& theOutValue, QString& theOutText);
 
  private:
    ///< the current widget feature
index 0849ba3e31f7c4073cdb456c48b6ddb44bd35089..3f2ef5ed89f1bbf75327f0f165b2ed3bb73562f9 100755 (executable)
@@ -125,10 +125,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
   XGUI_Workshop* aWorkshop = aConnector->workshop();
 
-  XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
-  connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
-          this, SLOT(onOperationActivatedByPreselection()));
-
   ModuleBase_IViewer* aViewer = theWshop->viewer();
   connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
           this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
@@ -275,6 +271,86 @@ void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
 }
 
 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
+{
+  ModuleBase_IWorkshop* anIWorkshop = workshop();
+  if (!theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
+    anIWorkshop->updateCommandStatus();
+  }
+  else {
+    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                                                 (theOperation);
+    if (aFOperation) {
+      XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(anIWorkshop);
+      XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+      ModuleBase_ModelWidget* aFilledWidget = 0;
+      bool aPostonedWidgetActivation = false;
+      FeaturePtr aFeature = aFOperation->feature();
+
+      std::string aGreedAttributeId = ModuleBase_Tools::findGreedAttribute(anIWorkshop, aFeature);
+      // if there is a greed attribute, automatic commit by preselection for this feature is prohibited
+      aWorkshop->setPropertyPanel(aFOperation);
+
+      // filling the operation values by the current selection
+      // if the operation can be committed after the controls filling, the method perform should
+      // be stopped. Otherwise unnecessary presentations can be shown(e.g. operation prs in sketch)
+      bool isOperationCommitted = false;
+      if (!aFOperation->isEditOperation()) {
+        aFilledWidget = aFOperation->activateByPreselection(aGreedAttributeId);
+        if (currentOperation() != aFOperation)
+          isOperationCommitted = true;
+        else {
+          if (aGreedAttributeId.empty()) {
+            // a signal should be emitted before the next widget activation
+            // because, the activation of the next widget will give a focus to the widget. As a result
+            // the value of the widget is initialized. And commit may happens until the value is entered.
+            if (aFilledWidget) {
+              if (mySketchReentrantMgr->canBeCommittedByPreselection())
+                isOperationCommitted = mySketchMgr->operationActivatedByPreselection();
+              // activate the next obligatory widget
+              if (!isOperationCommitted)
+                aPropertyPanel->activateNextWidget(aFilledWidget);
+            }
+          }
+          else { // there is a greed widget
+            const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+            std::string aFirstAttributeId = aWidgets.front()->attributeID();
+            // activate next widget after greeded if it is the first widget in the panel
+            // else the first panel widget is already activated by operation start
+            if (aFirstAttributeId == aGreedAttributeId)
+              aPostonedWidgetActivation = true;
+          }
+        }
+      } if (!isOperationCommitted) {
+        anIWorkshop->updateCommandStatus();
+        aWorkshop->connectToPropertyPanel(true);
+        operationStartedInternal(aFOperation);
+
+        // the objects of the current operation should be deactivated
+        QObjectPtrList anObjects;
+        anObjects.append(aFeature);
+        std::list<ResultPtr> aResults = aFeature->results();
+        std::list<ResultPtr>::const_iterator aIt;
+        for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+          anObjects.append(*aIt);
+        }
+        QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
+        for (; anIt != aLast; anIt++)
+          aWorkshop->deactivateActiveObject(*anIt, false);
+        if (anObjects.size() > 0) {
+          XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+          aDisplayer->updateViewer();
+        }
+      }
+      if (aPostonedWidgetActivation) {
+        // if the widget is an empty in the chain of activated widgets, the current operation
+        // is restarted. It should be performed after functionality of the operation starting
+        aPropertyPanel->activateNextWidget(aFilledWidget);
+      }
+    }
+  }
+}
+
+void PartSet_Module::operationStartedInternal(ModuleBase_Operation* theOperation)
 {
   /// Restart sketcher operations automatically
   mySketchReentrantMgr->operationStarted(theOperation);
@@ -557,13 +633,6 @@ void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* the
   anOpMgr->onKeyReleased(theWnd->viewPort(), theEvent);
 }
 
-void PartSet_Module::onOperationActivatedByPreselection()
-{
-  if (!mySketchReentrantMgr->canBeCommittedByPreselection())
-    return;
-  mySketchMgr->operationActivatedByPreselection();
-}
-
 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType,
                                                            QWidget* theParent,
                                                            Config_WidgetAPI* theWidgetApi)
index d3731bd8be0e9365a6c9856e11f6bb26465881e9..2581d7bb2d5f4889381f56a0d5054d647d30466d 100755 (executable)
@@ -312,10 +312,6 @@ protected slots:
   /// \param theEvent the key event
   void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
 
-  /// SLOT, that is called by the current operation filling with the preselection.
-  /// It commits the operation of it is can be committed
-  void onOperationActivatedByPreselection();
-
   /// A slot called on view window creation
   void onViewCreated(ModuleBase_IViewWindow*);
 
@@ -338,6 +334,12 @@ protected:
   /// \param isToConnect a boolean value whether connect or disconnect
   virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect);
 
+  /// Realizes some functionality by an operation start
+  /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
+  /// Activate the operation presentation
+  /// \param theOperation a started operation
+  virtual void operationStartedInternal(ModuleBase_Operation* theOperation);
+
  private slots:
    void onTreeViewDoubleClick(const QModelIndex&);
 
index dcb1a81b57d0dc1990b58e287945e0975e7425d4..869ee082b33616d5db73e77f5476affd639b8e84 100755 (executable)
@@ -23,6 +23,7 @@
 #include <XGUI_PropertyPanel.h>
 #include <XGUI_ViewerProxy.h>
 #include <XGUI_OperationMgr.h>
+#include <XGUI_Tools.h>
 
 #include <ModuleBase_IPropertyPanel.h>
 #include <ModuleBase_ISelection.h>
@@ -1008,85 +1009,30 @@ void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate)
     myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
 }
 
-void PartSet_SketcherMgr::operationActivatedByPreselection()
+bool PartSet_SketcherMgr::operationActivatedByPreselection()
 {
+  bool isOperationStopped = false;
   ModuleBase_Operation* anOperation = getCurrentOperation();
   if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
     // Set final definitions if they are necessary
     //propertyPanelDefined(aOperation);
     /// Commit sketcher operations automatically
+    /// distance operation are able to show popup editor to modify the distance value
+    /// after entering the value, the operation should be committed/aborted(by Esc key)
+    bool aCanCommitOperation = true;
     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                             (anOperation);
-    if (aFOperation) {
-      if (PartSet_SketcherMgr::isDistanceOperation(aFOperation)) {
-        FeaturePtr aFeature = aFOperation->feature();
-        // editor is shown only if all attribute references are filled by preseletion
-        bool anAllRefAttrInitialized = true;
-
-        std::list<AttributePtr> aRefAttrs = aFeature->data()->attributes(
-                                                    ModelAPI_AttributeRefAttr::typeId());
-        std::list<AttributePtr>::const_iterator anIt = aRefAttrs.begin(), aLast = aRefAttrs.end();
-        for (; anIt != aLast && anAllRefAttrInitialized; anIt++) {
-          anAllRefAttrInitialized = (*anIt)->isInitialized();
-        }
-        if (anAllRefAttrInitialized) {
-          // 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") {
-              // 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);
-                }
-              }
-            }
-          }
-        }
-      }
+    if (aFOperation && PartSet_SketcherMgr::isDistanceOperation(aFOperation))
+      aCanCommitOperation = setDistanceValueByPreselection(anOperation, myModule->workshop());
+
+    if (aCanCommitOperation)
+      isOperationStopped = anOperation->commit();
+    else {
+      anOperation->abort();
+      isOperationStopped = true;
     }
-    anOperation->commit();
   }
+  return isOperationStopped;
 }
 
 bool PartSet_SketcherMgr::canUndo() const
@@ -1370,6 +1316,79 @@ void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& th
   myPlaneFilter->setPlane(thePln);
 }
 
+bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* theOperation,
+                                                         ModuleBase_IWorkshop* theWorkshop)
+{
+  bool isValueAccepted = false;
+
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                                              (theOperation);
+  FeaturePtr aFeature = aFOperation->feature();
+  // editor is shown only if all attribute references are filled by preseletion
+  bool anAllRefAttrInitialized = true;
+
+  std::list<AttributePtr> aRefAttrs = aFeature->data()->attributes(
+                                              ModelAPI_AttributeRefAttr::typeId());
+  std::list<AttributePtr>::const_iterator anIt = aRefAttrs.begin(), aLast = aRefAttrs.end();
+  for (; anIt != aLast && anAllRefAttrInitialized; anIt++) {
+    anAllRefAttrInitialized = (*anIt)->isInitialized();
+  }
+  if (anAllRefAttrInitialized) {
+    // 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") {
+        // 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_Workshop* aWorkshop = XGUI_Tools::workshop(theWorkshop);
+          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 = 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);
+            isValueAccepted = anEditor->showPopupEditor(false);
+          }
+        }
+      }
+    }
+  }
+  return isValueAccepted;
+}
+
 void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
                                               const FeaturePtr& theSketch,
                                               ModuleBase_IWorkshop* theWorkshop,
index ef5fb511a5fe41cee6c2cc93d5c27c0e0324c3d2..a7118e899e09b4035258cbe6fa80edb2e264179b 100644 (file)
@@ -149,7 +149,8 @@ public:
 
   /// Commit the operation if it is possible. If the operation is dimention constraint,
   /// it gives widget editor to input dimention value
-  void operationActivatedByPreselection();
+  /// \return true if the operation is stopped after activation
+  bool operationActivatedByPreselection();
 
   /// Returns True if there are available Undos and the sketch manager allows undo
   /// \return the boolean result
@@ -284,6 +285,12 @@ private:
   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
                   Point& thePoint);
 
+  /// Show distance value editor if it is a distance operation and all attribute references
+  /// are filled by preseletion
+  /// \return true if the value is accepted
+  static bool setDistanceValueByPreselection(ModuleBase_Operation* theOperation,
+                                             ModuleBase_IWorkshop* theWorkshop);
+
   typedef QMap<FeaturePtr, std::pair<std::set<AttributePtr>, std::set<ResultPtr> > >
                                                                        FeatureToSelectionMap;
 
index 3e6c412235cbbcaef8a5b84a0576d08f1632c321..e2b43b619f271b868d0790bb2b7e21ba049f9977 100644 (file)
@@ -194,11 +194,6 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
 
   connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
   connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
-  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                                                        (theOperation);
-  if (aFOperation)
-    connect(aFOperation, SIGNAL(activatedByPreselection()),
-            SIGNAL(operationActivatedByPreselection()));
 
   bool isStarted = theOperation->start();
   if (isStarted)
index 7a62ddbe3efd2cabecbfb81b341a28275580316f..3b08ba8b9ef7b72b82cc3fa270dbfd8dd90209cf 100755 (executable)
@@ -134,9 +134,6 @@ signals:
   /// Emitted when current operation is aborted
   void operationAborted(ModuleBase_Operation* theOperation);
 
-  /// Signal is emitted after the current operation is filled with existing preselection.
-  void operationActivatedByPreselection();
-
   /// Signal is emitted after the key released click.
   void keyEnterReleased();
 
index e04181c6c36f2f2c3567149b461eead199e3b65a..e5c0578d28aa91b9e4685346f4b983fdb85023ac 100755 (executable)
@@ -439,42 +439,7 @@ bool XGUI_Workshop::isFeatureOfNested(const FeaturePtr& theFeature)
 void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation)
 {
   setGrantedFeatures(theOperation);
-
-  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                                                               (theOperation);
-  if (!aFOperation)
-    return;
-
-  if (aFOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
-    setPropertyPanel(aFOperation);
-    // filling the operation values by the current selection
-    // if the operation can be committed after the controls filling, the method perform should
-    // be stopped. Otherwise unnecessary presentations can be shown(e.g. operation prs in sketch)
-    if (!aFOperation->isEditOperation()) {
-      aFOperation->activateByPreselection(moduleConnector());
-      if (operationMgr()->currentOperation() != aFOperation)
-        return;
-    }
-  }
-  updateCommandStatus();
-
-  connectToPropertyPanel(true);
-  myModule->operationStarted(aFOperation);
-
-  // the objects of the current operation should be deactivated
-  QObjectPtrList anObjects;
-  FeaturePtr aFeature = aFOperation->feature();
-  anObjects.append(aFeature);
-  std::list<ResultPtr> aResults = aFeature->results();
-  std::list<ResultPtr>::const_iterator aIt;
-  for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
-    anObjects.append(*aIt);
-  }
-  QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
-  for (; anIt != aLast; anIt++)
-    deactivateActiveObject(*anIt, false);
-  if (anObjects.size() > 0)
-    myDisplayer->updateViewer();
+  myModule->operationStarted(theOperation);
 }
 
 //******************************************************
index 00245d70e0f0f26370957a44fe4c4e45c60671c3..37685b16975e972402f10fd5ed111b13e3157fe2 100755 (executable)
@@ -258,6 +258,15 @@ Q_OBJECT
   /// \param theUpdateViewer update viewer flag
   void synchronizeGroupInViewer(const DocumentPtr& theDoc, const std::string& theGroup, bool theUpdateViewer);
 
+  /// Update the property panel content by the XML description of the operation and set the panel
+  /// into the operation
+  /// \param theOperation an operation
+  void setPropertyPanel(ModuleBase_Operation* theOperation);
+
+  /// Connects or disconnects to the value changed signal of the property panel widgets
+  /// \param isToConnect a boolean value whether connect or disconnect
+  void connectToPropertyPanel(const bool isToConnect);
+
   /// A constant string used for "Move to end" command definition
   /// It is used for specific processing of Undo/Redo for this command.
   static QString MOVE_TO_END_COMMAND;
@@ -349,15 +358,6 @@ signals:
   /// \param theOperation an operation
    void setGrantedFeatures(ModuleBase_Operation* theOperation);
 
-  /// Update the property panel content by the XML description of the operation and set the panel
-  /// into the operation
-  /// \param theOperation an operation
-  void setPropertyPanel(ModuleBase_Operation* theOperation);
-
-  /// Connects or disconnects to the value changed signal of the property panel widgets
-  /// \param isToConnect a boolean value whether connect or disconnect
-  void connectToPropertyPanel(const bool isToConnect);
-
   //! Find all referenced features. Return direct and indirect lists of referenced object
   //! \param theList an objects to be checked
   //! \param aDirectRefFeatures a list of direct reference features