1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "Plot2d_ViewManager.h"
23 #include "Plot2d_ViewModel.h"
24 #include "Plot2d_ViewWindow.h"
25 #include "Plot2d_ViewFrame.h"
30 Plot2d_ViewManager::Plot2d_ViewManager( SUIT_Study* study, SUIT_Desktop* desk )
31 : SUIT_ViewManager( study, desk, new Plot2d_Viewer() )
33 setTitle( tr( "PLOT2D_VIEW_TITLE" ) );
39 Plot2d_ViewManager::~Plot2d_ViewManager()
44 \return corresponding viewer
46 Plot2d_Viewer* Plot2d_ViewManager::getPlot2dModel() const
48 return (Plot2d_Viewer*)myViewModel;
53 \param theView - view to be added
55 bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView )
57 bool res = SUIT_ViewManager::insertView( theView );
60 Plot2d_ViewWindow* view = (Plot2d_ViewWindow*)theView;
61 connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) );
63 Plot2d_ViewFrame* aViewFrame = view->getViewFrame();
64 Plot2d_Viewer* aViewer = getPlot2dModel();
65 connect( aViewFrame, SIGNAL( legendClicked( QwtPlotItem* ) ),
66 aViewer, SLOT( onLegendClicked( QwtPlotItem* ) ) );
74 void Plot2d_ViewManager::createView()
80 SLOT: called if action "Clone view" is activated, emits signal cloneView()
82 void Plot2d_ViewManager::onCloneView()
84 if( sender() && sender()->inherits( "Plot2d_ViewWindow" ) )
86 Plot2d_ViewWindow* srcWnd = ( Plot2d_ViewWindow* )sender();
92 \brief Creates clone of source window
93 \param srcWnd source window
94 \return Pointer on the new window
97 Plot2d_ViewWindow* Plot2d_ViewManager::cloneView( Plot2d_ViewWindow* srcWnd )
99 SUIT_ViewWindow* vw = createViewWindow();
101 Plot2d_ViewWindow* newWnd = 0;
102 if( vw && vw->inherits( "Plot2d_ViewWindow" ) )
103 newWnd = ( Plot2d_ViewWindow* )vw;
105 if( newWnd && srcWnd )
106 emit cloneView( srcWnd->getViewFrame(), newWnd->getViewFrame() );