From bc6acbbcc9feb34a7d68ba8298a8528e42caf8a9 Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Tue, 14 Oct 2025 01:46:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B2=E6=9F=93=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ActWorld/main.cpp | 2 +- MapPresent/MapPresent.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ActWorld/main.cpp b/ActWorld/main.cpp index d08f075..5837345 100644 --- a/ActWorld/main.cpp +++ b/ActWorld/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char* argv[]) MapPresent p; p.show(); - p.zoomTo(0); + p.zoomTo(0.5); //QObject::connect(&p, &MapPresent::mouseIn, [=]() { // qDebug() << "Mouse Enter"; diff --git a/MapPresent/MapPresent.cpp b/MapPresent/MapPresent.cpp index 4c113f2..b3a2cb3 100644 --- a/MapPresent/MapPresent.cpp +++ b/MapPresent/MapPresent.cpp @@ -127,20 +127,24 @@ void MapPresent::paintEvent(QPaintEvent* ev) for (auto unit_idx : _updated_index_list.mid(0, update_batch_count)) { pic_painter.save(); + // 原点偏移,绘制缩放 auto opt = _visible_units[unit_idx]; - auto rect = opt.outline; - pic_painter.translate(rect.topLeft()); - rect.moveTo(0, 0); + pic_painter.translate(opt.outline.topLeft()); + pic_painter.scale(_scale_times, _scale_times); + // PresentOption重组,ClipPath设置 + auto rect = QRectF(0, 0, _primitive_region_len, _primitive_region_len); + opt.outline = rect; auto clip_path = BasicUnitDelegate::clipPathGet(rect); pic_painter.setClipPath(clip_path); - opt.outline = rect; - int unit_type = 0; if (_map_data_model) { unit_type = _map_data_model->mapData(MapDataModel::DataType::UnitType, unit_idx).toInt(); } + if (!_type_present_delegate.contains(unit_type)) { + unit_type = 0; + } UnitPresentDelegate& t = *_type_present_delegate[unit_type]; t.paint(&pic_painter, opt);