[Libreoffice-commits] core.git: 4 commits - chart2/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Wed Jul 30 12:53:41 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 226 ++++++++++++++++++++-----
chart2/source/view/inc/GL3DBarChart.hxx | 18 +
2 files changed, 201 insertions(+), 43 deletions(-)
New commits:
commit de674248740abbecc2a469d90aa61cba163bcd3f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed Jul 30 21:42:54 2014 +0200
fix spelling error
Change-Id: Id9b7abfed70c33eb3cd12e0976f55be232ce3ca5
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index da0db01..6091137 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -215,7 +215,7 @@ void RenderBenchMarkThread::MoveCamera()
{
mnStep = 0;
mbExecuting = false;
- mpChart->maRenderEvent = EVENT_NON;
+ mpChart->maRenderEvent = EVENT_NONE;
}
}
@@ -226,7 +226,7 @@ void RenderBenchMarkThread::MoveToDefault()
{
mnStep = 0;
mbExecuting = false;
- mpChart->maRenderEvent = EVENT_NON;
+ mpChart->maRenderEvent = EVENT_NONE;
return;
}
if (!mbExecuting)
@@ -251,7 +251,7 @@ void RenderBenchMarkThread::MoveToBar()
std::map<sal_uInt32, const GL3DBarChart::BarInformation>::const_iterator itr = mpChart->maBarMap.find(mpChart->mSelectBarId);
if(itr == mpChart->maBarMap.end())
{
- mpChart->maRenderEvent = EVENT_NON;
+ mpChart->maRenderEvent = EVENT_NONE;
mpChart->maClickCond.set();
return;
}
@@ -286,7 +286,7 @@ void RenderBenchMarkThread::MoveToCorner()
void RenderBenchMarkThread::ProcessScroll()
{
//will add other process later
- mpChart->maRenderEvent = EVENT_NON;
+ mpChart->maRenderEvent = EVENT_NONE;
}
@@ -348,7 +348,7 @@ GL3DBarChart::GL3DBarChart(
mbNeedsNewRender(true),
mbCameraInit(false),
mbRenderDie(false),
- maRenderEvent(EVENT_NON)
+ maRenderEvent(EVENT_NONE)
{
Size aSize = mrWindow.GetSizePixel();
mpRenderer->SetSize(aSize);
@@ -622,7 +622,7 @@ void GL3DBarChart::moveToDefault()
if(BENCH_MARK_MODE)
{
// add correct handling here!!
- if (maRenderEvent != EVENT_NON)
+ if (maRenderEvent != EVENT_NONE)
return;
{
@@ -663,7 +663,7 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
if (BENCH_MARK_MODE)
{
// add correct handling here !!
- if (maRenderEvent != EVENT_NON)
+ if (maRenderEvent != EVENT_NONE)
return;
{
@@ -732,7 +732,7 @@ void GL3DBarChart::mouseDragMove(const Point& rStartPos, const Point& rEndPos, s
{
long direction = rEndPos.X() - rStartPos.X();
osl::MutexGuard aGuard(maMutex);
- if (maRenderEvent == EVENT_NON)
+ if (maRenderEvent == EVENT_NONE)
maRenderEvent = direction > 0 ? EVENT_DRAG_RIGHT : EVENT_DRAG_LEFT;
if(direction < 0)
{
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 701d50b..1969290 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -40,7 +40,7 @@ class Camera;
enum RenderEventType
{
- EVENT_NON,
+ EVENT_NONE,
EVENT_CLICK,
EVENT_MOVE_TO_DEFAULT,
EVENT_DRAG_LEFT,
commit 53cb769e2e1dd62b25787cf654b532a05b6b51b5
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Jul 26 19:44:16 2014 +0800
add scroll animation for benchmark
Change-Id: I72416ee6bf6c314feb4c5a88742aedd515abc13b
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index cb48452..da0db01 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -189,6 +189,7 @@ private:
void MoveToBar();
void MoveToDefault();
void MoveToCorner();
+ void ProcessScroll();
private:
glm::vec3 maStartPos;
glm::vec3 maEndPos;
@@ -282,6 +283,13 @@ void RenderBenchMarkThread::MoveToCorner()
MoveCamera();
}
+void RenderBenchMarkThread::ProcessScroll()
+{
+ //will add other process later
+ mpChart->maRenderEvent = EVENT_NON;
+}
+
+
void RenderBenchMarkThread::ProcessMouseEvent()
{
if (mpChart->maRenderEvent == EVENT_CLICK)
@@ -296,6 +304,10 @@ void RenderBenchMarkThread::ProcessMouseEvent()
{
MoveToCorner();
}
+ else if (mpChart->maRenderEvent == EVENT_SCROLL)
+ {
+ ProcessScroll();
+ }
}
void RenderBenchMarkThread::execute()
@@ -798,6 +810,8 @@ void GL3DBarChart::scroll(long nDelta)
glm::vec3 maDir = glm::normalize(maCameraPosition - maCameraDirection);
maCameraPosition -= (float((nDelta/10)) * maDir);
mpCamera->setPosition(maCameraPosition);
+ if(BENCH_MARK_MODE)
+ maRenderEvent = EVENT_SCROLL;
}
update();
commit 8828dbfa0870cb834efda035bc5e041a1434166b
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Jul 26 19:29:44 2014 +0800
add drag animation for benchmark
Change-Id: Ie9146272dd88b7b51edace7023048629874c360f
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index a613e99..cb48452 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -181,7 +181,6 @@ public:
{
}
- void SetAnimationCamera(glm::vec3 aStartPos, glm::vec3 aEndPos, sal_Int32 nSteps);
protected:
virtual void execute() SAL_OVERRIDE;
private:
@@ -189,6 +188,7 @@ private:
void MoveCamera();
void MoveToBar();
void MoveToDefault();
+ void MoveToCorner();
private:
glm::vec3 maStartPos;
glm::vec3 maEndPos;
@@ -200,13 +200,6 @@ private:
size_t mnStepsTotal;
};
-void RenderBenchMarkThread::SetAnimationCamera(glm::vec3 startPos, glm::vec3 endPos, sal_Int32 steps)
-{
- maStartPos = startPos;
- maEndPos = endPos;
- mnSteps = steps;
-}
-
void RenderBenchMarkThread::MoveCamera()
{
if(mnStep < mnStepsTotal)
@@ -277,6 +270,18 @@ void RenderBenchMarkThread::MoveToBar()
MoveCamera();
}
+void RenderBenchMarkThread::MoveToCorner()
+{
+ if (!mbExecuting)
+ {
+ mnStepsTotal = STEPS;
+ maStep = (mpChart->getCornerPosition(mpChart->mnCornerId) - mpChart->maCameraPosition) / float(mnStepsTotal);
+ maStepDirection = (glm::vec3(mpChart->mnMaxX/2.0f, mpChart->mnMaxY/2.0f, 0) - mpChart->maCameraDirection)/ float(mnStepsTotal);
+ mbExecuting = true;
+ }
+ MoveCamera();
+}
+
void RenderBenchMarkThread::ProcessMouseEvent()
{
if (mpChart->maRenderEvent == EVENT_CLICK)
@@ -287,6 +292,10 @@ void RenderBenchMarkThread::ProcessMouseEvent()
{
MoveToDefault();
}
+ else if ((mpChart->maRenderEvent == EVENT_DRAG_LEFT) || (mpChart->maRenderEvent == EVENT_DRAG_RIGHT))
+ {
+ MoveToCorner();
+ }
}
void RenderBenchMarkThread::execute()
@@ -710,6 +719,9 @@ void GL3DBarChart::render()
void GL3DBarChart::mouseDragMove(const Point& rStartPos, const Point& rEndPos, sal_uInt16 )
{
long direction = rEndPos.X() - rStartPos.X();
+ osl::MutexGuard aGuard(maMutex);
+ if (maRenderEvent == EVENT_NON)
+ maRenderEvent = direction > 0 ? EVENT_DRAG_RIGHT : EVENT_DRAG_LEFT;
if(direction < 0)
{
mnCornerId = (mnCornerId + 1) % 4;
commit 4e4047c288c8d93d7d2d6dd0389866033b9f40ef
Author: weigao <weigao at multicorewareinc.com>
Date: Fri Jul 25 03:59:11 2014 +0200
add click event animation for benchmark
Change-Id: I1e5a879fa315a775a77d3fddc6de1d02963b5f7d
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 7624ce1..a613e99 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -32,6 +32,46 @@ namespace chart {
const size_t STEPS = 200;
+namespace {
+
+const float TEXT_HEIGHT = 10.0f;
+float DEFAULT_CAMERA_HEIGHT = 500.0f;
+const sal_uInt32 ID_STEP = 10;
+
+#if 0
+const float BAR_SIZE_X = 15.0f;
+const float BAR_SIZE_Y = 15.0f;
+#else
+const float BAR_SIZE_X = 30.0f;
+const float BAR_SIZE_Y = 5.0f;
+#endif
+const float BAR_DISTANCE_X = 5.0f;
+const float BAR_DISTANCE_Y = 5.0;
+
+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;
+}
+
+}
+
class RenderThread : public salhelper::Thread
{
public:
@@ -136,20 +176,117 @@ class RenderBenchMarkThread : public RenderThread
{
public:
RenderBenchMarkThread(GL3DBarChart * pChart):
- RenderThread(pChart)
+ RenderThread(pChart),
+ mbExecuting(false)
{
}
+
+ void SetAnimationCamera(glm::vec3 aStartPos, glm::vec3 aEndPos, sal_Int32 nSteps);
protected:
virtual void execute() SAL_OVERRIDE;
private:
void ProcessMouseEvent();
+ void MoveCamera();
+ void MoveToBar();
+ void MoveToDefault();
private:
glm::vec3 maStartPos;
glm::vec3 maEndPos;
+ sal_Int32 mnSteps;
+ bool mbExecuting;
+ glm::vec3 maStep;
+ glm::vec3 maStepDirection;
+ size_t mnStep;
+ size_t mnStepsTotal;
};
+void RenderBenchMarkThread::SetAnimationCamera(glm::vec3 startPos, glm::vec3 endPos, sal_Int32 steps)
+{
+ maStartPos = startPos;
+ maEndPos = endPos;
+ mnSteps = steps;
+}
+
+void RenderBenchMarkThread::MoveCamera()
+{
+ if(mnStep < mnStepsTotal)
+ {
+ ++mnStep;
+ mpChart->maCameraPosition += maStep;
+ mpChart->mpCamera->setPosition(mpChart->maCameraPosition);
+ mpChart->maCameraDirection += maStepDirection;
+ mpChart->mpCamera->setDirection(mpChart->maCameraDirection);
+ }
+ else
+ {
+ mnStep = 0;
+ mbExecuting = false;
+ mpChart->maRenderEvent = EVENT_NON;
+ }
+}
+
+void RenderBenchMarkThread::MoveToDefault()
+{
+ if ((mpChart->maCameraPosition == mpChart->maDefaultCameraDirection) &&
+ (mpChart->maCameraDirection == mpChart->maDefaultCameraDirection))
+ {
+ mnStep = 0;
+ mbExecuting = false;
+ mpChart->maRenderEvent = EVENT_NON;
+ return;
+ }
+ if (!mbExecuting)
+ {
+ mnStepsTotal = STEPS;
+ maStep = (mpChart->maDefaultCameraPosition - mpChart->maCameraPosition)/((float)mnStepsTotal);
+ maStepDirection = (mpChart->maDefaultCameraDirection - mpChart->maCameraDirection)/((float)mnStepsTotal);
+ mbExecuting = true;
+ }
+ MoveCamera();
+}
+
+void RenderBenchMarkThread::MoveToBar()
+{
+ if (!mbExecuting)
+ {
+ mpChart->mpRenderer->SetPickingMode(true);
+ mpChart->mpCamera->render();
+ mpChart->mpRenderer->ProcessUnrenderedShape(mpChart->mbNeedsNewRender);
+ mpChart->mSelectBarId = mpChart->mpRenderer->GetPixelColorFromPoint(mpChart->maClickPos.X(), mpChart->maClickPos.Y());
+ mpChart->mpRenderer->SetPickingMode(false);
+ std::map<sal_uInt32, const GL3DBarChart::BarInformation>::const_iterator itr = mpChart->maBarMap.find(mpChart->mSelectBarId);
+ if(itr == mpChart->maBarMap.end())
+ {
+ mpChart->maRenderEvent = EVENT_NON;
+ mpChart->maClickCond.set();
+ return;
+ }
+ const GL3DBarChart::BarInformation& rBarInfo = itr->second;
+ mnStepsTotal = STEPS;
+ glm::vec3 maTargetPosition = rBarInfo.maPos;
+ maTargetPosition.z += 240;
+ maTargetPosition.x += BAR_SIZE_X / 2.0f;
+ maStep = (maTargetPosition - mpChart->maCameraPosition)/((float)mnStepsTotal);
+ glm::vec3 maTargetDirection = rBarInfo.maPos;
+ maTargetDirection.x += BAR_SIZE_X / 2.0f;
+ maTargetDirection.y += BAR_SIZE_Y / 2.0f;
+ maStepDirection = (maTargetDirection - mpChart->maCameraDirection)/((float)mnStepsTotal);
+ mpChart->maClickCond.set();
+ mbExecuting = true;
+ }
+ MoveCamera();
+}
+
void RenderBenchMarkThread::ProcessMouseEvent()
{
+ if (mpChart->maRenderEvent == EVENT_CLICK)
+ {
+ MoveToBar();
+ }
+ else if (mpChart->maRenderEvent == EVENT_MOVE_TO_DEFAULT)
+ {
+ MoveToDefault();
+ }
}
void RenderBenchMarkThread::execute()
@@ -189,7 +326,8 @@ GL3DBarChart::GL3DBarChart(
mnCornerId(0),
mbNeedsNewRender(true),
mbCameraInit(false),
- mbRenderDie(false)
+ mbRenderDie(false),
+ maRenderEvent(EVENT_NON)
{
Size aSize = mrWindow.GetSizePixel();
mpRenderer->SetSize(aSize);
@@ -221,46 +359,6 @@ GL3DBarChart::~GL3DBarChart()
mrWindow.setRenderer(NULL);
}
-namespace {
-
-const float TEXT_HEIGHT = 10.0f;
-float DEFAULT_CAMERA_HEIGHT = 500.0f;
-const sal_uInt32 ID_STEP = 10;
-
-#if 0
-const float BAR_SIZE_X = 15.0f;
-const float BAR_SIZE_Y = 15.0f;
-#else
-const float BAR_SIZE_X = 30.0f;
-const float BAR_SIZE_Y = 5.0f;
-#endif
-const float BAR_DISTANCE_X = 5.0f;
-const float BAR_DISTANCE_Y = 5.0;
-
-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,
ExplicitCategoriesProvider& rCatProvider)
{
@@ -503,6 +601,13 @@ void GL3DBarChart::moveToDefault()
if(BENCH_MARK_MODE)
{
// add correct handling here!!
+ if (maRenderEvent != EVENT_NON)
+ return;
+
+ {
+ osl::MutexGuard aGuard(maMutex);
+ maRenderEvent = EVENT_MOVE_TO_DEFAULT;
+ }
return;
}
@@ -537,6 +642,16 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
if (BENCH_MARK_MODE)
{
// add correct handling here !!
+ if (maRenderEvent != EVENT_NON)
+ return;
+
+ {
+ osl::MutexGuard aGuard(maMutex);
+ maClickPos = rPos;
+ maRenderEvent = EVENT_CLICK;
+ maClickCond.reset();
+ }
+ maClickCond.wait();
return;
}
@@ -668,7 +783,6 @@ void GL3DBarChart::scroll(long nDelta)
{
{
osl::MutexGuard aGuard(maMutex);
-
glm::vec3 maDir = glm::normalize(maCameraPosition - maCameraDirection);
maCameraPosition -= (float((nDelta/10)) * maDir);
mpCamera->setPosition(maCameraPosition);
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 6066c6e..701d50b 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -23,6 +23,7 @@
#include <rtl/ref.hxx>
#include <salhelper/thread.hxx>
+#include <osl/conditn.hxx>
namespace chart {
@@ -37,6 +38,19 @@ class Camera;
}
+enum RenderEventType
+{
+ EVENT_NON,
+ EVENT_CLICK,
+ EVENT_MOVE_TO_DEFAULT,
+ EVENT_DRAG_LEFT,
+ EVENT_DRAG_RIGHT,
+ EVENT_SCROLL,
+ EVENT_SHOW_SCROLL,
+ EVENT_DIE
+};
+
+
class RenderThread;
class RenderOneFrameThread;
class RenderAnimationThread;
@@ -119,6 +133,10 @@ private:
osl::Mutex maMutex;
rtl::Reference<RenderThread> mpRenderThread;
bool mbRenderDie;
+ ::osl::Condition maClickCond;
+ RenderEventType maRenderEvent;
+ sal_uInt32 mSelectBarId;
+ Point maClickPos;
};
}
More information about the Libreoffice-commits
mailing list