[Libreoffice-commits] core.git: chart2/source
Kohei Yoshida
kohei.yoshida at collabora.com
Thu May 8 09:45:16 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 28 +++++++++--
chart2/source/view/inc/3DChartObjects.hxx | 2
chart2/source/view/inc/GL3DBarChart.hxx | 11 +++-
chart2/source/view/main/3DChartObjects.cxx | 3 -
chart2/source/view/main/ChartView.cxx | 62 ++++++++++++++-----------
5 files changed, 71 insertions(+), 35 deletions(-)
New commits:
commit 56e36f2e36aef20ef594b6725ee091dd534d1eba
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu May 8 11:26:48 2014 -0400
Put category and data series names into the shape collection.
Their positions are yet to be calculated.
Change-Id: Ibb1f2498eb2af3305c2afb6d41be99eaf279daaf
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 12a5417..6cd0d0a 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -16,16 +16,22 @@
#include "3DChartObjects.hxx"
#include "GL3DRenderer.hxx"
+#include <ExplicitCategoriesProvider.hxx>
+#include <DataSeriesHelper.hxx>
using namespace com::sun::star;
namespace chart {
-GL3DBarChart::GL3DBarChart(const std::vector<VDataSeries*>& rDataSeries,
- OpenGLWindow& rWindow):
+GL3DBarChart::GL3DBarChart(
+ const css::uno::Reference<css::chart2::XChartType>& xChartType,
+ const std::vector<VDataSeries*>& rDataSeries,
+ OpenGLWindow& rWindow, ExplicitCategoriesProvider& rCatProvider ) :
+ mxChartType(xChartType),
maDataSeries(rDataSeries),
mpRenderer(new opengl3D::OpenGL3DRenderer()),
- mrWindow(rWindow)
+ mrWindow(rWindow),
+ mrCatProvider(rCatProvider)
{
}
@@ -40,15 +46,29 @@ void GL3DBarChart::create3DShapes()
const float nBarDistanceX = nBarSizeX / 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.push_back(new opengl3D::Camera(mpRenderer.get()));
sal_Int32 nSeriesIndex = 0;
- sal_uInt32 nId = 1;
for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
itrEnd = maDataSeries.end(); itr != itrEnd; ++itr)
{
VDataSeries* pDataSeries = *itr;
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)
{
float nVal = pDataSeries->getYValue(nIndex);
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index 05c2f5b..ca56580 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -62,7 +62,7 @@ private:
class Text : public Renderable3DObject
{
public:
- Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
+ Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE;
private:
BitmapEx maText;
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 06b1be5..f3e225f 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -18,6 +18,8 @@
namespace chart {
+class ExplicitCategoriesProvider;
+
namespace opengl3D {
class Renderable3DObject;
@@ -32,7 +34,11 @@ class TemporaryContext;
class GL3DBarChart
{
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();
void create3DShapes();
@@ -40,12 +46,13 @@ public:
void render();
private:
-
+ css::uno::Reference<css::chart2::XChartType> mxChartType;
std::vector<VDataSeries*> maDataSeries;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
OpenGLWindow& mrWindow;
+ ExplicitCategoriesProvider& mrCatProvider;
};
}
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index b4ca2c4..daa5eca 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -51,9 +51,10 @@ void Line::render()
mpRenderer->EndAddShapePolygon3DObject();
}
-Text::Text(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
+Text::Text(OpenGL3DRenderer* pRenderer, const OUString& /*rStr*/, sal_uInt32 nId):
Renderable3DObject(pRenderer, nId)
{
+ // TODO : convert OUString to BitmapEx.
}
void Text::render()
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 93d4133..0c23d05 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -3121,45 +3121,53 @@ void ChartView::createShapes3D()
uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
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
- uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- OSL_ASSERT( xChartTypeContainer.is());
- if( !xChartTypeContainer.is() )
- continue;
- uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
- {
- uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
+ 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< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
- OSL_ASSERT( xDataSeriesContainer.is());
- if( !xDataSeriesContainer.is() )
- continue;
+ uno::Reference<XCoordinateSystem> xCooSys( aCooSysList[0] );
- 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;
+ //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;
- VDataSeries* pSeries = new VDataSeries( xDataSeries );
- aDataSeries.push_back(pSeries);
- }
- }
+ 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;
+
+ VDataSeries* pSeries = new VDataSeries( xDataSeries );
+ aDataSeries.push_back(pSeries);
}
OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();
if(!pWindow)
return;
+ boost::scoped_ptr<ExplicitCategoriesProvider> pCatProvider(new ExplicitCategoriesProvider(xCooSys, mrChartModel));
+
pWindow->Show();
- GL3DBarChart aBarChart(aDataSeries, *pWindow);
+ GL3DBarChart aBarChart(xChartType, aDataSeries, *pWindow, *pCatProvider);
aBarChart.create3DShapes();
aBarChart.render();
}
More information about the Libreoffice-commits
mailing list