restore correct repaint after changed value in 3D chart

Change-Id: Ied1904a56b8d526288a89fd8df0bed639cd317d0
This commit is contained in:
Markus Mohrhard
2014-05-13 05:28:18 +02:00
committed by Markus Mohrhard
parent 9fbafe9fe8
commit 15e2c82acb
4 changed files with 73 additions and 69 deletions

View File

@@ -25,13 +25,10 @@ namespace chart {
GL3DBarChart::GL3DBarChart( GL3DBarChart::GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType, const css::uno::Reference<css::chart2::XChartType>& xChartType,
const boost::ptr_vector<VDataSeries>& rDataSeries, OpenGLWindow& rWindow) :
OpenGLWindow& rWindow, ExplicitCategoriesProvider& rCatProvider ) :
mxChartType(xChartType), mxChartType(xChartType),
maDataSeries(rDataSeries),
mpRenderer(new opengl3D::OpenGL3DRenderer()), mpRenderer(new opengl3D::OpenGL3DRenderer()),
mrWindow(rWindow), mrWindow(rWindow)
mrCatProvider(rCatProvider)
{ {
mrWindow.setRenderer(this); mrWindow.setRenderer(this);
mpRenderer->init(); mpRenderer->init();
@@ -42,7 +39,8 @@ GL3DBarChart::~GL3DBarChart()
mrWindow.setRenderer(NULL); mrWindow.setRenderer(NULL);
} }
void GL3DBarChart::create3DShapes() void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer,
ExplicitCategoriesProvider& rCatProvider)
{ {
// Each series of data flows from left to right, and multiple series are // Each series of data flows from left to right, and multiple series are
// stacked vertically along y axis. // stacked vertically along y axis.
@@ -68,8 +66,8 @@ void GL3DBarChart::create3DShapes()
maShapes.clear(); maShapes.clear();
maShapes.push_back(new opengl3D::Camera(mpRenderer.get())); maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));
sal_Int32 nSeriesIndex = 0; sal_Int32 nSeriesIndex = 0;
for (boost::ptr_vector<VDataSeries>::const_iterator itr = maDataSeries.begin(), for (boost::ptr_vector<VDataSeries>::const_iterator itr = rDataSeriesContainer.begin(),
itrEnd = maDataSeries.end(); itr != itrEnd; ++itr) itrEnd = rDataSeriesContainer.end(); itr != itrEnd; ++itr)
{ {
nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY) + nBarSizeY; nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY) + nBarSizeY;
@@ -147,7 +145,7 @@ void GL3DBarChart::create3DShapes()
pRect->setLineColor(COL_BLUE); pRect->setLineColor(COL_BLUE);
// Create category texts along X-axis at the bottom. // Create category texts along X-axis at the bottom.
uno::Sequence<OUString> aCats = mrCatProvider.getSimpleCategories(); uno::Sequence<OUString> aCats = rCatProvider.getSimpleCategories();
for (sal_Int32 i = 0; i < aCats.getLength(); ++i) for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
{ {
float nXPos = i * (nBarSizeX + nBarDistanceX); float nXPos = i * (nBarSizeX + nBarDistanceX);

View File

@@ -34,12 +34,12 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer
public: public:
GL3DBarChart( GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType, const css::uno::Reference<css::chart2::XChartType>& xChartType,
const boost::ptr_vector<VDataSeries>& rDataSeries, OpenGLWindow& rContext, OpenGLWindow& rContext);
ExplicitCategoriesProvider& rCatProvider );
virtual ~GL3DBarChart(); virtual ~GL3DBarChart();
virtual void create3DShapes() SAL_OVERRIDE; virtual void create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeries,
ExplicitCategoriesProvider& rCatProvider) SAL_OVERRIDE;
virtual void render() SAL_OVERRIDE; virtual void render() SAL_OVERRIDE;
@@ -49,12 +49,10 @@ public:
private: private:
css::uno::Reference<css::chart2::XChartType> mxChartType; css::uno::Reference<css::chart2::XChartType> mxChartType;
const boost::ptr_vector<VDataSeries>& maDataSeries;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes; boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer; boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
OpenGLWindow& mrWindow; OpenGLWindow& mrWindow;
ExplicitCategoriesProvider& mrCatProvider;
}; };
} }

View File

@@ -10,14 +10,20 @@
#ifndef CHART2_GL3DPLOTTERBASE_HXX #ifndef CHART2_GL3DPLOTTERBASE_HXX
#define CHART2_GL3DPLOTTERBASE_HXX #define CHART2_GL3DPLOTTERBASE_HXX
#include <boost/ptr_container/ptr_vector.hpp>
#include "VDataSeries.hxx"
namespace chart { namespace chart {
class ExplicitCategoriesProvider;
class GL3DPlotterBase class GL3DPlotterBase
{ {
public: public:
virtual ~GL3DPlotterBase(); virtual ~GL3DPlotterBase();
virtual void create3DShapes() = 0; virtual void create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeries,
ExplicitCategoriesProvider& rCatProvider) = 0;
virtual void render() = 0; virtual void render() = 0;
}; };

View File

@@ -3115,65 +3115,67 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased)
void ChartView::createShapes3D() 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<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;
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) if (!m_pGL3DPlotter)
{ {
uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, *pWindow));
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;
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] );
//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<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel));
pWindow->Show();
m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, aDataSeries, *pWindow, *pCatProvider));
m_pGL3DPlotter->create3DShapes();
} }
uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
OSL_ASSERT( xDataSeriesContainer.is());
if( !xDataSeriesContainer.is() )
return;
boost::ptr_vector<VDataSeries> 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<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel));
m_pGL3DPlotter->create3DShapes(aDataSeries, *pCatProvider);
m_pGL3DPlotter->render(); m_pGL3DPlotter->render();
pWindow->Show();
} }
} //namespace chart } //namespace chart