[Libreoffice-commits] core.git: Branch 'private/moggi/chart-opengl2' - chart2/inc chart2/Library_chartcore.mk chart2/source

Markus Mohrhard markus.mohrhard at googlemail.com
Tue Dec 31 10:02:21 PST 2013


 chart2/Library_chartcore.mk             |    1 
 chart2/inc/ChartView.hxx                |   18 +++++++++++
 chart2/source/model/main/ChartModel.cxx |    2 +
 chart2/source/view/main/ChartView.cxx   |   49 ++++++++++++++++++++++++++++++--
 4 files changed, 67 insertions(+), 3 deletions(-)

New commits:
commit 1fb48228cc4d07850776ec28df751fb8c3027eff
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Dec 31 20:59:28 2013 +0100

    first try at implementing time based updates in new chart implementation
    
    Change-Id: I3d03e44a415023ca12548ea99a3732cba49c8074

diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index bcad947..de4c888 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -46,6 +46,7 @@ $(eval $(call gb_Library_use_libraries,chartcore,\
     fwe \
     i18nlangtag \
     sal \
+	salhelper \
 	sfx \
     svl \
     svt \
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index 66925ab..b1c6b5f 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -45,6 +45,8 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
 
+#include <salhelper/thread.hxx>
+
 class SdrPage;
 
 namespace chart {
@@ -54,14 +56,25 @@ class DrawModelWrapper;
 class SeriesPlotterContainer;
 class VDataSeries;
 
+enum TimeBasedMode
+{
+    MANUAL,
+    AUTOMATIC,
+    AUTOMATIC_WRAP
+};
+
 struct TimeBasedInfo
 {
     TimeBasedInfo():
         bTimeBased(false),
-        nFrame(0) {}
+        nFrame(0),
+        eMode(AUTOMATIC),
+        mpThread(NULL) {}
 
     bool bTimeBased;
     size_t nFrame;
+    TimeBasedMode eMode;
+    salhelper::Thread* mpThread;
 
     // only valid when we are in the time based mode
     ::std::vector< std::vector< VDataSeries* > > m_aDataSeriesList;
@@ -181,6 +194,8 @@ public:
     virtual OUString SAL_CALL dump()
             throw(::com::sun::star::uno::RuntimeException);
 
+    void setViewDirty();
+
 private: //methods
     ChartView();
 
@@ -254,6 +269,7 @@ private: //member
     ::com::sun::star::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes;
 
     TimeBasedInfo maTimeBased;
+    osl::Mutex maTimeMutex;
 };
 
 }
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 4e6d245..d65ab67 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -93,6 +93,7 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
     , m_bModified( sal_False )
     , m_nInLoad(0)
     , m_bUpdateNotificationsPending(false)
+    , mbTimeBased(true)
     , mpChartView(NULL)
     , m_pUndoManager( NULL )
     , m_aControllers( m_aModelMutex )
@@ -131,6 +132,7 @@ ChartModel::ChartModel( const ChartModel & rOther )
     , m_bModified( rOther.m_bModified )
     , m_nInLoad(0)
     , m_bUpdateNotificationsPending(false)
+    , mbTimeBased(rOther.mbTimeBased)
     , mpChartView(NULL)
     , m_aResource( rOther.m_aResource )
     , m_aMediaDescriptor( rOther.m_aMediaDescriptor )
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index c7db1b1..72b0d95 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -108,6 +108,9 @@
 #include <rtl/strbuf.hxx>
 #include <rtl/ustring.hxx>
 
+#include <osl/conditn.hxx>
+#include <osl/time.h>
+
 #include <boost/shared_ptr.hpp>
 
 namespace chart {
@@ -121,6 +124,30 @@ using ::com::sun::star::uno::Any;
 namespace
 {
     class theExplicitValueProviderUnoTunnelId  : public rtl::Static< UnoTunnelIdInit, theExplicitValueProviderUnoTunnelId > {};
+
+class UpdateTimeBasedThread : public salhelper::Thread
+{
+public:
+    UpdateTimeBasedThread(ChartView& rChartView, TimeBasedInfo& rTimeBasedInfo):
+        salhelper::Thread("ChartUpdate"),
+        mrChartView(rChartView),
+        mrTimeBasedInfo(rTimeBasedInfo) {}
+private:
+    virtual void execute()
+    {
+        TimeValue const aTime = { 0, 100 };
+        for(size_t i = 0; i < 60; ++i)
+        {
+            mrChartView.setViewDirty();
+            mrChartView.update();
+            wait(aTime);
+        }
+    }
+
+    ChartView& mrChartView;
+    TimeBasedInfo& mrTimeBasedInfo;
+};
+
 }
 
 const uno::Sequence<sal_Int8>& ExplicitValueProvider::getUnoTunnelId()
@@ -2369,9 +2396,20 @@ void ChartView::createShapes()
     clock_t nStart = clock();
     OSL_TRACE( "\nPPPPPPPPP>>>>>>>>>>>> chart view :: createShapes()" );
 #endif
+
+    osl::ResettableMutexGuard aTimedGuard(maTimeMutex);
     if(mrChartModel.isTimeBased())
+    {
         maTimeBased.bTimeBased = true;
 
+        if(!maTimeBased.mpThread)
+        {
+            maTimeBased.mpThread = new UpdateTimeBasedThread(*this, maTimeBased);
+            maTimeBased.mpThread->launch();
+        }
+
+    }
+
     //make sure add-in is refreshed after creating the shapes
     const ::comphelper::ScopeGuard aGuard( boost::bind( &ChartView::impl_refreshAddIn, this ) );
     if( impl_AddInDrawsAllByItself() )
@@ -2444,7 +2482,7 @@ void ChartView::createShapes()
 
         SeriesPlotterContainer aSeriesPlotterContainer( m_aVCooSysList );
         aSeriesPlotterContainer.initializeCooSysAndSeriesPlotter( mrChartModel );
-        if(maTimeBased.bTimeBased)
+        if(maTimeBased.bTimeBased && maTimeBased.nFrame != 0)
         {
             std::vector<VSeriesPlotter*>& rSeriesPlotter =
                 aSeriesPlotterContainer.getSeriesPlotterList();
@@ -2549,6 +2587,8 @@ void ChartView::createShapes()
         //cleanup: remove all empty group shapes to avoid grey border lines:
         lcl_removeEmptyGroupShapes( mxRootShape );
 
+        pShapeFactory->render( mxRootShape );
+
         if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
         {
             // create copy of the data for next frame
@@ -2582,7 +2622,6 @@ void ChartView::createShapes()
         m_pDrawModelWrapper->getSdrModel().EnableUndo( true );
     }
 
-    pShapeFactory->render( mxRootShape );
 
     if(maTimeBased.bTimeBased)
     {
@@ -3007,6 +3046,12 @@ OUString ChartView::dump() throw (uno::RuntimeException)
 
 }
 
+void ChartView::setViewDirty()
+{
+    osl::ResettableMutexGuard aGuard(maTimeMutex);
+    m_bViewDirty = true;
+}
+
 } //namespace chart
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list