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

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sun May 25 13:03:25 PDT 2014


 chart2/source/view/charttypes/GL3DBarChart.cxx |   83 ++++++++++++++++++++++++-
 chart2/source/view/inc/GL3DBarChart.hxx        |   19 +++++
 chart2/source/view/inc/GL3DRenderer.hxx        |    7 --
 chart2/source/view/main/GL3DRenderer.cxx       |   79 ++---------------------
 4 files changed, 107 insertions(+), 81 deletions(-)

New commits:
commit fe454926945619ab766f60ba3a66f5b389eabc7f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun May 25 21:46:05 2014 +0200

    remove unused variables
    
    Change-Id: I020be0cecd3becc24edc1267b4bce714db3bb627

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index b3e412a..0b518aa 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -81,7 +81,6 @@ struct Polygon3DInfo
     glm::vec4 polygonColor;
     glm::vec4 id;
     Vertices3D *vertices;
-    UVs3D *uvs;
     Normals3D *normals;
     std::vector <Vertices3D *> verticesList;
     std::vector <Normals3D *> normalsList;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 9803d30..db6e5ab 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -80,7 +80,6 @@ OpenGL3DRenderer::OpenGL3DRenderer():
     m_Polygon3DInfo.lineOnly = false;
     m_Polygon3DInfo.twoSidesLighting = false;
     m_Polygon3DInfo.vertices = NULL;
-    m_Polygon3DInfo.uvs = NULL;
     m_Polygon3DInfo.normals = NULL;
     m_Polygon3DInfo.lineWidth = 0.001f;
 
commit 45c25954dbab4dd8c0beb74656d94356f1549d63
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun May 25 21:38:38 2014 +0200

    remove all the unused functions
    
    Change-Id: Idb78a97793615ff0ccb5377d87442deaaa09161d

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index cf95f30..b3e412a 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -160,9 +160,6 @@ public:
     void EndAddPolygon3DObjectPoint();
     void AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 color, sal_uInt32 specular, const glm::mat4& modelMatrix, sal_uInt32 nUniqueId);
     void EndAddShape3DExtrudeObject();
-    double GetTime();
-    void SetFPS(float fps);
-    void RenderClickPos(Point aMPos);
     void SetSize(const Size& rSize);
     void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
     void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft, sal_uInt32 nUniqueId);
@@ -174,17 +171,14 @@ public:
 private:
     void MoveModelf(PosVecf3& trans,PosVecf3& angle,PosVecf3& scale);
 
-    void GetFreq();
     void RenderPolygon3DObject();
     void RenderLine3D(Polygon3DInfo &polygon);
     void RenderPolygon3D(Polygon3DInfo &polygon);
     void Init3DUniformBlock();
     void Update3DUniformBlock();
     void RenderExtrude3DObject();
-    void RenderFPS(float fps);
     //add for text
     void RenderTextShape();
-    void RenderText(const ::rtl::OUString& string, com::sun::star::awt::Point aPos);
     void RenderExtrudeSurface(const Extrude3DInfo& extrude3D);
     void RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D);
     void RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D);
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index d9c7e26..9803d30 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -67,7 +67,6 @@ glm::vec4 getColorAsVector(sal_uInt32 nColor)
             ((nColor & 0x0000FF00) >> 8) / 255.0f,
             (nColor & 0x000000FF) / 255.0f,
             (0xFF - (nColor & 0xFF000000)/255.0));
-
 }
 
 }
@@ -87,7 +86,6 @@ OpenGL3DRenderer::OpenGL3DRenderer():
 
     m_Extrude3DInfo.twoSidesLighting = false;
 
-    GetFreq();
     m_RoundBarMesh.iMeshSizes = 0;
 }
 
@@ -669,25 +667,6 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
     return iFacesAdded;
 }
 
-void OpenGL3DRenderer::GetFreq()
-{
-#if 0
-    LARGE_INTEGER litmpold;
-    QueryPerformanceFrequency(&litmpold);
-    m_dFreq= litmpold.QuadPart;
-#endif
-}
-
-double OpenGL3DRenderer::GetTime()
-{
-#if 0
-    LARGE_INTEGER litmpold;
-    QueryPerformanceCounter(&litmpold);
-    return litmpold.QuadPart*1000000 / m_dFreq;
-#endif
-    return 0;
-}
-
 void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 {
     glUseProgram(maResources.m_CommonProID);
@@ -1487,54 +1466,6 @@ void OpenGL3DRenderer::RenderTextShape()
     CHECK_GL_ERROR();
 }
 
