From: nds Date: Thu, 11 Jun 2015 12:48:35 +0000 (+0300) Subject: SkethMgr - to avoid big arrows in gzy_reactor file X-Git-Tag: V_1.3.0~250 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=90ae02f67bbf42f79ea2fc05404d455159cb53a7;p=modules%2Fshaper.git SkethMgr - to avoid big arrows in gzy_reactor file Displayer - performance correction on the file ISelection, WidgetValidated - preliminary processing of preselection --- diff --git a/src/ModuleBase/ModuleBase_ISelection.cpp b/src/ModuleBase/ModuleBase_ISelection.cpp index 190447668..708382115 100644 --- a/src/ModuleBase/ModuleBase_ISelection.cpp +++ b/src/ModuleBase/ModuleBase_ISelection.cpp @@ -1,7 +1,44 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D #include "ModuleBase_ISelection.h" +//******************************************************************** +ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs) +{ + ResultPtr aResult; + + if (!thePrs.owner().IsNull()) { + ObjectPtr anObject = getSelectableObject(thePrs.owner()); + aResult = std::dynamic_pointer_cast(anObject); + } + else { + aResult = std::dynamic_pointer_cast(thePrs.object()); + } + + return aResult; +} + +//******************************************************************** +GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs) +{ + GeomShapePtr aShape; + + const TopoDS_Shape& aTDSShape = thePrs.shape(); + // if only result is selected, an empty shape is set to the model + if (aTDSShape.IsNull()) { + } + else { + aShape = GeomShapePtr(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aTDSShape)); + // If the result object is built on the same shape, the result shape here is empty one + ResultPtr aResult = getResult(thePrs); + if (aResult.get() && aShape->isEqual(aResult->shape())) + aShape = GeomShapePtr(); + } + return aShape; +} + +//******************************************************************** QList ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects) { QList aSelectedPrs; diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 86cfd4f52..e6a92d558 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D // File: ModuleBase_ISelection.h // Created: 2 June 2014 @@ -11,6 +11,9 @@ #include "ModuleBase_Definitions.h" #include "ModuleBase_ViewerPrs.h" +#include +#include + #include #include #include @@ -70,6 +73,18 @@ class ModuleBase_ISelection virtual void selectedShapes(NCollection_List& theList, std::list& theOwners) const = 0; + //! Return the shape from the viewer presentation. + //! If the shape is equal to the shape of selected object, it returns an empty shape + //! \param thePrs a selected object + //! \return a shape + MODULEBASE_EXPORT ResultPtr getResult(const ModuleBase_ViewerPrs& thePrs); + + //! Return the shape from the viewer presentation. + //! If the shape is equal to the shape of selected object, it returns an empty shape + //! \param thePrs a selected object + //! \return a shape + MODULEBASE_EXPORT GeomShapePtr getShape(const ModuleBase_ViewerPrs& thePrs); + //! Wraps the object list into the viewer prs list //! \param theObjects a list of objects //! \return a list of prs, where only object is not empty diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 619548f39..6caa7de0b 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D #include #include @@ -49,6 +49,10 @@ bool ModuleBase_WidgetValidated::setSelection(const QList& //******************************************************************** bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue) { + bool aValid = isValidSelectionCustom(theValue); + if (!aValid) + return aValid; + DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); @@ -63,8 +67,7 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th storeAttributeValue(); // saves the owner value to the widget attribute - bool aValid = setSelectionCustom(theValue); - + aValid = setSelectionCustom(theValue); if (aValid) // checks the attribute validity aValid = isValidAttribute(); @@ -88,6 +91,12 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th return aValid; } +//******************************************************************** +bool ModuleBase_WidgetValidated::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +{ + return true; +} + //******************************************************************** bool ModuleBase_WidgetValidated::isValidAttribute() const { diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 0ac6657e7..5c4f319dc 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D // File: ModuleBase_WidgetValidated.h // Created: 12 Mar 2015 @@ -41,7 +41,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg virtual ~ModuleBase_WidgetValidated(); /// Checks all widget validator if the owner is valid - /// \param theOwner a selected owner in the view + /// \param theValue a selected presentation in the view /// \return a boolean value bool isValidSelection(const ModuleBase_ViewerPrs& theValue); @@ -65,6 +65,11 @@ protected: /// \param theValid a boolean flag, if restore happens for valid parameters virtual void restoreAttributeValue(const bool theValid) = 0; + /// Checks the widget validity. By default, it returns true. + /// \param theValue a selected presentation in the view + /// \return a boolean value + virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + /// Fills the attribute with the value of the selected owner /// \param theOwner a selected owner virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0; diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 1228a03ba..aa57ecd8a 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -157,6 +157,10 @@ public slots: /// \param theAIS a presentation object virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS); + /// Called on transformation in current viewer + /// \param theTrsfType type of tranformation + void onViewTransformed(int theTrsfType = 2); + protected slots: /// Called when previous operation is finished virtual void onSelectionChanged(); @@ -188,10 +192,6 @@ protected slots: /// Processing of vertex selected void onVertexSelected(); - /// Called on transformation in current viewer - /// \param theTrsfType type of tranformation - void onViewTransformed(int theTrsfType = 2); - void onTreeViewDoubleClick(const QModelIndex&); private: diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index df93f32a2..a84ea1609 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -689,6 +689,8 @@ bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) { + myModule->onViewTransformed(); + // Display all sketcher sub-Objects myCurrentSketch = std::dynamic_pointer_cast(theOperation->feature()); XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index d76bf6d3f..cae0e29e2 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -363,8 +363,10 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrL AIS_ListIteratorOfListOfInteractive aLIt(aPrsList); for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){ anAISIO = aLIt.Value(); - activate(anAISIO, myActiveSelectionModes, theUpdateViewer); + activate(anAISIO, myActiveSelectionModes, false); } + if (theUpdateViewer) + updateViewer(); } bool XGUI_Displayer::isActive(ObjectPtr theObject) const