daily update
This commit is contained in:
@@ -14,7 +14,7 @@ set(CMAKE_AUTORCC ON)
|
|||||||
add_compile_options(-Os -O3)
|
add_compile_options(-Os -O3)
|
||||||
|
|
||||||
set(QT_VERSION Qt6)
|
set(QT_VERSION Qt6)
|
||||||
find_package(${QT_VERSION} REQUIRED COMPONENTS Widgets Network)
|
find_package(${QT_VERSION} REQUIRED COMPONENTS Widgets Network PrintSupport)
|
||||||
find_package(Eigen3 REQUIRED)
|
find_package(Eigen3 REQUIRED)
|
||||||
|
|
||||||
# For #include "..."
|
# For #include "..."
|
||||||
@@ -60,6 +60,7 @@ target_link_libraries(
|
|||||||
qcustomplot PUBLIC
|
qcustomplot PUBLIC
|
||||||
${QT_VERSION}::Core
|
${QT_VERSION}::Core
|
||||||
${QT_VERSION}::Gui
|
${QT_VERSION}::Gui
|
||||||
|
${QT_VERSION}::PrintSupport
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
@@ -85,4 +86,5 @@ target_link_libraries(
|
|||||||
${QT_VERSION}::Widgets
|
${QT_VERSION}::Widgets
|
||||||
${QT_VERSION}::Network
|
${QT_VERSION}::Network
|
||||||
modern-qt
|
modern-qt
|
||||||
|
qcustomplot
|
||||||
)
|
)
|
||||||
@@ -8,17 +8,27 @@
|
|||||||
#include <qcolor.h>
|
#include <qcolor.h>
|
||||||
#include <qcolormap.h>
|
#include <qcolormap.h>
|
||||||
#include <qcontainerfwd.h>
|
#include <qcontainerfwd.h>
|
||||||
|
#include <qdebug.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <qobject.h> #include <qsize.h>
|
#include <qobject.h>
|
||||||
|
#include <qsize.h>
|
||||||
|
|
||||||
BasicPlot::BasicPlot() : pimpl{std::make_unique<Impl>(*this)} {}
|
BasicPlot::BasicPlot() : pimpl{std::make_unique<Impl>(*this)} {
|
||||||
|
init_plot();
|
||||||
|
}
|
||||||
|
|
||||||
|
BasicPlot::~BasicPlot() {}
|
||||||
|
|
||||||
void BasicPlot::set_matrix_size(const QSize& size) {
|
void BasicPlot::set_matrix_size(const QSize& size) {
|
||||||
|
qDebug() << "set matrix size" << size;
|
||||||
|
matrix_size = size;
|
||||||
pimpl->set_matrix_size(size);
|
pimpl->set_matrix_size(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicPlot::set_matrix_size(const int& w, const int& h) {
|
void BasicPlot::set_matrix_size(const int& w, const int& h) {
|
||||||
QSize size(w, h);
|
QSize size(w, h);
|
||||||
|
qDebug() << "set matrix size" << size;
|
||||||
|
matrix_size = size;
|
||||||
pimpl->set_matrix_size(size);
|
pimpl->set_matrix_size(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +48,12 @@ QSize BasicPlot::get_matrix_size() {
|
|||||||
return matrix_size;
|
return matrix_size;
|
||||||
}
|
}
|
||||||
void BasicPlot::init_plot() {
|
void BasicPlot::init_plot() {
|
||||||
|
QVector<PointData> origin_data = {PointData{0, 0, 5}, PointData{0, 1, 3}, PointData{0, 2, 0},
|
||||||
|
PointData{1, 0, 5}, PointData{1, 1, 3}, PointData{1, 2, 9},
|
||||||
|
PointData{2, 0, 5}, PointData{2, 1, 3}, PointData{2, 2, 3},
|
||||||
|
PointData{3, 0, 5}, PointData{3, 1, 3}, PointData{3, 2, 8}};
|
||||||
QCPColorMap* cpmp = new QCPColorMap(xAxis, yAxis);
|
QCPColorMap* cpmp = new QCPColorMap(xAxis, yAxis);
|
||||||
|
qDebug() << "cpmp->data()->setSize():" << matrix_size;
|
||||||
cpmp->data()->setSize(matrix_size.width(), matrix_size.height());
|
cpmp->data()->setSize(matrix_size.width(), matrix_size.height());
|
||||||
cpmp->data()->setRange(QCPRange(0.5, matrix_size.width()), (QCPRange(0.5, matrix_size.height())));
|
cpmp->data()->setRange(QCPRange(0.5, matrix_size.width()), (QCPRange(0.5, matrix_size.height())));
|
||||||
// cpmp ->setSize(matrix_size.width(), matrix_size.height());
|
// cpmp ->setSize(matrix_size.width(), matrix_size.height());
|
||||||
@@ -62,6 +77,10 @@ void BasicPlot::init_plot() {
|
|||||||
xAxis->setRange(0, matrix_size.width());
|
xAxis->setRange(0, matrix_size.width());
|
||||||
yAxis->setRange(0, matrix_size.height());
|
yAxis->setRange(0, matrix_size.height());
|
||||||
|
|
||||||
|
for (const auto& item : origin_data) {
|
||||||
|
cpmp->data()->setCell(item.x, item.y, item.z);
|
||||||
|
}
|
||||||
|
|
||||||
QCPColorScale* color_scale = new QCPColorScale(this);
|
QCPColorScale* color_scale = new QCPColorScale(this);
|
||||||
color_scale->setType(QCPAxis::atBottom);
|
color_scale->setType(QCPAxis::atBottom);
|
||||||
this->plotLayout()->addElement(1, 0, color_scale);
|
this->plotLayout()->addElement(1, 0, color_scale);
|
||||||
@@ -79,6 +98,22 @@ void BasicPlot::init_plot() {
|
|||||||
color_scale->setMarginGroup(QCP::msLeft | QCP::msRight, margin_group);
|
color_scale->setMarginGroup(QCP::msLeft | QCP::msRight, margin_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasicPlot::dataChanged(QVector<PointData>& map) {
|
||||||
|
auto *cpmp = static_cast<QCPColorMap*>(this->plottable(0));
|
||||||
|
|
||||||
|
size_t key_size = cpmp->data()->keySize();
|
||||||
|
size_t value_size = cpmp->data()->valueSize();
|
||||||
|
for (auto& item : map) {
|
||||||
|
if (cpmp->data()->alpha(item.x, item.y)) {
|
||||||
|
if (cpmp->data()->alpha(item.x, item.y)) {
|
||||||
|
cpmp->data()->setCell(item.x, item.y, item.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
replot();
|
||||||
|
}
|
||||||
|
|
||||||
void BasicPlot::update_dynamic_heatmap(QVector<PointData>& map) {
|
void BasicPlot::update_dynamic_heatmap(QVector<PointData>& map) {
|
||||||
auto *cpmp = static_cast<QCPColorMap*>(this->plottable(0));
|
auto *cpmp = static_cast<QCPColorMap*>(this->plottable(0));
|
||||||
|
|
||||||
@@ -92,3 +127,8 @@ void BasicPlot::update_dynamic_heatmap(QVector<PointData>& map) {
|
|||||||
|
|
||||||
replot();
|
replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace creeper;
|
||||||
|
auto HeatMapPlot::paintEvent(QPaintEvent* event) -> void {
|
||||||
|
QCustomPlot::paintEvent(event);
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,33 +6,42 @@
|
|||||||
#define TOUCHSENSOR_HEATMAP_H
|
#define TOUCHSENSOR_HEATMAP_H
|
||||||
|
|
||||||
#include "modern-qt/utility/theme/theme.hh"
|
#include "modern-qt/utility/theme/theme.hh"
|
||||||
|
#include "modern-qt/utility/wrapper/common.hh"
|
||||||
#include "modern-qt/utility/wrapper/pimpl.hh"
|
#include "modern-qt/utility/wrapper/pimpl.hh"
|
||||||
|
#include "modern-qt/utility/wrapper/property.hh"
|
||||||
#include "qcustomplot/qcustomplot.h"
|
#include "qcustomplot/qcustomplot.h"
|
||||||
|
#include "modern-qt/utility/wrapper/widget.hh"
|
||||||
|
#include <concepts>
|
||||||
#include <qcontainerfwd.h>
|
#include <qcontainerfwd.h>
|
||||||
|
|
||||||
struct point_data {
|
struct point_data {
|
||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double z;
|
double z;
|
||||||
|
explicit point_data(double x, double y, double z) : x{x}, y{y}, z{z} {}
|
||||||
};
|
};
|
||||||
using PointData = struct point_data;
|
using PointData = struct point_data;
|
||||||
namespace creeper {
|
namespace creeper {
|
||||||
class heatmap;
|
class HeatMapPlot;
|
||||||
|
|
||||||
namespace plot_widget::internal {
|
namespace plot_widget::internal {
|
||||||
class BasicPlot : public QCustomPlot {
|
class BasicPlot : public QCustomPlot {
|
||||||
CREEPER_PIMPL_DEFINITION(BasicPlot);
|
public:
|
||||||
friend heatmap;
|
// CREEPER_PIMPL_DEFINITION(BasicPlot);
|
||||||
|
BasicPlot();
|
||||||
|
~BasicPlot();
|
||||||
|
BasicPlot(const BasicPlot&) = delete;
|
||||||
|
BasicPlot& operator=(const BasicPlot&) = delete; private: struct Impl;
|
||||||
|
std::unique_ptr<Impl> pimpl;
|
||||||
|
|
||||||
|
friend HeatMapPlot;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct ColorSpace {};
|
struct ColorSpace {};
|
||||||
|
|
||||||
void init_plot();
|
void init_plot();
|
||||||
|
|
||||||
void load_theme_manager(ThemeManager&);
|
void load_theme_manager(ThemeManager&); void set_xlabel_text(const QString&);
|
||||||
|
|
||||||
void set_xlabel_text(const QString&);
|
|
||||||
|
|
||||||
void set_ylabel_text(const QString&);
|
void set_ylabel_text(const QString&);
|
||||||
|
|
||||||
void set_matrix_size(const QSize&);
|
void set_matrix_size(const QSize&);
|
||||||
@@ -41,33 +50,52 @@ class BasicPlot : public QCustomPlot {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void update_dynamic_heatmap(QVector<PointData>& map);
|
void update_dynamic_heatmap(QVector<PointData>& map);
|
||||||
|
void dataChanged(QVector<PointData>& map);
|
||||||
private:
|
private:
|
||||||
QSize get_matrix_size();
|
QSize get_matrix_size();
|
||||||
private:
|
private:
|
||||||
friend class Impl;
|
friend class Impl;
|
||||||
|
// QSize matrix_size = {3, 4};
|
||||||
QSize matrix_size;
|
QSize matrix_size;
|
||||||
};
|
};
|
||||||
} // namespace plot_widget::internal
|
} // namespace plot_widget::internal
|
||||||
|
|
||||||
namespace plot_widget::pro {
|
namespace plot_widget::pro {
|
||||||
using Token = common::Token<internal::BasicPlot>;
|
using Token = common::Token<internal::BasicPlot>;
|
||||||
using XLabelText =
|
using XLabelText =
|
||||||
common::pro::String<Token, [](auto& self, const auto& string) {
|
common::pro::String<Token, [](auto& self, const auto& string) {
|
||||||
self.set_xlabel_text(string);
|
self.set_xlabel_text(string);
|
||||||
}>;
|
}>;
|
||||||
using YLabelText =
|
using YLabelText =
|
||||||
common::pro::String<Token, [](auto& self, const auto& string) {
|
common::pro::String<Token, [](auto& self, const auto& string) {
|
||||||
self.set_ylabel_text(string);
|
self.set_ylabel_text(string);
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
struct MatrixSize : Token {
|
struct MatrixSize : Token {
|
||||||
QSize size;
|
QSize size;
|
||||||
explicit MatrixSize(const int& w, const int& h) : size{w, h} {}
|
explicit MatrixSize(const int& w, const int& h) : size{w, h} {}
|
||||||
|
explicit MatrixSize(const QSize& s) : size{s} {}
|
||||||
void apply(auto& self) const {
|
void apply(auto& self) const {
|
||||||
self.set_matrix_size(size.width(), size.height());
|
self.set_matrix_size(size.width(), size.height());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}; // namespace plot_widget::pro
|
|
||||||
} // namespace creeper
|
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
using OnDataChanged =
|
||||||
|
common::pro::SignalInjection<F, Token, &internal::BasicPlot::dataChanged>;
|
||||||
|
|
||||||
|
template<class PlotWidget>
|
||||||
|
concept trait = std::derived_from<PlotWidget, Token>;
|
||||||
|
|
||||||
|
CREEPER_DEFINE_CHECKER(trait);
|
||||||
|
using namespace widget::pro;
|
||||||
|
using namespace theme::pro;
|
||||||
|
}
|
||||||
|
struct HeatMapPlot
|
||||||
|
: public Declarative<plot_widget::internal::BasicPlot,
|
||||||
|
CheckerOr<plot_widget::pro::checker, widget::pro::checker, theme::pro::checker>> {
|
||||||
|
using Declarative::Declarative;
|
||||||
|
void paintEvent(QPaintEvent*) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // TOUCHSENSOR_HEATMAP_H
|
#endif // TOUCHSENSOR_HEATMAP_H
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ struct BasicPlot::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto load_theme_manager(ThemeManager& mgr) {
|
auto load_theme_manager(ThemeManager& mgr) {
|
||||||
mgr.append_handler(&self, [this](const ThemeManager& mgr){
|
// mgr.append_handler(&self, [this](const ThemeManager& mgr){
|
||||||
set_color_scheme(mgr.color_scheme());
|
// set_color_scheme(mgr.color_scheme());
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto set_color_scheme(slider::pro::Measurements measurements) {
|
// auto set_color_scheme(slider::pro::Measurements measurements) {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
private:
|
private:
|
||||||
QString xlabel;
|
QString xlabel;
|
||||||
QString ylabel;
|
QString ylabel;
|
||||||
|
|||||||
@@ -2,10 +2,14 @@
|
|||||||
// Created by Lenn on 2025/10/14.
|
// Created by Lenn on 2025/10/14.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <qsize.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include "component.hh"
|
#include "component.hh"
|
||||||
|
#include "modern-qt/utility/theme/theme.hh"
|
||||||
|
#include "modern-qt/utility/wrapper/layout.hh"
|
||||||
|
#include "modern-qt/utility/wrapper/widget.hh"
|
||||||
|
#include "components/charts/heatmap.hh"
|
||||||
#include <modern-qt/layout/flow.hh>
|
#include <modern-qt/layout/flow.hh>
|
||||||
#include <modern-qt/layout/linear.hh>
|
#include <modern-qt/layout/linear.hh>
|
||||||
#include <modern-qt/utility/material-icon.hh>
|
#include <modern-qt/utility/material-icon.hh>
|
||||||
@@ -27,12 +31,12 @@ namespace lnpro = linear::pro;
|
|||||||
namespace impro = image::pro;
|
namespace impro = image::pro;
|
||||||
namespace ibpro = icon_button::pro;
|
namespace ibpro = icon_button::pro;
|
||||||
namespace slpro = select_widget::pro;
|
namespace slpro = select_widget::pro;
|
||||||
|
namespace pwpro = plot_widget::pro;
|
||||||
|
|
||||||
static auto ComConfigComponent(ThemeManager& manager, auto&& callback) {
|
static auto ComConfigComponent(ThemeManager& manager, auto&& callback) {
|
||||||
auto slogen_context = std::make_shared<MutableValue<QString>>();
|
auto slogen_context = std::make_shared<MutableValue<QString>>();
|
||||||
slogen_context->set_silent("BanG Bream! It's MyGo!!!");
|
slogen_context->set_silent("BanG Bream! It's MyGo!!!");
|
||||||
|
|
||||||
// 创建一个MutableValue<QStringList>来存储MatSelect的选项
|
|
||||||
auto select_com_context = std::make_shared<MutableValue<QStringList>>();
|
auto select_com_context = std::make_shared<MutableValue<QStringList>>();
|
||||||
select_com_context->set_silent(QStringList {});
|
select_com_context->set_silent(QStringList {});
|
||||||
|
|
||||||
@@ -138,6 +142,18 @@ static auto ComConfigComponent(ThemeManager& manager, auto&& callback) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static auto DisplayComponent(ThemeManager& manager, int index = 0) noexcept {
|
||||||
|
const auto row = new Row{
|
||||||
|
lnpro::Item<HeatMapPlot> {
|
||||||
|
pwpro::MatrixSize {
|
||||||
|
QSize{3, 4}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return new Widget {
|
||||||
|
widget::pro::Layout{row},
|
||||||
|
};
|
||||||
|
}
|
||||||
auto ViewComponent(ViewComponentState& state) noexcept -> raw_pointer<QWidget> {
|
auto ViewComponent(ViewComponentState& state) noexcept -> raw_pointer<QWidget> {
|
||||||
const auto texts = std::array {
|
const auto texts = std::array {
|
||||||
std::make_shared<MutableValue<QString>>("0.500"),
|
std::make_shared<MutableValue<QString>>("0.500"),
|
||||||
@@ -173,6 +189,10 @@ auto ViewComponent(ViewComponentState& state) noexcept -> raw_pointer<QWidget> {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lnpro::Item {
|
||||||
|
DisplayComponent(state.manager),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user