X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_SelectionMgr.cpp;h=caf78cededfa473823d177c7ad21591edcd6f852;hb=880a5c5b031fe9bbd7833fa3918af3e216d98d34;hp=d117c1dea114bf86de617a1aee1bc4dfab7d0e30;hpb=13386fb08ef3453b9560d9459ce72885ef9a0afb;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index d117c1dea..caf78cede 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -1,25 +1,31 @@ #include "XGUI_SelectionMgr.h" + #include "XGUI_Workshop.h" #include "XGUI_MainWindow.h" #include "XGUI_ObjectsBrowser.h" -#include "XGUI_Viewer.h" #include "XGUI_SalomeConnector.h" -#include "XGUI_SalomeViewer.h" +#include "XGUI_ViewerProxy.h" +#include "XGUI_Displayer.h" +#include "XGUI_Selection.h" #include #include #include #include +#include +#include XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) : QObject(theParent), myWorkshop(theParent) { + mySelection = new XGUI_Selection(myWorkshop); } XGUI_SelectionMgr::~XGUI_SelectionMgr() { + delete mySelection; } //************************************************************** @@ -29,33 +35,39 @@ void XGUI_SelectionMgr::connectViewers() this, SLOT(onObjectBrowserSelection())); //Connect to other viewers - if (myWorkshop->isSalomeMode()) { - connect(myWorkshop, SIGNAL(salomeViewerSelection()), - this, SLOT(onViewerSelection())); - } else { - connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()), - this, SLOT(onViewerSelection())); - } + connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), + this, SLOT(onViewerSelection())); } //************************************************************** void XGUI_SelectionMgr::onObjectBrowserSelection() { - - // TODO: Highliht selected objects in Viewer 3d - + QList aObjects = myWorkshop->objectBrowser()->selectedObjects(); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->setSelected(aObjects); emit selectionChanged(); } //************************************************************** void XGUI_SelectionMgr::onViewerSelection() { - // TODO: Highliht selected objects in Object Browser + QList aFeatures; + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { + Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive(); + ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO); + if (aResult) + aFeatures.append(aResult); + } + bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); + myWorkshop->objectBrowser()->setObjectsSelected(aFeatures); + myWorkshop->objectBrowser()->blockSignals(aBlocked); + emit selectionChanged(); } //************************************************************** -QFeatureList XGUI_SelectionMgr::selectedFeatures() const +/*QFeatureList XGUI_SelectionMgr::selectedFeatures() const { return myWorkshop->objectBrowser()->selectedFeatures(); } @@ -63,36 +75,26 @@ QFeatureList XGUI_SelectionMgr::selectedFeatures() const //************************************************************** QModelIndexList XGUI_SelectionMgr::selectedIndexes() const { - return myWorkshop->objectBrowser()->selectionModel()->selectedIndexes(); + return myWorkshop->objectBrowser()->selectedIndexes(); } //************************************************************** void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const { - if (myWorkshop->isSalomeMode()) { - Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeViewer()->AISContext(); - theList.Clear(); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) - theList.Append(aContext->SelectedInteractive()); - } else { - XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); - aViewer->getSelectedObjects(theList); - } + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + theList.Clear(); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) + theList.Append(aContext->SelectedInteractive()); } //************************************************************** void XGUI_SelectionMgr::selectedShapes(NCollection_List& theList) const { - if (myWorkshop->isSalomeMode()) { - theList.Clear(); - Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeViewer()->AISContext(); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - TopoDS_Shape aShape = aContext->SelectedShape(); - if (!aShape.IsNull()) - theList.Append(aShape); - } - } else { - XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); - aViewer->getSelectedShapes(theList); + theList.Clear(); + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { + TopoDS_Shape aShape = aContext->SelectedShape(); + if (!aShape.IsNull()) + theList.Append(aShape); } -} +}*/