diff --git a/src/core/modules/GridLinesMgr.cpp b/src/core/modules/GridLinesMgr.cpp index 8dc86e323304e..16b5699a63f76 100644 --- a/src/core/modules/GridLinesMgr.cpp +++ b/src/core/modules/GridLinesMgr.cpp @@ -57,14 +57,14 @@ class SkyGrid void setFadeDuration(float duration) {fader.setDuration(static_cast(duration*1000.f));} void setDisplayed(const bool displayed){fader = displayed;} bool isDisplayed() const {return fader;} - void setLineThickness(const int thickness) {lineThickness = thickness;} - int getLineThickness() const {return lineThickness;} + void setLineThickness(const float thickness) {lineThickness = thickness;} + float getLineThickness() const {return lineThickness;} private: Vec3f color; StelCore::FrameType frameType; QFont font; LinearFader fader; - int lineThickness; + float lineThickness; }; //! @class SkyPoint @@ -161,10 +161,10 @@ class SkyLine void setLabeled(const bool displayed){showLabel = displayed;} bool isLabeled() const {return showLabel;} void setFontSize(int newSize); - void setLineThickness(const int thickness) {lineThickness = thickness;} - int getLineThickness() const {return lineThickness;} - void setPartThickness(const int thickness) {partThickness = thickness;} - int getPartThickness() const {return partThickness;} + void setLineThickness(const float thickness) {lineThickness = thickness;} + float getLineThickness() const {return lineThickness;} + void setPartThickness(const float thickness) {partThickness = thickness;} + float getPartThickness() const {return partThickness;} //! Re-translates the label and sets the frameType. Must be called in the constructor! void updateLabel(); static void setSolarSystem(SolarSystem* ss); @@ -176,8 +176,8 @@ class SkyLine LinearFader fader; QFont font; QString label; - int lineThickness; - int partThickness; + float lineThickness; + float partThickness; bool showPartitions; bool showLabel; static QMap precessionPartitions; @@ -271,12 +271,12 @@ void viewportEdgeIntersectCallback(const Vec3d& screenPos, const Vec3d& directio lon = 0.; const double delta = raAngle90.f || angleDeg<-90.f) { angleDeg+=180.f; - xshift=-(d->sPainter->getFontMetrics().boundingRect(text).width() + xshift*ppx); + xshift=-(static_cast(d->sPainter->getFontMetrics().boundingRect(text).width()) + xshift*ppx); } d->sPainter->drawText(static_cast(screenPos[0]), static_cast(screenPos[1]), text, angleDeg, xshift*ppx, yshift*ppx); @@ -421,7 +421,7 @@ void SkyGrid::draw(const StelCore* core) const // Initialize a painter and set OpenGL state StelPainter sPainter(prj); sPainter.setBlending(true); - if (lineThickness>1) + if (lineThickness>1.f) sPainter.setLineWidth(lineThickness); // set line thickness sPainter.setLineSmooth(true); @@ -839,7 +839,7 @@ void SkyLine::draw(StelCore *core) const // Special case for Umbra and Penumbra labels Vec3d point(dist, 0.0, 0.0); rot.transfo(point); - const float shift=sPainter.getProjector()->getPixelPerRadAtCenter()*(line_type==EARTH_UMBRA ? radii.first[0] : radii.second[0])*0.0000112f/M_PIf; + const float shift=static_cast(sPainter.getProjector()->getPixelPerRadAtCenter()*(line_type==EARTH_UMBRA ? radii.first[0] : radii.second[0]))*0.0000112f/M_PIf; sPainter.drawText(pos+point, (line_type==EARTH_UMBRA ? q_("Umbra") : q_("Penumbra")), 0.f, shift, shift, false); return; } @@ -1070,7 +1070,7 @@ void SkyLine::draw(StelCore *core) const const float lineThickness=sPainter.getLineWidth(); sPainter.setLineWidth(partThickness); - // TODO: Before drawing the lines themselves (and returning), draw the short partition lines + // Before drawing the lines themselves (and returning), draw the short partition lines // Define short lines from "equator" a bit "southwards" Vec3d part0 = fpt; Vec3d partAxis(0,1,0); @@ -1211,7 +1211,8 @@ void SkyLine::draw(StelCore *core) const double dx=screenPosTgtL[0]-screenPosTgt[0]; double dy=screenPosTgtL[1]-screenPosTgt[1]; float textAngle=static_cast(atan2(dy,dx)); - sPainter.drawText(part30l, label, textAngle*M_180_PIf + extraTextAngle, shiftx, shifty, false); + // Gravity labels look outright terrible here! Disable them. + sPainter.drawText(part30l, label, textAngle*M_180_PIf + extraTextAngle, shiftx, shifty, true); } } @@ -1791,8 +1792,8 @@ void GridLinesMgr::init() setFlagApexPoints(conf->value("viewing/flag_apex_points").toBool()); // Set the line thickness for grids and lines - setLineThickness(conf->value("viewing/line_thickness", 1).toInt()); - setPartThickness(conf->value("viewing/part_thickness", 1).toInt()); + setLineThickness(conf->value("viewing/line_thickness", 1.f).toFloat()); + setPartThickness(conf->value("viewing/part_thickness", 1.f).toFloat()); // Load colors from config file QString defaultColor = conf->value("color/default_color", "0.5,0.5,0.7").toString(); @@ -3575,12 +3576,12 @@ void GridLinesMgr::setColorApexPoints(const Vec3f& newColor) } } -void GridLinesMgr::setLineThickness(const int thickness) +void GridLinesMgr::setLineThickness(const float thickness) { - int lineThickness = equGrid->getLineThickness(); - if (lineThickness!=thickness) + float lineThickness = equGrid->getLineThickness(); + if (!qFuzzyCompare(lineThickness, thickness)) { - lineThickness=qBound(1, thickness, 5); + lineThickness=qBound(1.f, thickness, 5.f); // Grids equGrid->setLineThickness(lineThickness); equJ2000Grid->setLineThickness(lineThickness); @@ -3616,46 +3617,46 @@ void GridLinesMgr::setLineThickness(const int thickness) } } - int GridLinesMgr::getLineThickness() const +float GridLinesMgr::getLineThickness() const { return equGrid->getLineThickness(); } - void GridLinesMgr::setPartThickness(const int thickness) - { - int partThickness = equatorLine->getPartThickness(); - if (partThickness!=thickness) - { - partThickness=qBound(1, thickness, 5); - // Lines - equatorLine->setPartThickness(partThickness); - equatorJ2000Line->setPartThickness(partThickness); - eclipticLine->setPartThickness(partThickness); - eclipticJ2000Line->setPartThickness(partThickness); - //invariablePlaneLine->setPartThickness(partThickness); - solarEquatorLine->setPartThickness(partThickness); - precessionCircleN->setPartThickness(partThickness); - precessionCircleS->setPartThickness(partThickness); - meridianLine->setPartThickness(partThickness); - longitudeLine->setPartThickness(partThickness); - horizonLine->setPartThickness(partThickness); - galacticEquatorLine->setPartThickness(partThickness); - supergalacticEquatorLine->setPartThickness(partThickness); - primeVerticalLine->setPartThickness(partThickness); - currentVerticalLine->setPartThickness(partThickness); - colureLine_1->setPartThickness(partThickness); - colureLine_2->setPartThickness(partThickness); - //circumpolarCircleN->setPartThickness(partThickness); - //circumpolarCircleS->setPartThickness(partThickness); - - emit partThicknessChanged(partThickness); - } - } - - int GridLinesMgr::getPartThickness() const - { - return equatorLine->getPartThickness(); - } +void GridLinesMgr::setPartThickness(const float thickness) +{ + float partThickness = equatorLine->getPartThickness(); + if (!qFuzzyCompare(partThickness, thickness)) + { + partThickness=qBound(1.f, thickness, 5.f); + // Lines + equatorLine->setPartThickness(partThickness); + equatorJ2000Line->setPartThickness(partThickness); + eclipticLine->setPartThickness(partThickness); + eclipticJ2000Line->setPartThickness(partThickness); + //invariablePlaneLine->setPartThickness(partThickness); + solarEquatorLine->setPartThickness(partThickness); + precessionCircleN->setPartThickness(partThickness); + precessionCircleS->setPartThickness(partThickness); + meridianLine->setPartThickness(partThickness); + longitudeLine->setPartThickness(partThickness); + horizonLine->setPartThickness(partThickness); + galacticEquatorLine->setPartThickness(partThickness); + supergalacticEquatorLine->setPartThickness(partThickness); + primeVerticalLine->setPartThickness(partThickness); + currentVerticalLine->setPartThickness(partThickness); + colureLine_1->setPartThickness(partThickness); + colureLine_2->setPartThickness(partThickness); + //circumpolarCircleN->setPartThickness(partThickness); + //circumpolarCircleS->setPartThickness(partThickness); + + emit partThicknessChanged(partThickness); + } +} + +float GridLinesMgr::getPartThickness() const +{ + return equatorLine->getPartThickness(); +} void GridLinesMgr::setFontSizeFromApp(int size) { diff --git a/src/core/modules/GridLinesMgr.hpp b/src/core/modules/GridLinesMgr.hpp index 7744bc6f9b96b..5e64a061df615 100644 --- a/src/core/modules/GridLinesMgr.hpp +++ b/src/core/modules/GridLinesMgr.hpp @@ -185,8 +185,8 @@ class GridLinesMgr : public StelModule Q_PROPERTY(bool apexPointsDisplayed READ getFlagApexPoints WRITE setFlagApexPoints NOTIFY apexPointsDisplayedChanged) Q_PROPERTY(Vec3f apexPointsColor READ getColorApexPoints WRITE setColorApexPoints NOTIFY apexPointsColorChanged) - Q_PROPERTY(int lineThickness READ getLineThickness WRITE setLineThickness NOTIFY lineThicknessChanged) - Q_PROPERTY(int partThickness READ getPartThickness WRITE setPartThickness NOTIFY partThicknessChanged) + Q_PROPERTY(float lineThickness READ getLineThickness WRITE setLineThickness NOTIFY lineThicknessChanged) + Q_PROPERTY(float partThickness READ getPartThickness WRITE setPartThickness NOTIFY partThicknessChanged) public: GridLinesMgr(); virtual ~GridLinesMgr() Q_DECL_OVERRIDE; @@ -895,20 +895,20 @@ public slots: //! Set the thickness of lines //! @param thickness of line in pixels - void setLineThickness(const int thickness); + void setLineThickness(const float thickness); //! Get the thickness of lines - int getLineThickness() const; + float getLineThickness() const; //! Set the thickness of partition lines //! @param thickness of line in pixels - void setPartThickness(const int thickness); + void setPartThickness(const float thickness); //! Get the thickness of lines - int getPartThickness() const; + float getPartThickness() const; signals: void gridlinesDisplayedChanged(const bool); - void lineThicknessChanged(const int); - void partThicknessChanged(const int); + void lineThicknessChanged(const float); + void partThicknessChanged(const float); void azimuthalGridDisplayedChanged(const bool); void azimuthalGridColorChanged(const Vec3f & newColor); void equatorGridDisplayedChanged(const bool displayed); diff --git a/src/core/modules/LandscapeMgr.cpp b/src/core/modules/LandscapeMgr.cpp index c8fa15e0072ed..a942287d6ebf5 100644 --- a/src/core/modules/LandscapeMgr.cpp +++ b/src/core/modules/LandscapeMgr.cpp @@ -65,23 +65,6 @@ Cardinals::Cardinals() // Draw the principal wind points even smaller. font16WCR.setPixelSize(conf->value("viewing/16wcr_font_size", screenFontSize+2).toInt()); - // Directions - rose4winds = { - { dN, Vec3f(-1.f, 0.f, 0.f) }, { dS, Vec3f(1.f, 0.f, 0.f) }, - { dE, Vec3f( 0.f, 1.f, 0.f) }, { dW, Vec3f(0.f, -1.f, 0.f) } - }; - rose8winds = { - { dNE, Vec3f(-1.f, 1.f, 0.f) }, { dSE, Vec3f( 1.f, 1.f, 0.f) }, - { dSW, Vec3f( 1.f, -1.f, 0.f) }, { dNW, Vec3f(-1.f, -1.f, 0.f) } - }; - const float cp = 1.f/(1.f+sqrt(2.f)); - const float cn = -1.f*cp; - rose16winds = { - { dNNE, Vec3f(-1.f, cp, 0.f) }, { dENE, Vec3f( cn, 1.f, 0.f) }, - { dESE, Vec3f( cp, 1.f, 0.f) }, { dSSE, Vec3f( 1.f, cp, 0.f) }, - { dSSW, Vec3f( 1.f, cn, 0.f) }, { dWSW, Vec3f( cp, -1.f, 0.f) }, - { dWNW, Vec3f( cn, -1.f, 0.f) }, { dNNW, Vec3f(-1.f, cn, 0.f) } - }; // English names for cardinals labels = { { dN, "N" }, { dS, "S" }, { dE, "E" }, { dW, "W" }, @@ -95,6 +78,21 @@ Cardinals::~Cardinals() { } +const QMap Cardinals::rose4winds = { + { Cardinals::dN, Vec3f(-1.f, 0.f, 0.f) }, { Cardinals::dS, Vec3f(1.f, 0.f, 0.f) }, + { Cardinals::dE, Vec3f( 0.f, 1.f, 0.f) }, { Cardinals::dW, Vec3f(0.f, -1.f, 0.f) } +}; +const QMap Cardinals::rose8winds = { + { Cardinals::dNE, Vec3f(-1.f, 1.f, 0.f) }, { Cardinals::dSE, Vec3f( 1.f, 1.f, 0.f) }, + { Cardinals::dSW, Vec3f( 1.f, -1.f, 0.f) }, { Cardinals::dNW, Vec3f(-1.f, -1.f, 0.f) } +}; +const QMap Cardinals::rose16winds = { + { dNNE, Vec3f(-1.f, cp, 0.f) }, { dENE, Vec3f( -cp, 1.f, 0.f) }, + { dESE, Vec3f( cp, 1.f, 0.f) }, { dSSE, Vec3f( 1.f, cp, 0.f) }, + { dSSW, Vec3f( 1.f, -cp, 0.f) }, { dWSW, Vec3f( cp, -1.f, 0.f) }, + { dWNW, Vec3f( -cp, -1.f, 0.f) }, { dNNW, Vec3f(-1.f, -cp, 0.f) } +}; + void Cardinals::update(double deltaTime) { fader4WCR.update(static_cast(deltaTime*1000)); @@ -129,20 +127,27 @@ void Cardinals::draw(const StelCore* core, double latitude) const vshift = static_cast(screenFontSize + 12)*ppx; Vec3f xy; - QString directionLabel; sPainter.setColor(color, fader4WCR.getInterstate()); sPainter.setBlending(true); QMapIterator it4w(rose4winds); while(it4w.hasNext()) { it4w.next(); - directionLabel = labels.value(it4w.key(), ""); + QString directionLabel = labels.value(it4w.key(), ""); if (flagMask) sshift = ppx*static_cast(sPainter.getFontMetrics().boundingRect(directionLabel).width())*0.5f; if (prj->project(it4w.value(), xy)) - sPainter.drawText(xy[0], xy[1], directionLabel, 0., -sshift, vshift, false); + { + Vec3f up(it4w.value()[0], it4w.value()[1], 1.*M_PI/180.); + Vec3f upPrj; + prj->project(up, upPrj); + double dx=upPrj[0]-xy[0]; + double dy=upPrj[1]-xy[1]; + float textAngle=static_cast(atan2(dx, dy)); + sPainter.drawText(xy[0], xy[1], directionLabel, -textAngle*180.f/M_PI, -sshift, vshift, true); + } } if (fader8WCR.getInterstate()>0.f) @@ -155,13 +160,21 @@ void Cardinals::draw(const StelCore* core, double latitude) const while(it8w.hasNext()) { it8w.next(); - directionLabel = labels.value(it8w.key(), ""); + QString directionLabel = labels.value(it8w.key(), ""); if (flagMask) bshift = ppx*static_cast(sPainter.getFontMetrics().boundingRect(directionLabel).width())*0.5f; if (prj->project(it8w.value(), xy)) - sPainter.drawText(xy[0], xy[1], directionLabel, 0., -bshift, vshift, false); + { + Vec3f up(it8w.value()[0], it8w.value()[1], 1.*M_PI/180.); + Vec3f upPrj; + prj->project(up, upPrj); + double dx=upPrj[0]-xy[0]; + double dy=upPrj[1]-xy[1]; + float textAngle=static_cast(atan2(dx, dy)); + sPainter.drawText(xy[0], xy[1], directionLabel, -textAngle*180.f/M_PI, -bshift, vshift, true); + } } @@ -174,13 +187,21 @@ void Cardinals::draw(const StelCore* core, double latitude) const while(it16w.hasNext()) { it16w.next(); - directionLabel = labels.value(it16w.key(), ""); + QString directionLabel = labels.value(it16w.key(), ""); if (flagMask) cshift = ppx*static_cast(sPainter.getFontMetrics().boundingRect(directionLabel).width())*0.5f; if (prj->project(it16w.value(), xy)) - sPainter.drawText(xy[0], xy[1], directionLabel, 0., -cshift, vshift, false); + { + Vec3f up(it16w.value()[0], it16w.value()[1], 1.*M_PI/180.); + Vec3f upPrj; + prj->project(up, upPrj); + double dx=upPrj[0]-xy[0]; + double dy=upPrj[1]-xy[1]; + float textAngle=static_cast(atan2(dx, dy)); + sPainter.drawText(xy[0], xy[1], directionLabel, -textAngle*180.f/M_PI, -cshift, vshift, true); + } } } } @@ -229,7 +250,7 @@ void Cardinals::updateI18n() LandscapeMgr::LandscapeMgr() : StelModule() , atmosphere(Q_NULLPTR) - , cardinalsPoints(Q_NULLPTR) + , cardinalPoints(Q_NULLPTR) , landscape(Q_NULLPTR) , oldLandscape(Q_NULLPTR) , flagLandscapeSetsLocation(false) @@ -260,7 +281,7 @@ LandscapeMgr::LandscapeMgr() LandscapeMgr::~LandscapeMgr() { delete atmosphere; - delete cardinalsPoints; + delete cardinalPoints; if (oldLandscape) { delete oldLandscape; @@ -310,7 +331,7 @@ void LandscapeMgr::update(double deltaTime) } } landscape->update(deltaTime); - cardinalsPoints->update(deltaTime); + cardinalPoints->update(deltaTime); // Compute the atmosphere color and intensity // Compute the sun position in local coordinate @@ -475,7 +496,7 @@ void LandscapeMgr::draw(StelCore* core) landscape->draw(core, flagPolyLineDisplayedOnly); // Draw the cardinal points - cardinalsPoints->draw(core, static_cast(StelApp::getInstance().getCore()->getCurrentLocation().latitude)); + cardinalPoints->draw(core, static_cast(StelApp::getInstance().getCore()->getCurrentLocation().latitude)); // Workaround for a bug with spherical mirror mode when we don't show the cardinal points. // I am not really sure why this seems to fix the problem. If you want to @@ -497,7 +518,7 @@ void LandscapeMgr::drawPolylineOnly(StelCore* core) landscape->draw(core, true); // Draw the cardinal points - cardinalsPoints->draw(core, static_cast(StelApp::getInstance().getCore()->getCurrentLocation().latitude)); + cardinalPoints->draw(core, static_cast(StelApp::getInstance().getCore()->getCurrentLocation().latitude)); } @@ -544,10 +565,10 @@ void LandscapeMgr::init() setFlagPolyLineDisplayed(conf->value("landscape/flag_polyline_only", false).toBool()); setPolyLineThickness(conf->value("landscape/polyline_thickness", 1).toInt()); - cardinalsPoints = new Cardinals(); - cardinalsPoints->setFlagShow4WCRLabels(conf->value("viewing/flag_cardinal_points", true).toBool()); - cardinalsPoints->setFlagShow8WCRLabels(conf->value("viewing/flag_ordinal_points", true).toBool()); - cardinalsPoints->setFlagShow16WCRLabels(conf->value("viewing/flag_16wcr_points", false).toBool()); + cardinalPoints = new Cardinals(); + cardinalPoints->setFlagShow4WCRLabels(conf->value("viewing/flag_cardinal_points", true).toBool()); + cardinalPoints->setFlagShow8WCRLabels(conf->value("viewing/flag_ordinal_points", true).toBool()); + cardinalPoints->setFlagShow16WCRLabels(conf->value("viewing/flag_16wcr_points", false).toBool()); // Load colors from config file QString defaultColor = conf->value("color/default_color").toString(); setColorCardinalPoints(Vec3f(conf->value("color/cardinal_color", defaultColor).toString())); @@ -565,9 +586,9 @@ void LandscapeMgr::init() QString displayGroup = N_("Display Options"); addAction("actionShow_Atmosphere", displayGroup, N_("Atmosphere"), "atmosphereDisplayed", "A"); addAction("actionShow_Fog", displayGroup, N_("Fog"), "fogDisplayed", "F"); - addAction("actionShow_Cardinal_Points", displayGroup, N_("Cardinal points"), "cardinalsPointsDisplayed", "Q"); - addAction("actionShow_Intercardinal_Points", displayGroup, N_("Ordinal (Intercardinal) points"), "ordinalsPointsDisplayed"); - addAction("actionShow_Secondary_Intercardinal_Points", displayGroup, N_("Secondary Intercardinal points"), "ordinals16WRPointsDisplayed"); + addAction("actionShow_Cardinal_Points", displayGroup, N_("Cardinal points"), "cardinalPointsDisplayed", "Q"); + addAction("actionShow_Intercardinal_Points", displayGroup, N_("Ordinal (Intercardinal) points"), "ordinalPointsDisplayed"); + addAction("actionShow_Secondary_Intercardinal_Points", displayGroup, N_("Secondary Intercardinal points"), "ordinal16WRPointsDisplayed"); addAction("actionShow_Ground", displayGroup, N_("Ground"), "landscapeDisplayed", "G"); addAction("actionShow_LandscapeIllumination", displayGroup, N_("Landscape illumination"), "illuminationDisplayed", "Shift+G"); addAction("actionShow_LandscapeLabels", displayGroup, N_("Landscape labels"), "labelsDisplayed", "Ctrl+Shift+G"); @@ -763,7 +784,7 @@ bool LandscapeMgr::setDefaultLandscapeID(const QString& id) void LandscapeMgr::updateI18n() { // Translate all labels with the new language - if (cardinalsPoints) cardinalsPoints->updateI18n(); + if (cardinalPoints) cardinalPoints->updateI18n(); landscape->loadLabels(getCurrentLandscapeID()); } @@ -858,7 +879,7 @@ void LandscapeMgr::onTargetLocationChanged(const StelLocation &loc) setFlagAtmosphere(false); setFlagFog(false); setFlagLandscape(false); - setFlagCardinalsPoints(false); + setFlagCardinalPoints(false); //setFlagOrdinalsPoints(false); //setFlagOrdinals16WRPoints(false); } @@ -873,9 +894,9 @@ void LandscapeMgr::onTargetLocationChanged(const StelLocation &loc) setFlagAtmosphere(pl->hasAtmosphere() && conf->value("landscape/flag_atmosphere", true).toBool()); setFlagFog(pl->hasAtmosphere() && conf->value("landscape/flag_fog", true).toBool()); setFlagLandscape(true); - setFlagCardinalsPoints(conf->value("viewing/flag_cardinal_points", true).toBool()); - setFlagOrdinalsPoints(conf->value("viewing/flag_ordinal_points", true).toBool()); - setFlagOrdinals16WRPoints(conf->value("viewing/flag_16wcr_points", false).toBool()); + setFlagCardinalPoints(conf->value("viewing/flag_cardinal_points", true).toBool()); + setFlagOrdinalPoints(conf->value("viewing/flag_ordinal_points", true).toBool()); + setFlagOrdinal16WRPoints(conf->value("viewing/flag_16wcr_points", false).toBool()); } } } @@ -1063,51 +1084,51 @@ QString LandscapeMgr::getCurrentLandscapeHtmlDescription() const } //! Set flag for displaying cardinal points -void LandscapeMgr::setFlagCardinalsPoints(const bool displayed) +void LandscapeMgr::setFlagCardinalPoints(const bool displayed) { - if (cardinalsPoints->getFlagShow4WCRLabels() != displayed) + if (cardinalPoints->getFlagShow4WCRLabels() != displayed) { - cardinalsPoints->setFlagShow4WCRLabels(displayed); - emit cardinalsPointsDisplayedChanged(displayed); + cardinalPoints->setFlagShow4WCRLabels(displayed); + emit cardinalPointsDisplayedChanged(displayed); } } //! Get flag for displaying cardinal points -bool LandscapeMgr::getFlagCardinalsPoints() const +bool LandscapeMgr::getFlagCardinalPoints() const { - return cardinalsPoints->getFlagShowCardinals(); + return cardinalPoints->getFlagShowCardinals(); } //! Set flag for displaying ordinal points -void LandscapeMgr::setFlagOrdinalsPoints(const bool displayed) +void LandscapeMgr::setFlagOrdinalPoints(const bool displayed) { - if (cardinalsPoints->getFlagShow8WCRLabels() != displayed) + if (cardinalPoints->getFlagShow8WCRLabels() != displayed) { - cardinalsPoints->setFlagShow8WCRLabels(displayed); - emit ordinalsPointsDisplayedChanged(displayed); + cardinalPoints->setFlagShow8WCRLabels(displayed); + emit ordinalPointsDisplayedChanged(displayed); } } //! Get flag for displaying ordinal points -bool LandscapeMgr::getFlagOrdinalsPoints() const +bool LandscapeMgr::getFlagOrdinalPoints() const { - return cardinalsPoints->getFlagShow8WCRLabels(); + return cardinalPoints->getFlagShow8WCRLabels(); } //! Set flag for displaying ordinal points -void LandscapeMgr::setFlagOrdinals16WRPoints(const bool displayed) +void LandscapeMgr::setFlagOrdinal16WRPoints(const bool displayed) { - if (cardinalsPoints->getFlagShow16WCRLabels() != displayed) + if (cardinalPoints->getFlagShow16WCRLabels() != displayed) { - cardinalsPoints->setFlagShow16WCRLabels(displayed); - emit ordinals16WRPointsDisplayedChanged(displayed); + cardinalPoints->setFlagShow16WCRLabels(displayed); + emit ordinal16WRPointsDisplayedChanged(displayed); } } //! Get flag for displaying ordinal points -bool LandscapeMgr::getFlagOrdinals16WRPoints() const +bool LandscapeMgr::getFlagOrdinal16WRPoints() const { - return cardinalsPoints->getFlagShow16WCRLabels(); + return cardinalPoints->getFlagShow16WCRLabels(); } //! Set Cardinals Points color @@ -1115,15 +1136,15 @@ void LandscapeMgr::setColorCardinalPoints(const Vec3f& v) { if(v != getColorCardinalPoints()) { - cardinalsPoints->setColor(v); - emit cardinalsPointsColorChanged(v); + cardinalPoints->setColor(v); + emit cardinalPointsColorChanged(v); } } //! Get Cardinals Points color Vec3f LandscapeMgr::getColorCardinalPoints() const { - return cardinalsPoints->getColor(); + return cardinalPoints->getColor(); } /////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/modules/LandscapeMgr.hpp b/src/core/modules/LandscapeMgr.hpp index 6450301787917..be41c0e7c1b24 100644 --- a/src/core/modules/LandscapeMgr.hpp +++ b/src/core/modules/LandscapeMgr.hpp @@ -84,7 +84,8 @@ class Cardinals class StelPropertyMgr* propMgr; QFont font4WCR, font8WCR, font16WCR; Vec3f color; - QMap rose4winds, rose8winds, rose16winds; + static constexpr float cp = static_cast(1./(1.+M_SQRT2)); // dimension for secondary intercardinals + static const QMap rose4winds, rose8winds, rose16winds; QMap labels; LinearFader fader4WCR, fader8WCR, fader16WCR; int screenFontSize; @@ -116,22 +117,22 @@ class LandscapeMgr : public StelModule READ getFlagAtmosphereNoScatter WRITE setFlagAtmosphereNoScatter NOTIFY atmosphereNoScatterChanged) - Q_PROPERTY(bool cardinalsPointsDisplayed - READ getFlagCardinalsPoints - WRITE setFlagCardinalsPoints - NOTIFY cardinalsPointsDisplayedChanged) - Q_PROPERTY(bool ordinalsPointsDisplayed - READ getFlagOrdinalsPoints - WRITE setFlagOrdinalsPoints - NOTIFY ordinalsPointsDisplayedChanged) - Q_PROPERTY(bool ordinals16WRPointsDisplayed - READ getFlagOrdinals16WRPoints - WRITE setFlagOrdinals16WRPoints - NOTIFY ordinals16WRPointsDisplayedChanged) - Q_PROPERTY(Vec3f cardinalsPointsColor + Q_PROPERTY(bool cardinalPointsDisplayed + READ getFlagCardinalPoints + WRITE setFlagCardinalPoints + NOTIFY cardinalPointsDisplayedChanged) + Q_PROPERTY(bool ordinalPointsDisplayed + READ getFlagOrdinalPoints + WRITE setFlagOrdinalPoints + NOTIFY ordinalPointsDisplayedChanged) + Q_PROPERTY(bool ordinal16WRPointsDisplayed + READ getFlagOrdinal16WRPoints + WRITE setFlagOrdinal16WRPoints + NOTIFY ordinal16WRPointsDisplayedChanged) + Q_PROPERTY(Vec3f cardinalPointsColor READ getColorCardinalPoints WRITE setColorCardinalPoints - NOTIFY cardinalsPointsColorChanged) + NOTIFY cardinalPointsColorChanged) Q_PROPERTY(bool fogDisplayed READ getFlagFog WRITE setFlagFog @@ -407,19 +408,19 @@ public slots: bool getFlagUseLightPollutionFromDatabase() const; //! Get flag for displaying cardinal points (4-wind compass rose directions) - bool getFlagCardinalsPoints() const; + bool getFlagCardinalPoints() const; //! Set flag for displaying cardinal points (4-wind compass rose directions) - void setFlagCardinalsPoints(const bool displayed); + void setFlagCardinalPoints(const bool displayed); //! Get flag for displaying intercardinal (or ordinal) points (8-wind compass rose directions). - bool getFlagOrdinalsPoints() const; + bool getFlagOrdinalPoints() const; //! Set flag for displaying intercardinal (or ordinal) points (8-wind compass rose directions). - void setFlagOrdinalsPoints(const bool displayed); + void setFlagOrdinalPoints(const bool displayed); //! Get flag for displaying intercardinal (or ordinal) points (16-wind compass rose directions). - bool getFlagOrdinals16WRPoints() const; + bool getFlagOrdinal16WRPoints() const; //! Set flag for displaying intercardinal (or ordinal) points (16-wind compass rose directions). - void setFlagOrdinals16WRPoints(const bool displayed); + void setFlagOrdinal16WRPoints(const bool displayed); //! Get Cardinals Points color. Vec3f getColorCardinalPoints() const; @@ -559,10 +560,10 @@ public slots: signals: void atmosphereDisplayedChanged(const bool displayed); void atmosphereNoScatterChanged(const bool noScatter); - void cardinalsPointsDisplayedChanged(const bool displayed); - void ordinalsPointsDisplayedChanged(const bool displayed); - void ordinals16WRPointsDisplayedChanged(const bool displayed); - void cardinalsPointsColorChanged(const Vec3f & newColor) const; + void cardinalPointsDisplayedChanged(const bool displayed); + void ordinalPointsDisplayedChanged(const bool displayed); + void ordinal16WRPointsDisplayedChanged(const bool displayed); + void cardinalPointsColorChanged(const Vec3f & newColor) const; void fogDisplayedChanged(const bool displayed); void landscapeDisplayedChanged(const bool displayed); void illuminationDisplayedChanged(const bool displayed); @@ -641,7 +642,7 @@ private slots: static QString getLandscapePath(const QString landscapeID); Atmosphere* atmosphere; // Atmosphere - Cardinals* cardinalsPoints; // Cardinals points + Cardinals* cardinalPoints; // Cardinals points Landscape* landscape; // The landscape i.e. the fog, the ground and "decor" Landscape* oldLandscape; // Used only during transitions to newly loaded landscape. diff --git a/src/core/modules/SpecialMarkersMgr.cpp b/src/core/modules/SpecialMarkersMgr.cpp index 04e2ac57aa171..6983405c2430a 100644 --- a/src/core/modules/SpecialMarkersMgr.cpp +++ b/src/core/modules/SpecialMarkersMgr.cpp @@ -40,7 +40,7 @@ class SpecialSkyMarker COMPASS_MARKS }; SpecialSkyMarker(SKY_MARKER_TYPE _marker_type = FOV_CENTER); - virtual ~SpecialSkyMarker(); + virtual ~SpecialSkyMarker(){} void draw(StelCore* core) const; void setColor(const Vec3f& c) {color = c;} const Vec3f& getColor() const {return color;} @@ -77,11 +77,6 @@ SpecialSkyMarker::SpecialSkyMarker(SKY_MARKER_TYPE _marker_type) : marker_type(_ } } -SpecialSkyMarker::~SpecialSkyMarker() -{ - // -} - void SpecialSkyMarker::draw(StelCore *core) const { if (fader.getInterstate()<=0.0001f) @@ -178,28 +173,38 @@ void SpecialSkyMarker::draw(StelCore *core) const for(int i=0; i<360; i++) { - double a = i*M_PI/180; + double a = i*(M_PI/180); pos.set(sin(a),cos(a), 0.); - double h = -0.002; + double h = 6.; // height of tickmark endpoint, arcminutes if (i % 15 == 0) { - h = -0.02; // the size of the mark every 15 degrees - - QString s = QString("%1").arg((i+90+f)%360); - - float shiftx = ppx*sPainter.getFontMetrics().boundingRect(s).width() *0.5f; - float shifty = ppx*sPainter.getFontMetrics().height() *0.5f; - sPainter.drawText(pos, s, 0, -shiftx, shifty); + h = 15.; // the size of the mark every 15 degrees remains small: it is labeled! + + QString s = QString("%1°").arg((i+90+f)%360); + + Vec3d target(pos[0], pos[1], tan(h/60.*M_PI/180.)); target.normalize(); + Vec3d screenPos, screenTgt; + prj->project(pos, screenPos); + prj->project(target, screenTgt); + double dx=screenTgt[0]-screenPos[0]; + double dy=screenTgt[1]-screenPos[1]; + float textAngle=static_cast(atan2(dx, dy)); + float wx = ppx*sPainter.getFontMetrics().boundingRect(s).width() *0.5f; + float wy = ppx*sPainter.getFontMetrics().height() *0.25f; + + // Gravity labels look outright terrible here! Disable them. + sPainter.drawText(target, s, -textAngle*180.f/M_PI, -wx, wy, true); } else if (i % 5 == 0) { - h = -0.01; // the size of the mark every 5 degrees + h = 30.; // the size of the mark every 5 degrees } // Limit arcs to those that are visible for improved performance if (prj->project(pos, screenPos) && screenPos[0]>prj->getViewportPosX() && screenPos[0] < prj->getViewportPosX() + prj->getViewportWidth()) { - sPainter.drawGreatCircleArc(pos, Vec3d(pos[0], pos[1], h), Q_NULLPTR); + Vec3d target(pos[0], pos[1], tan(h/60.*M_PI/180.)); target.normalize(); + sPainter.drawGreatCircleArc(pos, target, Q_NULLPTR); } } } diff --git a/src/gui/ConfigurationDialog.cpp b/src/gui/ConfigurationDialog.cpp index 74158c378357a..4c1c475ce6d2a 100644 --- a/src/gui/ConfigurationDialog.cpp +++ b/src/gui/ConfigurationDialog.cpp @@ -922,9 +922,9 @@ void ConfigurationDialog::saveAllSettings() conf->setValue("viewing/flag_galactic_equator_line", propMgr->getStelPropertyValue("GridLinesMgr.galacticEquatorLineDisplayed").toBool()); conf->setValue("viewing/flag_galactic_equator_parts", propMgr->getStelPropertyValue("GridLinesMgr.galacticEquatorPartsDisplayed").toBool()); conf->setValue("viewing/flag_galactic_equator_labels", propMgr->getStelPropertyValue("GridLinesMgr.galacticEquatorPartsLabeled").toBool()); - conf->setValue("viewing/flag_cardinal_points", propMgr->getStelPropertyValue("LandscapeMgr.cardinalsPointsDisplayed").toBool()); - conf->setValue("viewing/flag_ordinal_points", propMgr->getStelPropertyValue("LandscapeMgr.ordinalsPointsDisplayed").toBool()); - conf->setValue("viewing/flag_16wcr_points", propMgr->getStelPropertyValue("LandscapeMgr.ordinals16WRPointsDisplayed").toBool()); + conf->setValue("viewing/flag_cardinal_points", propMgr->getStelPropertyValue("LandscapeMgr.cardinalPointsDisplayed").toBool()); + conf->setValue("viewing/flag_ordinal_points", propMgr->getStelPropertyValue("LandscapeMgr.ordinalPointsDisplayed").toBool()); + conf->setValue("viewing/flag_16wcr_points", propMgr->getStelPropertyValue("LandscapeMgr.ordinal16WRPointsDisplayed").toBool()); conf->setValue("viewing/flag_compass_marks", propMgr->getStelPropertyValue("SpecialMarkersMgr.compassMarksDisplayed").toBool()); conf->setValue("viewing/flag_prime_vertical_line", propMgr->getStelPropertyValue("GridLinesMgr.primeVerticalLineDisplayed").toBool()); conf->setValue("viewing/flag_prime_vertical_parts", propMgr->getStelPropertyValue("GridLinesMgr.primeVerticalPartsDisplayed").toBool()); diff --git a/src/gui/StelGui.cpp b/src/gui/StelGui.cpp index 81ed86dcac4b7..115a8c7ba145e 100644 --- a/src/gui/StelGui.cpp +++ b/src/gui/StelGui.cpp @@ -585,7 +585,7 @@ void StelGui::update() if (getAction("actionShow_Asterism_Labels")->isChecked() != flag) getAction("actionShow_Asterism_Labels")->setChecked(flag); - flag = propMgr->getProperty("LandscapeMgr.cardinalsPointsDisplayed")->getValue().toBool(); + flag = propMgr->getProperty("LandscapeMgr.cardinalPointsDisplayed")->getValue().toBool(); if (getAction("actionShow_Cardinal_Points")->isChecked() != flag) getAction("actionShow_Cardinal_Points")->setChecked(flag); diff --git a/src/gui/ViewDialog.cpp b/src/gui/ViewDialog.cpp index c3b1479c77f11..e1a8a1499ae5c 100644 --- a/src/gui/ViewDialog.cpp +++ b/src/gui/ViewDialog.cpp @@ -469,7 +469,7 @@ void ViewDialog::createDialogContent() connectColorButton(ui->colorFOVCenterMarker, "SpecialMarkersMgr.fovCenterMarkerColor", "color/fov_center_marker_color"); connectColorButton(ui->colorFOVCircularMarker, "SpecialMarkersMgr.fovCircularMarkerColor", "color/fov_circular_marker_color"); connectColorButton(ui->colorFOVRectangularMarker, "SpecialMarkersMgr.fovRectangularMarkerColor", "color/fov_rectangular_marker_color"); - connectColorButton(ui->colorCardinalPoints, "LandscapeMgr.cardinalsPointsColor", "color/cardinal_color"); + connectColorButton(ui->colorCardinalPoints, "LandscapeMgr.cardinalPointsColor", "color/cardinal_color"); connectColorButton(ui->colorCompassMarks, "SpecialMarkersMgr.compassMarksColor", "color/compass_marks_color"); connect(ui->showCardinalPointsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setSelectedCardinalCheckBoxes())); @@ -624,13 +624,13 @@ void ViewDialog::updateHips() if (props.contains("obs_copyright") && props.contains("obs_copyright_url")) { html += QString("

Copyright %1

\n") - .arg(props["obs_copyright"].toString()).arg(props["obs_copyright_url"].toString()); + .arg(props["obs_copyright"].toString(), props["obs_copyright_url"].toString()); } html += QString("

%1

\n").arg(props["obs_description"].toString()); html += "

" + q_("properties") + "

\n
    \n"; for (auto iter = props.constBegin(); iter != props.constEnd(); iter++) { - html += QString("
  • %1 %2
  • \n").arg(iter.key()).arg(iter.value().toString()); + html += QString("
  • %1 %2
  • \n").arg(iter.key(), iter.value().toString()); } html += "
\n"; if (gui) @@ -707,15 +707,15 @@ void ViewDialog::updateTabBarListWidgetWidth() void ViewDialog::setSelectedCardinalCheckBoxes() { StelPropertyMgr* propMgr = StelApp::getInstance().getStelPropertyManager(); - bool cardinals = propMgr->getProperty("LandscapeMgr.cardinalsPointsDisplayed")->getValue().toBool(); - bool ordinals = propMgr->getProperty("LandscapeMgr.ordinalsPointsDisplayed")->getValue().toBool(); + bool cardinals = propMgr->getProperty("LandscapeMgr.cardinalPointsDisplayed")->getValue().toBool(); + bool ordinals = propMgr->getProperty("LandscapeMgr.ordinalPointsDisplayed")->getValue().toBool(); ui->showOrdinal8WRPointsCheckBox->setEnabled(cardinals); ui->showOrdinal16WRPointsCheckBox->setEnabled(cardinals && ordinals); } void ViewDialog::setSelectedCatalogsFromCheckBoxes() { - Nebula::CatalogGroup flags(Q_NULLPTR); + Nebula::CatalogGroup flags(Nebula::CatNone); if (ui->checkBoxNGC->isChecked()) flags |= Nebula::CatNGC; if (ui->checkBoxIC->isChecked()) @@ -782,7 +782,7 @@ void ViewDialog::setSelectedCatalogsFromCheckBoxes() void ViewDialog::setSelectedTypesFromCheckBoxes() { - Nebula::TypeGroup flags(Q_NULLPTR); + Nebula::TypeGroup flags(Nebula::TypeNone); if (ui->checkBoxGalaxiesType->isChecked()) flags |= Nebula::TypeGalaxies; if (ui->checkBoxActiveGalaxiesType->isChecked()) diff --git a/src/scripting/StelMainScriptAPI.cpp b/src/scripting/StelMainScriptAPI.cpp index 83ae8febf9bc1..9fcc9050d6748 100644 --- a/src/scripting/StelMainScriptAPI.cpp +++ b/src/scripting/StelMainScriptAPI.cpp @@ -1016,7 +1016,7 @@ void StelMainScriptAPI::clear(const QString& state) ssmgr->setFlagMoonScale(false); ssmgr->setFlagMinorBodyScale(false); ssmgr->setFlagTrails(false); - lmgr->setFlagCardinalsPoints(false); + lmgr->setFlagCardinalPoints(false); amgr->setFlagLines(false); amgr->setFlagLabels(false); amgr->setFlagRayHelpers(false);