X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Displayer.cpp;h=bca8d2d24c37de2107155910d1d9fc51cca2d3a4;hb=622014f62af50bfd219fb242df168760849e2006;hp=1df32917011497fda656630e3987b3b61bd6ef6f;hpb=de0f49686ec6655ddc5816c8fa5383964662aec4;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 1df329170..bca8d2d24 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -1,47 +1,95 @@ +// File: XGUI_Displayer.cpp +// Created: 20 Apr 2014 +// Author: Natalia ERMOLAEVA + #include "XGUI_Displayer.h" -#include "XGUI_Tools.h" #include "XGUI_Viewer.h" #include #include +#include +#include + #include -/*! - \brief Constructor - */ XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer) : myViewer(theViewer) { } -/*! - \brief Destructor - */ XGUI_Displayer::~XGUI_Displayer() { } -/*! - * Display the feature - * \param theFeature a feature instance - */ -void XGUI_Displayer::Display(std::shared_ptr theFeature) +void XGUI_Displayer::Display(boost::shared_ptr theFeature, + const bool isUpdateViewer) { } -/*! - * Display the feature and a shape. This shape would be associated to the given feature - * \param theFeature a feature instance - * \param theFeature a shape - */ -void XGUI_Displayer::Display(std::shared_ptr theFeature, - const TopoDS_Shape& theShape) +void XGUI_Displayer::Display(boost::shared_ptr theFeature, + const TopoDS_Shape& theShape, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = myViewer->AISContext(); Handle(AIS_Shape) anAIS = new AIS_Shape(theShape); + std::vector aDispAIS; + if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) { + aDispAIS = myFeature2AISObjectMap[theFeature]; + } + aDispAIS.push_back(anAIS); + myFeature2AISObjectMap[theFeature] = aDispAIS; + aContext->Display(anAIS, Standard_False); - aContext->UpdateCurrentViewer(); + if (isUpdateViewer) + aContext->UpdateCurrentViewer(); } + +void XGUI_Displayer::Erase(boost::shared_ptr theFeature, + const bool isUpdateViewer) +{ + if (myFeature2AISObjectMap.find(theFeature) == myFeature2AISObjectMap.end()) + return; + + std::vector aDispAIS = myFeature2AISObjectMap[theFeature]; + std::vector::const_iterator anIt = aDispAIS.begin(), + aLast = aDispAIS.end(); + Handle(AIS_InteractiveContext) aContext = myViewer->AISContext(); + for (; anIt != aLast; anIt++) { + Handle(AIS_InteractiveObject) anAIS = *anIt; + Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS); + if (anAISShape.IsNull()) + continue; + aContext->Erase(anAISShape); + } + + if (isUpdateViewer) + aContext->UpdateCurrentViewer(); +} + +void XGUI_Displayer::LocalSelection(boost::shared_ptr theFeature, + const TopoDS_Shape& theShape, + const int theMode, const bool isUpdateViewer) +{ + Handle(AIS_InteractiveContext) aContext = myViewer->AISContext(); + + Handle(AIS_Shape) anAIS = new AIS_Shape(theShape); + std::vector aDispAIS; + if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) { + aDispAIS = myFeature2AISObjectMap[theFeature]; + } + aDispAIS.push_back(anAIS); + myFeature2AISObjectMap[theFeature] = aDispAIS; + aContext->Display(anAIS, Standard_False); + + AIS_ListOfInteractive anAISList; + anAISList.Append(anAIS); + myViewer->setLocalSelection(anAISList, theMode, true); +} + +void XGUI_Displayer::GlobalSelection(const bool isUpdateViewer) +{ + myViewer->setGlobalSelection(true); +} +