-void OpenGL3DRenderer::RenderText(const ::rtl::OUString& , awt::Point )
-{
-    //TODO: moggi: disabled for now
-    /*
-    Font aFont("Arial", Size(0, 100));
-    Rectangle aRect;
-    VirtualDevice aDevice;
-    aDevice.GetTextBoundRect(aRect, string);
-    int screenWidth = (aRect.BottomRight().X() + 3) & ~3;
-    int screenHeight = (aRect.BottomRight().Y() + 3) & ~3;
-    int textHeight = OPENGL_SCALE_VALUE * m_iHeight / 20;
-    int textWidth = (float)textHeight * ((float)screenWidth / (float)screenHeight);
-    textWidth = (textWidth + 3) & ~3;
-    awt::Size aSize(textWidth, textHeight);
-    //clear text info
-    size_t listNum = m_TextInfoList.size();
-    for (size_t i = 0; i < listNum; i++)
-    {
-        TextInfo &textInfo = m_TextInfoList.front();
-        glDeleteTextures(1, &textInfo.texture);
-        m_TextInfoList.pop_front();
-    }
-    //create text texture
-    CreateTextTexture(string, aFont, 0xFF0000, aPos, aSize, 0);
-    RenderTextShape();
-    */
-}
-
-void OpenGL3DRenderer::RenderFPS(float fps)
-{
-    //use width and height to get the position
-    ::rtl::OUString stringFps = ::rtl::OUString("fps ") + ::rtl::OUString::number(fps);
-    awt::Point aPos(0,0);
-    RenderText(stringFps, aPos);
-}
-
-void OpenGL3DRenderer::RenderClickPos(Point aMPos)
-{
-    //use width and height to get the position
-    ::rtl::OUString stringPos = ::rtl::OUString("(") +
-                                ::rtl::OUString::number(aMPos.X()) +
-                                ::rtl::OUString(",") +
-                                ::rtl::OUString::number(aMPos.Y()) +
-                                ::rtl::OUString(")");
-    awt::Point aPos(aMPos.X(), aMPos.Y());
-    RenderText(stringPos, aPos);
-}
-
 void OpenGL3DRenderer::CreateSceneBoxView()
 {
     m_3DView = glm::lookAt(m_CameraInfo.cameraPos,
commit 14a443c107355e9aaa7cb65ce14afe93237d7201
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun May 25 21:30:55 2014 +0200

    avoid magic numbers
    
    Change-Id: Ib7c3bd23e119ebee91f3f76b073faf10daa87b3e

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 13de81f..d9c7e26 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -31,6 +31,9 @@ namespace opengl3D {
 
 namespace {
 
+const int CORNER_DIVION_Y = 10;
+const int CORNER_DIVION_Z = 10;
+
 int static checkGLError(const char *file, int line)
 {
     GLenum glErr;
@@ -398,7 +401,8 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
 int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, std::vector<glm::vec3> &normals, float fRadius, int iSubDivY, int iSubDivZ, float width, float height, float depth)
 {
     //float fAddAngleY = 360.0f/float(iSubDivY), fAddAngleZ = 180.0f/float(iSubDivZ);
-    float fAddAngleY = 360.0f/float(iSubDivY), fAddAngleZ = 180.0f/float(iSubDivZ);
+    float fAddAngleY = 360.0f/float(iSubDivY);
+    float fAddAngleZ = 180.0f/float(iSubDivZ);
     float fCurAngleY = 0.0f;
     int iStepsY = 1;
 
@@ -1003,7 +1007,8 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
     if (m_Extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
     {
         float radius = 0.2f;
-        CreateActualRoundedCube(radius, 10, 10, 1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1 + 2 * radius);
+        CreateActualRoundedCube(radius, CORNER_DIVION_Y, CORNER_DIVION_Z,
+                1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1 + 2 * radius);
         AddVertexData(m_CubeVertexBuf);
         AddNormalData(m_CubeNormalBuf);
         AddIndexData(m_CubeElementBuf);
commit d051a1a677fb99e07b0e1c234aef32276235c23e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun May 25 21:04:02 2014 +0200

    implement movement from one corner to the next
    
    Change-Id: I6c782f7630c9f77e3e3f28a79e26391e8c97c706

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index c95458b..6594c03 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -31,12 +31,16 @@ GL3DBarChart::GL3DBarChart(
     mrWindow(rWindow),
     mpCamera(NULL),
     mbValidContext(true),
-    mpTextCache(new opengl3D::TextCache())
+    mpTextCache(new opengl3D::TextCache()),
+    mnStep(0),
+    mnStepsTotal(0),
+    mnCornerId(0)
 {
     Size aSize = mrWindow.GetSizePixel();
     mpRenderer->SetSize(aSize);
     mrWindow.setRenderer(this);
     mpRenderer->init();
+    maTimer.SetTimeoutHdl(LINK(this, GL3DBarChart, MoveCamera));
 }
 
 GL3DBarChart::~GL3DBarChart()
@@ -48,6 +52,7 @@ GL3DBarChart::~GL3DBarChart()
 namespace {
 
 const float TEXT_HEIGHT = 15.0f;
+const sal_uLong TIMEOUT = 5;
 
 float calculateTextWidth(const OUString& rText)
 {
@@ -227,6 +232,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
         p->setPosition(aTopLeft, aTopRight, aBottomRight);
     }
 
+    mnMaxX = nMaxPointCount * (nBarSizeX + nBarDistanceX) + 40;
+    mnMaxY = nSeriesIndex * (nBarSizeY + nBarDistanceY) + 40;
+
     maCameraPosition = glm::vec3(-30, -30, 200);
     mpCamera->setPosition(maCameraPosition);
     maCameraDirection = glm::vec3(0, 0, 0);
@@ -293,12 +301,83 @@ void GL3DBarChart::clickedAt(const Point& rPos)
 void GL3DBarChart::mouseDragMove(const Point& rStartPos, const Point& rEndPos, sal_uInt16 nButtons)
 {
     SAL_WARN("chart2.opengl", "Dragging: " << rStartPos << " to : " << rEndPos << " Buttons: " << nButtons);
+    if(nButtons == MOUSE_RIGHT)
+    {
+        mnCornerId = (mnCornerId + 1) % 4;
+        moveToCorner();
+    }
+    else if(nButtons == MOUSE_LEFT)
+    {
+        mnCornerId = mnCornerId - 1;
+        if(mnCornerId < 0)
+            mnCornerId = 3;
+        moveToCorner();
+    }
+}
+
+glm::vec3 GL3DBarChart::getCornerPosition(sal_Int8 nId)
+{
+    switch(nId)
+    {
+        case 0:
+        {
+            return glm::vec3(-30, -30, 200);
+        }
+        break;
+        case 1:
+        {
+            return glm::vec3(mnMaxX, -30, 200);
+        }
+        break;
+        case 2:
+        {
+            return glm::vec3(mnMaxX, mnMaxY, 200);
+        }
+        break;
+        case 3:
+        {
+            return glm::vec3(-30, mnMaxY, 200);
+        }
+        break;
+        default:
+            assert(false);
+    }
+
+    return glm::vec3(-30, -30, 200);
+}
+
+void GL3DBarChart::moveToCorner()
+{
+    mnStepsTotal = 100;
+    maStep = (getCornerPosition(mnCornerId) - maCameraPosition) / float(mnStepsTotal);
+    maTimer.SetTimeout(TIMEOUT);
+    maTimer.Start();
+}
+
+IMPL_LINK_NOARG(GL3DBarChart, MoveCamera)
+{
+    maTimer.Stop();
+    if(mnStep < mnStepsTotal)
+    {
+        ++mnStep;
+        maCameraPosition += maStep;
+        mpCamera->setPosition(maCameraPosition);
+        render();
+        maTimer.SetTimeout(TIMEOUT);
+        maTimer.Start();
+    }
+    else
+    {
+        mnStep = 0;
+    }
+
+    return 0;
 }
 
 void GL3DBarChart::scroll(long nDelta)
 {
     glm::vec3 maDir = glm::normalize(maCameraPosition - maCameraDirection);
-    maCameraPosition += (float((nDelta/10)) * maDir);
+    maCameraPosition -= (float((nDelta/10)) * maDir);
     mpCamera->setPosition(maCameraPosition);
     render();
 }
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 7997174..0f56b64 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -18,6 +18,7 @@
 
 #include <glm/glm.hpp>
 
+#include <vcl/timer.hxx>
 #include <vcl/openglwin.hxx>
 
 namespace chart {
@@ -55,6 +56,12 @@ public:
     virtual void contextDestroyed() SAL_OVERRIDE;
 
 private:
+
+    void moveToCorner();
+    glm::vec3 getCornerPosition(sal_Int8 nCornerId);
+
+    DECL_LINK(MoveCamera, void*);
+
     css::uno::Reference<css::chart2::XChartType> mxChartType;
     boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
 
@@ -68,6 +75,18 @@ private:
 
     glm::vec3 maCameraPosition;
     glm::vec3 maCameraDirection;
+
+    Timer maTimer;
+    glm::vec3 maStep;
+    size_t mnStep;
+    size_t mnStepsTotal;
+    float mnMaxX;
+    float mnMaxY;
+    /**
+     * 0 = corner at (0,0,0);
+     * numbering counter clockwise
+     */
+    sal_Int8 mnCornerId;
 };
 
 }
commit c8d07416e3c9f56b48b2861d9b7249779098fe49
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun May 25 21:03:10 2014 +0200

    reduce the number of traingles per bar
    
    Change-Id: If24391481c916b689e8c8e90d6430bf7ca56a5e3

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 7d4db19..13de81f 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1003,7 +1003,7 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
     if (m_Extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
     {
         float radius = 0.2f;
-        CreateActualRoundedCube(radius, 30, 30, 1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1 + 2 * radius);
+        CreateActualRoundedCube(radius, 10, 10, 1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1 + 2 * radius);
         AddVertexData(m_CubeVertexBuf);
         AddNormalData(m_CubeNormalBuf);
         AddIndexData(m_CubeElementBuf);


More information about the Libreoffice-commits mailing list