summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-12 13:44:20 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-12 13:47:32 -0400
commitef69c15bb98683ca6a70ad2f0b92fec54f7a23e0 (patch)
treea3ba5484d1fbfe57d44ada5b87e7514ebc062d18 /chart2
parente2f94a8e2cf1761f5e2b0ae166f6a8bd73e0a15d (diff)
Have ChartView keep the instance of GL3D chart object between rendering.
Change-Id: I49419d20bf283fba1c31d8516972b0ca7fddcb5b
Diffstat (limited to 'chart2')
-rw-r--r--chart2/Library_chartcore.mk1
-rw-r--r--chart2/inc/ChartView.hxx2
-rw-r--r--chart2/source/view/inc/GL3DBarChart.hxx10
-rw-r--r--chart2/source/view/inc/GL3DPlotterBase.hxx28
-rw-r--r--chart2/source/view/main/ChartView.cxx91
-rw-r--r--chart2/source/view/main/GL3DPlotterBase.cxx18
6 files changed, 103 insertions, 47 deletions
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index e4e1fee2c5d6..97245ca8ef12 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -103,6 +103,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/main/Clipping \
chart2/source/view/main/DataPointSymbolSupplier \
chart2/source/view/main/DrawModelWrapper \
+ chart2/source/view/main/GL3DPlotterBase \
chart2/source/view/main/GL3DRenderer \
chart2/source/view/main/LabelPositionHelper \
chart2/source/view/main/Linear3DTransformation \
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index 0ba3bf86f132..69f1eedf3313 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -54,6 +54,7 @@ class VCoordinateSystem;
class DrawModelWrapper;
class SeriesPlotterContainer;
class VDataSeries;
+class GL3DPlotterBase;
enum TimeBasedMode
{
@@ -271,6 +272,7 @@ private: //member
::com::sun::star::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes;
+ boost::shared_ptr<GL3DPlotterBase> m_pGL3DPlotter;
TimeBasedInfo maTimeBased;
osl::Mutex maTimeMutex;
};
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 86115decc462..7a1733e1eae3 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -10,6 +10,8 @@
#ifndef CHART2_GL3DBARCHART_HXX
#define CHART2_GL3DBARCHART_HXX
+#include <GL3DPlotterBase.hxx>
+
#include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
#include "VDataSeries.hxx"
@@ -27,7 +29,7 @@ class OpenGL3DRenderer;
}
-class GL3DBarChart
+class GL3DBarChart : public GL3DPlotterBase
{
public:
GL3DBarChart(
@@ -35,11 +37,11 @@ public:
const boost::ptr_vector<VDataSeries>& rDataSeries, OpenGLWindow& rContext,
ExplicitCategoriesProvider& rCatProvider );
- ~GL3DBarChart();
+ virtual ~GL3DBarChart();
- void create3DShapes();
+ virtual void create3DShapes() SAL_OVERRIDE;
- void render();
+ virtual void render() SAL_OVERRIDE;
private:
css::uno::Reference<css::chart2::XChartType> mxChartType;
diff --git a/chart2/source/view/inc/GL3DPlotterBase.hxx b/chart2/source/view/inc/GL3DPlotterBase.hxx
new file mode 100644
index 000000000000..9c89008f2c4d
--- /dev/null
+++ b/chart2/source/view/inc/GL3DPlotterBase.hxx
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef CHART2_GL3DPLOTTERBASE_HXX
+#define CHART2_GL3DPLOTTERBASE_HXX
+
+namespace chart {
+
+class GL3DPlotterBase
+{
+public:
+ virtual ~GL3DPlotterBase();
+
+ virtual void create3DShapes() = 0;
+ virtual void render() = 0;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 13f4bf717d3d..49c32020318d 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2461,11 +2461,12 @@ void ChartView::createShapes()
}
else
{
+ m_pGL3DPlotter.reset();
+
// hide OpenGL window for now in normal charts
OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
if(pWindow)
pWindow->Show(false);
-
}
#endif
@@ -3114,61 +3115,65 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased)
void ChartView::createShapes3D()
{
- uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() );
- uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( !xCooSysContainer.is())
- return;
+ 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<VDataSeries> aDataSeries;
+ uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
+ boost::ptr_vector<VDataSeries> 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;
+ 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<XCoordinateSystem> xCooSys( aCooSysList[0] );
+ uno::Reference<XCoordinateSystem> 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;
+ //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::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< XChartType > xChartType( aChartTypeList[0] );
- uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
- OSL_ASSERT( xDataSeriesContainer.is());
- if( !xDataSeriesContainer.is() )
- return;
+ 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;
+ 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));
- }
+ aDataSeries.push_back(new VDataSeries(xDataSeries));
+ }
- OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
- if(!pWindow)
- return;
+ OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
+ if(!pWindow)
+ return;
- boost::scoped_ptr<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel));
+ boost::scoped_ptr<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel));
- pWindow->Show();
+ pWindow->Show();
+
+ m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, aDataSeries, *pWindow, *pCatProvider));
+ m_pGL3DPlotter->create3DShapes();
+ }
- GL3DBarChart aBarChart(xChartType, aDataSeries, *pWindow, *pCatProvider);
- aBarChart.create3DShapes();
- aBarChart.render();
+ m_pGL3DPlotter->render();
}
} //namespace chart
diff --git a/chart2/source/view/main/GL3DPlotterBase.cxx b/chart2/source/view/main/GL3DPlotterBase.cxx
new file mode 100644
index 000000000000..e342b68a304a
--- /dev/null
+++ b/chart2/source/view/main/GL3DPlotterBase.cxx
@@ -0,0 +1,18 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <GL3DPlotterBase.hxx>
+
+namespace chart {
+
+GL3DPlotterBase::~GL3DPlotterBase() {}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */