1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 #include "Plot2d_ViewManager.h"
24 #include "Plot2d_ViewModel.h"
25 #include "Plot2d_ViewWindow.h"
26 #include "Plot2d_ViewFrame.h"
28 #include "SUIT_PreferenceMgr.h"
29 #include "SUIT_ResourceMgr.h"
34 Plot2d_ViewManager::Plot2d_ViewManager( SUIT_Study* study, SUIT_Desktop* desk )
35 : SUIT_ViewManager( study, desk, new Plot2d_Viewer() )
37 setTitle( tr( "PLOT2D_VIEW_TITLE" ) );
43 Plot2d_ViewManager::~Plot2d_ViewManager()
48 \return corresponding viewer
50 Plot2d_Viewer* Plot2d_ViewManager::getPlot2dModel() const
52 return (Plot2d_Viewer*)myViewModel;
57 \param theView - view to be added
59 bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView )
61 bool res = SUIT_ViewManager::insertView( theView );
64 Plot2d_ViewWindow* view = (Plot2d_ViewWindow*)theView;
65 connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) );
67 Plot2d_ViewFrame* aViewFrame = view->getViewFrame();
68 Plot2d_Viewer* aViewer = getPlot2dModel();
69 connect( aViewFrame, SIGNAL( legendClicked( QwtPlotItem* ) ),
70 aViewer, SLOT( onLegendClicked( QwtPlotItem* ) ) );
78 void Plot2d_ViewManager::createView()
84 SLOT: called if action "Clone view" is activated, emits signal cloneView()
86 void Plot2d_ViewManager::onCloneView()
88 if( sender() && sender()->inherits( "Plot2d_ViewWindow" ) )
90 Plot2d_ViewWindow* srcWnd = ( Plot2d_ViewWindow* )sender();
96 \brief Creates clone of source window
97 \param srcWnd source window
98 \return Pointer on the new window
101 Plot2d_ViewWindow* Plot2d_ViewManager::cloneView( Plot2d_ViewWindow* srcWnd )
103 SUIT_ViewWindow* vw = createViewWindow();
105 Plot2d_ViewWindow* newWnd = 0;
106 if( vw && vw->inherits( "Plot2d_ViewWindow" ) )
107 newWnd = ( Plot2d_ViewWindow* )vw;
109 if( newWnd && srcWnd )
110 emit cloneView( srcWnd->getViewFrame(), newWnd->getViewFrame() );
116 Fills preference manager for viewer
118 int Plot2d_ViewManager::fillPreferences( SUIT_PreferenceMgr* thePrefMgr, const int theId )
120 int aGrpId = thePrefMgr->addItem( tr( "PREF_GROUP_PLOT2DVIEWER" ), theId,
121 SUIT_PreferenceMgr::GroupBox );
123 thePrefMgr->addItem( tr( "PREF_SHOW_LEGEND" ), aGrpId,
124 SUIT_PreferenceMgr::Bool, "Plot2d", "ShowLegend" );
126 int legendPosition = thePrefMgr->addItem( tr( "PREF_LEGEND_POSITION" ), aGrpId,
127 SUIT_PreferenceMgr::Selector, "Plot2d", "LegendPos" );
128 QStringList aLegendPosList;
129 aLegendPosList.append( tr("PREF_LEFT") );
130 aLegendPosList.append( tr("PREF_RIGHT") );
131 aLegendPosList.append( tr("PREF_TOP") );
132 aLegendPosList.append( tr("PREF_BOTTOM") );
134 QList<QVariant> anIndexesList;
135 anIndexesList.append(0);
136 anIndexesList.append(1);
137 anIndexesList.append(2);
138 anIndexesList.append(3);
140 thePrefMgr->setItemProperty( "strings", aLegendPosList, legendPosition );
141 thePrefMgr->setItemProperty( "indexes", anIndexesList, legendPosition );
143 int curveType = thePrefMgr->addItem( tr( "PREF_CURVE_TYPE" ), aGrpId,
144 SUIT_PreferenceMgr::Selector, "Plot2d", "CurveType" );
145 QStringList aCurveTypesList;
146 aCurveTypesList.append( tr("PREF_POINTS") );
147 aCurveTypesList.append( tr("PREF_LINES") );
148 aCurveTypesList.append( tr("PREF_SPLINE") );
150 anIndexesList.clear();
151 anIndexesList.append(0);
152 anIndexesList.append(1);
153 anIndexesList.append(2);
155 thePrefMgr->setItemProperty( "strings", aCurveTypesList, curveType );
156 thePrefMgr->setItemProperty( "indexes", anIndexesList, curveType );
158 int markerSize = thePrefMgr->addItem( tr( "PREF_MARKER_SIZE" ), aGrpId,
159 SUIT_PreferenceMgr::IntSpin, "Plot2d", "MarkerSize" );
161 thePrefMgr->setItemProperty( "min", 0, markerSize );
162 thePrefMgr->setItemProperty( "max", 100, markerSize );
164 QStringList aScaleModesList;
165 aScaleModesList.append( tr("PREF_LINEAR") );
166 aScaleModesList.append( tr("PREF_LOGARITHMIC") );
168 anIndexesList.clear();
169 anIndexesList.append(0);
170 anIndexesList.append(1);
172 int horScale = thePrefMgr->addItem( tr( "PREF_HOR_AXIS_SCALE" ), aGrpId,
173 SUIT_PreferenceMgr::Selector, "Plot2d", "HorScaleMode" );
175 thePrefMgr->setItemProperty( "strings", aScaleModesList, horScale );
176 thePrefMgr->setItemProperty( "indexes", anIndexesList, horScale );
178 int verScale = thePrefMgr->addItem( tr( "PREF_VERT_AXIS_SCALE" ), aGrpId,
179 SUIT_PreferenceMgr::Selector, "Plot2d", "VerScaleMode" );
181 thePrefMgr->setItemProperty( "strings", aScaleModesList, verScale );
182 thePrefMgr->setItemProperty( "indexes", anIndexesList, verScale );
184 thePrefMgr->addItem( tr( "PREF_VIEWER_BACKGROUND" ), aGrpId,
185 SUIT_PreferenceMgr::Color, "Plot2d", "Background" );