From: vsv Date: Thu, 12 Nov 2015 13:19:39 +0000 (+0300) Subject: Selection of Trihedron X-Git-Tag: V_2.0.0_alfa2~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a6dce4fede391a385e1c427027c768bd3cd12f3d;p=modules%2Fshaper.git Selection of Trihedron --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 8ec4326d0..a9a2232fa 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -822,6 +822,7 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) // Display all sketcher sub-Objects myCurrentSketch = std::dynamic_pointer_cast(aFOperation->feature()); XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); + aConnector->workshop()->displayer()->activateTrihedron(true); // Hide sketcher result std::list aResults = myCurrentSketch->results(); @@ -924,6 +925,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) } // restore the module selection modes, which were changed on startSketch aConnector->activateModuleSelectionModes(); + aConnector->workshop()->displayer()->activateTrihedron(false); } void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation) @@ -1375,3 +1377,4 @@ XGUI_OperationMgr* PartSet_SketcherMgr::operationMgr() const return aWorkshop->operationMgr(); } + diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 59e99f4c7..6c1387077 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -99,7 +99,8 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS } XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) - : myWorkshop(theWorkshop), myEnableUpdateViewer(true), myNeedUpdate(false) + : myWorkshop(theWorkshop), myEnableUpdateViewer(true), myNeedUpdate(false), + myIsTrihedronActive(false) { enableUpdateViewer(true); myCustomPrs = std::shared_ptr(new XGUI_CustomPrs()); @@ -364,9 +365,9 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject, const bool theUpdateViewer) void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList, const bool theUpdateViewer) { - //Handle(AIS_InteractiveObject) aTriehedron = getTrihedron(); - //if (!aTriehedron.IsNull()) - // deactivateAIS(aTriehedron); + //Handle(AIS_InteractiveObject) aTrihedron = getTrihedron(); + //if (!aTrihedron.IsNull()) + // deactivateAIS(aTrihedron); QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end(); for (; anIt != aLast; anIt++) { @@ -452,10 +453,12 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrL //} // Add trihedron because it has to partisipate in selection - Handle(AIS_InteractiveObject) aTrihedron = getTrihedron(); - if (!aTrihedron.IsNull()) - aPrsList.Append(aTrihedron); - + Handle(AIS_InteractiveObject) aTrihedron; + if (isTrihedronActive()) { + aTrihedron = getTrihedron(); + if (!aTrihedron.IsNull()) + aPrsList.Append(aTrihedron); + } if (aPrsList.Extent() == 0) return; @@ -468,7 +471,7 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrL } if (!aTrihedron.IsNull()) { foreach(int aMode, myActiveSelectionModes) - aContext->SetSelectionSensitivity(aTrihedron, aMode, 8); + aContext->SetSelectionSensitivity(aTrihedron, aMode, 15); } // VSV It seems that there is no necessity to update viewer on activation //if (theUpdateViewer && isActivationChanged) @@ -574,8 +577,7 @@ void XGUI_Displayer::deactivateTrihedron() const { Handle(AIS_InteractiveObject) aTrihedron = getTrihedron(); if (!aTrihedron.IsNull()) { - Handle(AIS_InteractiveContext) aContext = AISContext(); - aContext->Deactivate(aTrihedron); + deactivateAIS(aTrihedron); } } @@ -778,7 +780,8 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (!aContext.IsNull() && !aContext->HasOpenedContext()) { aContext->OpenLocalContext(); - //deactivateTrihedron(); + if (!isTrihedronActive()) + deactivateTrihedron(); aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0); aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0); } @@ -1033,22 +1036,21 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, // trihedron AIS check should be after the AIS loading. // If it is not loaded, it is steel selectable in the viewer. - //Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO); - //if (aTrihedron.IsNull()) { - //aContext->Load(anAISIO, -1, true); + Handle(AIS_Trihedron) aTrihedron; + if (!isTrihedronActive()) + aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO); + if (aTrihedron.IsNull()) { // In order to clear active modes list if (theModes.size() == 0) { - //aContext->Load(anAISIO, 0, true); activateAIS(theIO, 0, theUpdateViewer); } else { foreach(int aMode, theModes) { - //aContext->Load(anAISIO, aMode, true); if (!aModesActivatedForIO.contains(aMode)) { activateAIS(theIO, aMode, theUpdateViewer); isActivationChanged = true; } } - //} + } } return isActivationChanged; } @@ -1120,3 +1122,10 @@ std::string XGUI_Displayer::getResult2AISObjectMapInfo() const return QString("myResult2AISObjectMap: size = %1\n%2\n").arg(myResult2AISObjectMap.size()). arg(aContent.join("\n")).toStdString().c_str(); } + +void XGUI_Displayer::activateTrihedron(bool theIsActive) +{ + myIsTrihedronActive = theIsActive; + if (!myIsTrihedronActive) + deactivateTrihedron(); +} diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 373966883..78da19457 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -231,6 +231,11 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// Returns Trihedron object if it is displayed Handle(AIS_InteractiveObject) getTrihedron() const; + // Set trihedron active (used in selection) or non active + void activateTrihedron(bool theIsActive); + + bool isTrihedronActive() const { return myIsTrihedronActive; } + /// Converts shape type (TopAbs_ShapeEnum) to selection mode /// \param theShapeType a shape type from TopAbs_ShapeEnum static int getSelectionMode(int theShapeType); @@ -319,6 +324,9 @@ private: /// the enable update viewer flag bool myEnableUpdateViewer; + // Flag: use trihedgon for selection or not + bool myIsTrihedronActive; + /// A flag that update was requested but not done mutable bool myNeedUpdate; };