Skip to content

Commit

Permalink
Force redraw of NomenclatureItems if needed: (Fix #3706)
Browse files Browse the repository at this point in the history
- Still avoid recomputing when time is frozen.
- Force redraw when location changed.

- also comment away an unused function in StelCore
  • Loading branch information
gzotti committed May 10, 2024
1 parent c50be3c commit bad1efc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/core/StelCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,11 @@ void StelCore::lookAtJ2000(const Vec3d& pos, const Vec3d& aup)
invertMatAltAzModelView = matAltAzModelView.inverse();
}

void StelCore::setMatAltAzModelView(const Mat4d& mat)
{
matAltAzModelView = mat;
invertMatAltAzModelView = matAltAzModelView.inverse();
}
//void StelCore::setMatAltAzModelView(const Mat4d& mat)
//{
// matAltAzModelView = mat;
// invertMatAltAzModelView = matAltAzModelView.inverse();
//}

Vec3d StelCore::altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode) const
{
Expand Down
3 changes: 2 additions & 1 deletion src/core/StelCore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ class StelCore : public QObject

//! Set vision direction
void lookAtJ2000(const Vec3d& pos, const Vec3d& up);
void setMatAltAzModelView(const Mat4d& mat);
// Unused as of 24.1
//void setMatAltAzModelView(const Mat4d& mat);

Vec3d altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
Vec3d equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode=RefractionAuto) const;
Expand Down
4 changes: 3 additions & 1 deletion src/core/modules/NomenclatureItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ Vec3f NomenclatureItem::getInfoColor(void) const

Vec3d NomenclatureItem::getJ2000EquatorialPos(const StelCore* core) const
{
if (fuzzyEquals(jde, core->getJDE())) return XYZ;
if (!forceItems && fuzzyEquals(jde, core->getJDE())) return XYZ;
jde = core->getJDE();
const Vec3d equPos = planet->getJ2000EquatorialPos(core);
// East/West points are assumed to be along the equator, on the planet rim. Start with sub-observer point
Expand Down Expand Up @@ -849,3 +849,5 @@ Vec4d NomenclatureItem::getRTSTime(const StelCore* core, const double altitude)
{
return planet->getRTSTime(core, altitude);
}

bool NomenclatureItem::forceItems;
3 changes: 3 additions & 0 deletions src/core/modules/NomenclatureItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ class NomenclatureItem : public StelObject
double size; // km

static LinearFader labelsFader;
// Flag to be set by our friend class NomenclatureMgr.
// Usually drawing avoids recomputation when time is frozen. However, changing location then needs a redraw. (GH#3706)
static bool forceItems;
};

#endif // NOMENCLATUREITEM_HPP
11 changes: 11 additions & 0 deletions src/core/modules/NomenclatureMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ NomenclatureMgr::NomenclatureMgr() : StelObjectModule()
font.setPixelSize(StelApp::getInstance().getScreenFontSize());
connect(&StelApp::getInstance(), SIGNAL(screenFontSizeChanged(int)), this, SLOT(setFontSize(int)));
ssystem = GETSTELMODULE(SolarSystem);
setForceItems(true);
}

NomenclatureMgr::~NomenclatureMgr()
Expand Down Expand Up @@ -81,6 +82,9 @@ void NomenclatureMgr::init()
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(ssystem, SIGNAL(solarSystemDataReloaded()), this, SLOT(updateNomenclatureData()));

StelCore *core=app->getCore();
connect(core, &StelCore::locationChanged, this, [=](){setForceItems(true);});

QString displayGroup = N_("Display Options");
addAction("actionShow_Planets_Nomenclature", displayGroup, N_("Nomenclature labels"), "flagShowNomenclature", "Alt+N");
addAction("actionShow_Planets_Nomenclature_SpecialPoints_Only", displayGroup, N_("Special nomenclature points only"), "specialNomenclatureOnlyDisplayed");
Expand Down Expand Up @@ -312,6 +316,13 @@ void NomenclatureMgr::draw(StelCore* core)
nItem->draw(core, &painter);
}
}
// avoid further forcing
setForceItems(false);
}

void NomenclatureMgr::setForceItems(bool b)
{
NomenclatureItem::forceItems=b;
}

void NomenclatureMgr::drawPointer(StelCore* core, StelPainter& painter)
Expand Down
2 changes: 2 additions & 0 deletions src/core/modules/NomenclatureMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public slots:
void updateI18n();

void updateNomenclatureData();
//! trigger in a lambda connected from StelCore::locationChanged
void setForceItems(bool b);

signals:
void flagShowNomenclatureChanged(bool b);
Expand Down

0 comments on commit bad1efc

Please sign in to comment.