Kaydet (Commit) 2c64e08a authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Best effort of blindly placing axes and background objects.

Change-Id: I3a7c77ee8d9c6ff033b112158daec3923ed27034
üst aa26f8b6
...@@ -55,6 +55,7 @@ void GL3DBarChart::create3DShapes() ...@@ -55,6 +55,7 @@ void GL3DBarChart::create3DShapes()
const float nBarDistanceY = nBarSizeY / 2; const float nBarDistanceY = nBarSizeY / 2;
sal_uInt32 nId = 1; sal_uInt32 nId = 1;
float nXEnd = 0.0;
float nYPos = 0.0; float nYPos = 0.0;
maShapes.clear(); maShapes.clear();
...@@ -98,11 +99,46 @@ void GL3DBarChart::create3DShapes() ...@@ -98,11 +99,46 @@ void GL3DBarChart::create3DShapes()
maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId++)); maShapes.push_back(new opengl3D::Bar(mpRenderer.get(), aBarPosition, nColor, nId++));
} }
float nThisXEnd = nPointCount * (nBarSizeX + nBarDistanceX);
if (nXEnd < nThisXEnd)
nXEnd = nThisXEnd;
++nSeriesIndex; ++nSeriesIndex;
} }
nYPos += nBarSizeY + nBarDistanceY; nYPos += nBarSizeY + nBarDistanceY;
// X axis
maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId++));
opengl3D::Line* pAxis = static_cast<opengl3D::Line*>(&maShapes.back());
glm::vec3 aBegin;
aBegin.y = nYPos;
glm::vec3 aEnd = aBegin;
aEnd.x = nXEnd;
pAxis->setPosition(aBegin, aEnd);
pAxis->setLineColor(COL_WHITE);
// Y axis
maShapes.push_back(new opengl3D::Line(mpRenderer.get(), nId++));
pAxis = static_cast<opengl3D::Line*>(&maShapes.back());
aBegin.x = aBegin.y = 0;
aEnd = aBegin;
aEnd.y = nYPos;
pAxis->setPosition(aBegin, aEnd);
pAxis->setLineColor(COL_WHITE);
// Chart background.
maShapes.push_back(new opengl3D::Rectangle(mpRenderer.get(), nId++));
opengl3D::Rectangle* pRect = static_cast<opengl3D::Rectangle*>(&maShapes.back());
glm::vec3 aTopLeft;
glm::vec3 aTopRight = aTopLeft;
aTopRight.x = nXEnd;
glm::vec3 aBottomRight = aTopRight;
aBottomRight.y = nYPos;
pRect->setPosition(aTopLeft, aTopRight, aBottomRight);
pRect->setFillColor(COL_BLACK);
pRect->setLineColor(COL_WHITE);
// Create category texts along X-axis at the bottom. // Create category texts along X-axis at the bottom.
uno::Sequence<OUString> aCats = mrCatProvider.getSimpleCategories(); uno::Sequence<OUString> aCats = mrCatProvider.getSimpleCategories();
for (sal_Int32 i = 0; i < aCats.getLength(); ++i) for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
...@@ -112,12 +148,11 @@ void GL3DBarChart::create3DShapes() ...@@ -112,12 +148,11 @@ void GL3DBarChart::create3DShapes()
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++)); maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aCats[i], nId++));
opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back()); opengl3D::Text* p = static_cast<opengl3D::Text*>(&maShapes.back());
Size aTextSize = p->getSize(); Size aTextSize = p->getSize();
glm::vec3 aTopLeft;
aTopLeft.x = nXPos; aTopLeft.x = nXPos;
aTopLeft.y = nYPos; aTopLeft.y = nYPos;
glm::vec3 aTopRight = aTopLeft; aTopRight = aTopLeft;
aTopRight.x += aTextSize.getWidth(); aTopRight.x += aTextSize.getWidth();
glm::vec3 aBottomRight = aTopRight; aBottomRight = aTopRight;
aBottomRight.y += aTextSize.getHeight(); aBottomRight.y += aTextSize.getHeight();
p->setPosition(aTopLeft, aTopRight, aBottomRight); p->setPosition(aTopLeft, aTopRight, aBottomRight);
} }
......
...@@ -53,6 +53,9 @@ public: ...@@ -53,6 +53,9 @@ public:
virtual void render() SAL_OVERRIDE; virtual void render() SAL_OVERRIDE;
void setPosition(const glm::vec3& rBegin, const glm::vec3& rEnd);
void setLineColor(const Color& rColor);
private: private:
glm::vec3 maPosBegin; glm::vec3 maPosBegin;
glm::vec3 maPosEnd; glm::vec3 maPosEnd;
...@@ -81,6 +84,11 @@ class Rectangle : public Renderable3DObject ...@@ -81,6 +84,11 @@ class Rectangle : public Renderable3DObject
public: public:
Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId); Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE; virtual void render() SAL_OVERRIDE;
void setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight);
void setFillColor(const Color& rColor);
void setLineColor(const Color& rColor);
private: private:
glm::vec3 maTopLeft; glm::vec3 maTopLeft;
glm::vec3 maTopRight; glm::vec3 maTopRight;
......
...@@ -53,6 +53,17 @@ void Line::render() ...@@ -53,6 +53,17 @@ void Line::render()
mpRenderer->EndAddShapePolygon3DObject(); mpRenderer->EndAddShapePolygon3DObject();
} }
void Line::setPosition(const glm::vec3& rBegin, const glm::vec3& rEnd)
{
maPosBegin = rBegin;
maPosEnd = rEnd;
}
void Line::setLineColor(const Color& rColor)
{
maLineColor = rColor;
}
Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId): Text::Text(OpenGL3DRenderer* pRenderer, const OUString& rStr, sal_uInt32 nId):
Renderable3DObject(pRenderer, nId) Renderable3DObject(pRenderer, nId)
{ {
...@@ -124,6 +135,23 @@ void Rectangle::render() ...@@ -124,6 +135,23 @@ void Rectangle::render()
mpRenderer->EndAddShapePolygon3DObject(); mpRenderer->EndAddShapePolygon3DObject();
} }
void Rectangle::setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight)
{
maTopLeft = rTopLeft;
maTopRight = rTopRight;
maBottomRight = rBottomRight;
}
void Rectangle::setFillColor(const Color& rColor)
{
maColor = rColor;
}
void Rectangle::setLineColor(const Color& rColor)
{
maLineColor = rColor;
}
Camera::Camera(OpenGL3DRenderer* pRenderer): Camera::Camera(OpenGL3DRenderer* pRenderer):
Renderable3DObject(pRenderer, 0), Renderable3DObject(pRenderer, 0),
maPos(10,10,-10), maPos(10,10,-10),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment