#include <XGUI_Workshop.h>
#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_OCCSelector.h>
#include <OCCViewer_ViewModel.h>
+#include <SUIT_Selector.h>
#include <SUIT_Desktop.h>
#include <SUIT_ViewManager.h>
#include <QtxActionMenuMgr.h>
-
extern "C" {
NewGeom_EXPORT CAM_Module* createModule() {
return new NewGeom_Module();
if (isDone) {
setMenuShown( true );
setToolShown( true );
+
+ SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
+ if (aMgr) {
+ OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+ }
}
return isDone;
}
aContext = aViewer->getAISContext();
}
return aContext;
-}
\ No newline at end of file
+}
+
+//******************************************************
+void NewGeom_Module::selectionChanged()
+{
+ LightApp_Module::selectionChanged();
+ //myWorkshop->salomeViewerSelectionChanged();
+}
NewGeom_Module();
virtual ~NewGeom_Module();
+ //----- LightAPP_Module interface ---------------
virtual void initialize( CAM_Application* theApp);
virtual void windows( QMap<int, int>& theWndMap) const;
virtual void viewManagers( QStringList& theList) const;
+ virtual void selectionChanged();
//--- XGUI connector interface -----
virtual void addFeature(const QString& theWBName,
#include <XGUI_Viewer.h>
#include <XGUI_Workshop.h>
#include <XGUI_OperationMgr.h>
+#include <XGUI_SelectionMgr.h>
#include <Config_PointerMessage.h>
#include <Config_ModuleReader.h>
connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
- if (!myWorkshop->isSalomeMode())
- connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
+ connect(myWorkshop->selector(), SIGNAL(selectionChanged()),
this, SLOT(onViewSelectionChanged()));
}
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
- if (aViewer) {
+ XGUI_SelectionMgr* aSelector = myWorkshop->selector();
+ if (aSelector) {
NCollection_List<TopoDS_Shape> aList;
- aViewer->getSelectedShapes(aList);
+ aSelector->selectedShapes(aList);
aPreviewOp->setSelectedShapes(aList);
}
}
XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
//! Returns list of currently selected features
- QFeatureList selectedData() const { return mySelectedData; }
+ QFeatureList selectedFeatures() const { return mySelectedData; }
signals:
//! Emited when selection is changed
#include "XGUI_Workshop.h"
#include "XGUI_MainWindow.h"
#include "XGUI_ObjectsBrowser.h"
+#include "XGUI_Viewer.h"
+#include "XGUI_SalomeConnector.h"
#include <ModelAPI_Feature.h>
#include <ModelAPI_PluginManager.h>
{
}
-void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB)
+XGUI_SelectionMgr::~XGUI_SelectionMgr()
{
- myObjectBrowser = theOB;
- connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
}
-XGUI_SelectionMgr::~XGUI_SelectionMgr()
+//**************************************************************
+void XGUI_SelectionMgr::connectViewers()
{
+ connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()),
+ 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()));
+ }
}
-void XGUI_SelectionMgr::onSelectionChanged()
+//**************************************************************
+void XGUI_SelectionMgr::onObjectBrowserSelection()
{
- XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->objectBrowser();
- mySelectedData = aObjBrowser->selectedData();
-
- // Set current document
- if (mySelectedData.size() > 0) {
- FeaturePtr aFeature = mySelectedData.first();
-
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
- if (aDocRef)
- aMgr->setCurrentDocument(aDocRef->value());
- }
+
+ // TODO: Highliht selected objects in Viewer 3d
emit selectionChanged();
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::onViewerSelection()
+{
+ emit selectionChanged();
+}
+
+//**************************************************************
+QFeatureList XGUI_SelectionMgr::selectedFeatures() const
+{
+ return myWorkshop->objectBrowser()->selectedFeatures();
+}
+
+//**************************************************************
+QModelIndexList XGUI_SelectionMgr::selectedIndexes() const
+{
+ return myWorkshop->objectBrowser()->selectionModel()->selectedIndexes();
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
+{
+ if (myWorkshop->isSalomeMode()) {
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
+ theList.Clear();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ theList.Append(aContext->SelectedInteractive());
+ } else {
+ XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+ aViewer->getSelectedObjects(theList);
+ }
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
+{
+ if (myWorkshop->isSalomeMode()) {
+ theList.Clear();
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->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);
+ }
}
\ No newline at end of file
#include "XGUI.h"
#include "XGUI_Constants.h"
#include <QObject>
+#include <QModelIndexList>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
class XGUI_Workshop;
class XGUI_ObjectsBrowser;
XGUI_SelectionMgr(XGUI_Workshop* theParent);
virtual ~XGUI_SelectionMgr();
- //! Returns list of currently selected objects
- QFeatureList selectedData() const { return mySelectedData; }
+ //! Returns list of currently selected data objects
+ QFeatureList selectedFeatures() const;
+
+ //! Returns list of currently selected QModelIndexes
+ QModelIndexList selectedIndexes() const;
+
+ //! Returns list of currently selected AIS objects
+ void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+
+ //! Returns list of currently selected shapes
+ void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
- void connectObjectBrowser(XGUI_ObjectsBrowser* theOB);
+ //! Connects the manager to all viewers accessible by Workshop
+ void connectViewers();
signals:
//! Emited when selection in a one of viewers was changed
void selectionChanged();
-public slots:
- void onSelectionChanged();
+private slots:
+ void onObjectBrowserSelection();
+ void onViewerSelection();
private:
- XGUI_Workshop* myWorkshop;
- XGUI_ObjectsBrowser* myObjectBrowser;
- //! List of selected features
- QFeatureList mySelectedData;
+ XGUI_Workshop* myWorkshop;
};
#endif
myGripWgt->update();
myViewBar->update();
myWindowBar->update();
- //QTimer::singleShot(50, Qt::VeryCoarseTimer, this, SLOT(repaintToolBar()));
}
-/*void XGUI_ViewWindow::repaintToolBar()
-{
- QApplication::sync();
- myGripWgt->repaint();
- myViewBar->repaint();
- myWindowBar->repaint();
-}*/
// So, displayer will be created on demand.
mySelector = new XGUI_SelectionMgr(this);
+ connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
myOperationMgr = new XGUI_OperationMgr(this);
connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
QApplication::setOverrideCursor(Qt::WaitCursor);
if (objectBrowser() == 0) {
createDockWidgets();
- mySelector->connectObjectBrowser(objectBrowser());
+ mySelector->connectViewers();
}
showObjectBrowser();
if (!isSalomeMode()) {
}
return myDisplayer;
}
+
+//******************************************************
+void XGUI_Workshop::changeCurrentDocument()
+{
+ QFeatureList aFeatures = objectBrowser()->selectedFeatures();
+
+ // Set current document
+ if (aFeatures.size() > 0) {
+ FeaturePtr aFeature = aFeatures.first();
+
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
+ if (aDocRef)
+ aMgr->setCurrentDocument(aDocRef->value());
+ }
+}
+
+//******************************************************
+void XGUI_Workshop::salomeViewerSelectionChanged()
+{
+ emit salomeViewerSelection();
+}
\ No newline at end of file
//! Returns Object browser
XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
+ void salomeViewerSelectionChanged();
+
+signals:
+ void salomeViewerSelection();
+
public slots:
void updateCommandStatus();
void onFeatureTriggered();
+ void changeCurrentDocument();
+
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);