Skip to content
Merged
12 changes: 12 additions & 0 deletions data/gui/normalStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ QSizeGrip {
QTextEdit,
QPlainTextEdit,
QListWidget,
QTreeWidget,
QLineEdit {
border: 1px solid rgb(0, 0, 0);
border-radius: 0;
Expand All @@ -67,6 +68,7 @@ QLineEdit {

QTextEdit:disabled,
QListWidget:disabled,
QTreeWidget:disabled,
QLineEdit:disabled {
background: rgb(90, 90, 90);
}
Expand Down Expand Up @@ -424,69 +426,79 @@ QGroupBox::indicator {
* indicators, but there's a problem with spacing discussed at
* https://stackoverflow.com/q/77422984 */
QListWidget::indicator,
QTreeWidget::indicator,
QListView::indicator {
margin: 0;
background: none;
}

QCheckBox::indicator:checked,
QListWidget::indicator:checked,
QTreeWidget::indicator:checked,
QListView::indicator:checked,
QGroupBox::indicator:checked {
image: url(:/graphicGui/uieCheckbox-checked.png);
}

QCheckBox::indicator:indeterminate,
QListWidget::indicator:indeterminate,
QTreeWidget::indicator:indeterminate,
QListView::indicator:indeterminate,
QGroupBox::indicator:indeterminate {
image: url(:/graphicGui/uieCheckbox-partial.png);
}

QCheckBox::indicator:unchecked,
QListWidget::indicator:unchecked,
QTreeWidget::indicator:unchecked,
QListView::indicator:unchecked,
QGroupBox::indicator:unchecked {
image: url(:/graphicGui/uieCheckbox-unchecked.png);
}

QCheckBox::indicator:hover:checked,
QListWidget::indicator:hover:checked,
QTreeWidget::indicator:hover:checked,
QListView::indicator:hover:checked,
QGroupBox::indicator:hover:checked {
image: url(:/graphicGui/uieCheckbox-checked-hover.png);
}

QCheckBox::indicator:hover:indeterminate,
QListWidget::indicator:hover:indeterminate,
QTreeWidget::indicator:hover:indeterminate,
QListView::indicator:hover:indeterminate,
QGroupBox::indicator:hover:indeterminate {
image: url(:/graphicGui/uieCheckbox-partial-hover.png);
}

QCheckBox::indicator:hover:unchecked,
QListWidget::indicator:hover:unchecked,
QTreeWidget::indicator:hover:unchecked,
QListView::indicator:hover:unchecked,
QGroupBox::indicator:hover:unchecked {
image: url(:/graphicGui/uieCheckbox-unchecked-hover.png);
}

QCheckBox::indicator:checked:disabled,
QListWidget::indicator:checked:disabled,
QTreeWidget::indicator:checked:disabled,
QListView::indicator:checked:disabled,
QGroupBox::indicator:checked:disabled {
image: url(:/graphicGui/uieCheckbox-checked-disabled.png);
}

QCheckBox::indicator:indeterminate:disabled,
QListWidget::indicator:indeterminate:disabled,
QTreeWidget::indicator:indeterminate:disabled,
QListView::indicator:indeterminate:disabled,
QGroupBox::indicator:indeterminate:disabled {
image: url(:/graphicGui/uieCheckbox-partial-disabled.png);
}

QCheckBox::indicator:unchecked:disabled,
QListWidget::indicator:unchecked:disabled,
QTreeWidget::indicator:unchecked:disabled,
QListView::indicator:unchecked:disabled,
QGroupBox::indicator:unchecked:disabled {
image: url(:/graphicGui/uieCheckbox-unchecked-disabled.png);
Expand Down
41 changes: 37 additions & 4 deletions src/core/StelHips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ static QString getExt(const QString& format)
return QString();
}

static int shiftPix180deg(const int order, const int origPix)
{
const int scale = 1 << (2 * order);
const int baseSide = origPix / scale; // 0..11
Q_ASSERT(baseSide < 12);
const int newBaseSide = baseSide / 4 * 4 + (baseSide + 2) % 4;
const int newPix = origPix + (newBaseSide - baseSide) * scale;
Q_ASSERT(newPix >= 0);
return newPix;
}

QUrl HipsSurvey::getUrlFor(const QString& path) const
{
QUrl base = url;
Expand All @@ -66,9 +77,10 @@ QUrl HipsSurvey::getUrlFor(const QString& path) const
return QString("%1/%2%3").arg(base.url(), path, args);
}

HipsSurvey::HipsSurvey(const QString& url_, const QString& frame, const QString& type,
HipsSurvey::HipsSurvey(const QString& url_, const QString& group, const QString& frame, const QString& type,
const QMap<QString, QString>& hipslistProps, const double releaseDate_) :
url(url_),
group(group),
type(type),
hipsFrame(frame),
releaseDate(releaseDate_),
Expand Down Expand Up @@ -121,11 +133,22 @@ HipsSurvey::~HipsSurvey()
{
}

QString HipsSurvey::frameToPlanetName(const QString& frame)
{
if (frame == "ceres")
return "(1) ceres";
return frame;
}

void HipsSurvey::checkForPlanetarySurvey()
{
planetarySurvey = !QStringList{"equatorial","galactic","ecliptic"}.contains(hipsFrame, Qt::CaseInsensitive) ||
std::as_const(properties)["creator_did"].toString().contains("moon", Qt::CaseInsensitive) ||
std::as_const(properties)["client_category"].toString().contains("solar system", Qt::CaseInsensitive);

// Assume that all the planetary HiPS describe color maps by default
if (planetarySurvey && type.isEmpty())
type = "planet";
}

bool HipsSurvey::isVisible() const
Expand Down Expand Up @@ -219,6 +242,9 @@ void HipsSurvey::setNormalsSurvey(const HipsSurveyP& normals)
return;
}
this->normals = normals;
// Resetting normals should result in clearing normal maps from all
// the tiles. The easiest way to do this is to remove the tiles.
if (!normals) tiles.clear();
}

void HipsSurvey::setHorizonsSurvey(const HipsSurveyP& horizons)
Expand All @@ -229,6 +255,9 @@ void HipsSurvey::setHorizonsSurvey(const HipsSurveyP& horizons)
return;
}
this->horizons = horizons;
// Resetting horizons should result in clearing horizon maps from all
// the tiles. The easiest way to do this is to remove the tiles.
if (!horizons) tiles.clear();
}

void HipsSurvey::draw(StelPainter* sPainter, double angle, HipsSurvey::DrawCallback callback)
Expand Down Expand Up @@ -368,7 +397,8 @@ HipsTile* HipsSurvey::getTile(int order, int pix)
tile->order = order;
tile->pix = pix;
QString ext = getExt(properties["hips_tile_format"].toString());
QUrl path = getUrlFor(QString("Norder%1/Dir%2/Npix%3.%4").arg(order).arg((pix / 10000) * 10000).arg(pix).arg(ext));
const int texturePix = properties["type"].toString().isEmpty() ? shiftPix180deg(order, pix) : pix;
QUrl path = getUrlFor(QString("Norder%1/Dir%2/Npix%3.%4").arg(order).arg((texturePix / 10000) * 10000).arg(texturePix).arg(ext));
const StelTexture::StelTextureParams texParams(true, GL_LINEAR, GL_CLAMP_TO_EDGE, true);
tile->texture = texMgr.createTextureThread(path.url(), texParams, false);

Expand Down Expand Up @@ -675,7 +705,7 @@ int HipsSurvey::fillArrays(int order, int pix, int drawOrder, int splitOrder,
}

//! Parse a hipslist file into a list of surveys.
QList<HipsSurveyP> HipsSurvey::parseHipslist(const QString& data)
QList<HipsSurveyP> HipsSurvey::parseHipslist(const QString& hipslistURL, const QString& data)
{
QList<HipsSurveyP> ret;
static const QString defaultFrame = "equatorial";
Expand All @@ -685,6 +715,7 @@ QList<HipsSurveyP> HipsSurvey::parseHipslist(const QString& data)
QString type;
QString frame = defaultFrame;
QString status;
QString group = hipslistURL;
double releaseDate = 0;
QMap<QString, QString> hipslistProps;
for (const auto &line : entry.split('\n'))
Expand Down Expand Up @@ -715,9 +746,11 @@ QList<HipsSurveyP> HipsSurvey::parseHipslist(const QString& data)
type = value.toLower();
else if (key == "hips_status")
status = value.toLower();
else if (key == "group")
group = value;
}
if(status.split(' ').contains("public"))
ret.append(HipsSurveyP(new HipsSurvey(url, frame, type, hipslistProps, releaseDate)));
ret.append(HipsSurveyP(new HipsSurvey(url, group, frame, type, hipslistProps, releaseDate)));
}
return ret;
}
Expand Down
12 changes: 10 additions & 2 deletions src/core/StelHips.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ class HipsSurvey : public QObject
const QVector<uint16_t>& indices)> DrawCallback;
//! Create a new HipsSurvey from its url.
//! @param url The location of the survey.
//! @param group A string that identifies a group of color/normals/horizons
//! surveys that this survey belongs to.
//! @param frame The reference frame from the survey's \c hips_frame property.
//! @param type Survey type from the survey's \c type property.
//! @param releaseDate If known the UTC JD release date of the survey. Used for cache busting.
HipsSurvey(const QString& url, const QString& frame, const QString& type,
HipsSurvey(const QString& url, const QString& group, const QString& frame, const QString& type,
const QMap<QString, QString>& hipslistProps, double releaseDate=0.0);
~HipsSurvey() override;

static QString frameToPlanetName(const QString& frame);

//! Get whether the survey is visible.
bool isVisible() const;

Expand All @@ -91,6 +95,9 @@ class HipsSurvey : public QObject
//! Return the type of the survey (its \c type property).
QString getType() const { return type; }

//! Return the group of of color/normals/horizons surveys that this survey belongs to.
QString getGroup() const { return group; }

//! Get whether the survey is still loading.
bool isLoading(void) const;

Expand All @@ -100,7 +107,7 @@ class HipsSurvey : public QObject
void setHorizonsSurvey(const HipsSurveyP& horizons);

//! Parse a hipslist file into a list of surveys.
static QList<HipsSurveyP> parseHipslist(const QString& data);
static QList<HipsSurveyP> parseHipslist(const QString& hipslistURL, const QString& data);

signals:
void propertiesChanged(void);
Expand All @@ -113,6 +120,7 @@ class HipsSurvey : public QObject
private:
LinearFader fader;
QString url;
QString group;
QString type;
QString hipsFrame;
QString planet;
Expand Down
2 changes: 1 addition & 1 deletion src/core/modules/HipsMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void HipsMgr::loadSources()
QNetworkReply* networkReply = StelApp::getInstance().getNetworkAccessManager()->get(req);
connect(networkReply, &QNetworkReply::finished, this, [=] {
QByteArray data = networkReply->readAll();
QList<HipsSurveyP> newSurveys = HipsSurvey::parseHipslist(data);
QList<HipsSurveyP> newSurveys = HipsSurvey::parseHipslist(source.toString(), data);
for (HipsSurveyP &survey: newSurveys)
{
connect(survey.data(), SIGNAL(propertiesChanged()), this, SIGNAL(surveysChanged()));
Expand Down
36 changes: 26 additions & 10 deletions src/core/modules/Planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ Planet::Planet(const QString& englishName,
axisRotation(0.f),
objModel(Q_NULLPTR),
objModelLoader(Q_NULLPTR),
survey(Q_NULLPTR),
rings(Q_NULLPTR),
distance(0.0),
sphereScale(1.),
Expand Down Expand Up @@ -397,6 +396,27 @@ void Planet::replaceTexture(const QString &texName)
}
}

void Planet::setSurvey(const HipsSurveyP& colors, const HipsSurveyP& normals, const HipsSurveyP& horizons)
{
Q_ASSERT(colors);
Q_ASSERT(colors->getType() == "planet");
Q_ASSERT(!normals || normals->getType() == "planet-normal");
Q_ASSERT(!horizons || horizons->getType() == "planet-horizon");
Q_ASSERT(!normals || normals->getFrame() == colors->getFrame());
Q_ASSERT(!horizons || horizons->getFrame() == colors->getFrame());

survey.colors = colors;
survey.normals = normals;
survey.horizons = horizons;

if (survey.normals)
survey.colors->setNormalsSurvey(survey.normals);
if (survey.horizons)
survey.colors->setHorizonsSurvey(survey.horizons);

survey.colors->setProperty("planet", getEnglishName());
}

void Planet::translateName(const StelTranslator& trans)
{
nameI18 = trans.tryQtranslate(englishName, getContextString());
Expand Down Expand Up @@ -3748,12 +3768,12 @@ void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP trans
drawSphere(&sPainter, screenRd, drawOnlyRing);
}
}
else if (!survey || survey->getInterstate() < 1.0f)
else if (!survey || survey.colors->getInterstate() < 1.0f)
{
drawSphere(&sPainter, screenRd, drawOnlyRing);
}

if (survey && survey->getInterstate() > 0.0f)
if (survey && survey.colors->getInterstate() > 0.0f)
{
drawSurvey(core, &sPainter);
drawSphere(&sPainter, screenRd, true);
Expand Down Expand Up @@ -4374,11 +4394,6 @@ void Planet::drawSurvey(StelCore* core, StelPainter* painter)
if (!Planet::initShader()) return;
static SolarSystem* ssm = GETSTELMODULE(SolarSystem);

if (surveyForNormals && survey)
survey->setNormalsSurvey(surveyForNormals);
if (surveyForHorizons && survey)
survey->setHorizonsSurvey(surveyForHorizons);

painter->setDepthMask(true);
painter->setDepthTest(true);

Expand All @@ -4402,7 +4417,7 @@ void Planet::drawSurvey(StelCore* core, StelPainter* painter)
}

GL(shader->bind());
RenderData rData = setCommonShaderUniforms(*painter, shader, *shaderVars, surveyForNormals != nullptr, surveyForHorizons != nullptr);
RenderData rData = setCommonShaderUniforms(*painter, shader, *shaderVars, !!survey.normals, !!survey.horizons);
QVector<Vec3f> projectedVertsArray;
QVector<Vec3f> vertsArray;
const double angle = 2 * getSpheroidAngularRadius(core) * M_PI_180;
Expand Down Expand Up @@ -4432,7 +4447,8 @@ void Planet::drawSurvey(StelCore* core, StelPainter* painter)
painter->getProjector()->getModelViewTransform()->combine(Mat4d::zrotation(M_PI * 0.5));
painter->getProjector()->getModelViewTransform()->combine(Mat4d::scaling(Vec3d(1, 1, oneMinusOblateness)));

survey->draw(painter, angle, [&](const QVector<Vec3d>& verts, const QVector<Vec2f>& tex, const QVector<uint16_t>& indices) {
survey.colors->draw(painter, angle, [&](const QVector<Vec3d>& verts, const QVector<Vec2f>& tex,
const QVector<uint16_t>& indices) {
projectedVertsArray.resize(verts.size());
vertsArray.resize(verts.size());
for (int i = 0; i < verts.size(); i++)
Expand Down
16 changes: 12 additions & 4 deletions src/core/modules/Planet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,9 @@ class Planet : public StelObject
void resetTextures();
//! Use texture from @param texName (must reside inside the scripts directory!)
void replaceTexture(const QString& texName);


void setSurvey(const HipsSurveyP& colors, const HipsSurveyP& normals, const HipsSurveyP& horizons);

protected:
// These components for getInfoString() can be overridden in subclasses
virtual QString getInfoStringName(const StelCore *core, const InfoStringGroup& flags) const;
Expand Down Expand Up @@ -808,9 +810,15 @@ class Planet : public StelObject
QFuture<PlanetOBJModel*>* objModelLoader; //!< For async loading of the OBJ file
QString objModelPath;

HipsSurveyP survey;
HipsSurveyP surveyForNormals;
HipsSurveyP surveyForHorizons;
struct SurveyPack
{
HipsSurveyP colors;
HipsSurveyP normals;
HipsSurveyP horizons;
operator bool() const { return !!colors; }
};

SurveyPack survey;

Ring* rings; //!< Planet rings
double distance; //!< Temporary variable used to store the distance to a given point
Expand Down
Loading
Loading