]> SALOME platform Git repositories - modules/gui.git/blob - src/Plot2d/Plot2d_ViewManager.cxx
Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / Plot2d / Plot2d_ViewManager.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #include "Plot2d_ViewManager.h"
20 #include "Plot2d_ViewModel.h"
21 #include "Plot2d_ViewWindow.h"
22
23 int Plot2d_ViewManager::myMaxId = 0;
24
25 /*!
26   Constructor
27 */
28 Plot2d_ViewManager::Plot2d_ViewManager( SUIT_Study* study, SUIT_Desktop* desk ) 
29 : SUIT_ViewManager( study, desk )
30 {
31   myId = ++myMaxId;
32   Plot2d_Viewer* v = new Plot2d_Viewer();
33   setViewModel( v );
34 }
35
36 /*!
37   Destructor
38 */
39 Plot2d_ViewManager::~Plot2d_ViewManager()
40 {
41 }
42
43 /*!
44   \return corresponding viewer
45 */
46 Plot2d_Viewer* Plot2d_ViewManager::getPlot2dModel() const
47 {
48   return (Plot2d_Viewer*)myViewModel;
49 }
50
51 /*!
52   Sets default name of view
53   \param the View - view to be renamed
54 */
55 void Plot2d_ViewManager::setViewName( SUIT_ViewWindow* theView )
56 {
57   int aPos = myViews.find(theView);
58   theView->setCaption( QString( "Plot2d scene:%1 - viewer:%2" ).arg(myId).arg(aPos+1));
59 }
60
61 /*!
62   Adds new view
63   \param theView - view to be added
64 */
65 bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView )
66 {
67   bool res = SUIT_ViewManager::insertView( theView );
68   if ( res )
69   {
70     Plot2d_ViewWindow* view = (Plot2d_ViewWindow*)theView;
71     connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) );
72   }
73   return res;
74 }
75
76 /*!
77   Creates new view
78 */
79 void Plot2d_ViewManager::createView()
80 {
81   createViewWindow();
82 }
83
84 /*!
85   SLOT: called if action "Clone view" is activated, emits signal cloneView()
86 */
87 void Plot2d_ViewManager::onCloneView()
88 {
89   SUIT_ViewWindow* vw = createViewWindow();
90
91   Plot2d_ViewWindow  *newWnd = 0, *clonedWnd = 0;
92   if( vw && vw->inherits( "Plot2d_ViewWindow" ) )
93     newWnd = ( Plot2d_ViewWindow* )vw;
94   if( sender() && sender()->inherits( "Plot2d_ViewWindow" ) )
95     clonedWnd = ( Plot2d_ViewWindow* )sender();
96   
97   if( newWnd && clonedWnd )
98     emit cloneView( clonedWnd->getViewFrame(), newWnd->getViewFrame() );
99 }