Files
Renderive/YSGraphic_Core/Axis/TimeAxis.cpp
T
2026-07-23 11:39:46 +08:00

45 lines
1.5 KiB
C++

#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<int, bool> ret = pd->mTimeTicker.getNewDataTickInfo();
auto input = reinterpret_cast<TimeAxisInputData*>(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<QTime>() + 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<TimeAxisRenderState*>(pd->state(State_Edit));
PROP_R(int, timePointSize)
PROP_R(int, tickPixelSpace)
PROP_R(QString, timeFormat)
PROP_R(QFont, font)
return ret;
}
}