38 lines
1013 B
C++
38 lines
1013 B
C++
#pragma once
|
|
#include "../Tool.h"
|
|
|
|
|
|
static QWidget* createTimeAxisTestPlot() {
|
|
class AxisTestPlot : public YSG::Plot {
|
|
public:
|
|
YSG::TimeAxis *axis{};
|
|
QMenu *mMenu{};
|
|
void init() override {
|
|
Plot::init();
|
|
mObjectName = "TimeAxisTestPlot";
|
|
axis = YSG::TimeAxis::Builder(this, Qt::Horizontal)
|
|
.set_tickLength(-10)
|
|
.set_subTickLength(-5).build();
|
|
}
|
|
protected:
|
|
void resizeEvent(QResizeEvent* event) override {
|
|
int space = 50;
|
|
axis->set_x(space);
|
|
axis->set_y(height()/2);
|
|
axis->set_pixelSize(width() - space * 2);
|
|
}
|
|
void contextMenuEvent(QContextMenuEvent* event) override {
|
|
if(!mMenu) {
|
|
auto ws = bw( cw(axis, 30), "时间轴");
|
|
mMenu = createMenu(this, ws);
|
|
}
|
|
mMenu->exec(event->globalPos());
|
|
}
|
|
};
|
|
auto w = new AxisTestPlot;
|
|
w->init();
|
|
|
|
return w;
|
|
}
|
|
|