#include "SUIT_Study.h"
#include "SUIT_Desktop.h"
+#include "CAM_Module.h"
+
#include "SalomeApp_Application.h"
+#include "SalomeApp_SelectionMgr.h"
#include "SalomeApp_VTKSelector.h"
-#include "CAM_Module.h"
#include "SVTK_ViewManager.h"
#include "SVTK_ViewModel.h"
-//using namespace VISU;
-
#ifdef _DEBUG_
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
-VisuGUI_Module::VisuGUI_Module() : VisuGUI()
+#define GAUSS_NEW_VIEWER 5100
+
+using namespace VISU;
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ class Viewer
+ {
+ SVTK_ViewManager* myViewManager;
+ SalomeApp_VTKSelector* mySelector;
+ public:
+
+ Viewer(SalomeApp_Application* theApp, TViewerMap& theViewerMap)
+ {
+ myViewManager = new SVTK_ViewManager( theApp->activeStudy(), theApp->desktop() );
+ SVTK_Viewer* aViewer = (SVTK_Viewer*)myViewManager->getViewModel();
+ mySelector = new SalomeApp_VTKSelector( aViewer, theApp->selectionMgr() );
+ theApp->addViewManager( myViewManager );
+ theViewerMap.insert(TViewerMap::value_type(myViewManager,PViewer(this)));
+
+ //aViewer->setBackgroundColor( Qt::darkGreen );
+ myViewManager->createViewWindow();
+ }
+
+ virtual
+ ~Viewer()
+ {
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ typedef void (SUIT_ViewWindow::* TViewVisibility)();
+ void
+ SetViewVisibility(const TViewerMap& theViewerMap,
+ TViewVisibility theViewVisibility)
+ {
+ TViewerMap::const_iterator anIter = theViewerMap.begin();
+ for(; anIter != theViewerMap.end(); anIter++){
+ if(SUIT_ViewManager* aViewManager = anIter->first){
+ QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+ int aSize = aViews.size();
+ for(int anId = 0; anId < aSize; anId++){
+ if(SUIT_ViewWindow* aView = aViews[anId]){
+ (aView->* theViewVisibility)();
+ }
+ }
+ }
+ }
+ }
+
+}
+
+//---------------------------------------------------------------
+VisuGUI_Module
+::VisuGUI_Module() :
+ VisuGUI()
{
}
-VisuGUI_Module::~VisuGUI_Module()
+//---------------------------------------------------------------
+VisuGUI_Module
+::~VisuGUI_Module()
{
}
+
+//---------------------------------------------------------------
void
-VisuGUI_Module::
-initialize( CAM_Application* theApp )
+VisuGUI_Module
+::initialize( CAM_Application* theApp )
{
VisuGUI::initialize( theApp );
- myViewManager = new SVTK_ViewManager( getApp()->activeStudy(), getApp()->desktop() );
-
- SVTK_Viewer* aViewer = new SVTK_Viewer();
- myViewManager->setViewModel( aViewer );
-
- myViewManager->createViewWindow();
- myViewManager->getActiveView()->hide();
-
- //aViewer->setBackgroundColor( Qt::darkGreen );
-
- new SalomeApp_VTKSelector( aViewer, ( SUIT_SelectionMgr* )getApp()->selectionMgr() );
+ onCreateViewManager();
- theApp->addViewManager( myViewManager );
+ // Add menus
+ int aMenuId;
+ aMenuId = createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 );
+ createAction( GAUSS_NEW_VIEWER, tr("MEN_NEW_VIEWER"), QIconSet(),
+ tr("MEN_NEW_VIEWER"), "", 0, this, false,
+ this, SLOT(onCreateViewManager()));
+ createMenu( GAUSS_NEW_VIEWER, aMenuId, 10 ); // new viewer
}
+
+//---------------------------------------------------------------
bool
-VisuGUI_Module::
-activateModule( SUIT_Study* theStudy )
+VisuGUI_Module
+::activateModule( SUIT_Study* theStudy )
{
VisuGUI::activateModule( theStudy );
- myViewManager->getActiveView()->show();
+ SetViewVisibility(myViewerMap,&SUIT_ViewWindow::show);
return true;
}
+
+//---------------------------------------------------------------
bool
-VisuGUI_Module::
-deactivateModule( SUIT_Study* theStudy )
+VisuGUI_Module
+::deactivateModule( SUIT_Study* theStudy )
{
VisuGUI::deactivateModule( theStudy );
- myViewManager->getActiveView()->hide();
+ SetViewVisibility(myViewerMap,&SUIT_ViewWindow::hide);
return true;
}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module
+::onCreateViewManager()
+{
+ new Viewer(getApp(),myViewerMap);
+}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module
+::onLastViewClosed(SUIT_ViewManager* theViewManager)
+{
+ myViewerMap.erase(theViewManager);
+}
+
#define VisuGUI_Module_HeaderFile
#include "VisuGUI.h"
+#include "STD_Application.h"
+class SUIT_ViewManager;
class SVTK_ViewManager;
+#include "MED_SharedPtr.hxx"
+
+namespace VISU
+{
+ class Viewer;
+ typedef MED::SharedPtr<Viewer> PViewer;
+
+ typedef std::map<SUIT_ViewManager*,PViewer> TViewerMap;
+}
+
+
class VisuGUI_Module: public VisuGUI
{
- Q_OBJECT
+ Q_OBJECT;
public:
VisuGUI_Module();
- virtual ~VisuGUI_Module();
- virtual void initialize( CAM_Application* );
+ virtual
+ ~VisuGUI_Module();
+
+ virtual
+ void
+ initialize( CAM_Application* );
public slots:
- virtual bool deactivateModule( SUIT_Study* );
- virtual bool activateModule( SUIT_Study* );
+ virtual
+ bool
+ deactivateModule( SUIT_Study* );
+
+ virtual
+ bool
+ activateModule( SUIT_Study* );
+
+protected slots:
+ void
+ onCreateViewManager();
+
+ void
+ onLastViewClosed(SUIT_ViewManager*);
protected:
- SVTK_ViewManager* myViewManager;
+ VISU::TViewerMap myViewerMap;
};
#endif