Kaydet (Commit) 56e36f2e authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Put category and data series names into the shape collection.

Their positions are yet to be calculated.

Change-Id: Ibb1f2498eb2af3305c2afb6d41be99eaf279daaf
üst 80ec4885
...@@ -16,16 +16,22 @@ ...@@ -16,16 +16,22 @@
#include "3DChartObjects.hxx" #include "3DChartObjects.hxx"
#include "GL3DRenderer.hxx" #include "GL3DRenderer.hxx"
#include <ExplicitCategoriesProvider.hxx>
#include <DataSeriesHelper.hxx>
using namespace com::sun::star; using namespace com::sun::star;
namespace chart { namespace chart {
GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries, GL3DBarChart::GL3DBarChart(
OpenGLWindow& rWindow): const css::uno::Reference<css::chart2::XChartType>& xChartType,
const std::vector<VDataSeries*>& rDataSeries,
OpenGLWindow& rWindow, ExplicitCategoriesProvider& rCatProvider ) :
mxChartType(xChartType),
maDataSeries(rDataSeries), maDataSeries(rDataSeries),
mpRenderer(new opengl3D::OpenGL3DRenderer()), mpRenderer(new opengl3D::OpenGL3DRenderer()),
mrWindow(rWindow) mrWindow(rWindow),
mrCatProvider(rCatProvider)
{ {
} }
...@@ -40,15 +46,29 @@ void GL3DBarChart::create3DShapes() ...@@ -40,15 +46,29 @@ void GL3DBarChart::create3DShapes()
const float nBarDistanceX = nBarSizeX / 2; const float nBarDistanceX = nBarSizeX / 2;
const float nBarDistanceY = nBarSizeY / 2; const float nBarDistanceY = nBarSizeY / 2;
sal_uInt32 nId = 1;
uno::Sequence<OUString> aCats = mrCatProvider.getSimpleCategories();
for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
// Category name text object.
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
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;
sal_uInt32 nId = 1;
for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(), for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
itrEnd = maDataSeries.end(); itr != itrEnd; ++itr) itrEnd = maDataSeries.end(); itr != itrEnd; ++itr)
{ {
VDataSeries* pDataSeries = *itr; VDataSeries* pDataSeries = *itr;
sal_Int32 nPointCount = pDataSeries->getTotalPointCount(); sal_Int32 nPointCount = pDataSeries->getTotalPointCount();
// Create series name text object.
OUString aSeriesName =
DataSeriesHelper::getDataSeriesLabel(
pDataSeries->getModel(), mxChartType->getRoleOfSequenceForSeriesLabel());
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex) for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
{ {
float nVal = pDataSeries->getYValue(nIndex); float nVal = pDataSeries->getYValue(nIndex);
......
...@@ -62,7 +62,7 @@ private: ...@@ -62,7 +62,7 @@ private:
class Text : public Renderable3DObject class Text : public Renderable3DObject
{ {
public: public:
Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId); Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE; virtual void render() SAL_OVERRIDE;
private: private:
BitmapEx maText; BitmapEx maText;
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
namespace chart { namespace chart {
class ExplicitCategoriesProvider;
namespace opengl3D { namespace opengl3D {
class Renderable3DObject; class Renderable3DObject;
...@@ -32,7 +34,11 @@ class TemporaryContext; ...@@ -32,7 +34,11 @@ class TemporaryContext;
class GL3DBarChart class GL3DBarChart
{ {
public: public:
GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries, OpenGLWindow& rContext); GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType,
const std::vector<VDataSeries*>& rDataSeries, OpenGLWindow& rContext,
ExplicitCategoriesProvider& rCatProvider );
~GL3DBarChart(); ~GL3DBarChart();
void create3DShapes(); void create3DShapes();
...@@ -40,12 +46,13 @@ public: ...@@ -40,12 +46,13 @@ public:
void render(); void render();
private: private:
css::uno::Reference<css::chart2::XChartType> mxChartType;
std::vector<VDataSeries*> maDataSeries; std::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;
}; };
} }
......
...@@ -51,9 +51,10 @@ void Line::render() ...@@ -51,9 +51,10 @@ void Line::render()
mpRenderer->EndAddShapePolygon3DObject(); mpRenderer->EndAddShapePolygon3DObject();
} }
Text::Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId): Text::Text(OpenGL3DRenderer* pRenderer, const OUString& /*rStr*/, sal_uInt32 nId):
Renderable3DObject(pRenderer, nId) Renderable3DObject(pRenderer, nId)
{ {
// TODO : convert OUString to BitmapEx.
} }
void Text::render() void Text::render()
......
...@@ -3121,45 +3121,53 @@ void ChartView::createShapes3D() ...@@ -3121,45 +3121,53 @@ void ChartView::createShapes3D()
uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
std::vector<VDataSeries*> aDataSeries; std::vector<VDataSeries*> aDataSeries;
for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
{
uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] );
//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.
continue; return;
uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
{
uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); uno::Reference<XCoordinateSystem> xCooSys( aCooSysList[0] );
OSL_ASSERT( xDataSeriesContainer.is());
if( !xDataSeriesContainer.is() )
continue;
uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); //iterate through all chart types in the current coordinate system
for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS ) uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
{ OSL_ASSERT( xChartTypeContainer.is());
uno::Reference< XDataSeries > xDataSeries( aSeriesList[nS], uno::UNO_QUERY ); if( !xChartTypeContainer.is() )
if(!xDataSeries.is()) return;
continue;
VDataSeries* pSeries = new VDataSeries( xDataSeries ); uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
aDataSeries.push_back(pSeries); 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;
VDataSeries* pSeries = new VDataSeries( xDataSeries );
aDataSeries.push_back(pSeries);
} }
OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow(); OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
if(!pWindow) if(!pWindow)
return; return;
boost::scoped_ptr<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel));
pWindow->Show(); pWindow->Show();
GL3DBarChart aBarChart(aDataSeries, *pWindow); GL3DBarChart aBarChart(xChartType, aDataSeries, *pWindow, *pCatProvider);
aBarChart.create3DShapes(); aBarChart.create3DShapes();
aBarChart.render(); aBarChart.render();
} }
......
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