From 306a7ee38dd887883e3a7bb7d286e4f08cae835e Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Sun, 12 Oct 2025 21:11:54 +0800 Subject: [PATCH] update --- ActWorld/ActWorld.vcxproj | 7 +++++++ MapPresent/MapPresent.cpp | 20 ++++++++++---------- MapPresent/MapPresent.h | 16 +++++++++++----- MapPresent/MapPresent.vcxproj | 2 +- MapPresent/UnitDelegate.cpp | 5 +++-- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/ActWorld/ActWorld.vcxproj b/ActWorld/ActWorld.vcxproj index f46daa1..3806e09 100644 --- a/ActWorld/ActWorld.vcxproj +++ b/ActWorld/ActWorld.vcxproj @@ -64,12 +64,19 @@ $(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath) + $(SolutionDir)MapPresent;$(IncludePath) + $(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath) MapPresent.lib;%(AdditionalDependencies) + + + MapPresent.lib;%(AdditionalDependencies) + + true diff --git a/MapPresent/MapPresent.cpp b/MapPresent/MapPresent.cpp index 6bb9e4f..2d2bb62 100644 --- a/MapPresent/MapPresent.cpp +++ b/MapPresent/MapPresent.cpp @@ -46,7 +46,7 @@ MapPresent::MapPresent(QWidget* parent /*= nullptr*/) PresentIndex MapPresent::indexGet(const QPointF& pos) const { QList templist; - for (auto unit_g : _visible_units) { + for (auto unit_g : _visible_unit_groups) { while (unit_g) { auto unit = unit_g->optionGet(); @@ -82,7 +82,7 @@ QRectF MapPresent::outlineGet(const PresentIndex& idx) const auto widget_rect = this->rect(); auto widget_center = widget_rect.center(); - const float ap_len = _primitive_region_square_len / 2; + const float ap_len = _primitive_region_len / 2; auto a2_vec = ap_len * sqrt(3) / 2; auto n_yinc = QVector3D(a2_vec, ap_len * 3 / 2, 0); auto n_xinc = QVector3D(a2_vec, -ap_len * 3 / 2, 0); @@ -103,7 +103,7 @@ void MapPresent::paintEvent(QPaintEvent* ev) UnitPresentDelegate& t = *_present_delegate[0]; QPainter p(this); - for (auto opt_g : _visible_units) { + for (auto opt_g : _visible_unit_groups) { while (opt_g) { p.save(); @@ -129,7 +129,7 @@ void MapPresent::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); - visibleUnitsTidy(); + visible_units_tidy(); } void MapPresent::mouseMoveEvent(QMouseEvent* event) @@ -164,11 +164,11 @@ PresentOption AssumeOpt(PresentIndex index, QRectF rf) { return opt; } -void MapPresent::visibleUnitsTidy() { - _visible_units.clear(); +void MapPresent::visible_units_tidy() { + _visible_unit_groups.clear(); QRectF curr_outline = this->rect(); - _visible_units << std::make_shared( + _visible_unit_groups << std::make_shared( AssumeOpt(_center_index, outlineGet(_center_index)) ); @@ -187,7 +187,7 @@ void MapPresent::visibleUnitsTidy() { } if (prev_g) { - _visible_units << prev_g; + _visible_unit_groups << prev_g; } } @@ -209,12 +209,12 @@ QList MapPresent::siblingsGet(const PresentIndex& center, uint16_t for (auto idx = 0; idx < 6; ++idx) { auto ap = e6_points[idx]; auto bp = e6_points[idx + 1]; - values << itemFills(ap, bp); + values << item_supply(ap, bp); } return values; } -QList MapPresent::itemFills(const PresentIndex& a, const PresentIndex& b) const +QList MapPresent::item_supply(const PresentIndex& a, const PresentIndex& b) const { QList items; auto sign_row = (a.row == b.row) ? 0 : ((b.row - a.row) / std::abs(a.row - b.row)); diff --git a/MapPresent/MapPresent.h b/MapPresent/MapPresent.h index 6d90c2f..592b1a7 100644 --- a/MapPresent/MapPresent.h +++ b/MapPresent/MapPresent.h @@ -80,7 +80,7 @@ private: /// /// 初级区域矩形变长 /// - const float _primitive_region_square_len = 100; + const float _primitive_region_len = 100; /// /// 缩放倍数 /// @@ -91,11 +91,10 @@ private: PresentIndex _center_index; // =================================== - QList> _visible_units; - void visibleUnitsTidy(); + QList> _visible_unit_groups; + void visible_units_tidy(); - QList siblingsGet(const PresentIndex& center, uint16_t dist = 1) const; - QList itemFills(const PresentIndex& a, const PresentIndex& b) const; + QList item_supply(const PresentIndex& a, const PresentIndex& b) const; // =================================== QHash _present_delegate; @@ -116,6 +115,13 @@ public: /// /// QRectF outlineGet(const PresentIndex& idx) const; + /// + /// 获取周围包裹单元 + /// + /// 核心单元索引 + /// 单元距离 + /// + QList siblingsGet(const PresentIndex& center, uint16_t dist = 1) const; signals: void mouseIn(); diff --git a/MapPresent/MapPresent.vcxproj b/MapPresent/MapPresent.vcxproj index afbd2f1..b91558b 100644 --- a/MapPresent/MapPresent.vcxproj +++ b/MapPresent/MapPresent.vcxproj @@ -42,7 +42,7 @@ 5.12.11_msvc2017_64 - core + core;xml;sql;gui;widgets;3dcore;3danimation;3dextras;3dinput;3dlogic;3drender release diff --git a/MapPresent/UnitDelegate.cpp b/MapPresent/UnitDelegate.cpp index b6c63b7..bd31676 100644 --- a/MapPresent/UnitDelegate.cpp +++ b/MapPresent/UnitDelegate.cpp @@ -23,15 +23,16 @@ void BasicUnitDelegate::paint(QPainter* p, const PresentOption& option) brush.setColorAt(0, Qt::gray); brush.setColorAt(1, Qt::white); p->setBrush(brush); + p->drawRect(rect); - auto pathx = clipPathGet(rect); if (_hot_index == option.index) { auto pen = p->pen(); pen.setColor(Qt::red); pen.setWidth(10); p->setPen(pen); + auto pathx = clipPathGet(rect); + p->drawPath(pathx); } - p->drawPath(pathx); auto ft = p->font(); ft.setPixelSize(alen * 0.3);