From: nds Date: Tue, 6 Sep 2016 05:53:30 +0000 (+0300) Subject: Preselection correction for scenario: X-Git-Tag: V_2.5.0~54 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=19376bdf1642897fc498d54784c8ab17018f54dd;p=modules%2Fshaper.git Preselection correction for scenario: create several lines, start point creation. Only first click on the line build a coincidence to the line. --- diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp index aff8f49eb..2e7721629 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp @@ -23,6 +23,8 @@ #include #include +const int DEFAULT_NAME_COLUMN_WIDTH = 200; + ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent, const Config_WidgetAPI* theData) : ModuleBase_ModelWidget(theParent, theData) @@ -124,6 +126,11 @@ void ModuleBase_WidgetConcealedObjects::addViewRow(const std::shared_ptrsetCellWidget(anId, 0, aVisibilityBtn); myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str())); + + if (anId == 1) { + myView->setColumnWidth(0, myView->verticalHeader()->defaultSectionSize()); + myView->setColumnWidth(1, DEFAULT_NAME_COLUMN_WIDTH); + } } void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState) diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 95a68cf42..4674f43b1 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -21,6 +21,7 @@ #include #include #include "ModuleBase_ToolBox.h" +#include "ModuleBase_ISelection.h" #include #include @@ -209,6 +210,13 @@ bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow* ModuleBase_OperationFeature* aFOperation = dynamic_cast (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 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(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); diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 6bdd0009b..110ae2648 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -450,6 +450,9 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo QList 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& thePreSelected) +{ + myPreSelected = thePreSelected; +} void PartSet_WidgetPoint2D::mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent) { diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index a65a51c08..dcb39aa4e 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -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& 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 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