From 7accbed88faf9e9049ed5253a099f5c36084d958 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 14 Jul 2015 08:11:15 +0300 Subject: [PATCH] 1. #700 - filter, preselection of two not coincide edges should fill only first control 2. Preselected default plane to be used as preselection for sketch operation 3. deviation coefficient [commented due to problems of performance] 4. rotation zero value correction after deselection of rotation elements [commented due to debug is necessary] --- src/ModuleBase/ModuleBase_FilterValidated.cpp | 8 ++--- src/ModuleBase/ModuleBase_ResultPrs.cpp | 9 ++++++ src/ModuleBase/ModuleBase_Tools.cpp | 4 +++ src/ModuleBase/ModuleBase_Tools.h | 5 ++++ src/PartSet/PartSet_OperationPrs.cpp | 7 +++++ src/PartSet/PartSet_SketcherMgr.cpp | 3 ++ src/PartSet/PartSet_WidgetSketchLabel.cpp | 30 ++++++++++++------- src/PartSet/PartSet_WidgetSketchLabel.h | 4 +++ src/XGUI/XGUI_Workshop.cpp | 14 +++++---- 9 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/ModuleBase/ModuleBase_FilterValidated.cpp b/src/ModuleBase/ModuleBase_FilterValidated.cpp index a1b9bdb94..88f16c6d8 100644 --- a/src/ModuleBase/ModuleBase_FilterValidated.cpp +++ b/src/ModuleBase/ModuleBase_FilterValidated.cpp @@ -23,11 +23,11 @@ Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityO ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation(); if (anOperation) { ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel(); - ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget(); - if (!anActiveWidget) - anActiveWidget = aPanel->preselectionWidget(); + ModuleBase_ModelWidget* aCurrentWidget = aPanel->preselectionWidget(); + if (!aCurrentWidget) + aCurrentWidget = aPanel->activeWidget(); ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast - (anActiveWidget); + (aCurrentWidget); ModuleBase_ViewerPrs aPrs; myWorkshop->selection()->fillPresentation(aPrs, theOwner); diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index 5dd2f536b..4469a2189 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -5,6 +5,7 @@ // Author: Vitaly SMETANNIKOV #include "ModuleBase_ResultPrs.h" +#include "ModuleBase_Tools.h" #include #include @@ -65,7 +66,15 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t myOriginalShape = aShapePtr->impl(); if (!myOriginalShape.IsNull()) { Set(myOriginalShape); + + // change deviation coefficient to provide more precise circle + Handle(Prs3d_Drawer) aDrawer = Attributes(); + Standard_Real aPrevDeviation = aDrawer->DeviationCoefficient(); + //aDrawer->SetDeviationCoefficient(ModuleBase_Tools::defaultDeviationCoefficient()); + AIS_Shape::Compute(thePresentationManager, thePresentation, theMode); + + //aDrawer->SetDeviationCoefficient(aPrevDeviation); } } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 4dbc9ee3b..40615158a 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -242,6 +242,10 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe } } +double defaultDeviationCoefficient() +{ + return 1.e-5; +} } diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index f0d9ad2b6..cc7ced07a 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -92,6 +92,11 @@ Check types of objects which are in the given list \param hasSubFeature will be set to true if list contains Sub-Feature objects */ MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature); + +/*! Returns the default deviation coefficient value +\return double value +*/ +MODULEBASE_EXPORT double defaultDeviationCoefficient(); } #endif diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index 36de5da03..ca36cc88f 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -11,6 +11,8 @@ #include "XGUI_ModuleConnector.h" #include "XGUI_Displayer.h" +#include "ModuleBase_Tools.h" + #include #include #include @@ -83,7 +85,12 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t for (; aShIt != aShLast; aShIt++) { GeomShapePtr aGeomShape = *aShIt; TopoDS_Shape aShape = aGeomShape->impl(); + // change deviation coefficient to provide more precise circle + Standard_Real aPrevDeviation = aDrawer->DeviationCoefficient(); + //aDrawer->SetDeviationCoefficient(ModuleBase_Tools::defaultDeviationCoefficient()); + StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer); + //aDrawer->SetDeviationCoefficient(aPrevDeviation); } } } diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 73dd90c13..4c83fb774 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -969,6 +969,9 @@ bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& thePln) { + if (myPlaneFilter.IsNull()) + myPlaneFilter = new ModuleBase_ShapeInPlaneFilter(); + myPlaneFilter->setPlane(thePln); } diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 728ebf0ca..566552ba6 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -92,7 +92,12 @@ bool PartSet_WidgetSketchLabel::setSelection(QList& theVal if (plane().get()) return true; - return ModuleBase_WidgetValidated::setSelection(theValues, theToValidate); + ModuleBase_ViewerPrs aPrs = theValues.first(); + bool aDone = ModuleBase_WidgetValidated::setSelection(theValues, theToValidate); + if (aDone) + updateByPlaneSelected(aPrs); + + return aDone; } QList PartSet_WidgetSketchLabel::getControls() const @@ -110,14 +115,17 @@ void PartSet_WidgetSketchLabel::onSelectionChanged() return; ModuleBase_ViewerPrs aPrs = aSelected.first(); - bool isDone = ModuleBase_WidgetValidated::setSelection(aSelected, false); - if (!isDone) - return; + bool aDone = ModuleBase_WidgetValidated::setSelection(aSelected, false); + if (aDone) + updateByPlaneSelected(aPrs); +} - // 3. hide main planes if they have been displayed +void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs) +{ + // 1. hide main planes if they have been displayed erasePreviewPlanes(); - // 4. if the planes were displayed, change the view projection - TopoDS_Shape aShape = aPrs.shape(); + // 2. if the planes were displayed, change the view projection + TopoDS_Shape aShape = thePrs.shape(); std::shared_ptr aGShape; std::shared_ptr aBaseShape; @@ -162,15 +170,15 @@ void PartSet_WidgetSketchLabel::onSelectionChanged() myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z()); } - // 5. Clear text in the label + // 3. Clear text in the label myLabel->setText(""); myLabel->setToolTip(""); disconnect(workshop()->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); - // 6. deactivate face selection filter + // 4. deactivate face selection filter activateFilters(false); - // 7. Clear selection mode and define sketching mode + // 5. Clear selection mode and define sketching mode //XGUI_Displayer* aDisp = workshop()->displayer(); //aDisp->closeLocalContexts(); emit planeSelected(plane()); @@ -179,7 +187,7 @@ void PartSet_WidgetSketchLabel::onSelectionChanged() // the selection by any label deactivation, but need to switch it off by stop the sketch activateSelection(true); - // 8. Update sketcher actions + // 6. Update sketcher actions XGUI_ActionsMgr* anActMgr = workshop()->actionsMgr(); anActMgr->update(); myWorkshop->viewer()->update(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 3eddeb2d2..beaff58be 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -110,6 +110,10 @@ protected: /// The methiod called when widget is activated virtual void activateCustom(); + /// Erase preview planes, disconnect widget, change the view projection + /// \param thePrs a selected presentation + void updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs); + protected: /// Activate or deactivate selection void activateSelection(bool toActivate); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index b2bb15a38..92c158662 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -365,6 +365,14 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation) if (theOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel connectWithOperation(theOperation); setPropertyPanel(theOperation); + // filling the operation values by the current selection + // if the operation can be commited after the controls filling, the method perform should + // be stopped. Otherwise unnecessary presentations can be shown(e.g. operation prs in sketch) + if (!theOperation->isEditOperation()) { + theOperation->activateByPreselection(); + if (operationMgr()->currentOperation() != theOperation) + return; + } } updateCommandStatus(); @@ -384,12 +392,6 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation) deactivateActiveObject(*anIt, false); if (anObjects.size() > 0) myDisplayer->updateViewer(); - - // filling the operation values by the selection in the viewer - // it should be perfomed at the end of the method because it can commit the operation - // if after the controls fill, the operation becomes valid - if (!theOperation->isEditOperation()) - theOperation->activateByPreselection(); } //****************************************************** -- 2.39.2