summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-01-21 00:17:55 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-29 08:09:54 +0100
commit8d8a2f2be58529d70f4783d5d1e91fca350f119f (patch)
treed09c38f1fd750e508e8548d127157a66294cdaa0 /chart2
parent1cc82471a823c992b5527e09576cb66eebf78b39 (diff)
more work in the direction of correct text rendering
It still does not render text correctly (or visible) but at least according to my debugging skills we are making progress. Change-Id: I2bff955b7395126770295ba1546e8cb3f70557c7
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/main/DummyXShape.cxx38
-rwxr-xr-xchart2/source/view/main/OpenGLRender.cxx42
-rwxr-xr-xchart2/source/view/main/OpenGLRender.hxx6
3 files changed, 67 insertions, 19 deletions
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 9f6316a03538..9b861f98d123 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -122,6 +122,10 @@ void DummyXShape::setPropertyValue( const OUString& rName, const uno::Any& rValu
{
SAL_WARN("chart2", "DummyXShape::setProperty: " << rName << " " << "Any");
maProperties[rName] = rValue;
+ if(rName == "Transformation")
+ {
+ SAL_WARN("chart2.opengl", "Transformation");
+ }
}
uno::Any DummyXShape::getPropertyValue( const OUString& rName )
@@ -642,8 +646,8 @@ struct FontAttribSetter
}
else if(rPropName == "CharHeight")
{
- //float fHeight = rProp.second.get<float>();
- mrFont.SetSize(Size(0,100)); //taken from the MCW implementation
+ float fHeight = rProp.second.get<float>();
+ mrFont.SetSize(Size(0,(fHeight*127+36)/72)); //taken from the MCW implementation
}
else if(rPropName == "CharUnderline")
{
@@ -693,7 +697,14 @@ DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
int bmpHeight = (aRect.Bottom() - aRect.Top() + 3) & ~3;
maBitmap = BitmapEx(aDevice.GetBitmapEx(aRect.TopLeft(), Size(bmpWidth, bmpHeight)));
- setSize(awt::Size(bmpWidth, bmpHeight));
+ if(rTrans.hasValue())
+ {
+ drawing::HomogenMatrix3 aTrans = rTrans.get<drawing::HomogenMatrix3>();
+ setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
+ setPosition(awt::Point(aTrans.Line1.Column3, aTrans.Line2.Column3));
+ }
+ else
+ setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
}
void DummyText::render()
@@ -702,7 +713,26 @@ void DummyText::render()
debugProperties(maProperties);
DummyChart* pChart = getRootShape();
- pChart->m_GLRender.CreateTextTexture(maBitmap, maPosition, maSize, 0);
+
+ drawing::HomogenMatrix3 aTransformation;
+ bool bHasTransformation = false;
+ std::map<OUString, uno::Any>::const_iterator itr =
+ maProperties.find("Transformation");
+ if(itr != maProperties.end())
+ {
+ SAL_WARN("chart2.opengl", "found a transformation");
+ if(itr->second.hasValue())
+ {
+ aTransformation = itr->second.get<drawing::HomogenMatrix3>();
+ bHasTransformation = true;
+ }
+ }
+ else if(maTrans.hasValue())
+ {
+ aTransformation = maTrans.get<drawing::HomogenMatrix3>();
+ }
+ pChart->m_GLRender.CreateTextTexture(maBitmap, maPosition, maSize, 0,
+ bHasTransformation, aTransformation);
pChart->m_GLRender.RenderTextShape();
}
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index f407d119cf0b..98681d642c18 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1456,8 +1456,12 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
}
-int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos, awt::Size aSize, long rotation)
+int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos, awt::Size aSize, long rotation,
+ bool bRotation, const drawing::HomogenMatrix3& rTrans)
{
+ glm::mat3 aTrans(rTrans.Line1.Column1, rTrans.Line1.Column2, rTrans.Line1.Column3,
+ rTrans.Line2.Column1, rTrans.Line2.Column2, rTrans.Line2.Column3,
+ rTrans.Line3.Column1, rTrans.Line3.Column3, rTrans.Line3.Column3);
#if DEBUG_PNG // debug PNG writing
static int nIdx = 0;
@@ -1500,17 +1504,29 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos,
aTextInfo.y = (float)(aPos.Y + aSize.Height / 2);
aTextInfo.z = m_fZStep;
aTextInfo.rotation = -(double)rotation * GL_PI / 18000.0f;
- aTextInfo.vertex[0] = (float)(aPos.X);
- aTextInfo.vertex[1] = (float)(aPos.Y);
-
- aTextInfo.vertex[2] = (float)(aPos.X + aSize.Width);
- aTextInfo.vertex[3] = (float)(aPos.Y);
-
- aTextInfo.vertex[4] = (float)(aPos.X + aSize.Width);
- aTextInfo.vertex[5] = (float)(aPos.Y + aSize.Height);
-
- aTextInfo.vertex[6] = (float)(aPos.X);
- aTextInfo.vertex[7] = (float)(aPos.Y + aSize.Height);
+ glm::vec3 aPos1( 0, 0, 1 );
+ glm::vec3 aPos1Trans = aTrans * aPos1;
+ aTextInfo.vertex[0] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[1] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[2] = m_fZStep;
+
+ glm::vec3 aPos2( 1, 0, 1 );
+ glm::vec3 aPos2Trans = aTrans * aPos2;
+ aTextInfo.vertex[3] = (rTrans.Line1.Column3 + aSize.Width ) / OPENGL_SCALE_VALUE ;
+ aTextInfo.vertex[4] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[5] = m_fZStep;
+
+ glm::vec3 aPos3( 1, 1, 1 );
+ glm::vec3 aPos3Trans = aTrans * aPos3;
+ aTextInfo.vertex[6] = (rTrans.Line1.Column3 + aSize.Width) / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[7] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[8] = m_fZStep;
+
+ glm::vec3 aPos4( 0, 1, 1 );
+ glm::vec3 aPos4Trans = aTrans * aPos4;
+ aTextInfo.vertex[9] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[10] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+ aTextInfo.vertex[11] = m_fZStep;
//if has ratotion, we must re caculate the central pos
if (!rtl::math::approxEqual(0, rotation))
@@ -1574,7 +1590,7 @@ int OpenGLRender::RenderTextShape()
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glVertexAttribPointer(
m_TextVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
- 2, // size
+ 3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 4871943de029..ebd3b2af87b4 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -29,6 +29,7 @@
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/bitmapex.hxx>
+#include <com/sun/star/drawing/HomogenMatrix3.hpp>
#if defined( _WIN32 )
#include <GL/glu.h>
@@ -95,7 +96,7 @@ typedef struct TextInfo
float y;
float z;
double rotation;
- float vertex[8];
+ float vertex[12];
}TextInfo;
typedef std::vector<GLfloat> Area2DPointList;
@@ -166,7 +167,8 @@ public:
int RectangleShapePoint(float x, float y, float directionX, float directionY);
int CreateTextTexture(const BitmapEx& rBitmapEx,
- com::sun::star::awt::Point aPos, com::sun::star::awt::Size aSize, long rotation);
+ com::sun::star::awt::Point aPos, com::sun::star::awt::Size aSize, long rotation,
+ bool bTransformation, const com::sun::star::drawing::HomogenMatrix3& rTrans);
int RenderTextShape();
int SetArea2DShapePoint(float x, float y, int listLength);