From: vsv Date: Tue, 23 Sep 2014 15:20:38 +0000 (+0400) Subject: Display shapes in shaded mode X-Git-Tag: V_0.4.4~28^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae10303116314dd4ae5b01246229f7eb5e3b2cdc;p=modules%2Fshaper.git Display shapes in shaded mode --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 97f253c67..fe04a7f98 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -171,6 +171,9 @@ void PartSet_Module::onOperationStarted() XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->openLocalContext(); + aDisplayer->deactivateObjectsOutOfContext(); } } @@ -368,6 +371,7 @@ void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode) if (!isDisplay) aDisplayer->erase((*aSFIt), false); } + aDisplayer->deactivateObjectsOutOfContext(); } if (isDisplay) ModelAPI_EventCreator::get()->sendUpdated( @@ -524,6 +528,8 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi if (aSketchOp) { Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane); aDisplayer->activateObjectsOutOfContext(aModes, aFilter); + } else { + aDisplayer->deactivateObjectsOutOfContext(); } } } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 83b2f0eb7..68e8b68bd 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -48,6 +48,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer) boost::shared_ptr anAIS; GeomPresentablePtr aPrs = boost::dynamic_pointer_cast(theObject); + bool isShading = false; if (aPrs) { anAIS = aPrs->getAISObject(boost::shared_ptr()); } else { @@ -57,16 +58,17 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer) if (aShapePtr) { anAIS = boost::shared_ptr(new GeomAPI_AISObject()); anAIS->createShape(aShapePtr); + isShading = true; } } } if (anAIS) - display(theObject, anAIS, isUpdateViewer); + display(theObject, anAIS, isShading, isUpdateViewer); } } -void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr theAIS, - bool isUpdateViewer) +void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr theAIS, + bool isShading, bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); if (aContext.IsNull()) @@ -75,7 +77,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptrimpl(); if (!anAISIO.IsNull()) { myResult2AISObjectMap[theObject] = theAIS; - aContext->Display(anAISIO, isUpdateViewer); + aContext->Display(anAISIO, false); + aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, isUpdateViewer); } } @@ -97,36 +100,6 @@ void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer) myResult2AISObjectMap.erase(theObject); } -/*bool XGUI_Displayer::redisplay(ObjectPtr theObject, - boost::shared_ptr theAIS, - const bool isUpdateViewer) - { - bool isCreated = false; - Handle(AIS_InteractiveObject) anAIS = - theAIS ? theAIS->impl() : Handle(AIS_InteractiveObject)(); - Handle(AIS_InteractiveContext) aContext = AISContext(); - // Open local context if there is no one - if (!aContext->HasOpenedContext()) { - aContext->ClearCurrents(false); - aContext->OpenLocalContext(false /use displayed objects/, true /allow shape decomposition/); - // set mouse sensitivity - //aContext->SetSensitivityMode(StdSelect_SM_WINDOW); - //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL); - } - // display or redisplay presentation - boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; - if (isVisible(theObject) && anObj && !anObj->empty()) { - aContext->Redisplay(anAIS, isUpdateViewer); - //aContext->RecomputeSelectionOnly(anAIS); - } - else { - myResult2AISObjectMap[theObject] = theAIS; - aContext->Display(anAIS, isUpdateViewer); - isCreated = true; - } - return isCreated; - }*/ - void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) { if (!isVisible(theObject)) @@ -343,6 +316,20 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) updateViewer(); } +void XGUI_Displayer::openLocalContext() +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (aContext.IsNull()) + return; + // Open local context if there is no one + if (!aContext->HasOpenedContext()) { + aContext->ClearCurrents(false); + //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); + aContext->OpenLocalContext(); + aContext->NotUseDisplayedObjects(); + } +} + void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer) { AISContext()->ClearSelected(false); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index cf3a76798..f3236af30 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -105,6 +105,8 @@ class XGUI_EXPORT XGUI_Displayer /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void eraseDeletedResults(const bool isUpdateViewer = true); + void openLocalContext(); + /// Deactivates selection of sub-shapes /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void closeLocalContexts(const bool isUpdateViewer = true); @@ -155,7 +157,7 @@ class XGUI_EXPORT XGUI_Displayer /// \param theAIS AIS presentation /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly /// Returns true if the Feature succesfully displayed - void display(ObjectPtr theObject, boost::shared_ptr theAIS, + void display(ObjectPtr theObject, boost::shared_ptr theAIS, bool isShading, bool isUpdateViewer = true); /// Display the shape and activate selection of sub-shapes