remaining chart work for time based charting

Change-Id: Iac33c81df199a942ddf073f9eb1b34e147a34f3c
This commit is contained in:
Markus Mohrhard 2013-12-30 08:39:19 +01:00
parent 7a6d726563
commit a07cce8d06
7 changed files with 95 additions and 17 deletions

View file

@ -584,6 +584,8 @@ public:
bool isTimeBased() const;
void setTimeBased(bool bTimeBased);
void getNextTimePoint();
};
} // namespace chart

View file

@ -43,6 +43,7 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
class SdrPage;
@ -51,20 +52,19 @@ namespace chart {
class VCoordinateSystem;
class DrawModelWrapper;
class SeriesPlotterContainer;
class VDataSeriesGroup;
class VDataSeries;
struct TimeBasedInfo
{
TimeBasedInfo():
bTimeBased(false),
nFrame(0),
m_pZSlots(NULL) {}
nFrame(0) {}
bool bTimeBased;
size_t nFrame;
// only valid when we are in the time based mode
::std::vector< ::std::vector< VDataSeriesGroup > >* m_pZSlots;
::std::vector< std::vector< VDataSeries* > > m_aDataSeriesList;
};
/**

View file

@ -58,6 +58,7 @@
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/chart2/XTimeBased.hpp>
// header for class SvNumberFormatter
#include <svl/zforlist.hxx>
@ -1356,6 +1357,14 @@ void ChartModel::setTimeBased(bool bTimeBased)
mbTimeBased = bTimeBased;
}
void ChartModel::getNextTimePoint()
{
uno::Reference< chart2::XTimeBased > xTimeBased(getUsedData(), uno::UNO_QUERY);
SAL_WARN_IF(!xTimeBased.is(), "chart2", "does not support time based charting");
if(xTimeBased.is())
xTimeBased->switchToNext();
}
} // namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -40,7 +40,7 @@
namespace chart
{
class VDataSequence : boost::noncopyable
class VDataSequence
{
public:
void init( const ::com::sun::star::uno::Reference<
@ -62,10 +62,6 @@ class VDataSeries SAL_FINAL : boost::noncopyable
public:
VDataSeries( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xDataSeries );
// for time based charting
VDataSeries( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xDataSeries,
VDataSeries* pOldSeries, double nPercent);
~VDataSeries();
@ -176,11 +172,17 @@ public:
void setMissingValueTreatment( sal_Int32 nMissingValueTreatment );
sal_Int32 getMissingValueTreatment() const;
void setOldTimeBased( VDataSeries* pOldSeries, double nPercent );
VDataSeries* createCopyForTimeBased() const;
private: //methods
::com::sun::star::chart2::DataPointLabel*
getDataPointLabel( sal_Int32 index ) const;
void adaptPointCache( sal_Int32 nNewPointIndex ) const;
// for copies for time based charting
VDataSeries();
public: //member
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xGroupShape;
::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xLabelsGroupShape;

View file

@ -384,9 +384,6 @@ protected:
VDataSeries* getFirstSeries() const;
// ugly hack to cache the data for the next turn
const std::vector< std::vector< VDataSeriesGroup > >& getData();
protected:
PlottingPositionHelper* m_pMainPosHelper;

View file

@ -2444,6 +2444,25 @@ void ChartView::createShapes()
SeriesPlotterContainer aSeriesPlotterContainer( m_aVCooSysList );
aSeriesPlotterContainer.initializeCooSysAndSeriesPlotter( mrChartModel );
if(maTimeBased.bTimeBased)
{
std::vector<VSeriesPlotter*>& rSeriesPlotter =
aSeriesPlotterContainer.getSeriesPlotterList();
size_t n = rSeriesPlotter.size();
for(size_t i = 0; i < n; ++i)
{
std::vector< VDataSeries* > aAllNewDataSeries =
rSeriesPlotter[i]->getAllSeries();
std::vector< VDataSeries* >& rAllOldDataSeries =
maTimeBased.m_aDataSeriesList[i];
size_t m = std::min(aAllNewDataSeries.size(), rAllOldDataSeries.size());
for(size_t j = 0; j < m; ++j)
{
aAllNewDataSeries[j]->setOldTimeBased(
rAllOldDataSeries[j], (maTimeBased.nFrame % 60)/60.0);
}
}
}
lcl_createLegend( LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xShapeFactory, m_xCC
, aRemainingSpace, aPageSize, mrChartModel, aSeriesPlotterContainer.getLegendEntryProviderList()
@ -2529,6 +2548,31 @@ void ChartView::createShapes()
//cleanup: remove all empty group shapes to avoid grey border lines:
lcl_removeEmptyGroupShapes( mxRootShape );
if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
{
// create copy of the data for next frame
std::vector<VSeriesPlotter*>& rSeriesPlotter =
aSeriesPlotterContainer.getSeriesPlotterList();
size_t n = rSeriesPlotter.size();
maTimeBased.m_aDataSeriesList.clear();
maTimeBased.m_aDataSeriesList.resize(n);
for(size_t i = 0; i < n; ++i)
{
std::vector< VDataSeries* > aAllNewDataSeries =
rSeriesPlotter[i]->getAllSeries();
std::vector< VDataSeries* >& rAllOldDataSeries =
maTimeBased.m_aDataSeriesList[i];
size_t m = std::min(aAllNewDataSeries.size(), rAllOldDataSeries.size());
for(size_t j = 0; j < m; ++j)
{
rAllOldDataSeries.push_back( aAllNewDataSeries[j]->
createCopyForTimeBased() );
}
}
mrChartModel.getNextTimePoint();
}
}
// #i12587# support for shapes in chart
@ -2540,11 +2584,6 @@ void ChartView::createShapes()
pShapeFactory->render( mxRootShape );
if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
{
// create copy of the data for next frame
}
if(maTimeBased.bTimeBased)
{
maTimeBased.nFrame++;

View file

@ -182,6 +182,8 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
, m_nCurrentAttributedPoint(-1)
, m_nMissingValueTreatment(::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
, m_bAllowPercentValueInDataLabel(false)
, mpOldSeries(NULL)
, mnPercent(0.0)
{
::rtl::math::setNan( & m_fXMeanValue );
::rtl::math::setNan( & m_fYMeanValue );
@ -1053,6 +1055,33 @@ sal_Int32 VDataSeries::getMissingValueTreatment() const
return m_nMissingValueTreatment;
}
VDataSeries::VDataSeries()
{
}
void VDataSeries::setOldTimeBased( VDataSeries* pOldSeries, double nPercent )
{
mnPercent = nPercent;
mpOldSeries = pOldSeries;
}
VDataSeries* VDataSeries::createCopyForTimeBased() const
{
VDataSeries* pNew = new VDataSeries();
pNew->m_aValues_X = m_aValues_X;
pNew->m_aValues_Y = m_aValues_Y;
pNew->m_aValues_Z = m_aValues_Z;
pNew->m_aValues_Y_Min = m_aValues_Y_Min;
pNew->m_aValues_Y_Max = m_aValues_Y_Max;
pNew->m_aValues_Y_First = m_aValues_Y_First;
pNew->m_aValues_Y_Last = m_aValues_Y_Last;
pNew->m_aValues_Bubble_Size = m_aValues_Bubble_Size;
pNew->m_nPointCount = m_nPointCount;
return pNew;
}
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */