Kaydet (Commit) 2d6e556a authored tarafından Markus Mohrhard's avatar Markus Mohrhard

first try at implementing time based updates in new chart implementation

Change-Id: I3d03e44a415023ca12548ea99a3732cba49c8074
üst 46574ef1
......@@ -46,6 +46,7 @@ $(eval $(call gb_Library_use_libraries,chartcore,\
fwe \
i18nlangtag \
sal \
salhelper \
sfx \
svl \
svt \
......
......@@ -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;
};
}
......
......@@ -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 )
......
......@@ -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: */
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