96 lines
2.2 KiB
C++
96 lines
2.2 KiB
C++
//
|
|
// Created by Lenn on 2025/10/17.
|
|
//
|
|
|
|
#include "heatmap.hh"
|
|
#include "heatmap.impl.hh"
|
|
#include "qcustomplot/qcustomplot.h"
|
|
#include <qcolor.h>
|
|
#include <qcolormap.h>
|
|
#include <qcontainerfwd.h>
|
|
#include <qdebug.h>
|
|
#include <qnamespace.h>
|
|
#include <qobject.h>
|
|
#include <qsize.h>
|
|
|
|
using namespace creeper::plot_widget::internal;
|
|
|
|
BasicPlot::BasicPlot() : pimpl{std::make_unique<Impl>(*this)} {
|
|
// setStyleSheet("background-color: rgb(255, 0, 0);");
|
|
// QColor lightBlue(230, 240, 250);
|
|
setBackground(Qt::transparent);
|
|
}
|
|
|
|
BasicPlot::~BasicPlot() {}
|
|
|
|
void BasicPlot::set_matrix_size(const QSize& size) {
|
|
qDebug() << "set matrix size" << size;
|
|
pimpl->set_matrix_size(size);
|
|
}
|
|
|
|
void BasicPlot::set_matrix_size(const int& w, const int& h) {
|
|
QSize size(w, h);
|
|
qDebug() << "set matrix size" << size;
|
|
pimpl->set_matrix_size(size);
|
|
}
|
|
|
|
void BasicPlot::set_color_gradient_range(const double& min, const double& max) {
|
|
pimpl->set_color_gradient_range(min, max);
|
|
}
|
|
|
|
void BasicPlot::set_xlabel_text(const QString& text) {
|
|
pimpl->set_xlabel_text(text);
|
|
}
|
|
|
|
void BasicPlot::set_ylabel_text(const QString& text) {
|
|
pimpl->set_ylabel_text(text);
|
|
}
|
|
|
|
void BasicPlot::load_theme_manager(ThemeManager& mgr) {
|
|
pimpl->load_theme_manager(mgr);
|
|
}
|
|
|
|
QSize BasicPlot::get_matrix_size() const {
|
|
return pimpl->get_matrix_size();
|
|
}
|
|
|
|
void BasicPlot::set_data(const QVector<PointData>& data) {
|
|
qDebug() << "set data" << data.size();
|
|
pimpl->set_data(data);
|
|
}
|
|
|
|
bool BasicPlot::is_initialized() const {
|
|
return pimpl->is_plot_initialized();
|
|
}
|
|
|
|
void BasicPlot::init_plot() {
|
|
pimpl->initialize_plot();
|
|
}
|
|
|
|
void BasicPlot::paintEvent(QPaintEvent* event) {
|
|
// 确保在绘制前初始化
|
|
if (!is_initialized()) {
|
|
init_plot();
|
|
}
|
|
QCustomPlot::paintEvent(event);
|
|
}
|
|
|
|
void BasicPlot::dataChanged(const QVector<PointData>& map) {
|
|
set_data(map);
|
|
// emit dataChanged(map);
|
|
}
|
|
|
|
void BasicPlot::dataRangeChanged(const double& min, const double& max) {
|
|
set_color_gradient_range(min, max);
|
|
// emit dataRangeChanged(min, max);
|
|
}
|
|
|
|
void BasicPlot::update_dynamic_heatmap(const QVector<PointData>& map) {
|
|
set_data(map);
|
|
}
|
|
|
|
using namespace creeper;
|
|
|
|
void creeper::HeatMapPlot::paintEvent(QPaintEvent* event) {
|
|
BasicPlot::paintEvent(event);
|
|
} |