[Libreoffice-commits] core.git: chart2/source

xukai xukai at multicorewareinc.com
Tue Sep 23 08:12:42 PDT 2014


 chart2/source/view/charttypes/GL3DBarChart.cxx |   68 +++++++++++++++++++------
 chart2/source/view/inc/GL3DBarChart.hxx        |    5 +
 2 files changed, 57 insertions(+), 16 deletions(-)

New commits:
commit 7f895dfbf5fb084d747e52db678d75e3273cd825
Author: xukai <xukai at multicorewareinc.com>
Date:   Fri Sep 19 15:38:19 2014 +0800

    update camera when bar is clicked
    
    Change-Id: Icf397070d1b17a282a07e166d1387881b854b337
    Reviewed-on: https://gerrit.libreoffice.org/11541
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
    Tested-by: Kohei Yoshida <libreoffice at kohei.us>

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index cf05724..5a05323 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -42,7 +42,7 @@ using namespace com::sun::star;
 namespace chart {
 
 const size_t STEPS = 200;
-
+const size_t STEPS_UPDATE = 100;
 namespace {
 
 const float TEXT_HEIGHT = 10.0f;
@@ -211,6 +211,7 @@ private:
     void MoveCamera();
     void MoveCameraToBar();
     void MoveToBar();
+    void MoveToSelectedBar();
     void MoveToDefault();
     void MoveToCorner();
     void ProcessScroll();
@@ -336,6 +337,36 @@ void RenderBenchMarkThread::MoveToBar()
     MoveCameraToBar();
 }
 
+void RenderBenchMarkThread::MoveToSelectedBar()
+{
+    mpChart->mnSelectBarId = mpChart->mnUpdateBarId;
+    std::map<sal_uInt32, const GL3DBarChart::BarInformation>::const_iterator itr = mpChart->maBarMap.find(mpChart->mnSelectBarId);
+    if(itr == mpChart->maBarMap.end())
+    {
+        mpChart->mnSelectBarId = mpChart->mnPreSelectBarId;
+        mpChart->maRenderEvent = mpChart->maPreRenderEvent;
+        mpChart->maClickCond.set();
+        return;
+    }
+    mpChart->mpRenderer->EndClick();
+    const GL3DBarChart::BarInformation& rBarInfo = itr->second;
+    mnStep = 0;
+    mnStepsTotal = STEPS_UPDATE;
+    maTargetPosition = rBarInfo.maPos;
+    maTargetPosition.z += 240;
+    maTargetPosition.x += BAR_SIZE_X / 2.0f;
+    maTargetDirection = rBarInfo.maPos;
+    maTargetDirection.x += BAR_SIZE_X / 2.0f;
+    maTargetDirection.y += BAR_SIZE_Y / 2.0f;
+    maTargetPosition.y = maTargetDirection.y - 240;
+    maMatrixStep = mpChart->mpRenderer->GetDiffOfTwoCameras( maTargetPosition,  maTargetDirection)/((float)mnStepsTotal);
+    mpChart->maClickCond.set();
+    mbExecuting = true;
+    mbNeedFlyBack = false;
+    mpChart->mpRenderer->StartClick(mpChart->mnSelectBarId);
+    mpChart->maRenderEvent = EVENT_CLICK;
+}
+
 void RenderBenchMarkThread::AutoMoveToBar()
 {
     if (!mbAutoFlyExecuting)
@@ -403,7 +434,11 @@ void RenderBenchMarkThread::ProcessClickFlyBack()
 void RenderBenchMarkThread::ProcessMouseEvent()
 {
     ProcessClickFlyBack();
-    if (mpChart->maRenderEvent == EVENT_CLICK)
+    if (mpChart->maRenderEvent == EVENT_SELECTBAR_UPDEDATE)
+    {
+        MoveToSelectedBar();
+    }
+    else if (mpChart->maRenderEvent == EVENT_CLICK)
     {
         MoveToBar();
     }
@@ -495,7 +530,8 @@ GL3DBarChart::GL3DBarChart(
     mbBenchMarkMode(false),
     mnHistoryCounter(0),
     mnBarsInRow(0),
-    mbAutoFly(false)
+    mbAutoFly(false),
+    mnUpdateBarId(0)
 {
     maFPSRenderStartTime.Seconds = maFPSRenderStartTime.Nanosec = 0;
     maFPSRenderEndTime.Seconds = maFPSRenderEndTime.Nanosec = 0;
@@ -573,18 +609,22 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
 {
     SharedResourceAccess(maCond1, maCond2);
     osl::MutexGuard aGuard(maMutex);
-    mnPreSelectBarId = mnSelectBarId;
-    mnSelectBarId -= 10;
-    sal_uInt32 nSelectRow = (mnSelectBarId - SHAPE_START_ID) / ID_STEP / (mnBarsInRow + 1);
-    sal_uInt32 nPreSelectRow = (mnPreSelectBarId - SHAPE_START_ID) / ID_STEP / (mnBarsInRow + 1);
-    if(nSelectRow != nPreSelectRow)
-    {
-        mnSelectBarId = mnPreSelectBarId;
-    }
-    else
+    if(mnSelectBarId)
     {
-        mpRenderer->EndClick();
-        mpRenderer->StartClick(mnSelectBarId);
+        int nSelectBarId = mnSelectBarId;
+        int nPreSelectBarId = nSelectBarId;
+        nSelectBarId -= 10;
+        sal_uInt32 nSelectRow = (nSelectBarId - SHAPE_START_ID) / ID_STEP / (mnBarsInRow + 1);
+        sal_uInt32 nPreSelectRow = (nPreSelectBarId - SHAPE_START_ID) / ID_STEP / (mnBarsInRow + 1);
+        if(nSelectRow == nPreSelectRow)
+        {
+            std::map<sal_uInt32, const GL3DBarChart::BarInformation>::const_iterator itr = maBarMap.find(nSelectBarId);
+            if((maRenderEvent == EVENT_CLICK || maRenderEvent == EVENT_SHOW_SELECT || maRenderEvent == EVENT_AUTO_FLY)&&(itr != maBarMap.end()))
+            {
+                mnUpdateBarId = nSelectBarId;
+                maRenderEvent = EVENT_SELECTBAR_UPDEDATE;
+            }
+        }
     }
     mpRenderer->ReleaseShapes();
     // Each series of data flows from left to right, and multiple series are
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 4ae2385..30607e6 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -49,7 +49,8 @@ enum RenderEventType
     EVENT_SHOW_SCROLL,
     EVENT_SHOW_SELECT,
     EVENT_AUTO_FLY,
-    EVENT_DIE
+    EVENT_DIE,
+    EVENT_SELECTBAR_UPDEDATE
 };
 
 class RenderThread;
@@ -193,7 +194,7 @@ private:
     sal_uInt32 mnHistoryCounter;
     sal_uInt32 mnBarsInRow;
     bool mbAutoFly;
-
+    sal_Int32 mnUpdateBarId;
 
     // these form a pair:
     // main thread sets condition 1 and waits until it can take the mutex


More information about the Libreoffice-commits mailing list