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