Skip to content

Commit

Permalink
Added new visual filter for satellites (fix #1527; fix #2060)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-w committed Jun 22, 2022
1 parent e8b13ed commit e762b56
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 8 deletions.
24 changes: 20 additions & 4 deletions plugins/Satellites/src/Satellite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ double Satellite::maxCFRCS = 100.;
bool Satellite::flagVFAltitude = false;
double Satellite::minVFAltitude = 200.;
double Satellite::maxVFAltitude = 500.;
bool Satellite::flagVFMagnitude = false;
double Satellite::minVFMagnitude = 8.;
double Satellite::maxVFMagnitude = -8.;

#if (SATELLITES_PLUGIN_IRIDIUM == 1)
double Satellite::sunReflAngle = 180.;
Expand Down Expand Up @@ -291,12 +294,16 @@ QVariantMap Satellite::getMap(void)
return map;
}

float Satellite::getSelectPriority(const StelCore*) const
float Satellite::getSelectPriority(const StelCore* core) const
{
float limit = -10.f;
if (flagVFAltitude) // the visual filter is enabled
return (minVFAltitude<=height && height<=maxVFAltitude) ? -10. : 50.;
limit = (minVFAltitude<=height && height<=maxVFAltitude) ? -10.f : 50.f;

return -10.;
if (flagVFMagnitude) // the visual filter is enabled
limit = ((maxVFMagnitude<=getVMagnitude(core) && getVMagnitude(core)<=minVFMagnitude) && (stdMag<99. || RCS>0.)) ? -10.f : 50.f;

return limit;
}

QString Satellite::getInfoString(const StelCore *core, const InfoStringGroup& flags) const
Expand Down Expand Up @@ -1001,6 +1008,16 @@ void Satellite::draw(StelCore* core, StelPainter& painter)
return;
}

const float magSat = getVMagnitude(core);
if (flagVFMagnitude)
{
// visual filter is activated and he is applicable!
if (!(stdMag<99. || RCS>0.))
return;
if (!(maxVFMagnitude<=magSat && magSat<=minVFMagnitude))
return;
}

Vec3d win;
if (painter.getProjector()->projectCheck(XYZ, win))
{
Expand Down Expand Up @@ -1028,7 +1045,6 @@ void Satellite::draw(StelCore* core, StelPainter& painter)
}
else
{
const float magSat = getVMagnitude(core);
StelSkyDrawer* sd = core->getSkyDrawer();
RCMag rcMag;

Expand Down
3 changes: 3 additions & 0 deletions plugins/Satellites/src/Satellite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ class Satellite : public StelObject
static bool flagVFAltitude;
static double minVFAltitude;
static double maxVFAltitude;
static bool flagVFMagnitude;
static double minVFMagnitude;
static double maxVFMagnitude;

void draw(StelCore *core, StelPainter& painter);

Expand Down
27 changes: 27 additions & 0 deletions plugins/Satellites/src/Satellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@ void Satellites::loadSettings()
setFlagVFAltitude(conf->value("vf_altitude_flag", false).toBool());
setMinVFAltitude(conf->value("vf_altitude_min", 200.).toDouble());
setMaxVFAltitude(conf->value("vf_altitude_max", 500.).toDouble());
setFlagVFMagnitude(conf->value("vf_magnitude_flag", false).toBool());
setMinVFMagnitude(conf->value("vf_magnitude_min", 8.).toDouble());
setMaxVFMagnitude(conf->value("vf_magnitude_max", -8.).toDouble());

conf->endGroup();
}
Expand Down Expand Up @@ -934,6 +937,9 @@ void Satellites::saveSettingsToConfig()
conf->setValue("vf_altitude_flag", getFlagVFAltitude());
conf->setValue("vf_altitude_min", getMinVFAltitude());
conf->setValue("vf_altitude_max", getMaxVFAltitude());
conf->setValue("vf_magnitude_flag", getFlagVFMagnitude());
conf->setValue("vf_magnitude_min", getMinVFMagnitude());
conf->setValue("vf_magnitude_max", getMaxVFMagnitude());

