diff --git a/src/core/modules/GridLinesMgr.cpp b/src/core/modules/GridLinesMgr.cpp index 74ce57ea915dc..d2f6e1e237708 100644 --- a/src/core/modules/GridLinesMgr.cpp +++ b/src/core/modules/GridLinesMgr.cpp @@ -87,7 +87,9 @@ class SkyPoint SOLSTICES_OF_DATE, ANTISOLAR, EARTH_UMBRA_CENTER, - APEX + APEX, + LAGRANGE_SOLAR, + LAGRANGE_LUNAR }; // Create and precompute positions of a SkyGrid SkyPoint(SKY_POINT_TYPE _point_type = CELESTIALPOLES_J2000); @@ -103,7 +105,7 @@ class SkyPoint //! Re-translates the label. void updateLabel(); private: - QSharedPointer earth, sun; + QSharedPointer earth, sun, moon; SKY_POINT_TYPE point_type; Vec3f color; StelCore::FrameType frameType; @@ -1479,6 +1481,7 @@ SkyPoint::SkyPoint(SKY_POINT_TYPE _point_type) : point_type(_point_type), color( earth = GETSTELMODULE(SolarSystem)->getEarth(); sun = GETSTELMODULE(SolarSystem)->getSun(); + moon = GETSTELMODULE(SolarSystem)->getMoon(); updateLabel(); } @@ -1634,7 +1637,25 @@ void SkyPoint::updateLabel() southernLabel += speedStr; } break; - } + } + case LAGRANGE_SOLAR: + { + frameType = StelCore::FrameHeliocentricEclipticJ2000; + // TRANSLATORS: Lagrange point L4 + northernLabel = q_("L4 (Sun-Planet)"); + // TRANSLATORS: Lagrange point L5 + southernLabel = q_("L5 (Sun-Planet)"); + break; + } + case LAGRANGE_LUNAR: + { + frameType = StelCore::FrameObservercentricEclipticJ2000; + // TRANSLATORS: Lagrange point L4 + northernLabel = q_("L4 (Earth-Moon)"); + // TRANSLATORS: Lagrange point L5 + southernLabel = q_("L5 (Earth-Moon)"); + break; + } default: Q_ASSERT(0); } @@ -1756,7 +1777,52 @@ void SkyPoint::draw(StelCore *core) const sPainter.drawText(-dir, southernLabel, 0, shift, shift, false); } break; - } + } + case LAGRANGE_SOLAR: + { + QSharedPointer observerPlanet = core->getCurrentObserver()->getHomePlanet(); + if (observerPlanet->getPlanetType() == Planet::isObserver) + { + observerPlanet = observerPlanet->getParent(); + } + // Takes the positional vector of the planet from the solar object + Vec3d pos= observerPlanet->getHeliocentricEclipticPos(); + // Creates points by adding/subtracting 60 degrees to the vector along the common plane + // Vector orthogonal to pos vector, which should have z=0 + Vec3d orth = Vec3d(pos.v[0]*cos(M_PI/2)-pos.v[1]*sin(M_PI/2),pos.v[1]*cos(M_PI/2)+pos.v[0]*sin(M_PI/2),0); + // Normal to the plane + Vec3d normal = pos^orth; + normal.normalize(); + Vec3d l4 = cos(M_PI/3)*pos + sin(M_PI/3)*(normal^pos); + Vec3d l5 = cos(-M_PI/3)*pos + sin(-M_PI/3)*(normal^pos); + + sPainter.drawSprite2dMode(l4, 5.f); + sPainter.drawText(l4, northernLabel, 0, shift, shift, false); + sPainter.drawSprite2dMode(l5, 5.f); + sPainter.drawText(l5, southernLabel, 0, shift, shift, false); + + break; + } + case LAGRANGE_LUNAR: + { + // Takes the positional vector of the moon from the earth + const Vec3d pos = moon->getEclipticPos(); + // Creates points by adding/subtracting 60 degrees to the vector along the common plane + // Vector orthogonal to pos vector, which should have z=0 + Vec3d orth = Vec3d(pos.v[0]*cos(M_PI/2)-pos.v[1]*sin(M_PI/2),pos.v[1]*cos(M_PI/2)+pos.v[0]*sin(M_PI/2),0); + // Normal to the plane + Vec3d normal = pos^orth; + normal.normalize(); + Vec3d l4 = cos(M_PI/3)*pos + sin(M_PI/3)*(normal^pos); + Vec3d l5 = cos(-M_PI/3)*pos + sin(-M_PI/3)*(normal^pos); + + sPainter.drawSprite2dMode(l4, 5.f); + sPainter.drawText(l4, northernLabel, 0, shift, shift, false); + sPainter.drawSprite2dMode(l5, 5.f); + sPainter.drawText(l5, southernLabel, 0, shift, shift, false); + + break; + } default: Q_ASSERT(0); } @@ -1816,6 +1882,8 @@ GridLinesMgr::GridLinesMgr() antisolarPoint = new SkyPoint(SkyPoint::ANTISOLAR); umbraCenterPoint = new SkyPoint(SkyPoint::EARTH_UMBRA_CENTER); apexPoints = new SkyPoint(SkyPoint::APEX); + lagrangePointsSolar = new SkyPoint(SkyPoint::LAGRANGE_SOLAR); + lagrangePointsLunar = new SkyPoint(SkyPoint::LAGRANGE_LUNAR); earth = GETSTELMODULE(SolarSystem)->getEarth(); connect(GETSTELMODULE(SolarSystem), SIGNAL(solarSystemDataReloaded()), this, SLOT(connectSolarSystem())); @@ -1876,7 +1944,9 @@ GridLinesMgr::~GridLinesMgr() delete solsticePoints; delete antisolarPoint; delete umbraCenterPoint; - delete apexPoints; + delete apexPoints; + delete lagrangePointsSolar; + delete lagrangePointsLunar; SkyLine::deinit(); } @@ -1977,6 +2047,8 @@ void GridLinesMgr::init() setFlagAntisolarPoint(conf->value("viewing/flag_antisolar_point").toBool()); setFlagUmbraCenterPoint(conf->value("viewing/flag_umbra_center_point").toBool()); setFlagApexPoints(conf->value("viewing/flag_apex_points").toBool()); + setFlagLagrangePointsSolar(conf->value("viewing/flag_lagrange_points_solar").toBool()); + setFlagLagrangePointsLunar(conf->value("viewing/flag_lagrange_points_lunar").toBool()); // Set the line thickness for grids and lines setLineThickness(conf->value("viewing/line_thickness", 1.f).toFloat()); @@ -2026,6 +2098,8 @@ void GridLinesMgr::init() setColorSolsticePoints( Vec3f(conf->value("color/solstice_points_color", defaultColor).toString())); setColorAntisolarPoint( Vec3f(conf->value("color/antisolar_point_color", defaultColor).toString())); setColorApexPoints( Vec3f(conf->value("color/apex_points_color", defaultColor).toString())); + setColorLagrangePointsSolar( Vec3f(conf->value("color/lagrange_points_solar_color", defaultColor).toString())); + setColorLagrangePointsLunar( Vec3f(conf->value("color/lagrange_points_lunar_color", defaultColor).toString())); StelApp& app = StelApp::getInstance(); connect(&app, SIGNAL(languageChanged()), this, SLOT(updateLabels())); @@ -2076,6 +2150,8 @@ void GridLinesMgr::init() addAction("actionShow_Antisolar_Point", displayGroup, N_("Antisolar point"), "antisolarPointDisplayed"); addAction("actionShow_Umbra_Center_Point", displayGroup, N_("The center of the Earth's umbra"), "umbraCenterPointDisplayed"); addAction("actionShow_Apex_Points", displayGroup, N_("Apex points"), "apexPointsDisplayed"); + addAction("actionShow_Lagrange_Points_Solar", displayGroup, N_("Sun-planet lagrange points"), "lagrangePointsSolarDisplayed"); + addAction("actionShow_Lagrange_Points_Lunar", displayGroup, N_("Earth-Moon lagrange points"), "lagrangePointsLunarDisplayed"); } void GridLinesMgr::connectSolarSystem() @@ -2135,6 +2211,8 @@ void GridLinesMgr::update(double deltaTime) antisolarPoint->update(deltaTime); umbraCenterPoint->update(deltaTime); apexPoints->update(deltaTime); + lagrangePointsSolar->update(deltaTime); + lagrangePointsLunar->update(deltaTime); apexPoints->updateLabel(); } @@ -2181,6 +2259,7 @@ void GridLinesMgr::draw(StelCore* core) longitudeLine->draw(core); quadratureLine->draw(core); umbraCenterPoint->draw(core); + lagrangePointsLunar->draw(core); } circumpolarCircleN->draw(core); circumpolarCircleS->draw(core); @@ -2208,7 +2287,7 @@ void GridLinesMgr::draw(StelCore* core) solsticeJ2000Points->draw(core); celestialJ2000Poles->draw(core); celestialPoles->draw(core); - + lagrangePointsSolar->draw(core); zenithNadir->draw(core); } @@ -2252,7 +2331,9 @@ void GridLinesMgr::updateLabels() solsticePoints->updateLabel(); antisolarPoint->updateLabel(); umbraCenterPoint->updateLabel(); - apexPoints->updateLabel(); + apexPoints->updateLabel(); + lagrangePointsSolar->updateLabel(); + lagrangePointsLunar->updateLabel(); } //! Setter ("master switch") for displaying any grid/line. @@ -2326,6 +2407,8 @@ void GridLinesMgr::setFlagAllPoints(const bool displayed) setFlagSolsticeJ2000Points(displayed); setFlagApexPoints(displayed); setFlagUmbraCenterPoint(displayed); + setFlagLagrangePointsSolar(displayed); + setFlagLagrangePointsLunar(displayed); } //! Set flag for displaying Azimuthal Grid @@ -3920,6 +4003,60 @@ void GridLinesMgr::setColorApexPoints(const Vec3f& newColor) } } +//! Set flag for displaying vector point +void GridLinesMgr::setFlagLagrangePointsSolar(const bool displayed) +{ + if(displayed != lagrangePointsSolar->isDisplayed()) + { + lagrangePointsSolar->setDisplayed(displayed); + emit lagrangePointsSolarDisplayedChanged(displayed); + } +} +//! Get flag for displaying vector point +bool GridLinesMgr::getFlagLagrangePointsSolar() const +{ + return lagrangePointsSolar->isDisplayed(); +} +Vec3f GridLinesMgr::getColorLagrangePointsSolar() const +{ + return lagrangePointsSolar->getColor(); +} +void GridLinesMgr::setColorLagrangePointsSolar(const Vec3f& newColor) +{ + if(newColor != lagrangePointsSolar->getColor()) + { + lagrangePointsSolar->setColor(newColor); + emit lagrangePointsSolarColorChanged(newColor); + } +} + +//! Set flag for displaying vector point +void GridLinesMgr::setFlagLagrangePointsLunar(const bool displayed) +{ + if(displayed != lagrangePointsLunar->isDisplayed()) + { + lagrangePointsLunar->setDisplayed(displayed); + emit lagrangePointsLunarDisplayedChanged(displayed); + } +} +//! Get flag for displaying vector point +bool GridLinesMgr::getFlagLagrangePointsLunar() const +{ + return lagrangePointsLunar->isDisplayed(); +} +Vec3f GridLinesMgr::getColorLagrangePointsLunar() const +{ + return lagrangePointsLunar->getColor(); +} +void GridLinesMgr::setColorLagrangePointsLunar(const Vec3f& newColor) +{ + if(newColor != lagrangePointsLunar->getColor()) + { + lagrangePointsLunar->setColor(newColor); + emit lagrangePointsLunarColorChanged(newColor); + } +} + void GridLinesMgr::setLineThickness(const float thickness) { float lineThickness = equGrid->getLineThickness(); @@ -4059,5 +4196,7 @@ void GridLinesMgr::setFontSizeFromApp(int size) solsticeJ2000Points->setFontSize(pointFontSize); solsticePoints->setFontSize(pointFontSize); apexPoints->setFontSize(pointFontSize); + lagrangePointsSolar->setFontSize(pointFontSize); + lagrangePointsLunar->setFontSize(pointFontSize); umbraCenterPoint->setFontSize(pointFontSize); } diff --git a/src/core/modules/GridLinesMgr.hpp b/src/core/modules/GridLinesMgr.hpp index 4e8b35bfdc782..33ddb8d55eb85 100644 --- a/src/core/modules/GridLinesMgr.hpp +++ b/src/core/modules/GridLinesMgr.hpp @@ -197,6 +197,12 @@ 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(bool lagrangePointsSolarDisplayed READ getFlagLagrangePointsSolar WRITE setFlagLagrangePointsSolar NOTIFY lagrangePointsSolarDisplayedChanged) + Q_PROPERTY(Vec3f lagrangePointsSolarColor READ getColorLagrangePointsSolar WRITE setColorLagrangePointsSolar NOTIFY lagrangePointsSolarColorChanged) + + Q_PROPERTY(bool lagrangePointsLunarDisplayed READ getFlagLagrangePointsLunar WRITE setFlagLagrangePointsLunar NOTIFY lagrangePointsLunarDisplayedChanged) + Q_PROPERTY(Vec3f lagrangePointsLunarColor READ getColorLagrangePointsLunar WRITE setColorLagrangePointsLunar NOTIFY lagrangePointsLunarColorChanged) + Q_PROPERTY(float lineThickness READ getLineThickness WRITE setLineThickness NOTIFY lineThicknessChanged) Q_PROPERTY(float partThickness READ getPartThickness WRITE setPartThickness NOTIFY partThicknessChanged) public: @@ -972,6 +978,16 @@ public slots: //! Get the thickness of lines float getPartThickness() const; + void setFlagLagrangePointsSolar(const bool displayed); + bool getFlagLagrangePointsSolar() const; + Vec3f getColorLagrangePointsSolar() const; + void setColorLagrangePointsSolar(const Vec3f& newColor); + + void setFlagLagrangePointsLunar(const bool displayed); + bool getFlagLagrangePointsLunar() const; + Vec3f getColorLagrangePointsLunar() const; + void setColorLagrangePointsLunar(const Vec3f& newColor); + signals: void gridlinesDisplayedChanged(const bool); void lineThicknessChanged(const float); @@ -1094,6 +1110,10 @@ public slots: void umbraCenterPointDisplayedChanged(const bool displayed); void apexPointsDisplayedChanged(const bool displayed); void apexPointsColorChanged(const Vec3f & newColor); + void lagrangePointsSolarDisplayedChanged(const bool displayed); + void lagrangePointsSolarColorChanged(const Vec3f & newColor); + void lagrangePointsLunarDisplayedChanged(const bool displayed); + void lagrangePointsLunarColorChanged(const Vec3f & newColor); private slots: //! Re-translate the labels of the great circles. @@ -1156,6 +1176,8 @@ private slots: SkyPoint * antisolarPoint; // Antisolar point SkyPoint * umbraCenterPoint; // The point of the center of umbra SkyPoint * apexPoints; // Apex and Antapex points, i.e. the point where the observer planet is moving to or receding from + SkyPoint * lagrangePointsSolar; // Earth-Sun lagrange points + SkyPoint * lagrangePointsLunar; }; #endif // GRIDLINESMGR_HPP diff --git a/src/gui/ViewDialog.cpp b/src/gui/ViewDialog.cpp index e7edd1f48b91a..f57ebe7e36cf8 100644 --- a/src/gui/ViewDialog.cpp +++ b/src/gui/ViewDialog.cpp @@ -401,6 +401,8 @@ void ViewDialog::createDialogContent() connectCheckBox(ui->showSolsticePointsCheckBox, "actionShow_Solstice_Points"); connectCheckBox(ui->showAntisolarPointCheckBox, "actionShow_Antisolar_Point"); connectCheckBox(ui->showApexPointsCheckBox, "actionShow_Apex_Points"); + connectCheckBox(ui->showLagrangePointsSolarCheckBox, "actionShow_Lagrange_Points_Solar"); + connectCheckBox(ui->showLagrangePointsLunarCheckBox, "actionShow_Lagrange_Points_Lunar"); connectCheckBox(ui->showFOVCenterMarkerCheckBox, "actionShow_FOV_Center_Marker"); connectCheckBox(ui->showFOVCircularMarkerCheckBox, "actionShow_FOV_Circular_Marker"); connectCheckBox(ui->showFOVRectangularMarkerCheckBox, "actionShow_FOV_Rectangular_Marker"); @@ -485,6 +487,8 @@ void ViewDialog::createDialogContent() connectColorButton(ui->colorSolsticePoints, "GridLinesMgr.solsticePointsColor", "color/solstice_points_color"); connectColorButton(ui->colorAntisolarPoint, "GridLinesMgr.antisolarPointColor", "color/antisolar_point_color"); connectColorButton(ui->colorApexPoints, "GridLinesMgr.apexPointsColor", "color/apex_points_color"); + connectColorButton(ui->colorLagrangePointsSolar, "GridLinesMgr.lagrangePointsSolarColor", "color/lagrange_points_solar_color"); + connectColorButton(ui->colorLagrangePointsLunar, "GridLinesMgr.lagrangePointsLunarColor", "color/lagrange_points_lunar_color"); 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"); diff --git a/src/gui/viewDialog.ui b/src/gui/viewDialog.ui index 72e440b547630..7e5a39f33af32 100644 --- a/src/gui/viewDialog.ui +++ b/src/gui/viewDialog.ui @@ -3821,6 +3821,26 @@ + + + + Color of Sun-Planet Lagrange points + + + + + + + + + + Color of Earth-Moon Lagrange points + + + + + + @@ -4065,6 +4085,26 @@ + + + + Sun-planet Lagrange points L4 and L5 + + + Sun-Planet Lagrange Points + + + + + + + Earth-Moon Lagrange points L4 and L5 + + + Earth-Moon Lagrange Points + + +