[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - 11 commits - chart2/source include/vcl vcl/source
weigao
weigao at multicorewareinc.com
Sat May 24 01:54:21 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 37 ++++++++++++++-----------
chart2/source/view/main/3DChartObjects.cxx | 7 +++-
chart2/source/view/main/GL3DRenderer.cxx | 31 ++++++++------------
include/vcl/opengl/OpenGLHelper.hxx | 1
vcl/source/opengl/OpenGLHelper.cxx | 6 ++++
5 files changed, 47 insertions(+), 35 deletions(-)
New commits:
commit 0b363b9e38adfe92ad905a298b1a5420783e0126
Author: weigao <weigao at multicorewareinc.com>
Date: Sat May 24 11:45:02 2014 +0800
modify the camera position to show the whole scene
Change-Id: I0d197295046a478d59f4260f2931fbaec9a17a33
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index c61785d..6d6876b 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1559,7 +1559,7 @@ void OpenGL3DRenderer::CreateSceneBoxView()
m_SenceBox.maxZCoord *= m_fHeightWeight;
m_SenceBox.minZCoord *= m_fHeightWeight;
m_CameraInfo.cameraOrg = glm::vec3(m_SenceBox.minXCoord + senceBoxWidth / 2,
- m_SenceBox.minYCoord + senceBoxDepth * 2,
+ m_SenceBox.minYCoord + senceBoxDepth / 2,
m_SenceBox.minZCoord + senceBoxHeight * m_fHeightWeight/ 2); //update the camera position and org
m_CameraInfo.cameraPos.x = m_CameraInfo.cameraOrg.x + distance * cos(veriticalAngle) * sin(horizontalAngle);
m_CameraInfo.cameraPos.y = m_CameraInfo.cameraOrg.y + distance * cos(veriticalAngle) * cos(horizontalAngle);
commit a207e3c174eb9eee3a68909f07c9822a28a19a01
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 10:41:00 2014 +0200
the destructor alreadz clears the vector
Change-Id: I085e3463251a7d73be9724ae56bd6aa3fcf50a34
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6b3a3a4..c61785d 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -733,7 +733,6 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
glDisableVertexAttribArray(maResources.m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- pointList->clear();
delete pointList;
polygon.verticesList.pop_front();
}
@@ -827,8 +826,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glDisableVertexAttribArray(maResources.m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- pointList->clear();
- normalList->clear();
delete pointList;
delete normalList;
polygon.verticesList.pop_front();
commit 17ef5743d3974894fb1ea2f277393a6ac0152b27
Author: weigao <weigao at multicorewareinc.com>
Date: Fri May 23 05:07:38 2014 -0700
fix the calling of polygon API
Change-Id: I14d7e8594dae86830ca05aeb28633feac0a258cc
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index aa77743..bf8c10b 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -53,6 +53,7 @@ void Line::render()
mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0, mnUniqueId);
mpRenderer->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
mpRenderer->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
+ mpRenderer->EndAddPolygon3DObjectPoint();
mpRenderer->EndAddShapePolygon3DObject();
}
@@ -131,6 +132,7 @@ void Rectangle::render()
mpRenderer->AddPolygon3DObjectNormalPoint(normal.x, normal.y, normal.z);
mpRenderer->EndAddPolygon3DObjectPoint();
mpRenderer->EndAddPolygon3DObjectNormalPoint();
+ mpRenderer->EndAddShapePolygon3DObject();
//we should render the edge if the edge color is different from the fill color
if (maColor.GetColor() != maLineColor.GetColor())
{
@@ -140,8 +142,8 @@ void Rectangle::render()
mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z);
mpRenderer->AddPolygon3DObjectPoint(bottomLeft.x, bottomLeft.y, bottomLeft.z);
mpRenderer->EndAddPolygon3DObjectPoint();
+ mpRenderer->EndAddShapePolygon3DObject();
}
- mpRenderer->EndAddShapePolygon3DObject();
}
void Rectangle::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight)
commit e86abf0f00fee0f508cf35de9582de078e0e056e
Author: weigao <weigao at multicorewareinc.com>
Date: Fri May 23 05:03:37 2014 -0700
fix the polygon normal
Change-Id: I89f27b409cf04f98f90bdc61396a8c58ec91d7f7
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index bbeae20..6b3a3a4 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -951,7 +951,7 @@ void OpenGL3DRenderer::AddPolygon3DObjectNormalPoint(float x, float y, float z)
{
m_Polygon3DInfo.normals = new Normals3D;
}
- m_Polygon3DInfo.normals->push_back(glm::vec3(x, -y, z));
+ m_Polygon3DInfo.normals->push_back(glm::vec3(x, y, z));
}
}
commit 9db19b219f0f51f4a62117ba9e274b886b969062
Author: weigao <weigao at multicorewareinc.com>
Date: Fri May 23 09:12:46 2014 -0700
fix polygon render
Change-Id: Id808ce630f6b3a15a31fdcfac99b332ed5f7f29f
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index e9de1a2..bbeae20 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -40,12 +40,10 @@ int static checkGLError(const char *file, int line)
while (glErr != GL_NO_ERROR)
{
const char* sError = OpenGLHelper::GLErrorString(glErr);
-
if (sError)
SAL_WARN("chart2.opengl", "GL Error #" << glErr << "(" << sError << ") " << " in File " << file << " at line: " << line);
else
SAL_WARN("chart2.opengl", "GL Error #" << glErr << " (no message available)" << " in File " << file << " at line: " << line);
-
retCode = -1;
return retCode;
}
@@ -110,6 +108,7 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
glDeleteBuffers(1, &m_RenderVertexBuf);
glDeleteBuffers(1, &m_3DUBOBuffer);
glDeleteBuffers(1, &m_VertexBuffer);
+ glDeleteBuffers(1, &m_NormalBuffer);
glDeleteFramebuffers(1, &mnPickingFbo);
glDeleteRenderbuffers(1, &mnPickingRboDepth);
@@ -222,6 +221,7 @@ void OpenGL3DRenderer::init()
glGenBuffers(1, &m_CubeNormalBuf);
glGenBuffers(1, &m_CubeElementBuf);
glGenBuffers(1, &m_VertexBuffer);
+ glGenBuffers(1, &m_NormalBuffer);
glGenBuffers(1, &m_BoundBox);
glBindBuffer(GL_ARRAY_BUFFER, m_BoundBox);
glBufferData(GL_ARRAY_BUFFER, sizeof(boundBox), boundBox, GL_STATIC_DRAW);
@@ -733,6 +733,7 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
glDisableVertexAttribArray(maResources.m_2DVertexID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
+ pointList->clear();
delete pointList;
polygon.verticesList.pop_front();
}
@@ -754,7 +755,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glBufferSubData(GL_UNIFORM_BUFFER, m_3DActualSizeLight, sizeof(MaterialParameters), &polygon.material);
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
-
if(mbPickingMode)
{
glUseProgram(maPickingResources.m_CommonProID);
@@ -765,7 +765,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glUniformMatrix4fv(maResources.m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
glUniformMatrix4fv(maResources.m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
}
-
for (size_t i = 0; i < verticesNum; i++)
{
//move the circle to the pos, and scale using the xScale and Y scale
@@ -782,6 +781,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
//fill vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glBufferData(GL_ARRAY_BUFFER, pointList->size() * sizeof(glm::vec3), &pointList[0][0], GL_STATIC_DRAW);
+ CHECK_GL_ERROR();
if(!mbPickingMode)
{
@@ -797,9 +797,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
glUniform4fv(maResources.m_2DColorID, 1, &polygon.id[0]);
}
-
GLint maVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
-
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(maVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
@@ -810,7 +808,6 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
0, // stride
(void*)0 // array buffer offset
);
-
if(!mbPickingMode)
{
// 2nd attribute buffer : normals
@@ -824,14 +821,14 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
(void*)0 // array buffer offset
);
}
-
glDrawArrays(GL_POLYGON, 0, pointList->size());
-
glDisableVertexAttribArray(maVertexID);
if(!mbPickingMode)
glDisableVertexAttribArray(maResources.m_3DNormalID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
+ pointList->clear();
+ normalList->clear();
delete pointList;
delete normalList;
polygon.verticesList.pop_front();
@@ -1374,6 +1371,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
RenderExtrudeSurface(extrude3DInfo);
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
else
{
commit 0463ebc7258d74c5f385e9fcadda02a4453a8f86
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 10:35:07 2014 +0200
adapt code to the text mapping fix
Change-Id: I8fd22529a0749f9bf1bff75534dca61f2f65312b
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 02161bc..efd27af 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -104,8 +104,9 @@ 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());
glm::vec3 aTopLeft, aTopRight, aBottomRight;
- aTopLeft.x = calculateTextWidth(aSeriesName) * -1.0;
+ aTopLeft.x = 0.0f;
aTopLeft.y = nYPos;
+ aTopRight.x = calculateTextWidth(aSeriesName) * -1.0;
aTopRight.y = nYPos;
aBottomRight = aTopRight;
aBottomRight.y += TEXT_HEIGHT;
@@ -182,12 +183,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());
- aTopLeft.x = nXPos;
- aTopLeft.y = nYPos;
+ aTopLeft.x = nXPos + TEXT_HEIGHT;
+ aTopLeft.y = nYPos + calculateTextWidth(aCats[i]);
aTopRight = aTopLeft;
- aTopRight.x += calculateTextWidth(aCats[i]);
- aBottomRight = aTopRight;
- aBottomRight.y += TEXT_HEIGHT;
+ aTopRight.y = nYPos;
+ aBottomRight.x = nXPos;
+ aBottomRight.y = nYPos;
p->setPosition(aTopLeft, aTopRight, aBottomRight);
}
}
commit 5d300a6a403b78fa165bdeb0f978e9890398f881
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 10:34:34 2014 +0200
map strings correctly to 3d objects
Change-Id: I21b62a869b89c23ddba75eb8c33c30a73160098b
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 19b8c6f..e9de1a2 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1397,21 +1397,21 @@ void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vT
TextInfo aTextInfo;
aTextInfo.id = getColorAsVector(nUniqueId);
- aTextInfo.vertex[0] = vBottomRight.x;
- aTextInfo.vertex[1] = vBottomRight.y;
- aTextInfo.vertex[2] = vBottomRight.z * m_fHeightWeight;
+ aTextInfo.vertex[0] = vTopLeft.x;
+ aTextInfo.vertex[1] = vTopLeft.y;
+ aTextInfo.vertex[2] = vTopLeft.z * m_fHeightWeight;
aTextInfo.vertex[3] = vTopRight.x;
aTextInfo.vertex[4] = vTopRight.y;
- aTextInfo.vertex[5] = aTextInfo.vertex[2] + (vTopRight.z - vBottomRight.z);
+ aTextInfo.vertex[5] = vTopRight.z * m_fHeightWeight;
aTextInfo.vertex[9] = vBottomLeft.x;
aTextInfo.vertex[10] = vBottomLeft.y;
aTextInfo.vertex[11] = vBottomLeft.z * m_fHeightWeight;
- aTextInfo.vertex[6] = vTopLeft.x;
- aTextInfo.vertex[7] = vTopLeft.y;
- aTextInfo.vertex[8] = aTextInfo.vertex[11] + (vTopLeft.z - vBottomLeft.z);
+ aTextInfo.vertex[6] = vBottomRight.x;
+ aTextInfo.vertex[7] = vBottomRight.y;
+ aTextInfo.vertex[8] = vBottomRight.z * m_fHeightWeight;
CHECK_GL_ERROR();
glGenTextures(1, &aTextInfo.texture);
commit 6d011e8e64e6fec853aed1c969e2420e7402ef00
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 22:31:25 2014 +0200
GetTexBoundRect does not really return teh bounding rectangle
Change-Id: I66c996dadab51debc39a50c5e93e8c6a76842ceb
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index d9c0724..aa77743 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -80,7 +80,8 @@ Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId):
aDevice.Erase();
aDevice.GetTextBoundRect(aRect, rStr);
Size aSize = aRect.GetSize();
- aSize.Height() *= 2;
+ aSize.Width() += 5;
+ aSize.Height() *= 1.6;
aDevice.SetOutputSizePixel(aSize);
aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
aDevice.DrawText(Point(0,0), rStr);
commit decaa84f2e04bb920b16ab75a6bef914373d69b7
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 22:30:24 2014 +0200
add ostream operator<< for glm::vec3
Change-Id: Ic3ce4a647936f3f1c62c2dc3cf37f687d8fbccc1
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 475bd72..9cc485b 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -40,6 +40,7 @@ public:
VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix);
VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos);
+VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::vec3& rPos);
#endif
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index bace47b..a2d9b83 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -253,6 +253,12 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::vec4& rPos)
return rStrm;
}
+std::ostream& operator<<(std::ostream& rStrm, const glm::vec3& rPos)
+{
+ rStrm << "( " << rPos[0] << ", " << rPos[1] << ", " << rPos[2] << ")";
+ return rStrm;
+}
+
std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
{
for(int i = 0; i < 4; ++i)
commit 0d0ec30d21c2f171bd1cc859a6837bed4285d84e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 22:29:50 2014 +0200
improve text rendering
Change-Id: Idf2b0129f9d72739e934c65ccf40acf0b3000a5a
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index cbec5c3..02161bc 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -50,7 +50,7 @@ const float TEXT_HEIGHT = 15.0f;
float calculateTextWidth(const OUString& rText)
{
- return rText.getLength() * 7.5;
+ return rText.getLength() * 10;
}
}
commit a13e284689aee42700c3659b47e1260394ba1512
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 20:51:30 2014 +0200
avoid the creation of empty text
Change-Id: If1be3f50ed4ceac40b513b341f411fc2d2533f7f
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 5b0c764..cbec5c3 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -99,15 +99,18 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
DataSeriesHelper::getDataSeriesLabel(
rDataSeries.getModel(), mxChartType->getRoleOfSequenceForSeriesLabel());
- maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
- opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
- glm::vec3 aTopLeft, aTopRight, aBottomRight;
- aTopLeft.x = calculateTextWidth(aSeriesName) * -1.0;
- aTopLeft.y = nYPos;
- aTopRight.y = nYPos;
- aBottomRight = aTopRight;
- aBottomRight.y += TEXT_HEIGHT;
- p->setPosition(aTopLeft, aTopRight, aBottomRight);
+ if(!aSeriesName.isEmpty())
+ {
+ maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
+ opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
+ glm::vec3 aTopLeft, aTopRight, aBottomRight;
+ aTopLeft.x = calculateTextWidth(aSeriesName) * -1.0;
+ aTopLeft.y = nYPos;
+ aTopRight.y = nYPos;
+ aBottomRight = aTopRight;
+ aBottomRight.y += TEXT_HEIGHT;
+ p->setPosition(aTopLeft, aTopRight, aBottomRight);
+ }
sal_Int32 nColor = aSeriesColor[nSeriesIndex % SAL_N_ELEMENTS(aSeriesColor)].GetColor();
for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
@@ -172,6 +175,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
uno::Sequence<OUString> aCats = rCatProvider.getSimpleCategories();
for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
{
+ if(aCats[i].isEmpty())
+ continue;
+
float nXPos = i * (nBarSizeX + nBarDistanceX);
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
More information about the Libreoffice-commits
mailing list