[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - 7 commits - chart2/source include/vcl sc/source vcl/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sat May 24 14:50:40 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 62 ++++++++++++++++++++++---
chart2/source/view/inc/3DChartObjects.hxx | 19 ++++++-
chart2/source/view/inc/GL3DBarChart.hxx | 11 ++++
chart2/source/view/inc/GL3DRenderer.hxx | 10 ----
chart2/source/view/main/3DChartObjects.cxx | 36 +++++++++++---
chart2/source/view/main/GL3DRenderer.cxx | 42 ----------------
include/vcl/openglwin.hxx | 6 ++
sc/source/ui/view/viewdata.cxx | 8 ---
vcl/source/window/openglwin.cxx | 40 +++++++++++-----
9 files changed, 144 insertions(+), 90 deletions(-)
New commits:
commit 9c06f2ff0af9b261bab96b4737778a0fe0f7fcba
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 23:28:06 2014 +0200
some work on mouse scrolling and improved mouse dragging
Change-Id: I3265e26530183b2fc4fd7f67319f3dc124353c2e
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index c9419c2..c95458b 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -229,7 +229,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
maCameraPosition = glm::vec3(-30, -30, 200);
mpCamera->setPosition(maCameraPosition);
- mpCamera->setDirection(glm::vec3(nMaxPointCount*(nBarSizeX+ nBarDistanceX), nSeriesIndex*(nBarSizeY+nBarDistanceY), 0));
+ maCameraDirection = glm::vec3(0, 0, 0);
+ mpCamera->setDirection(maCameraDirection);
}
void GL3DBarChart::render()
@@ -289,9 +290,17 @@ void GL3DBarChart::clickedAt(const Point& rPos)
mpCamera->zoom(nId);
}
-void GL3DBarChart::mouseDragMove(const Point& rPos, sal_uInt16 nButtons)
+void GL3DBarChart::mouseDragMove(const Point& rStartPos, const Point& rEndPos, sal_uInt16 nButtons)
{
-// fprintf(stderr, "drag move %ld %ld (0x%x)\n", rPos.X(), rPos.Y(), nButtons);
+ SAL_WARN("chart2.opengl", "Dragging: " << rStartPos << " to : " << rEndPos << " Buttons: " << nButtons);
+}
+
+void GL3DBarChart::scroll(long nDelta)
+{
+ glm::vec3 maDir = glm::normalize(maCameraPosition - maCameraDirection);
+ maCameraPosition += (float((nDelta/10)) * maDir);
+ mpCamera->setPosition(maCameraPosition);
+ render();
}
void GL3DBarChart::contextDestroyed()
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index c85cff8..7997174 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -50,7 +50,8 @@ public:
virtual void update() SAL_OVERRIDE;
virtual void clickedAt(const Point& rPos) SAL_OVERRIDE;
- virtual void mouseDragMove(const Point& rPos, sal_uInt16 nButtons) SAL_OVERRIDE;
+ virtual void mouseDragMove(const Point& rStartPos, const Point& rEndPos, sal_uInt16 nButtons) SAL_OVERRIDE;
+ virtual void scroll(long nDelta) SAL_OVERRIDE;
virtual void contextDestroyed() SAL_OVERRIDE;
private:
@@ -66,6 +67,7 @@ private:
boost::scoped_ptr<opengl3D::TextCache> mpTextCache;
glm::vec3 maCameraPosition;
+ glm::vec3 maCameraDirection;
};
}
diff --git a/include/vcl/openglwin.hxx b/include/vcl/openglwin.hxx
index f69d0b3..d2e86cc 100644
--- a/include/vcl/openglwin.hxx
+++ b/include/vcl/openglwin.hxx
@@ -25,7 +25,8 @@ public:
virtual ~IRenderer() {}
virtual void update() = 0;
virtual void clickedAt(const Point& rPos) = 0;
- virtual void mouseDragMove(const Point& rPos, sal_uInt16 nButtons) = 0;
+ virtual void mouseDragMove(const Point& rPosBegin, const Point& rPosEnd, sal_uInt16 nButtons) = 0;
+ virtual void scroll(long nDelta) = 0;
virtual void contextDestroyed() = 0;
};
@@ -45,10 +46,13 @@ public:
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+ virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
private:
boost::scoped_ptr<OpenGLWindowImpl> mpImpl;
IRenderer* mpRenderer;
+
+ Point maStartPoint;
};
#endif
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index 9fd3935..455e455 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -57,24 +57,42 @@ void OpenGLWindow::Paint(const Rectangle&)
void OpenGLWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
- Point aPoint = rMEvt.GetPosPixel();
+ maStartPoint = rMEvt.GetPosPixel();
+}
- Color aColor = GetPixel(aPoint);
- SAL_WARN("vcl.opengl", aColor.GetColor());
- if(mpRenderer)
- mpRenderer->clickedAt(aPoint);
+void OpenGLWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ Point aPoint = rMEvt.GetPosPixel();
+ if(aPoint == maStartPoint)
+ {
+ Color aColor = GetPixel(aPoint);
+ SAL_WARN("vcl.opengl", aColor.GetColor());
+ if(mpRenderer)
+ mpRenderer->clickedAt(aPoint);
+ }
+ else
+ {
+ mpRenderer->mouseDragMove(maStartPoint, aPoint,
+ rMEvt.GetButtons());
+ }
}
-void OpenGLWindow::MouseButtonUp( const MouseEvent& /* rMEvt */ )
+void OpenGLWindow::Command( const CommandEvent& rCEvt )
{
- // in case we need to track button state ourselves.
+ if(rCEvt.GetCommand() == COMMAND_WHEEL)
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if(pData->GetMode() == COMMAND_WHEEL_SCROLL)
+ {
+ long nDelta = pData->GetDelta();
+ if(mpRenderer)
+ mpRenderer->scroll(nDelta);
+ }
+ }
}
-void OpenGLWindow::MouseMove( const MouseEvent& rMEvt )
+void OpenGLWindow::MouseMove( const MouseEvent& /*rMEvt*/ )
{
- if(rMEvt.GetButtons())
- mpRenderer->mouseDragMove(rMEvt.GetPosPixel(),
- rMEvt.GetButtons());
}
void OpenGLWindow::setRenderer(IRenderer* pRenderer)
commit 5395e00455016d459820c161e91effd47be16dcb
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 17:35:41 2014 +0200
much improved camera control for 3D chart
Change-Id: I5acc481db01e2ea66c11933ec05f222858ba36f9
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index e4a8f4e..c9419c2 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -54,6 +54,23 @@ float calculateTextWidth(const OUString& rText)
return rText.getLength() * 10;
}
+double findMaxValue(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer)
+{
+ double nMax = 0.0;
+ for (boost::ptr_vector<VDataSeries>::const_iterator itr = rDataSeriesContainer.begin(),
+ itrEnd = rDataSeriesContainer.end(); itr != itrEnd; ++itr)
+ {
+ const VDataSeries& rDataSeries = *itr;
+ sal_Int32 nPointCount = rDataSeries.getTotalPointCount();
+ for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
+ {
+ double nVal = rDataSeries.getYValue(nIndex);
+ nMax = std::max(nMax, nVal);
+ }
+ }
+ return nMax;
+}
+
}
void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSeriesContainer,
@@ -85,6 +102,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
mpCamera = static_cast<opengl3D::Camera*>(&maShapes.back());
sal_Int32 nSeriesIndex = 0;
+ sal_Int32 nMaxPointCount = 0;
+ double nMaxVal = findMaxValue(rDataSeriesContainer)/100;
for (boost::ptr_vector<VDataSeries>::const_iterator itr = rDataSeriesContainer.begin(),
itrEnd = rDataSeriesContainer.end(); itr != itrEnd; ++itr)
{
@@ -92,6 +111,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
const VDataSeries& rDataSeries = *itr;
sal_Int32 nPointCount = rDataSeries.getTotalPointCount();
+ nMaxPointCount = std::max(nMaxPointCount, nPointCount);
bool bMappedFillProperty = rDataSeries.hasPropertyMapping("FillColor");
@@ -126,8 +146,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
float nVal = rDataSeries.getYValue(nIndex);
float nXPos = nIndex * (nBarSizeX + nBarDistanceX) + nBarDistanceX;
-
- glm::mat4 aScaleMatrix = glm::scale(nBarSizeX, nBarSizeY, nVal);
+ glm::mat4 aScaleMatrix = glm::scale(nBarSizeX, nBarSizeY, float(nVal/nMaxVal));
glm::mat4 aTranslationMatrix = glm::translate(nXPos, nYPos, 0.0f);
glm::mat4 aBarPosition = aTranslationMatrix * aScaleMatrix;
@@ -207,6 +226,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
aBottomRight.y = -calculateTextWidth(aCats[i]) - 0.5 * nBarDistanceY;
p->setPosition(aTopLeft, aTopRight, aBottomRight);
}
+
+ maCameraPosition = glm::vec3(-30, -30, 200);
+ mpCamera->setPosition(maCameraPosition);
+ mpCamera->setDirection(glm::vec3(nMaxPointCount*(nBarSizeX+ nBarDistanceX), nSeriesIndex*(nBarSizeY+nBarDistanceY), 0));
}
void GL3DBarChart::render()
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index c92a435..1530dfc 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -115,6 +115,9 @@ public:
Camera(OpenGL3DRenderer* pRenderer);
virtual void render() SAL_OVERRIDE;
+ void setPosition(const glm::vec3& rPos);
+ void setDirection(const glm::vec3& rPos);
+
/// Zooms the camera towards the bar with Unique Id nId.
void zoom(sal_uInt32 nId);
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index d9c70bb..c85cff8 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -16,6 +16,8 @@
#include <boost/ptr_container/ptr_vector.hpp>
#include "VDataSeries.hxx"
+#include <glm/glm.hpp>
+
#include <vcl/openglwin.hxx>
namespace chart {
@@ -62,6 +64,8 @@ private:
bool mbValidContext;
boost::scoped_ptr<opengl3D::TextCache> mpTextCache;
+
+ glm::vec3 maCameraPosition;
};
}
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index ea20774..c77a273 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -186,6 +186,16 @@ void Camera::render()
mpRenderer->SetCameraInfo(maPos, maDirection, maUp);
}
+void Camera::setPosition(const glm::vec3& rPos)
+{
+ maPos = rPos;
+}
+
+void Camera::setDirection(const glm::vec3& rDir)
+{
+ maDirection = rDir;
+}
+
void Camera::zoom(sal_uInt32 /*nId*/)
{
// TODO here
commit 66045f4ff3d02bce65208b631f0028027c0a0a22
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 16:44:00 2014 +0200
add a text cache to improve rendering performance
Change-Id: I5b3fbe9476f0eafed4524f57aa7bf65dfd029c1d
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index e935e5e..e4a8f4e 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -30,7 +30,8 @@ GL3DBarChart::GL3DBarChart(
mpRenderer(new opengl3D::OpenGL3DRenderer()),
mrWindow(rWindow),
mpCamera(NULL),
- mbValidContext(true)
+ mbValidContext(true),
+ mpTextCache(new opengl3D::TextCache())
{
Size aSize = mrWindow.GetSizePixel();
mpRenderer->SetSize(aSize);
@@ -101,7 +102,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
if(!aSeriesName.isEmpty())
{
- maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
+ maShapes.push_back(new opengl3D::Text(mpRenderer.get(),
+ *mpTextCache, aSeriesName, nId++));
opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
glm::vec3 aTopLeft, aTopRight, aBottomRight;
aTopLeft.x = -nBarDistanceY;
@@ -181,7 +183,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
float nXPos = i * (nBarSizeX + nBarDistanceX);
- maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
+ maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
+ aCats[i], nId++));
opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
aTopLeft.x = nXPos + TEXT_HEIGHT;
aTopLeft.y = nYPos + calculateTextWidth(aCats[i]) + 0.5 * nBarDistanceY;
@@ -193,7 +196,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(), aCats[i], nId++));
+ maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
+ aCats[i], nId++));
p = static_cast<opengl3D::Text*>(&maShapes.back());
aTopLeft.x = nXPos + TEXT_HEIGHT;
aTopLeft.y = - 0.5 * nBarDistanceY;
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index f8138aa..c92a435 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -14,10 +14,22 @@
#include <vcl/opengl/OpenGLContext.hxx>
#include "GL3DRenderer.hxx"
+#include <boost/ptr_container/ptr_map.hpp>
+
namespace chart {
namespace opengl3D {
+class TextCache
+{
+public:
+ const BitmapEx& getText(OUString rText);
+private:
+ typedef boost::ptr_map<OUString, BitmapEx> TextCacheType;
+
+ TextCacheType maTextCache;
+};
+
class Renderable3DObject
{
public:
@@ -65,7 +77,7 @@ private:
class Text : public Renderable3DObject
{
public:
- Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId);
+ Text(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE;
Size getSize() const;
@@ -73,7 +85,7 @@ public:
void setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight);
private:
- BitmapEx maText;
+ const BitmapEx& mrText;
glm::vec3 maTopLeft;
glm::vec3 maTopRight;
glm::vec3 maBottomRight;
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 5f1bcf9..d9c70bb 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -26,6 +26,7 @@ namespace opengl3D {
class Renderable3DObject;
class OpenGL3DRenderer;
+class TextCache;
class Camera;
}
@@ -59,6 +60,8 @@ private:
opengl3D::Camera* mpCamera;
bool mbValidContext;
+
+ boost::scoped_ptr<opengl3D::TextCache> mpTextCache;
};
}
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index bf8c10b..ea20774 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -68,10 +68,12 @@ void Line::setLineColor(const Color& rColor)
maLineColor = rColor;
}
-Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId):
- Renderable3DObject(pRenderer, nId)
+const BitmapEx& TextCache::getText(OUString rText)
{
- // Convert OUString to BitmapEx.
+ TextCacheType::const_iterator itr = maTextCache.find(rText);
+ if(itr != maTextCache.end())
+ return *itr->second;
+
VirtualDevice aDevice(*Application::GetDefaultDevice(), 0, 0);
Font aFont = aDevice.GetFont();
aFont.SetSize(Size(0, 96));
@@ -79,27 +81,35 @@ Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId):
::Rectangle aRect;
aDevice.SetFont(aFont);
aDevice.Erase();
- aDevice.GetTextBoundRect(aRect, rStr);
+ aDevice.GetTextBoundRect(aRect, rText);
Size aSize = aRect.GetSize();
aSize.Width() += 5;
aSize.Height() *= 1.6;
aDevice.SetOutputSizePixel(aSize);
aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
- aDevice.DrawText(Point(0,0), rStr);
+ aDevice.DrawText(Point(0,0), rText);
- maText = BitmapEx(aDevice.GetBitmapEx(Point(0,0), aSize));
+ BitmapEx* pText = new BitmapEx(aDevice.GetBitmapEx(Point(0,0), aSize));
+ maTextCache.insert(rText, pText);
+ return *pText;
+}
+
+Text::Text(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, sal_uInt32 nId):
+ Renderable3DObject(pRenderer, nId),
+ mrText(rTextCache.getText(rStr))
+{
}
void Text::render()
{
glm::vec3 dir2 = maTopRight - maTopLeft;
glm::vec3 bottomLeft = maBottomRight - dir2;
- mpRenderer->CreateTextTexture(maText, maTopLeft, maTopRight, maBottomRight, bottomLeft, mnUniqueId);
+ mpRenderer->CreateTextTexture(mrText, maTopLeft, maTopRight, maBottomRight, bottomLeft, mnUniqueId);
}
Size Text::getSize() const
{
- return maText.GetSizePixel();
+ return mrText.GetSizePixel();
}
void Text::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight)
commit 42943ced670acf8cec3694ae8cc1fde91928e470
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 15:38:53 2014 +0200
fix chart background color
Change-Id: I4bda3201dff1094a7fd646c620b016532a4fbc77
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 1d924d6..75628da 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1532,7 +1532,7 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
{
glViewport(0, 0, m_iWidth, m_iHeight);
glClearDepth(1.0f);
- glClearColor(1.0, 0.0, 1.0, 1.0);
+ glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CreateSceneBoxView();
//Polygon
commit 2c0b1cb2994ca675d62fd5d85509e6371b7c5bbe
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 15:35:30 2014 +0200
add text on both sides of the chart
Change-Id: I12d5f5e92bf908bc6d8fbd0e88293e1fcaa31c96
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 1837736..e935e5e 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -190,6 +190,18 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
aBottomRight.x = nXPos;
aBottomRight.y = nYPos + 0.5 * nBarDistanceY;
p->setPosition(aTopLeft, aTopRight, aBottomRight);
+
+ // create shapes on other side as well
+
+ maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
+ p = static_cast<opengl3D::Text*>(&maShapes.back());
+ aTopLeft.x = nXPos + TEXT_HEIGHT;
+ aTopLeft.y = - 0.5 * nBarDistanceY;
+ aTopRight = aTopLeft;
+ aTopRight.y = -calculateTextWidth(aCats[i]) - 0.5* nBarDistanceY;
+ aBottomRight.x = nXPos;
+ aBottomRight.y = -calculateTextWidth(aCats[i]) - 0.5 * nBarDistanceY;
+ p->setPosition(aTopLeft, aTopRight, aBottomRight);
}
}
commit d62ea22e44f2b9889e628356478c2ac61516b732
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 15:24:57 2014 +0200
remove camera positioning from OpenGL code
Change-Id: I70a654282e8b187bc3d78041c44af17a11b4a622
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index c2d7b87..b5a5c68 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -143,15 +143,6 @@ struct TextInfo
float vertex[12];
};
-typedef struct SceneBox{
- float maxXCoord;
- float minXCoord;
- float maxYCoord;
- float minYCoord;
- float maxZCoord;
- float minZCoord;
-}SceneBox;
-
class OpenGL3DRenderer
{
public:
@@ -363,7 +354,6 @@ private:
float m_fHeightWeight;
bool mbPickingMode;
- SceneBox m_SenceBox;
GLuint mnPickingFbo;
GLuint mnPickingRboDepth;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6d6876b..1d924d6 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -22,8 +22,6 @@
#define DEBUG_FBO 0
-#define GL_PI 3.14159f
-
using namespace com::sun::star;
namespace chart {
@@ -87,12 +85,6 @@ OpenGL3DRenderer::OpenGL3DRenderer():
GetFreq();
m_RoundBarMesh.iMeshSizes = 0;
- m_SenceBox.maxXCoord = -1.0 * FLT_MAX;
- m_SenceBox.minXCoord = FLT_MAX;
- m_SenceBox.maxYCoord = -1.0 * FLT_MAX;
- m_SenceBox.minYCoord = FLT_MAX;
- m_SenceBox.maxZCoord = -1.0 * FLT_MAX;
- m_SenceBox.minZCoord = FLT_MAX;
}
OpenGL3DRenderer::~OpenGL3DRenderer()
@@ -970,12 +962,6 @@ void OpenGL3DRenderer::AddPolygon3DObjectPoint(float x, float y, float z)
float actualY = y;
float actualZ = z;
m_Polygon3DInfo.vertices->push_back(glm::vec3(actualX, actualY, actualZ));
- m_SenceBox.maxXCoord = std::max(m_SenceBox.maxXCoord, actualX);
- m_SenceBox.minXCoord = std::min(m_SenceBox.minXCoord, actualX);
- m_SenceBox.maxYCoord = std::max(m_SenceBox.maxYCoord, actualY);
- m_SenceBox.minYCoord = std::min(m_SenceBox.minYCoord, actualY);
- m_SenceBox.maxZCoord = std::max(m_SenceBox.maxZCoord, actualZ);
- m_SenceBox.minZCoord = std::min(m_SenceBox.minZCoord, actualZ);
}
void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
@@ -1029,12 +1015,6 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
m_Normals.clear();
m_Indeices.clear();
}
- m_SenceBox.maxXCoord = std::max(m_SenceBox.maxXCoord, m_Extrude3DInfo.xTransform + m_Extrude3DInfo.xScale);
- m_SenceBox.minXCoord = std::min(m_SenceBox.minXCoord, m_Extrude3DInfo.xTransform);
- m_SenceBox.maxYCoord = std::max(m_SenceBox.maxYCoord, m_Extrude3DInfo.yTransform + m_Extrude3DInfo.yScale);
- m_SenceBox.minYCoord = std::min(m_SenceBox.minYCoord, m_Extrude3DInfo.yTransform );
- m_SenceBox.maxZCoord = std::max(m_SenceBox.maxZCoord, m_Extrude3DInfo.zTransform + m_Extrude3DInfo.zScale);
- m_SenceBox.minZCoord = std::min(m_SenceBox.minZCoord, m_Extrude3DInfo.zTransform);
}
void OpenGL3DRenderer::EndAddShape3DExtrudeObject()
@@ -1543,38 +1523,16 @@ void OpenGL3DRenderer::RenderClickPos(Point aMPos)
void OpenGL3DRenderer::CreateSceneBoxView()
{
-//original code start
m_3DView = glm::lookAt(m_CameraInfo.cameraPos,
m_CameraInfo.cameraOrg,
m_CameraInfo.cameraUp);
-//original code end
- float senceBoxWidth = m_SenceBox.maxXCoord - m_SenceBox.minXCoord;
- float senceBoxHeight = m_SenceBox.maxZCoord - m_SenceBox.minZCoord;
- float senceBoxDepth = m_SenceBox.maxYCoord - m_SenceBox.minYCoord;
- float distanceY = m_SenceBox.maxYCoord + senceBoxWidth / 2 / tan(m_fViewAngle / 2 * GL_PI / 180.0f);
- float veriticalAngle = atan((float)m_iHeight / (float)m_iWidth);
- float distance = distanceY / cos(veriticalAngle);
- float horizontalAngle = 0;
- m_fHeightWeight = senceBoxWidth * (float)m_iHeight / (float)m_iWidth / senceBoxHeight;
- 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.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);
- m_CameraInfo.cameraPos.z = m_CameraInfo.cameraOrg.z + distance * sin(veriticalAngle);
- m_3DView = glm::lookAt(m_CameraInfo.cameraPos,
- m_CameraInfo.cameraOrg,
- m_CameraInfo.cameraUp
- );
}
void OpenGL3DRenderer::ProcessUnrenderedShape()
{
glViewport(0, 0, m_iWidth, m_iHeight);
glClearDepth(1.0f);
- glClearColor(1.0, 1.0, 1.0, 1.0);
+ glClearColor(1.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CreateSceneBoxView();
//Polygon
commit eb1785ab708c61d006c02a77d784590ac8ddc1da
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sat May 24 12:24:49 2014 +0200
remove whitespace
Change-Id: Ia8b664f09da0008bde48e55a144e63965dd00609
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 90f1377..d77d8cd 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -17,11 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
#include "scitems.hxx"
#include <editeng/eeitem.hxx>
-
#include <sfx2/viewfrm.hxx>
#include <editeng/adjustitem.hxx>
#include <svx/algitem.hxx>
@@ -442,7 +440,6 @@ void ScViewData::InitData( ScDocument* pDocument )
*pOptions = pDoc->GetViewOptions();
}
-
ScDocument* ScViewData::GetDocument() const
{
if (pDoc)
@@ -1611,10 +1608,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
return Point( nScrPosX, nScrPosY );
}
-
// Number of cells on a screen
-
-
SCCOL ScViewData::CellsAtX( SCsCOL nPosX, SCsCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeX ) const
{
OSL_ENSURE( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
@@ -1715,7 +1709,6 @@ SCROW ScViewData::PrevCellsY( ScVSplitPos eWhichY ) const
return CellsAtY( GetPosY( eWhichY ), -1, eWhichY, SC_SIZE_NONE );
}
-
bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& rSizeYPix ) const
{
const ScMergeAttr* pMerge = (const ScMergeAttr*) pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE );
@@ -3090,7 +3083,6 @@ void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY,
rPosY = nRow;
}
-
void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels,
SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
SCTAB nTabNo )
More information about the Libreoffice-commits
mailing list