#include "TimeAxis_p.h" #include "../base/Plot.h" namespace YSG { Q_Ptr_cpp(TimeAxis) PROP_P(TimeAxis, int, timePointSize) PROP_P(TimeAxis, int, tickPixelSpace) PROP_P(TimeAxis, QString, timeFormat) PROP_P(TimeAxis, QFont, font) int TimeAxis::giveData(QTime time) { if(!ok()) return -1; TimeAxisPrivate* pd = d(); SpinLockGuard _guard(&pd->mBufferLock); RenderInputGuard _inputGuard(pd); std::pair ret = pd->mTimeTicker.getNewDataTickInfo(); auto input = reinterpret_cast(pd->inputData(Input_Edit)); input->mAllTime.push_back(time); if(ret.second) { input->mData.push_front({time, ret.first}); } return ret.first; } QTime TimeAxis::tickToTime(int tick, SRC src) { INIT_GET(TimeAxis) int offset = tick - (int)renderState->coordStart; return *(d()->mRingBuffer.list() + offset); } TimeAxis::Builder::Builder(Plot* plot, Qt::Orientation orientation) { this->plot = plot; this->orientation = orientation; } TimeAxis* TimeAxis::Builder::build() { auto ret = new TimeAxis(); set(ret); TimeAxisPrivate* pd = ret->d(); TimeAxisRenderState* sc = reinterpret_cast(pd->state(State_Edit)); PROP_R(int, timePointSize) PROP_R(int, tickPixelSpace) PROP_R(QString, timeFormat) PROP_R(QFont, font) return ret; } }