[Libreoffice-commits] core.git: 4 commits - chart2/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Tue May 27 17:14:24 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 48 +++++++++++++++++++------
chart2/source/view/main/GL3DRenderer.cxx | 9 +++-
2 files changed, 45 insertions(+), 12 deletions(-)
New commits:
commit f9f8d930a17eb14365f914425c35df5a78f648ca
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 7d887f3..1bb558e 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 d0104ed..d869e16 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1662,9 +1662,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 16642b7febf95f43662e6ac5edaba51cb0937c16
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed May 28 01:18:18 2014 +0200
Revert "loplugin:unreffun"
This reverts commit 7686f93f58ae3eed7ed2ee2bead362d034e24c02.
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index cb92618..7d887f3 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -294,6 +294,28 @@ void GL3DBarChart::update()
render();
}
+namespace {
+
+class PickingModeSetter
+{
+private:
+ opengl3D::OpenGL3DRenderer* mpRenderer;
+
+public:
+ PickingModeSetter(opengl3D::OpenGL3DRenderer* pRenderer):
+ mpRenderer(pRenderer)
+ {
+ mpRenderer->SetPickingMode(true);
+ }
+
+ ~PickingModeSetter()
+ {
+ mpRenderer->SetPickingMode(false);
+ }
+};
+
+}
+
void GL3DBarChart::clickedAt(const Point& /*rPos*/, sal_uInt16 nButtons)
{
if(mbBlockUserInput)
commit 05ff9157791b95ed06e3e2f2c0698937dfdd731e
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 8e1a307..cb92618 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 5419a2a8633c0f195a99cdc422e3e6c29bd8911f
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 d1d4331..d0104ed 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1651,10 +1651,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