diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index c164bd27ee24..35bcb5180121 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -25,13 +25,10 @@ namespace chart { GL3DBarChart::GL3DBarChart( const css::uno::Reference& xChartType, - const boost::ptr_vector& rDataSeries, - OpenGLWindow& rWindow, ExplicitCategoriesProvider& rCatProvider ) : + OpenGLWindow& rWindow) : mxChartType(xChartType), - maDataSeries(rDataSeries), mpRenderer(new opengl3D::OpenGL3DRenderer()), - mrWindow(rWindow), - mrCatProvider(rCatProvider) + mrWindow(rWindow) { mrWindow.setRenderer(this); mpRenderer->init(); @@ -42,7 +39,8 @@ GL3DBarChart::~GL3DBarChart() mrWindow.setRenderer(NULL); } -void GL3DBarChart::create3DShapes() +void GL3DBarChart::create3DShapes(const boost::ptr_vector& rDataSeriesContainer, + ExplicitCategoriesProvider& rCatProvider) { // Each series of data flows from left to right, and multiple series are // stacked vertically along y axis. @@ -68,8 +66,8 @@ void GL3DBarChart::create3DShapes() maShapes.clear(); maShapes.push_back(new opengl3D::Camera(mpRenderer.get())); sal_Int32 nSeriesIndex = 0; - for (boost::ptr_vector::const_iterator itr = maDataSeries.begin(), - itrEnd = maDataSeries.end(); itr != itrEnd; ++itr) + for (boost::ptr_vector::const_iterator itr = rDataSeriesContainer.begin(), + itrEnd = rDataSeriesContainer.end(); itr != itrEnd; ++itr) { nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY) + nBarSizeY; @@ -147,7 +145,7 @@ void GL3DBarChart::create3DShapes() pRect->setLineColor(COL_BLUE); // Create category texts along X-axis at the bottom. - uno::Sequence aCats = mrCatProvider.getSimpleCategories(); + uno::Sequence aCats = rCatProvider.getSimpleCategories(); for (sal_Int32 i = 0; i < aCats.getLength(); ++i) { float nXPos = i * (nBarSizeX + nBarDistanceX); diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx index 7c1fc511ef2d..1741b3d071cf 100644 --- a/chart2/source/view/inc/GL3DBarChart.hxx +++ b/chart2/source/view/inc/GL3DBarChart.hxx @@ -34,12 +34,12 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer public: GL3DBarChart( const css::uno::Reference& xChartType, - const boost::ptr_vector& rDataSeries, OpenGLWindow& rContext, - ExplicitCategoriesProvider& rCatProvider ); + OpenGLWindow& rContext); virtual ~GL3DBarChart(); - virtual void create3DShapes() SAL_OVERRIDE; + virtual void create3DShapes(const boost::ptr_vector& rDataSeries, + ExplicitCategoriesProvider& rCatProvider) SAL_OVERRIDE; virtual void render() SAL_OVERRIDE; @@ -49,12 +49,10 @@ public: private: css::uno::Reference mxChartType; - const boost::ptr_vector& maDataSeries; boost::ptr_vector maShapes; boost::scoped_ptr mpRenderer; OpenGLWindow& mrWindow; - ExplicitCategoriesProvider& mrCatProvider; }; } diff --git a/chart2/source/view/inc/GL3DPlotterBase.hxx b/chart2/source/view/inc/GL3DPlotterBase.hxx index 9c89008f2c4d..cd69bf2eccd9 100644 --- a/chart2/source/view/inc/GL3DPlotterBase.hxx +++ b/chart2/source/view/inc/GL3DPlotterBase.hxx @@ -10,14 +10,20 @@ #ifndef CHART2_GL3DPLOTTERBASE_HXX #define CHART2_GL3DPLOTTERBASE_HXX +#include +#include "VDataSeries.hxx" + namespace chart { +class ExplicitCategoriesProvider; + class GL3DPlotterBase { public: virtual ~GL3DPlotterBase(); - virtual void create3DShapes() = 0; + virtual void create3DShapes(const boost::ptr_vector& rDataSeries, + ExplicitCategoriesProvider& rCatProvider) = 0; virtual void render() = 0; }; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 49c32020318d..6c5d7251d74e 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -3115,65 +3115,67 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased) void ChartView::createShapes3D() { + OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow(); + if(!pWindow) + return; + + uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); + uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); + if( !xCooSysContainer.is()) + return; + + uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); + + if (aCooSysList.getLength() != 1) + // Supporting multiple coordinates in a truly 3D chart (which implies + // it's a Cartesian coordinate system) is a bit of a challenge, if not + // impossible. + return; + + uno::Reference xCooSys( aCooSysList[0] ); + + //iterate through all chart types in the current coordinate system + uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY ); + OSL_ASSERT( xChartTypeContainer.is()); + if( !xChartTypeContainer.is() ) + return; + + uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); + if (aChartTypeList.getLength() != 1) + // Likewise, we can't really support multiple chart types here. + return; + + uno::Reference< XChartType > xChartType( aChartTypeList[0] ); + if (!m_pGL3DPlotter) { - uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); - uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); - if( !xCooSysContainer.is()) - return; - - uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); - boost::ptr_vector aDataSeries; - - if (aCooSysList.getLength() != 1) - // Supporting multiple coordinates in a truly 3D chart (which implies - // it's a Cartesian coordinate system) is a bit of a challenge, if not - // impossible. - return; - - uno::Reference xCooSys( aCooSysList[0] ); - - //iterate through all chart types in the current coordinate system - uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY ); - OSL_ASSERT( xChartTypeContainer.is()); - if( !xChartTypeContainer.is() ) - return; - - uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); - if (aChartTypeList.getLength() != 1) - // Likewise, we can't really support multiple chart types here. - return; - - uno::Reference< XChartType > xChartType( aChartTypeList[0] ); - - uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); - OSL_ASSERT( xDataSeriesContainer.is()); - if( !xDataSeriesContainer.is() ) - return; - - uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); - for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS ) - { - uno::Reference< XDataSeries > xDataSeries( aSeriesList[nS], uno::UNO_QUERY ); - if(!xDataSeries.is()) - continue; - - aDataSeries.push_back(new VDataSeries(xDataSeries)); - } - - OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow(); - if(!pWindow) - return; - - boost::scoped_ptr pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel)); - - pWindow->Show(); - - m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, aDataSeries, *pWindow, *pCatProvider)); - m_pGL3DPlotter->create3DShapes(); + m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, *pWindow)); } + + uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); + OSL_ASSERT( xDataSeriesContainer.is()); + if( !xDataSeriesContainer.is() ) + return; + + boost::ptr_vector aDataSeries; + uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); + for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS ) + { + uno::Reference< XDataSeries > xDataSeries( aSeriesList[nS], uno::UNO_QUERY ); + if(!xDataSeries.is()) + continue; + + aDataSeries.push_back(new VDataSeries(xDataSeries)); + } + + boost::scoped_ptr pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel)); + + + m_pGL3DPlotter->create3DShapes(aDataSeries, *pCatProvider); + m_pGL3DPlotter->render(); + pWindow->Show(); } } //namespace chart