[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - 3 commits - chart2/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Tue May 27 17:13:30 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 26 +++++++++++++++----------
chart2/source/view/main/GL3DRenderer.cxx | 9 ++++++--
2 files changed, 23 insertions(+), 12 deletions(-)
New commits:
commit 681ea792d0de9b9bfb5d48faa1309bd5795b775f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed May 28 01:18:10 2014 +0200
enable picking again
Right now with an ugly work-around. The image is vertically flipped so
we just adapt our access to it.
Change-Id: I0128f54d4a0fbe697dc8726f6e255111ecb8412f
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 701b452..c9ade73 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -316,7 +316,7 @@ public:
}
-void GL3DBarChart::clickedAt(const Point& /*rPos*/, sal_uInt16 nButtons)
+void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
{
if(mbBlockUserInput)
return;
@@ -325,13 +325,11 @@ void GL3DBarChart::clickedAt(const Point& /*rPos*/, sal_uInt16 nButtons)
return;
sal_uInt32 nId = 5;
- /*
{
PickingModeSetter aPickingModeSetter(mpRenderer.get());
render();
nId = mpRenderer->GetPixelColorFromPoint(rPos.X(), rPos.Y());
}
- */
std::map<sal_uInt32, const BarInformation>::const_iterator itr =
maBarMap.find(nId);
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 9a97118..07c3f4d 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1670,9 +1670,12 @@ void OpenGL3DRenderer::SetPickingMode(bool bPickingMode)
sal_uInt32 OpenGL3DRenderer::GetPixelColorFromPoint(long nX, long nY)
{
+ static sal_uInt32 nId = 0;
+ OUString aFileName = OUString("/home/moggi/work/picking_") + OUString::number(nId++) + ".png";
+ OpenGLHelper::renderToFile(m_iWidth, m_iHeight, aFileName);
boost::scoped_array<sal_uInt8> buf(new sal_uInt8[4]);
- glReadPixels(nX, nY, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, buf.get());
- Color aColor(buf[3], buf[2], buf[1], buf[0]);
+ glReadPixels(nX, m_iHeight-nY, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, buf.get());
+ Color aColor(255-buf[3], buf[2], buf[1], buf[0]);
return aColor.GetColor();
}
commit 8a1d530555658acd92701f713888021e201a655f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed May 28 01:16:57 2014 +0200
use a step width of 10 for the picking color
Change-Id: Icdf7653e9dc5a33d78381b9ea5f3fd4652b1be5a
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 2e24f06..701b452 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -64,6 +64,7 @@ const float TEXT_HEIGHT = 15.0f;
const float DEFAULT_CAMERA_HEIGHT = 500.0f;
const size_t STEPS = 100;
const sal_uLong TIMEOUT = 5;
+const sal_uInt32 ID_STEP = 10;
float calculateTextWidth(const OUString& rText)
{
@@ -145,7 +146,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
if(!aSeriesName.isEmpty())
{
maShapes.push_back(new opengl3D::Text(mpRenderer.get(),
- *mpTextCache, aSeriesName, nId++));
+ *mpTextCache, aSeriesName, nId));
+ nId += ID_STEP;
opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
glm::vec3 aTopLeft, aTopRight, aBottomRight;
aTopRight.x = -nBarDistanceY;
@@ -176,7 +178,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
BarInformation(glm::vec3(nXPos, nYPos, float(nVal/nMaxVal)),
nVal, nIndex, nSeriesIndex)));
- maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId++));
+ maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId));
+ nId += ID_STEP;
}
float nThisXEnd = nPointCount * (nBarSizeX + nBarDistanceX);
@@ -189,7 +192,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
nYPos += nBarSizeY + nBarDistanceY;
// X axis
- maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId++));
+ maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId));
+ nId += ID_STEP;
opengl3D::Line* pAxis = static_cast<opengl3D::Line*>(&maShapes.back());
glm::vec3 aBegin;
aBegin.y = nYPos;
@@ -199,7 +203,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
pAxis->setLineColor(COL_BLUE);
// Y axis
- maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId++));
+ maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId));
+ nId += ID_STEP;
pAxis = static_cast<opengl3D::Line*>(&maShapes.back());
aBegin.x = aBegin.y = 0;
aEnd = aBegin;
@@ -208,7 +213,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
pAxis->setLineColor(COL_BLUE);
// Chart background.
- maShapes.push_back(new opengl3D::Rectangle(mpRenderer.get(), nId++));
+ maShapes.push_back(new opengl3D::Rectangle(mpRenderer.get(), nId));
+ nId += ID_STEP;
opengl3D::Rectangle* pRect = static_cast<opengl3D::Rectangle*>(&maShapes.back());
glm::vec3 aTopLeft;
glm::vec3 aTopRight = aTopLeft;
@@ -230,7 +236,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
float nXPos = i * (nBarSizeX + nBarDistanceX);
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
- aCats[i], nId++));
+ aCats[i], nId));
+ nId += ID_STEP;
opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
aTopLeft.x = nXPos + TEXT_HEIGHT;
aTopLeft.y = nYPos + calculateTextWidth(aCats[i]) + 0.5 * nBarDistanceY;
@@ -243,7 +250,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
// create shapes on other side as well
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
- aCats[i], nId++));
+ aCats[i], nId));
+ nId += ID_STEP;
p = static_cast<opengl3D::Text*>(&maShapes.back());
aTopLeft.x = nXPos + TEXT_HEIGHT;
aTopLeft.y = - 0.5 * nBarDistanceY;
commit cd847aa081d60604fd76b7ccbe328c4178b1626d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed May 28 01:00:09 2014 +0200
disable MSAA for the picking
MSAA can and will result in mixed colors which is a problem if we use
the color for the selection.
Change-Id: Ifbd6d37902069b26e714d2e3e5576fb767f9fbbf
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index bfb7382..9a97118 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1659,10 +1659,12 @@ void OpenGL3DRenderer::SetPickingMode(bool bPickingMode)
if(mbPickingMode)
{
glBindFramebuffer(GL_FRAMEBUFFER, mnPickingFbo);
+ glDisable(GL_MULTISAMPLE);
}
else
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glEnable(GL_MULTISAMPLE);
}
}
More information about the Libreoffice-commits
mailing list