]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Preselection correction for scenario:
authornds <nds@opencascade.com>
Tue, 6 Sep 2016 05:53:30 +0000 (08:53 +0300)
committernds <nds@opencascade.com>
Tue, 6 Sep 2016 05:53:47 +0000 (08:53 +0300)
create several lines, start point creation. Only first click on the line build a coincidence to the line.

src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index aff8f49eb77a108ebc6e54aefd634cabc3f6c870..2e772162929e4a6bbfe9af5db63e60d1cec51526 100644 (file)
@@ -23,6 +23,8 @@
 #include <QHeaderView>\r
 #include <QToolButton>\r
 \r
+const int DEFAULT_NAME_COLUMN_WIDTH = 200;\r
+\r
 ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent,\r
                                                      const Config_WidgetAPI* theData)\r
 : ModuleBase_ModelWidget(theParent, theData)\r
@@ -124,6 +126,11 @@ void ModuleBase_WidgetConcealedObjects::addViewRow(const std::shared_ptr<ModelAP
 \r
   myView->setCellWidget(anId, 0, aVisibilityBtn);\r
   myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str()));\r
+\r
+  if (anId == 1) {\r
+    myView->setColumnWidth(0, myView->verticalHeader()->defaultSectionSize());\r
+    myView->setColumnWidth(1, DEFAULT_NAME_COLUMN_WIDTH);\r
+  }\r
 }\r
 \r
 void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState)\r
index 95a68cf42f054cc7f186305f12054787aa28e29f..4674f43b1a4b5fca8c21570ffc36c730a64b7c8e 100755 (executable)
@@ -21,6 +21,7 @@
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_OperationDescription.h>
 #include "ModuleBase_ToolBox.h"
+#include "ModuleBase_ISelection.h"
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Line.h>
@@ -209,6 +210,13 @@ bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow*
       ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                            (myWorkshop->currentOperation());
       myPreviousFeature = aFOperation->feature();
+
+      /// selection should be obtained from workshop before ask if the operation can be started as
+      /// the canStartOperation method performs commit/abort of previous operation. Sometimes commit/abort
+      /// may cause selection clear(Sketch operation) as a result it will be lost and is not used for preselection.
+      ModuleBase_ISelection* aSelection = myWorkshop->selection();
+      QList<ModuleBase_ViewerPrsPtr> aPreSelected = aSelection->getSelected(ModuleBase_ISelection::AllControls);
+
       restartOperation();
       myPreviousFeature = FeaturePtr();
       aProcessed = true;
@@ -219,7 +227,11 @@ bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow*
       PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
       ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
       if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
+        if (!aPreSelected.empty())
+          aPoint2DWdg->setPreSelection(aPreSelected.front());
         aPoint2DWdg->mouseReleased(theWnd, theEvent);
+        if (!aPreSelected.empty())
+          aPoint2DWdg->setPreSelection(ModuleBase_ViewerPrsPtr());
       }
       // unblock viewer update
       ModuleBase_Tools::blockUpdateViewer(false);
index 6bdd0009b324aa759c1a2eb6b647313f13d68c89..110ae2648e4294b7eabfc9a6eaf230e6bd6dfcc1 100644 (file)
@@ -450,6 +450,9 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo
 
   QList<ModuleBase_ViewerPrsPtr> aList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
   ModuleBase_ViewerPrsPtr aFirstValue = aList.size() > 0 ? aList.first() : ModuleBase_ViewerPrsPtr();
+  if (!aFirstValue.get() && myPreSelected.get()) {
+    aFirstValue = myPreSelected;
+  }
   // if we have selection and use it
   if (aFirstValue.get() && isValidSelectionCustom(aFirstValue)) {
     GeomShapePtr aGeomShape = aFirstValue->shape();
@@ -585,6 +588,10 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo
   }
 }
 
+void PartSet_WidgetPoint2D::setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected)
+{
+  myPreSelected = thePreSelected;
+}
 
 void PartSet_WidgetPoint2D::mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent)
 {
index a65a51c08a75ab6e1aeb0f22767d65af3c696adf..dcb39aa4e40fbab4c713c97a1c0eec14c8d55cdc 100755 (executable)
@@ -109,6 +109,9 @@ Q_OBJECT
   /// \param theEvent a mouse event
   virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
 
+  /// Fill preselection used in mouseReleased
+  void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
+
 signals:
   /// Signal about selection of an existing vertex from an object
   void vertexSelected();
@@ -197,6 +200,8 @@ private:
   ModuleBase_ParamSpinBox* myXSpin;  ///< the spin box for the X coordinate
   ModuleBase_ParamSpinBox* myYSpin;  ///< the spin box for the Y coordinate
 
+  std::shared_ptr<ModuleBase_ViewerPrs> myPreSelected; ///< value used as selection in mouse release method
+  ///< it is important during restart operation
   CompositeFeaturePtr mySketch;
 
   bool myValueIsCashed; /// boolean state if the value is cashed during value state change