Kaydet (Commit) 15e2c82a authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

restore correct repaint after changed value in 3D chart

Change-Id: Ied1904a56b8d526288a89fd8df0bed639cd317d0
üst 9fbafe9f
...@@ -25,13 +25,10 @@ namespace chart { ...@@ -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() ...@@ -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() ...@@ -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() ...@@ -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);
......
...@@ -34,12 +34,12 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer ...@@ -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: ...@@ -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;
}; };
} }
......
...@@ -10,14 +10,20 @@ ...@@ -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;
}; };
......
...@@ -3115,65 +3115,67 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased) ...@@ -3115,65 +3115,67 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased)
void ChartView::createShapes3D() void ChartView::createShapes3D()
{ {
if (!m_pGL3DPlotter) OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
{ if(!pWindow)
uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); return;
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) uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() );
// Supporting multiple coordinates in a truly 3D chart (which implies uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
// it's a Cartesian coordinate system) is a bit of a challenge, if not if( !xCooSysContainer.is())
// impossible. return;
return;
uno::Reference<XCoordinateSystem> xCooSys( aCooSysList[0] ); uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
//iterate through all chart types in the current coordinate system if (aCooSysList.getLength() != 1)
uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY ); // Supporting multiple coordinates in a truly 3D chart (which implies
OSL_ASSERT( xChartTypeContainer.is()); // it's a Cartesian coordinate system) is a bit of a challenge, if not
if( !xChartTypeContainer.is() ) // impossible.
return; return;
uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); uno::Reference<XCoordinateSystem> xCooSys( aCooSysList[0] );
if (aChartTypeList.getLength() != 1)
// Likewise, we can't really support multiple chart types here.
return;
uno::Reference< XChartType > xChartType( aChartTypeList[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::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
OSL_ASSERT( xDataSeriesContainer.is()); if (aChartTypeList.getLength() != 1)
if( !xDataSeriesContainer.is() ) // Likewise, we can't really support multiple chart types here.
return; return;
uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); uno::Reference< XChartType > xChartType( aChartTypeList[0] );
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)); if (!m_pGL3DPlotter)
} {
m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, *pWindow));
}
OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
if(!pWindow)
return;
boost::scoped_ptr<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel)); uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
OSL_ASSERT( xDataSeriesContainer.is());
if( !xDataSeriesContainer.is() )
return;
pWindow->Show(); 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;
m_pGL3DPlotter.reset(new GL3DBarChart(xChartType, aDataSeries, *pWindow, *pCatProvider)); aDataSeries.push_back(new VDataSeries(xDataSeries));
m_pGL3DPlotter->create3DShapes();
} }
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment