X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_SelectionMgr.cpp;h=caf78cededfa473823d177c7ad21591edcd6f852;hb=880a5c5b031fe9bbd7833fa3918af3e216d98d34;hp=c2d2c3de305f0dac81555fe4ee8aaef8a4167ad7;hpb=d4572a0253007ff9fc263253720e37bf896f8d0d;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index c2d2c3de3..caf78cede 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -1,44 +1,100 @@ #include "XGUI_SelectionMgr.h" + #include "XGUI_Workshop.h" #include "XGUI_MainWindow.h" #include "XGUI_ObjectsBrowser.h" +#include "XGUI_SalomeConnector.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); } -void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB) +XGUI_SelectionMgr::~XGUI_SelectionMgr() { - myObjectBrowser = theOB; - connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); + delete mySelection; } -XGUI_SelectionMgr::~XGUI_SelectionMgr() +//************************************************************** +void XGUI_SelectionMgr::connectViewers() +{ + connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()), + this, SLOT(onObjectBrowserSelection())); + + //Connect to other viewers + connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), + this, SLOT(onViewerSelection())); +} + +//************************************************************** +void XGUI_SelectionMgr::onObjectBrowserSelection() { + QList aObjects = myWorkshop->objectBrowser()->selectedObjects(); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->setSelected(aObjects); + emit selectionChanged(); } -void XGUI_SelectionMgr::onSelectionChanged() +//************************************************************** +void XGUI_SelectionMgr::onViewerSelection() { - XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->objectBrowser(); - mySelectedData = aObjBrowser->selectedData(); - - // Set current document - if (mySelectedData.size() > 0) { - FeaturePtr aFeature = mySelectedData.first(); - - boost::shared_ptr aMgr = ModelAPI_PluginManager::get(); - boost::shared_ptr aDocRef = aFeature->data()->docRef("PartDocument"); - if (aDocRef) - aMgr->setCurrentDocument(aDocRef->value()); + 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(); -} \ No newline at end of file +} + +//************************************************************** +/*QFeatureList XGUI_SelectionMgr::selectedFeatures() const +{ + return myWorkshop->objectBrowser()->selectedFeatures(); +} + +//************************************************************** +QModelIndexList XGUI_SelectionMgr::selectedIndexes() const +{ + return myWorkshop->objectBrowser()->selectedIndexes(); +} + +//************************************************************** +void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const +{ + 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 +{ + 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); + } +}*/