#include "NewGeom_Module.h"
#include "NewGeom_DataModel.h"
+#include "NewGeom_OCCSelector.h"
#include <XGUI_Workshop.h>
NewGeom_EXPORT CAM_Module* createModule() {
return new NewGeom_Module();
}
-
+
NewGeom_EXPORT char* getModuleVersion() {
return "0.0";
}
//******************************************************
NewGeom_Module::NewGeom_Module()
-: LightApp_Module( "NewGeom" )
+: LightApp_Module( "NewGeom" ), mySelector(0)
{
myWorkshop = new XGUI_Workshop(this);
}
setMenuShown( true );
setToolShown( true );
- SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
- if (aMgr) {
- OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+ if (!mySelector) {
+ ViewManagerList OCCViewManagers;
+ application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
+ if (OCCViewManagers.size() > 0) {
+ mySelector = createSelector(OCCViewManagers.first());
+ }
}
}
return isDone;
}
+//******************************************************
+void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
+{
+ if ((!mySelector)) {
+ mySelector = createSelector(theMgr);
+ }
+}
+
+//******************************************************
+NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
+{
+ if (theMgr->getType() == OCCViewer_Viewer::Type()) {
+ OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
+ NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer,
+ getApp()->selectionMgr());
+ LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
+ QList<SUIT_Selector*> aList;
+ aMgr->selectors(aList);
+ foreach(SUIT_Selector* aSel, aList) {
+ aSel->setEnabled(aSel == aSelector);
+ }
+ return aSelector;
+ }
+ return 0;
+}
+
//******************************************************
bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
{
Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
{
Handle(AIS_InteractiveContext) aContext;
- SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
- if (aMgr) {
- OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+ OCCViewer_Viewer* aViewer = mySelector->viewer();
+ if (aViewer) {
aContext = aViewer->getAISContext();
}
return aContext;
void NewGeom_Module::selectionChanged()
{
LightApp_Module::selectionChanged();
- //myWorkshop->salomeViewerSelectionChanged();
+ myWorkshop->salomeViewerSelectionChanged();
}
#include <QStringList>
-class XGUI_Workshop;
-
+class XGUI_Workshop;
+class NewGeom_OCCSelector;
+class OCCViewer_Viewer;
/**
* An implementation of SALOME connector class for implementation of
* XGUI functionality as a module of SALOME
virtual Handle(AIS_InteractiveContext) AISContext() const;
public slots:
- bool activateModule( SUIT_Study* theStudy);
- bool deactivateModule( SUIT_Study* theStudy);
+ virtual bool activateModule( SUIT_Study* theStudy);
+ virtual bool deactivateModule( SUIT_Study* theStudy);
+
+protected slots:
+ virtual void onViewManagerAdded( SUIT_ViewManager* theMgr );
protected:
CAM_DataModel* createDataModel();
private:
+ NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
+
QStringList myActionsList;
XGUI_Workshop* myWorkshop;
+
+ NewGeom_OCCSelector* mySelector;
};
#endif
--- /dev/null
+#include "NewGeom_OCCSelector.h"
+
+NewGeom_OCCSelector::NewGeom_OCCSelector( OCCViewer_Viewer* theViewer,
+ SUIT_SelectionMgr* theMgr)
+: LightApp_OCCSelector(theViewer, theMgr)
+{
+}
+
+NewGeom_OCCSelector::~NewGeom_OCCSelector()
+{
+}
+
+void NewGeom_OCCSelector::getSelection( SUIT_DataOwnerPtrList& thePtrList ) const
+{
+ OCCViewer_Viewer* vw = viewer();
+ if (!vw)
+ return;
+}
+
+void NewGeom_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& thePtrList )
+{
+ OCCViewer_Viewer* vw = viewer();
+ if (!vw)
+ return;
+
+}
--- /dev/null
+#ifndef NewGeom_OCCSelector_H
+#define NewGeom_OCCSelector_H
+
+#include "NewGeom.h"
+
+#include <LightApp_OCCSelector.h>
+
+class NewGeom_EXPORT NewGeom_OCCSelector : public LightApp_OCCSelector
+{
+public:
+ NewGeom_OCCSelector( OCCViewer_Viewer* theViewer, SUIT_SelectionMgr* theMgr );
+ virtual ~NewGeom_OCCSelector();
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& theList ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& theList );
+};
+
+#endif
\ No newline at end of file