From 083dc3edf584bd008e1114f618707a0bc5788cc2 Mon Sep 17 00:00:00 2001 From: peri4 Date: Wed, 10 Jul 2024 12:55:42 +0300 Subject: [PATCH] MapItemBase visible API MapItemEllipse::rebuild fix --- CMakeLists.txt | 2 +- libs/map/mapitembase.h | 4 ++++ libs/map/mapitemellipse.cpp | 15 ++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 343380c..975610e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default project(QAD) set(QAD_MAJOR 2) -set(QAD_MINOR 29) +set(QAD_MINOR 30) set(QAD_REVISION 0) set(QAD_SUFFIX ) set(QAD_COMPANY SHS) diff --git a/libs/map/mapitembase.h b/libs/map/mapitembase.h index 086c20f..59e45e8 100644 --- a/libs/map/mapitembase.h +++ b/libs/map/mapitembase.h @@ -44,6 +44,10 @@ public: bool isVisible() const { return m_visible; } void setVisible(bool newVisible); + bool isHidden() const { return !isVisible(); } + void setHidden(bool newHidden) { setVisible(!newHidden); } + void show() { setVisible(true); } + void hide() { setVisible(false); } double getRotation() const { return m_rotation; } void setRotation(double deg); diff --git a/libs/map/mapitemellipse.cpp b/libs/map/mapitemellipse.cpp index be7ad8b..2fd2b35 100644 --- a/libs/map/mapitemellipse.cpp +++ b/libs/map/mapitemellipse.cpp @@ -57,19 +57,20 @@ void MapItemEllipse::draw(QPainter * p) { void MapItemEllipse::rebuild() { pol.clear(); - QPointF c = rct.center(); - bool full = sa == ea; + QPointF c = rct.center(); + double starta = sa, enda = ea; + bool full = qFuzzyCompare(starta, enda); if (!full) pol << c; double w = rct.width() / 2., h = rct.height() / 2.; static double deg2rad = M_PI / 180.; if (full) { - sa = 0.; - ea = 360.; + starta = 0.; + enda = 360.; } else { - if (ea < sa) qSwap(sa, ea); + if (enda < starta) qSwap(starta, enda); } - for (double a = sa; a <= ea; a += 3.) { - if (a > ea) a = ea; + for (double a = starta; a <= enda; a += 3.) { + if (a > enda) a = enda; QPointF p(sin(a * deg2rad) * w, cos(a * deg2rad) * h); pol << (c + p); }