chart2/source/view/charttypes/GL3DBarChart.cxx | 57 +++++++++++++++++-------- chart2/source/view/inc/3DChartObjects.hxx | 8 +++ chart2/source/view/main/3DChartObjects.cxx | 28 ++++++++++++ 3 files changed, 76 insertions(+), 17 deletions(-)
New commits: commit 2c64e08aa3eac795cc0064f1f9dcce55d8e50384 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri May 9 10:52:32 2014 -0400 Best effort of blindly placing axes and background objects. Change-Id: I3a7c77ee8d9c6ff033b112158daec3923ed27034 diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index ce6349e..adce1ee 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -55,6 +55,7 @@ void GL3DBarChart::create3DShapes() const float nBarDistanceY = nBarSizeY / 2; sal_uInt32 nId = 1; + float nXEnd = 0.0; float nYPos = 0.0; maShapes.clear(); @@ -98,11 +99,46 @@ void GL3DBarChart::create3DShapes() maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId++)); } + float nThisXEnd = nPointCount * (nBarSizeX + nBarDistanceX); + if (nXEnd < nThisXEnd) + nXEnd = nThisXEnd; + ++nSeriesIndex; } nYPos += nBarSizeY + nBarDistanceY; + // X axis + maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId++)); + opengl3D::Line* pAxis = static_cast<opengl3D::Line*>(&maShapes.back()); + glm::vec3 aBegin; + aBegin.y = nYPos; + glm::vec3 aEnd = aBegin; + aEnd.x = nXEnd; + pAxis->setPosition(aBegin, aEnd); + pAxis->setLineColor(COL_WHITE); + + // Y axis + maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId++)); + pAxis = static_cast<opengl3D::Line*>(&maShapes.back()); + aBegin.x = aBegin.y = 0; + aEnd = aBegin; + aEnd.y = nYPos; + pAxis->setPosition(aBegin, aEnd); + pAxis->setLineColor(COL_WHITE); + + // Chart background. + maShapes.push_back(new opengl3D::Rectangle(mpRenderer.get(), nId++)); + opengl3D::Rectangle* pRect = static_cast<opengl3D::Rectangle*>(&maShapes.back()); + glm::vec3 aTopLeft; + glm::vec3 aTopRight = aTopLeft; + aTopRight.x = nXEnd; + glm::vec3 aBottomRight = aTopRight; + aBottomRight.y = nYPos; + pRect->setPosition(aTopLeft, aTopRight, aBottomRight); + pRect->setFillColor(COL_BLACK); + pRect->setLineColor(COL_WHITE); + // Create category texts along X-axis at the bottom. uno::Sequence<OUString> aCats = mrCatProvider.getSimpleCategories(); for (sal_Int32 i = 0; i < aCats.getLength(); ++i) @@ -112,12 +148,11 @@ void GL3DBarChart::create3DShapes() maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++)); opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back()); Size aTextSize = p->getSize(); - glm::vec3 aTopLeft; aTopLeft.x = nXPos; aTopLeft.y = nYPos; - glm::vec3 aTopRight = aTopLeft; + aTopRight = aTopLeft; aTopRight.x += aTextSize.getWidth(); - glm::vec3 aBottomRight = aTopRight; + aBottomRight = aTopRight; aBottomRight.y += aTextSize.getHeight(); p->setPosition(aTopLeft, aTopRight, aBottomRight); } diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx index e93d656..8571fd8 100644 --- a/chart2/source/view/inc/3DChartObjects.hxx +++ b/chart2/source/view/inc/3DChartObjects.hxx @@ -53,6 +53,9 @@ public: virtual void render() SAL_OVERRIDE; + void setPosition(const glm::vec3& rBegin, const glm::vec3& rEnd); + void setLineColor(const Color& rColor); + private: glm::vec3 maPosBegin; glm::vec3 maPosEnd; @@ -81,6 +84,11 @@ class Rectangle : public Renderable3DObject public: Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId); virtual void render() SAL_OVERRIDE; + + void setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight); + void setFillColor(const Color& rColor); + void setLineColor(const Color& rColor); + private: glm::vec3 maTopLeft; glm::vec3 maTopRight; diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx index 820e79d..6cad265 100644 --- a/chart2/source/view/main/3DChartObjects.cxx +++ b/chart2/source/view/main/3DChartObjects.cxx @@ -53,6 +53,17 @@ void Line::render() mpRenderer->EndAddShapePolygon3DObject(); } +void Line::setPosition(const glm::vec3& rBegin, const glm::vec3& rEnd) +{ + maPosBegin = rBegin; + maPosEnd = rEnd; +} + +void Line::setLineColor(const Color& rColor) +{ + maLineColor = rColor; +} + Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId): Renderable3DObject(pRenderer, nId) { @@ -124,6 +135,23 @@ void Rectangle::render() mpRenderer->EndAddShapePolygon3DObject(); } +void Rectangle::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight) +{ + maTopLeft = rTopLeft; + maTopRight = rTopRight; + maBottomRight = rBottomRight; +} + +void Rectangle::setFillColor(const Color& rColor) +{ + maColor = rColor; +} + +void Rectangle::setLineColor(const Color& rColor) +{ + maLineColor = rColor; +} + Camera::Camera(OpenGL3DRenderer* pRenderer): Renderable3DObject(pRenderer, 0), maPos(10,10,-10), commit aa26f8b6c79783447931d01e6c69eed07599f37f Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri May 9 10:09:24 2014 -0400 No need to store these text objects separately. Change-Id: I0ee63480fa0f15f42c81818d89ff5b5a3407ece4 diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index e65f07e..ce6349e 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -55,9 +55,6 @@ void GL3DBarChart::create3DShapes() const float nBarDistanceY = nBarSizeY / 2; sal_uInt32 nId = 1; - - std::vector<opengl3D::Text*> aYAxisTexts; - float nYPos = 0.0; maShapes.clear(); @@ -76,8 +73,8 @@ void GL3DBarChart::create3DShapes() DataSeriesHelper::getDataSeriesLabel( rDataSeries.getModel(), mxChartType->getRoleOfSequenceForSeriesLabel()); - aYAxisTexts.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++)); - opengl3D::Text* p = aYAxisTexts.back(); + maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++)); + opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back()); Size aTextSize = p->getSize(); glm::vec3 aTopLeft, aTopRight, aBottomRight; aTopLeft.x = aTextSize.getWidth() * -1.0; @@ -124,15 +121,6 @@ void GL3DBarChart::create3DShapes() aBottomRight.y += aTextSize.getHeight(); p->setPosition(aTopLeft, aTopRight, aBottomRight); } - - { - // Transfer all Y-axis text objects to the shape collection. - std::vector<opengl3D::Text*>::iterator itText = aYAxisTexts.begin(), itTextEnd = aYAxisTexts.end(); - for (; itText != itTextEnd; ++itText) - maShapes.push_back(*itText); - } - - aYAxisTexts.clear(); } void GL3DBarChart::render() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits