moduleAction->insertModule( *it, icon );
}
+
connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ), this, SLOT( onModuleActivation( const QString& ) ) );
registerAction( ModulesListId, moduleAction );
}
vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
new LightApp_VTKSelector( vm, mySelMgr );
+ vm->connectToApplication(this);
}
#else
viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
if ( objectBrowser() )
objectBrowser()->updateTree();
+ //emit moduleActivated(mod);
return res;
}
#include <vtkActorCollection.h>
//#include "SUIT_Session.h"
-#include "SUIT_ViewModel.h"
-#include "SUIT_ViewManager.h"
-
#include "SVTK_Selection.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_View.h"
-#include "SVTK_MainWindow.h"
+//#include "SVTK_MainWindow.h"
#include "SVTK_Prs.h"
#include "VTKViewer_ViewModel.h"
+#include "SUIT_ViewModel.h"
+#include "SUIT_ViewManager.h"
+#include "CAM_Module.h"
+#include "CAM_Application.h"
+
#include <SALOME_Actor.h>
+#include <QtxActionToolMgr.h>
+
+#include <CAM_ViewExtender.h>
+
// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
// SALOMEDS::StudyManager - no linkage with SalomeApp.
*/
SVTK_Viewer::SVTK_Viewer()
{
+ myActiveModule = 0;
myTrihedronSize = 105;
myTrihedronRelative = true;
}
aViewWindow->setBackgroundColor( backgroundColor() );
aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() );
-
+
+ if (myActiveModule) {
+ CAM_ViewExtender* aExtender = myActiveModule->getViewExtender();
+ if (aExtender) {
+ QtxActionToolMgr* aMgr = aViewWindow->toolMgr();
+ myExtToolBarId = aExtender->createToolbar(aMgr);
+ }
+ }
return aViewWindow;
}
thePopup->addAction( (*it)->toggleViewAction() );
aView->RefreshDumpImage();
}
+// SALOME_ViewExtender* aExtender = myActiveModule->getViewExtender();
+// if (aExtender) {
+// aExtender->contextMenuPopup(thePopup);
+// }
}
/*!
if(SVTK_View* aView = aViewWindow->getView())
aView->Repaint();
}
+
+void SVTK_Viewer::connectToApplication( CAM_Application* theApp )
+{
+ onModuleActivated(theApp->activeModule());
+// CAM_Module* aModule = dynamic_cast<CAM_Module*>(theApp->activeModule());
+// if (aModule) {
+// if (myActiveModule != aModule) {
+// CAM_ViewExtender* aExtender = (myActiveModule)? myActiveModule->getViewExtender() : 0;
+// if (aExtender)
+// aExtender->deactivate();
+
+// myActiveModule = aModule;
+// aExtender = myActiveModule->getViewExtender();
+// if (aExtender)
+// aExtender->activate();
+
+// updateToolBars();
+// }
+// }
+ connect(theApp, SIGNAL(moduleActivated(CAM_Module*)),
+ this, SLOT(onModuleActivated(CAM_Module*)));
+}
+
+
+void SVTK_Viewer::onModuleActivated( CAM_Module* mod )
+{
+ CAM_Module* aModule = dynamic_cast<CAM_Module*>(mod);
+ if (aModule) {
+ if (myActiveModule != aModule) {
+ CAM_ViewExtender* aExtender = (myActiveModule)? myActiveModule->getViewExtender() : 0;
+ if (aExtender)
+ aExtender->deactivate();
+
+ myActiveModule = aModule;
+ aExtender = myActiveModule->getViewExtender();
+ if (aExtender)
+ aExtender->activate();
+
+ updateToolBars();
+ }
+ }
+}
+
+
+void SVTK_Viewer::updateToolBars()
+{
+ if (!myActiveModule) return;
+
+ CAM_ViewExtender* aExtender = myActiveModule->getViewExtender();
+ int aNewId = -1;
+ QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+ if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+ if(TViewWindow* aViewWnd = dynamic_cast<TViewWindow*>(aViewWindow)) {
+ QtxActionToolMgr* aMgr = aViewWnd->toolMgr();
+ if (myExtToolBarId != -1)
+ aMgr->removeToolBar(myExtToolBarId);
+ if (aExtender)
+ aNewId = aExtender->createToolbar(aMgr);
+ }
+ }
+ }
+ myExtToolBarId = aNewId;
+}
#include "SALOME_InteractiveObject.hxx"
#include <QColor>
+#include <QMap>
class QMouseEvent;
class SVTK_ViewWindow;
+class CAM_Module;
+class CAM_Application;
+class CAM_Module;
//! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View
class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View
//! See #SALOME_View::Repaint()
virtual void Repaint();
+
+ virtual void connectToApplication(CAM_Application* theApp);
+
+
protected slots:
void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
void onDumpView();
void onChangeBgColor();
+ void onModuleActivated( CAM_Module* mod );
+
private:
+ void updateToolBars();
+
+
QColor myBgColor;
vtkFloatingPointType myTrihedronSize;
bool myTrihedronRelative;
bool mySelectionEnabled;
bool myMultiSelectionEnabled;
+
+ CAM_Module* myActiveModule;
+ int myExtToolBarId;
};
#endif