Salome HOME
c94fe7f66938b09fd2222e0f0906c3420e523461
[modules/gui.git] / src / Plot2d / Plot2d_ViewManager.cxx
1 #include "Plot2d_ViewManager.h"
2 #include "Plot2d_ViewModel.h"
3 #include "Plot2d_ViewWindow.h"
4
5 int Plot2d_ViewManager::myMaxId = 0;
6
7 Plot2d_ViewManager::Plot2d_ViewManager( SUIT_Study* study, SUIT_Desktop* desk ) 
8 : SUIT_ViewManager( study, desk )
9 {
10   myId = ++myMaxId;
11   Plot2d_Viewer* v = new Plot2d_Viewer();
12   setViewModel( v );
13 }
14
15 Plot2d_ViewManager::~Plot2d_ViewManager()
16 {
17 }
18
19 Plot2d_Viewer* Plot2d_ViewManager::getPlot2dModel() const
20 {
21   return (Plot2d_Viewer*)myViewModel;
22 }
23
24 void Plot2d_ViewManager::setViewName( SUIT_ViewWindow* theView )
25 {
26   int aPos = myViews.find(theView);
27   theView->setCaption( QString( "Plot2d scene:%1 - viewer:%2" ).arg(myId).arg(aPos+1));
28 }
29
30 bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView )
31 {
32   bool res = SUIT_ViewManager::insertView( theView );
33   if ( res )
34   {
35     Plot2d_ViewWindow* view = (Plot2d_ViewWindow*)theView;
36     connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) );
37   }
38   return res;
39 }
40
41 void Plot2d_ViewManager::createView()
42 {
43   createViewWindow();
44 }
45
46 void Plot2d_ViewManager::onCloneView()
47 {
48   SUIT_ViewWindow* vw = createViewWindow();
49
50   Plot2d_ViewWindow  *newWnd = 0, *clonedWnd = 0;
51   if( vw && vw->inherits( "Plot2d_ViewWindow" ) )
52     newWnd = ( Plot2d_ViewWindow* )vw;
53   if( sender() && sender()->inherits( "Plot2d_ViewWindow" ) )
54     clonedWnd = ( Plot2d_ViewWindow* )sender();
55   
56   if( newWnd && clonedWnd )
57     emit cloneView( clonedWnd->getViewFrame(), newWnd->getViewFrame() );
58 }