chart2/source/view/inc/AbstractShapeFactory.hxx | 2 chart2/source/view/inc/OpenglShapeFactory.hxx | 2 chart2/source/view/inc/ShapeFactory.hxx | 2 chart2/source/view/main/ChartView.cxx | 2 chart2/source/view/main/DummyXShape.cxx | 4 - chart2/source/view/main/DummyXShape.hxx | 2 chart2/source/view/main/OpenGLRender.cxx | 91 ++++++++++------------- chart2/source/view/main/OpenGLRender.hxx | 2 chart2/source/view/main/OpenglShapeFactory.cxx | 4 - framework/source/layoutmanager/layoutmanager.cxx | 6 - 10 files changed, 52 insertions(+), 65 deletions(-)
New commits: commit 8419d672198a1af988269f71988416ec46e3f39c Author: Zolnai Tamás <tamas.zol...@collabora.com> Date: Sun Sep 21 11:18:47 2014 +0200 OPENGL_SCALE_VALUE is not needed any more It seems to me that this value was a workaround to make chart fit to the OpenGL window (working in calc, in default view). Now it's uselss since projection matrix do this job better. Change-Id: I968d6d96cb45c2444b8ebed59830b87f0cb87b61 diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index 9c4ec11..ac193c6 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -1158,8 +1158,8 @@ void SAL_CALL DummyChart::setSize( const awt::Size& aSize ) throw( beans::PropertyVetoException, uno::RuntimeException, std::exception ) { SAL_INFO("chart2.opengl", "DummyChart::setSize()---aSize.Width = " << aSize.Width << ", aSize.Height = " << aSize.Height); - int width = aSize.Width / OPENGL_SCALE_VALUE; - int height = aSize.Height / OPENGL_SCALE_VALUE; + int width = aSize.Width; + int height = aSize.Height; DummyXShape::setSize(awt::Size(0,0)); m_GLRender.SetSize(width, height); SAL_INFO("chart2.opengl", "DummyChart::GLRender.Width = " << width << ", GLRender.Height = " << height); diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 64c94cb..b12dba5 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -177,10 +177,8 @@ int OpenGLRender::SetLine2DShapePoint(float x, float y, int listLength) { m_Line2DPointList.reserve(listLength*3); } - float actualX = (x / OPENGL_SCALE_VALUE); - float actualY = (y / OPENGL_SCALE_VALUE); - m_Line2DPointList.push_back(actualX); - m_Line2DPointList.push_back(actualY); + m_Line2DPointList.push_back(x); + m_Line2DPointList.push_back(y); m_Line2DPointList.push_back(m_fZStep); if (m_Line2DPointList.size() == size_t(listLength * 3)) @@ -368,7 +366,7 @@ void OpenGLRender::SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uIn void OpenGLRender::SetLine2DWidth(int width) { - m_fLineWidth = std::max((float)width / OPENGL_SCALE_VALUE, 0.001f); + m_fLineWidth = std::max((float)width, 0.001f); } void OpenGLRender::SetColor(sal_uInt32 color, sal_uInt8 nAlpha) @@ -406,13 +404,11 @@ int OpenGLRender::Bubble2DShapePoint(float x, float y, float directionX, float d Create2DCircle(100); } - float actualX = (x / OPENGL_SCALE_VALUE); - float actualY = (y / OPENGL_SCALE_VALUE); Bubble2DPointList aBubble2DPointList; - aBubble2DPointList.xScale = directionX / OPENGL_SCALE_VALUE; - aBubble2DPointList.yScale = directionY / OPENGL_SCALE_VALUE; - aBubble2DPointList.x = actualX + aBubble2DPointList.xScale / 2; - aBubble2DPointList.y = actualY + aBubble2DPointList.yScale / 2; + aBubble2DPointList.xScale = directionX; + aBubble2DPointList.yScale = directionY; + aBubble2DPointList.x = x + aBubble2DPointList.xScale / 2; + aBubble2DPointList.y = y + aBubble2DPointList.yScale / 2; m_Bubble2DShapePointList.push_back(aBubble2DPointList); return 0; @@ -499,24 +495,19 @@ int OpenGLRender::RenderBubble2FBO(int) int OpenGLRender::RectangleShapePoint(float x, float y, float directionX, float directionY) { - //check whether to create the circle data - float actualX = x / OPENGL_SCALE_VALUE; - float actualY = y / OPENGL_SCALE_VALUE; - float actualSizeX = directionX / OPENGL_SCALE_VALUE; - float actualSizeY = directionY / OPENGL_SCALE_VALUE; RectanglePointList aRectangle; - aRectangle.points[0] = actualX; - aRectangle.points[1] = actualY; + aRectangle.points[0] = x; + aRectangle.points[1] = y; aRectangle.points[2] = m_fZStep; - aRectangle.points[3] = actualX + actualSizeX; - aRectangle.points[4] = actualY; + aRectangle.points[3] = x + directionX; + aRectangle.points[4] = y; aRectangle.points[5] = m_fZStep; - aRectangle.points[6] = actualX + actualSizeX; - aRectangle.points[7] = actualY + actualSizeY; + aRectangle.points[6] = x + directionX; + aRectangle.points[7] = y + directionY; aRectangle.points[8] = m_fZStep; - aRectangle.points[9] = actualX; - aRectangle.points[10] = actualY + actualSizeY; + aRectangle.points[9] = x; + aRectangle.points[10] = y + directionY; aRectangle.points[11] = m_fZStep; m_RectangleShapePointList.push_back(aRectangle); @@ -696,23 +687,23 @@ int OpenGLRender::CreateTextTexture(const boost::shared_array<sal_uInt8> &rPixel TextInfo aTextInfo; aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI; - aTextInfo.vertex[0] = -aSize.Width / 2 / OPENGL_SCALE_VALUE; - aTextInfo.vertex[1] = -aSize.Height / 2 / OPENGL_SCALE_VALUE; + aTextInfo.vertex[0] = -aSize.Width / 2; + aTextInfo.vertex[1] = -aSize.Height / 2; aTextInfo.vertex[2] = m_fZStep; - aTextInfo.vertex[3] = aSize.Width / 2 / OPENGL_SCALE_VALUE ; - aTextInfo.vertex[4] = -aSize.Height / 2 / OPENGL_SCALE_VALUE; + aTextInfo.vertex[3] = aSize.Width / 2; + aTextInfo.vertex[4] = -aSize.Height / 2; aTextInfo.vertex[5] = m_fZStep; - aTextInfo.vertex[6] = aSize.Width / 2 / OPENGL_SCALE_VALUE; - aTextInfo.vertex[7] = aSize.Height / 2 / OPENGL_SCALE_VALUE; + aTextInfo.vertex[6] = aSize.Width / 2; + aTextInfo.vertex[7] = aSize.Height / 2; aTextInfo.vertex[8] = m_fZStep; - aTextInfo.vertex[9] = -aSize.Width / 2 / OPENGL_SCALE_VALUE; - aTextInfo.vertex[10] = aSize.Height / 2 / OPENGL_SCALE_VALUE; + aTextInfo.vertex[9] = -aSize.Width / 2; + aTextInfo.vertex[10] = aSize.Height / 2; aTextInfo.vertex[11] = m_fZStep; - aTextInfo.nDx = (rTrans.Line1.Column3 + aSize.Width / 2 ) / OPENGL_SCALE_VALUE - bmpWidth/2; - aTextInfo.nDy = (rTrans.Line2.Column3 + aSize.Height / 2 ) / OPENGL_SCALE_VALUE - bmpHeight/2; + aTextInfo.nDx = (rTrans.Line1.Column3 + aSize.Width / 2 ) - bmpWidth/2; + aTextInfo.nDy = (rTrans.Line2.Column3 + aSize.Height / 2 ) - bmpHeight/2; CHECK_GL_ERROR(); glGenTextures(1, &aTextInfo.texture); @@ -808,10 +799,8 @@ int OpenGLRender::SetArea2DShapePoint(float x, float y, int listLength) { m_Area2DPointList.reserve(listLength); } - float actualX = (x / OPENGL_SCALE_VALUE); - float actualY = (y / OPENGL_SCALE_VALUE); - m_Area2DPointList.push_back(actualX); - m_Area2DPointList.push_back(actualY); + m_Area2DPointList.push_back(x); + m_Area2DPointList.push_back(y); m_Area2DPointList.push_back(m_fZStep); if (m_Area2DPointList.size() == size_t(listLength * 3)) @@ -985,9 +974,9 @@ void OpenGLRender::GeneratePieSegment2D(double fInnerRadius, double fOutterRadiu int OpenGLRender::RenderPieSegment2DShape(float fSize, float fPosX, float fPosY) { int listNum = m_PieSegment2DShapePointList.size(); - PosVecf3 trans = {fPosX/OPENGL_SCALE_VALUE, fPosY/OPENGL_SCALE_VALUE, 0.0f}; + PosVecf3 trans = {fPosX, fPosY, 0.0f}; PosVecf3 angle = {0.0f, 0.0f, 0.0f}; - PosVecf3 scale = {fSize/OPENGL_SCALE_VALUE, fSize/OPENGL_SCALE_VALUE, 1.0f}; + PosVecf3 scale = {fSize, fSize, 1.0f}; MoveModelf(trans, angle, scale); m_MVP = m_Projection * m_View * m_Model; @@ -1040,7 +1029,7 @@ int OpenGLRender::RenderSymbol2DShape(float x, float y, float , float , sal_Int3 MoveModelf(trans, angle, scale); m_MVP = m_Projection * m_View * m_Model; - float aPos[3] = { x/OPENGL_SCALE_VALUE, y/OPENGL_SCALE_VALUE, m_fZStep }; + float aPos[3] = { x, y, m_fZStep }; //fill vertex buffer glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); CHECK_GL_ERROR(); diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx index 6203b43..54ded30 100644 --- a/chart2/source/view/main/OpenGLRender.hxx +++ b/chart2/source/view/main/OpenGLRender.hxx @@ -25,7 +25,6 @@ #include "glm/gtx/euler_angles.hpp" #include "glm/gtx/quaternion.hpp" -#define OPENGL_SCALE_VALUE 20 #define DEBUG_POSITIONING 0 #define RENDER_TO_FILE 0 commit 5278a0e3a750aa5a982086ab02f213552c5ce63a Author: Zolnai Tamás <tamas.zol...@collabora.com> Date: Sun Sep 21 10:16:16 2014 +0200 fdo#81237: OpenGL window is not resized by view change Reproduce: - Create a 2D OpenGL chart - Step out from edit mode - Zoom in / zoom out Behavior - Chart window is not resized, it has a constant size. When we step out from chart edit mode the chart becomes an inplace active object (instead of UI active) which means the m_xDockingAreaAcceptor is removed. On the other hand it seems we don't actually use this m_xDockingAreaAcceptor here, so don't need to check whether it exists. Change-Id: I056109b6e5cac28cdd2aeb8fabd9190413a16ed5 diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index b3487c9..89d1fe4 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -2650,12 +2650,6 @@ void SAL_CALL LayoutManager::windowResized( const awt::WindowEvent& aEvent ) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard g; - - if ( !m_xDockingAreaAcceptor.is() ) - return; - - // Request to set docking area space again. - Reference< XDockingAreaAcceptor > xDockingAreaAcceptor( m_xDockingAreaAcceptor ); Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY ); commit 3ef6bcc291df6d0c67709d1c97f4d55d75e77179 Author: Zolnai Tamás <tamas.zol...@collabora.com> Date: Sun Sep 21 08:13:54 2014 +0200 fdo#81237: 2D OpenGL charts have wrong size So far the size unit was 100th mm \ OPENGL_SCALE_VALUE which is an absolute value, independent from the actual size of the OpenGL window. To solve that I added the SetSizePixel() method with which we can specify the size in pixels and which method resize the whole scene accordingly. Change-Id: Ibd19a1bd9484c7bc8f8ce0d8113f60b95619db39 diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx index ffa99b7..b684ae2 100644 --- a/chart2/source/view/inc/AbstractShapeFactory.hxx +++ b/chart2/source/view/inc/AbstractShapeFactory.hxx @@ -240,7 +240,7 @@ public: */ virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape, bool bInitOpenGL = true) = 0; - virtual bool preRender(OpenGLWindow* pWindow) = 0; + virtual bool preRender(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape, OpenGLWindow* pWindow) = 0; virtual void postRender(OpenGLWindow* pWindow) = 0; virtual void clearPage(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape) = 0; diff --git a/chart2/source/view/inc/OpenglShapeFactory.hxx b/chart2/source/view/inc/OpenglShapeFactory.hxx index 6f23653..9f0a360 100644 --- a/chart2/source/view/inc/OpenglShapeFactory.hxx +++ b/chart2/source/view/inc/OpenglShapeFactory.hxx @@ -186,7 +186,7 @@ public: virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xDrawPage, bool bInitOpenGL = true) SAL_OVERRIDE; - virtual bool preRender(OpenGLWindow* pWindow) SAL_OVERRIDE; + virtual bool preRender(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xRootShape, OpenGLWindow* pWindow) SAL_OVERRIDE; virtual void postRender(OpenGLWindow* pWindow) SAL_OVERRIDE; virtual void clearPage(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xDrawPage) SAL_OVERRIDE; diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 58076bd..d7973da 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -199,7 +199,7 @@ public: */ virtual void render(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >, bool ) SAL_OVERRIDE {} - virtual bool preRender(OpenGLWindow*) SAL_OVERRIDE { return true; } + virtual bool preRender(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >, OpenGLWindow*) SAL_OVERRIDE { return true; } virtual void postRender(OpenGLWindow*) SAL_OVERRIDE {} virtual void clearPage(com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > ) SAL_OVERRIDE {} diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 3a6e6f5..9d75323 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2555,7 +2555,7 @@ void ChartView::render() OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow(); if(pWindow) pWindow->setRenderer(mp2DRenderer.get()); - bool bRender = pShapeFactory->preRender(pWindow); + bool bRender = pShapeFactory->preRender(mxRootShape, pWindow); if(bRender) { pShapeFactory->render(mxRootShape, pWindow != mp2DRenderer->getOpenGLWindow()); diff --git a/chart2/source/view/main/DummyXShape.hxx b/chart2/source/view/main/DummyXShape.hxx index 54f5df4..6b03733 100644 --- a/chart2/source/view/main/DummyXShape.hxx +++ b/chart2/source/view/main/DummyXShape.hxx @@ -398,6 +398,8 @@ public: void invalidateInit() { mbNotInit = true; } TextCache& getTextCache() { return maTextCache;} + OpenGLRender& getRenderer() { return m_GLRender; } + private: TextCache maTextCache; diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 6cdb5fd..64c94cb 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -106,14 +106,6 @@ int OpenGLRender::InitOpenGL() glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - //Init the Projection matrix - m_Projection = glm::ortho(0.f, float(m_iWidth), -float(m_iHeight), 0.f, -1.f, 1.f); - m_Projection = m_Projection * glm::scale(glm::vec3(1.0f, -1.0f, 1.0f)); - m_View = glm::lookAt(glm::vec3(0,0,1), // Camera is at (4,3,-3), in World Space - glm::vec3(0,0,0), // and looks at the origin - glm::vec3(0,1,0) // Head is up (set to 0,-1,0 to look upside-down) - ); - m_MVP = m_Projection * m_View * m_Model; glGenBuffers(1, &m_VertexBuffer); glGenBuffers(1, &m_ColorBuffer); @@ -357,8 +349,16 @@ void OpenGLRender::SetSize(int width, int height) { m_iWidth = width; m_iHeight = height; - m_Projection = glm::ortho(0.f, float(m_iWidth), -float(m_iHeight), 0.f, -4.f, 3.f); - m_Projection = m_Projection * glm::scale(glm::vec3(1.0f, -1.0f, 1.0f)); +} + +void OpenGLRender::SetSizePixel(int width, int height) +{ + m_Projection = glm::ortho(0.f, float(m_iWidth), 0.f, float(m_iHeight), -4.f, 3.f); + m_Projection = m_Projection * glm::scale((float)width / m_iWidth, -(float)height / m_iHeight, 1.0f); + + m_View = glm::lookAt(glm::vec3(0,m_iHeight,1), + glm::vec3(0,m_iHeight,0), + glm::vec3(0,1,0) ); } void OpenGLRender::SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uInt8 nAlpha) diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx index 26f81c2..6203b43 100644 --- a/chart2/source/view/main/OpenGLRender.hxx +++ b/chart2/source/view/main/OpenGLRender.hxx @@ -72,6 +72,7 @@ public: int InitOpenGL(); int MoveModelf(PosVecf3 trans, PosVecf3 angle, PosVecf3 scale); void SetSize(int width, int height); + void SetSizePixel(int width, int height); void Release(); int RenderLine2FBO(int wholeFlag); int SetLine2DShapePoint(float x, float y, int listLength); diff --git a/chart2/source/view/main/OpenglShapeFactory.cxx b/chart2/source/view/main/OpenglShapeFactory.cxx index 9443641..0f2dfe2 100644 --- a/chart2/source/view/main/OpenglShapeFactory.cxx +++ b/chart2/source/view/main/OpenglShapeFactory.cxx @@ -456,7 +456,7 @@ void OpenglShapeFactory::render(uno::Reference< drawing::XShapes > xRootShape, b rChart.render(); } -bool OpenglShapeFactory::preRender(OpenGLWindow* pWindow) +bool OpenglShapeFactory::preRender(uno::Reference< drawing::XShapes > xRootShape, OpenGLWindow* pWindow) { if(!pWindow) return false; @@ -465,6 +465,8 @@ bool OpenglShapeFactory::preRender(OpenGLWindow* pWindow) pWindow->getContext().makeCurrent(); Size aSize = pWindow->GetSizePixel(); pWindow->getContext().setWinSize(aSize); + dummy::DummyChart& rChart = dynamic_cast<dummy::DummyChart&>(*xRootShape.get()); + rChart.getRenderer().SetSizePixel(aSize.Width(), aSize.Height()); return true; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits