[Libreoffice-commits] core.git: 2 commits - chart2/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Wed May 21 05:56:06 PDT 2014


 chart2/source/view/charttypes/GL3DBarChart.cxx |   21 +++++++++++++++------
 chart2/source/view/main/3DChartObjects.cxx     |    5 +++--
 2 files changed, 18 insertions(+), 8 deletions(-)

New commits:
commit 1225fc104708d0d3b10233e19008f9a923ff5f90
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 21 14:48:44 2014 +0200

    improve the text rendering a bit
    
    Less scaling means more beautiful text
    
    Change-Id: I787244a5f7a472a14f463729f8f434a4969a6285

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index c2ec371..542711a 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -44,11 +44,11 @@ GL3DBarChart::~GL3DBarChart()
 
 namespace {
 
-const float TEXT_HEIGHT = 10.0f;
+const float TEXT_HEIGHT = 15.0f;
 
 float calculateTextWidth(const OUString& rText)
 {
-    return rText.getLength() * 5.0;
+    return rText.getLength() * 7.5;
 }
 
 }
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index e67c25d..6edb68f 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -73,14 +73,15 @@ Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId):
     // Convert OUString to BitmapEx.
     VirtualDevice aDevice(*Application::GetDefaultDevice(), 0, 0);
     Font aFont = aDevice.GetFont();
+    aFont.SetSize(Size(0, 96));
     aFont.SetColor(COL_BLACK);
     aDevice.SetFont(aFont);
     aDevice.Erase();
-    aDevice.SetOutputSizePixel(Size(20,12));
+    aDevice.SetOutputSizePixel(Size(160,96));
     aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
     aDevice.DrawText(Point(0,0), rStr);
 
-    maText = BitmapEx(aDevice.GetBitmapEx(Point(0,0), Size(20,12)));
+    maText = BitmapEx(aDevice.GetBitmapEx(Point(0,0), Size(160,96)));
 }
 
 void Text::render()
commit addc7e821fae471f2228af668791a19ee386fe30
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed May 21 14:36:03 2014 +0200

    we need to set text size in woorld coordinates
    
    Change-Id: If77133080851a3b2d700ac54c9722f560e71f26e

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 5e21945..c2ec371 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -42,6 +42,17 @@ GL3DBarChart::~GL3DBarChart()
     mrWindow.setRenderer(NULL);
 }
 
+namespace {
+
+const float TEXT_HEIGHT = 10.0f;
+
+float calculateTextWidth(const OUString& rText)
+{
+    return rText.getLength() * 5.0;
+}
+
+}
+
 void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer,
         ExplicitCategoriesProvider& rCatProvider)
 {
@@ -88,13 +99,12 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
 
         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;
+        aTopLeft.x = calculateTextWidth(aSeriesName) * -1.0;
         aTopLeft.y = nYPos;
         aTopRight.y = nYPos;
         aBottomRight = aTopRight;
-        aBottomRight.y += aTextSize.getHeight();
+        aBottomRight.y += TEXT_HEIGHT;
         p->setPosition(aTopLeft, aTopRight, aBottomRight);
 
         sal_Int32 nColor = aSeriesColor[nSeriesIndex % SAL_N_ELEMENTS(aSeriesColor)].GetColor();
@@ -164,13 +174,12 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
 
         maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
         opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
-        Size aTextSize = p->getSize();
         aTopLeft.x = nXPos;
         aTopLeft.y = nYPos;
         aTopRight = aTopLeft;
-        aTopRight.x += aTextSize.getWidth();
+        aTopRight.x += calculateTextWidth(aCats[i]);
         aBottomRight = aTopRight;
-        aBottomRight.y += aTextSize.getHeight();
+        aBottomRight.y += TEXT_HEIGHT;
         p->setPosition(aTopLeft, aTopRight, aBottomRight);
     }
 }


More information about the Libreoffice-commits mailing list