conf->endGroup();

Expand Down Expand Up @@ -1923,6 +1929,27 @@ void Satellites::setMaxVFAltitude(double v)
emit maxVFAltitudeChanged(v);
}

void Satellites::setFlagVFMagnitude(bool b)
{
if (Satellite::flagVFMagnitude != b)
{
Satellite::flagVFMagnitude = b;
emit flagVFMagnitudeChanged(b);
}
}

void Satellites::setMinVFMagnitude(double v)
{
Satellite::minVFMagnitude = v;
emit minVFMagnitudeChanged(v);
}

void Satellites::setMaxVFMagnitude(double v)
{
Satellite::maxVFMagnitude = v;
emit maxVFMagnitudeChanged(v);
}

void Satellites::setFlagCFEccentricity(bool b)
{
if (Satellite::flagCFEccentricity != b)
Expand Down
26 changes: 22 additions & 4 deletions plugins/Satellites/src/Satellites.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ class Satellites : public StelObjectModule
Q_PROPERTY(bool flagVFAltitude READ getFlagVFAltitude WRITE setFlagVFAltitude NOTIFY flagVFAltitudeChanged)
Q_PROPERTY(double minVFAltitude READ getMinVFAltitude WRITE setMinVFAltitude NOTIFY minVFAltitudeChanged)
Q_PROPERTY(double maxVFAltitude READ getMaxVFAltitude WRITE setMaxVFAltitude NOTIFY maxVFAltitudeChanged)
Q_PROPERTY(bool flagVFMagnitude READ getFlagVFMagnitude WRITE setFlagVFMagnitude NOTIFY flagVFMagnitudeChanged)
Q_PROPERTY(double minVFMagnitude READ getMinVFMagnitude WRITE setMinVFMagnitude NOTIFY minVFMagnitudeChanged)
Q_PROPERTY(double maxVFMagnitude READ getMaxVFMagnitude WRITE setMaxVFMagnitude NOTIFY maxVFMagnitudeChanged)


public:
Expand Down Expand Up @@ -443,10 +446,7 @@ class Satellites : public StelObjectModule
void maxCFApogeeChanged(double v);
void flagCFPerigeeChanged(bool b);
void minCFPerigeeChanged(double v);
void maxCFPerigeeChanged(double v);
void flagVFAltitudeChanged(bool b);
void minVFAltitudeChanged(double v);
void maxVFAltitudeChanged(double v);
void maxCFPerigeeChanged(double v);
void flagCFEccentricityChanged(bool b);
void minCFEccentricityChanged(double v);
void maxCFEccentricityChanged(double v);
Expand All @@ -459,6 +459,12 @@ class Satellites : public StelObjectModule
void flagCFRCSChanged(bool b);
void minCFRCSChanged(double v);
void maxCFRCSChanged(double v);
void flagVFAltitudeChanged(bool b);
void minVFAltitudeChanged(double v);
void maxVFAltitudeChanged(double v);
void flagVFMagnitudeChanged(bool b);
void minVFMagnitudeChanged(double v);
void maxVFMagnitudeChanged(double v);

//! Emitted when some of the plugin settings have been changed.
//! Used to communicate with the configuration window.
Expand Down Expand Up @@ -682,6 +688,18 @@ public slots:
void setMinVFAltitude(double v);
double getMinVFAltitude() { return Satellite::minVFAltitude; }

//! Set whether visual filter 'magnitude' enabled.
void setFlagVFMagnitude(bool b);
bool getFlagVFMagnitude() { return Satellite::flagVFMagnitude; }

//! Set visual filter 'magnitude' maximum value.
void setMaxVFMagnitude(double v);
double getMaxVFMagnitude() { return Satellite::maxVFMagnitude; }

//! Set visual filter 'magnitude' minimum value.
void setMinVFMagnitude(double v);
double getMinVFMagnitude() { return Satellite::minVFMagnitude; }

//! Set whether custom filter 'eccentricity' enabled.
//! Emits customFilterChanged()
void setFlagCFEccentricity(bool b);
Expand Down
14 changes: 14 additions & 0 deletions plugins/Satellites/src/gui/SatellitesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ void SatellitesDialog::createDialogContent()
connectDoubleProperty(ui->maxAltitude, "Satellites.maxVFAltitude");
enableMinMaxAltitude(ui->altitudeCheckBox->isChecked());
connect(ui->altitudeCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableMinMaxAltitude(bool)));
// Logic sub-group: Visual filter / Magnitude range
connectBoolProperty(ui->magnitudeCheckBox, "Satellites.flagVFMagnitude");
connectDoubleProperty(ui->minMagnitude, "Satellites.minVFMagnitude");
connectDoubleProperty(ui->maxMagnitude, "Satellites.maxVFMagnitude");
enableMinMaxMagnitude(ui->magnitudeCheckBox->isChecked());
connect(ui->magnitudeCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableMinMaxMagnitude(bool)));

connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(restoreDefaults()));
connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSettings()));
Expand Down Expand Up @@ -328,6 +334,12 @@ void SatellitesDialog::enableMinMaxAltitude(bool state)
ui->maxAltitude->setEnabled(state);
}

void SatellitesDialog::enableMinMaxMagnitude(bool state)
{
ui->minMagnitude->setEnabled(state);
ui->maxMagnitude->setEnabled(state);
}

void SatellitesDialog::handleOrbitLinesGroup(bool state)
{
ui->orbitSegmentsSpin->setEnabled(state);
Expand Down Expand Up @@ -1158,6 +1170,8 @@ void SatellitesDialog::populateInfo()
ui->orbitSegmentsSpin->setToolTip(QString("<p>%1. %2: %3..%4</p>").arg(q_("Number of segments: number of segments used to draw the line"), vr, QString::number(ui->orbitSegmentsSpin->minimum()), QString::number(ui->orbitSegmentsSpin->maximum())));
ui->orbitDurationSpin->setToolTip(QString("<p>%1. %2: %3..%4 %5</p>").arg(q_("Segment length: duration of a single segment in seconds"), vr, QString::number(ui->orbitDurationSpin->minimum()), QString::number(ui->orbitDurationSpin->maximum()), s));
ui->orbitFadeSpin->setToolTip(QString("<p>%1. %2: %3..%4</p>").arg(q_("Fade length: number of segments used to draw each end of the line"), vr, QString::number(ui->orbitFadeSpin->minimum()), QString::number(ui->orbitFadeSpin->maximum())));
ui->minMagnitude->setToolTip(QString("%1: %2..%3").arg(vr, QString::number(ui->minMagnitude->minimum(), 'f', 2), QString::number(ui->minMagnitude->maximum(), 'f', 2)));
ui->maxMagnitude->setToolTip(QString("%1: %2..%3").arg(vr, QString::number(ui->maxMagnitude->minimum(), 'f', 2), QString::number(ui->maxMagnitude->maximum(), 'f', 2)));
}

void SatellitesDialog::populateSourcesList()
Expand Down
1 change: 1 addition & 0 deletions plugins/Satellites/src/gui/SatellitesDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private slots:
void setRightSideToRWMode();

void enableMinMaxAltitude(bool state);
void enableMinMaxMagnitude(bool state);

private:
//! @todo find out if this is really necessary... --BM
Expand Down
37 changes: 37 additions & 0 deletions plugins/Satellites/src/gui/satellitesDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,43 @@
</property>
</spacer>
</item>
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QCheckBox" name="magnitudeCheckBox">
<property name="text">
<string>Magnitude range</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="maxMagnitude">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-12.000000000000000</double>
</property>
<property name="maximum">
<double>20.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="minMagnitude">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-12.000000000000000</double>
</property>
<property name="maximum">
<double>20.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit e762b56

Please sign in to comment.