Skip to content

Commit

Permalink
Further simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed Oct 20, 2024
1 parent 94b8646 commit 2a43d35
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 38 deletions.
11 changes: 5 additions & 6 deletions src/core/modules/Landscape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ void Landscape::loadCommon(const QSettings& landscapeIni, const QString& landsca
landscapeIni.value("landscape/polygonal_angle_rotatez", 0.f).toFloat(),
landscapeIni.value("landscape/polygonal_horizon_list_mode", "azDeg_altDeg").toString()
);
// This line can then be drawn in all classes with the color specified here.
// If not specified, don't draw it! (flagged by negative red)
horizonPolygonLineColor=Vec3f(landscapeIni.value("landscape/horizon_line_color", "-1,0,0" ).toString());
}
loadLabels(landscapeId);
}
Expand Down Expand Up @@ -332,7 +329,7 @@ void Landscape::createPolygonalHorizon(const QString& lineFileName, const float

void Landscape::drawHorizonLine(StelCore* core, StelPainter& painter)
{
if (!horizonPolygon || horizonPolygonLineThickness<1 || horizonPolygonLineColor == Vec3f(-1.f,0.f,0.f))
if (!horizonPolygon || horizonPolygonLineThickness<1 )
return;

StelProjector::ModelViewTranformP transfo = core->getAltAzModelViewTransform(StelCore::RefractionOff);
Expand Down Expand Up @@ -458,8 +455,8 @@ void Landscape::drawLabels(StelCore* core, StelPainter *painter)
}
else if (labelAngle>0)
{
painter->drawText(landscapeLabels.at(i).labelPoint, landscapeLabels.at(i).name, labelAngle, 0.5f*getLabelFontSize()*sinf(labelAngle*M_PI_180f),
-0.5f*getLabelFontSize()*sinf(labelAngle*M_PI_180f), true);
painter->drawText(landscapeLabels.at(i).labelPoint, landscapeLabels.at(i).name, labelAngle, 0.5f*fontSize*sinf(labelAngle*M_PI_180f),
-0.5f*fontSize*sinf(labelAngle*M_PI_180f), true);

}
else
Expand Down Expand Up @@ -2188,3 +2185,5 @@ int Landscape::labelAngle=45; // text tilt angle
int Landscape::fontSize=12; // Used for landscape labels (optionally indicating landscape features)
Vec3f Landscape::labelColor=Vec3f(0,1,0); // Color for the landscape labels.
double Landscape::landscapeTransparency=0.0;
LinearFader Landscape::illumFader;//! Used to slowly fade in/out illumination painting.
LinearFader Landscape::labelFader;//! Used to slowly fade in/out landscape feature labels.
26 changes: 7 additions & 19 deletions src/core/modules/Landscape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,17 @@ class Landscape
//! Set whether landscape is displayed (does not concern fog)
void setFlagShow(const bool b) {landFader=b;}
//! Get whether landscape is displayed (does not concern fog)
bool getFlagShow() const {return static_cast<bool>(landFader);}
bool getFlagShow() {return static_cast<bool>(landFader);}
//! Returns the currently effective land fade value
float getEffectiveLandFadeValue() const { return landFader.getInterstate(); }
float getEffectiveLandFadeValue() { return landFader.getInterstate(); }
//! Set whether fog is displayed
void setFlagShowFog(const bool b) {fogFader=b;}
//! Get whether fog is displayed
bool getFlagShowFog() const {return static_cast<bool>(fogFader);}
bool getFlagShowFog() {return static_cast<bool>(fogFader);}
//! Set whether illumination is displayed
void setFlagShowIllumination(const bool b) {illumFader=b;}
static void setFlagShowIllumination(const bool b) {illumFader=b;}
//! Get whether illumination is displayed
bool getFlagShowIllumination() const {return static_cast<bool>(illumFader);}
//! Set whether labels are displayed
void setFlagShowLabels(const bool b) {labelFader=b;}
//! Get whether labels are displayed
bool getFlagShowLabels() const {return static_cast<bool>(labelFader);}
//! Change font and fontsize for landscape labels
void setLabelFontSize(const int size){ fontSize=size; }
//! Get fontsize for landscape labels
int getLabelFontSize() { return fontSize; }
//! Get color for landscape labels
Vec3f getLabelColor() const { return labelColor; }
//! Set color for landscape labels
void setLabelColor(const Vec3f& c) { labelColor=c; }
static bool getFlagShowIllumination() {return static_cast<bool>(illumFader);}

//! Get landscape name
QString getName() const {return name;}
Expand Down Expand Up @@ -251,8 +239,8 @@ class Landscape
bool validLandscape; //! was a landscape loaded properly?
LinearFader landFader; //! Used to slowly fade in/out landscape painting.
LinearFader fogFader; //! Used to slowly fade in/out fog painting.
LinearFader illumFader;//! Used to slowly fade in/out illumination painting.
LinearFader labelFader;//! Used to slowly fade in/out landscape feature labels.
static LinearFader illumFader;//! Used to slowly fade in/out illumination painting.
static LinearFader labelFader;//! Used to slowly fade in/out landscape feature labels.
unsigned int rows; //! horizontal rows. May be given in landscape.ini:[landscape]tesselate_rows. More indicates higher accuracy, but is slower.
unsigned int cols; //! vertical columns. May be given in landscape.ini:[landscape]tesselate_cols. More indicates higher accuracy, but is slower.
float angleRotateZ; //! [radians] if pano does not have its left border in the east, rotate in azimuth. Configured in landscape.ini[landscape]angle_rotatez (or decor_angle_rotatez for old_style landscapes)
Expand Down
23 changes: 10 additions & 13 deletions src/core/modules/LandscapeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ void LandscapeMgr::init()
setFlagLabels(conf->value("landscape/flag_enable_labels", true).toBool());
setFlagPolyLineOnlyDisplayed(conf->value("landscape/flag_polyline_only", false).toBool());
setPolyLineThickness(conf->value("landscape/polyline_thickness", 1).toInt());
setPolyLineColor(Vec3f(conf->value("landscape/polyline_color", "1.0,0.0,0.0").toString()));
setLabelFontSize(conf->value("landscape/label_font_size", 18).toInt());
setLabelColor(Vec3f(conf->value("landscape/label_color", "0.2,0.8,0.2").toString()));
setLabelAngle(conf->value("landscape/label_angle", 45).toInt());
Expand Down Expand Up @@ -951,10 +952,6 @@ bool LandscapeMgr::setCurrentLandscapeID(const QString& id, const double changeL
// Copy display parameters from previous landscape to new one. TODO: Sort out possible static ones!
newLandscape->setFlagShow(landscape->getFlagShow());
newLandscape->setFlagShowFog(landscape->getFlagShowFog());
newLandscape->setFlagShowIllumination(landscape->getFlagShowIllumination());
newLandscape->setFlagShowLabels(landscape->getFlagShowLabels());
//newLandscape->setLabelFontSize(landscape->getLabelFontSize());
//newLandscape->setLabelColor(landscape->getLabelColor());

// If we have an oldLandscape that is not just swapped back, put that into cache.
if (oldLandscape && oldLandscape!=newLandscape)
Expand Down Expand Up @@ -1260,8 +1257,8 @@ bool LandscapeMgr::getFlagFog() const

void LandscapeMgr::setFlagIllumination(const bool displayed)
{
if (landscape->getFlagShowIllumination() != displayed) {
landscape->setFlagShowIllumination(displayed);
if (Landscape::getFlagShowIllumination() != displayed) {
Landscape::setFlagShowIllumination(displayed);
StelApp::immediateSave("landscape/flag_enable_illumination_layer", displayed);
emit illuminationDisplayedChanged(displayed);
}
Expand Down Expand Up @@ -1302,28 +1299,28 @@ void LandscapeMgr::setFlagLandscapeUseTransparency(bool b)

void LandscapeMgr::setFlagLabels(const bool displayed)
{
if (landscape->getFlagShowLabels() != displayed) {
landscape->setFlagShowLabels(displayed);
if (static_cast<bool>(Landscape::labelFader) != displayed) {
Landscape::labelFader=displayed;
StelApp::immediateSave("landscape/flag_enable_labels", displayed);
emit labelsDisplayedChanged(displayed);
}
}

bool LandscapeMgr::getFlagLabels() const
{
return landscape->getFlagShowLabels();
return static_cast<bool>(Landscape::labelFader);
}

void LandscapeMgr::setLabelFontSize(const int size)
{
landscape->setLabelFontSize(size);
Landscape::fontSize=size;
StelApp::immediateSave("landscape/label_font_size", size);
emit labelFontSizeChanged(size);
}

int LandscapeMgr::getLabelFontSize() const
{
return landscape->getLabelFontSize();
return Landscape::fontSize;
}

void LandscapeMgr::setLabelAngle(const int angleDeg)
Expand All @@ -1340,13 +1337,13 @@ int LandscapeMgr::getLabelAngle() const

void LandscapeMgr::setLabelColor(const Vec3f& c)
{
landscape->setLabelColor(c);
Landscape::labelColor=c;
emit labelColorChanged(c);
}

Vec3f LandscapeMgr::getLabelColor() const
{
return landscape->getLabelColor();
return Landscape::labelColor;
}

//! Retrieve flag for rendering polygonal line (if one is defined)
Expand Down

0 comments on commit 2a43d35

Please sign in to comment.