MapItemBase visible API

MapItemEllipse::rebuild fix
This commit is contained in:
2024-07-10 12:55:42 +03:00
parent 5bc7d7cf06
commit 083dc3edf5
3 changed files with 13 additions and 8 deletions

View File

@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
project(QAD) project(QAD)
set(QAD_MAJOR 2) set(QAD_MAJOR 2)
set(QAD_MINOR 29) set(QAD_MINOR 30)
set(QAD_REVISION 0) set(QAD_REVISION 0)
set(QAD_SUFFIX ) set(QAD_SUFFIX )
set(QAD_COMPANY SHS) set(QAD_COMPANY SHS)

View File

@@ -44,6 +44,10 @@ public:
bool isVisible() const { return m_visible; } bool isVisible() const { return m_visible; }
void setVisible(bool newVisible); 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; } double getRotation() const { return m_rotation; }
void setRotation(double deg); void setRotation(double deg);

View File

@@ -57,19 +57,20 @@ void MapItemEllipse::draw(QPainter * p) {
void MapItemEllipse::rebuild() { void MapItemEllipse::rebuild() {
pol.clear(); pol.clear();
QPointF c = rct.center(); QPointF c = rct.center();
bool full = sa == ea; double starta = sa, enda = ea;
bool full = qFuzzyCompare(starta, enda);
if (!full) pol << c; if (!full) pol << c;
double w = rct.width() / 2., h = rct.height() / 2.; double w = rct.width() / 2., h = rct.height() / 2.;
static double deg2rad = M_PI / 180.; static double deg2rad = M_PI / 180.;
if (full) { if (full) {
sa = 0.; starta = 0.;
ea = 360.; enda = 360.;
} else { } else {
if (ea < sa) qSwap(sa, ea); if (enda < starta) qSwap(starta, enda);
} }
for (double a = sa; a <= ea; a += 3.) { for (double a = starta; a <= enda; a += 3.) {
if (a > ea) a = ea; if (a > enda) a = enda;
QPointF p(sin(a * deg2rad) * w, cos(a * deg2rad) * h); QPointF p(sin(a * deg2rad) * w, cos(a * deg2rad) * h);
pol << (c + p); pol << (c + p);
} }