diff --git a/kstars/auxiliary/xplanetimageviewer.h b/kstars/auxiliary/xplanetimageviewer.h --- a/kstars/auxiliary/xplanetimageviewer.h +++ b/kstars/auxiliary/xplanetimageviewer.h @@ -65,6 +65,7 @@ void zoomIn(); void zoomOut(); void changePosition(QPoint); + void changeLocation(QPoint); protected: void paintEvent(QPaintEvent *e) override; @@ -158,6 +159,7 @@ double m_FOV { 0 }; double m_lat { 0 }; double m_lon { 0 }; + QPoint center; #ifndef Q_OS_WIN QFutureWatcher fifoImageLoadWatcher; @@ -215,11 +217,15 @@ void resetXPlanetRotation(); void invertXPlanetRotation(); + void reCenterXPlanet(); + // Free Rotation slots void changeXPlanetPosition(QPoint delta); + void changeXPlanetLocation(QPoint delta); void slotFreeRotate(); void updateStates(); void updatePositionDisplay(); + void resetLocation(); // Field of View slots void zoomInXPlanetFOV(); diff --git a/kstars/auxiliary/xplanetimageviewer.cpp b/kstars/auxiliary/xplanetimageviewer.cpp --- a/kstars/auxiliary/xplanetimageviewer.cpp +++ b/kstars/auxiliary/xplanetimageviewer.cpp @@ -171,7 +171,10 @@ QPoint newPoint = e->globalPos(); int dx = newPoint.x() - m_LastMousePoint.x(); int dy = newPoint.y() - m_LastMousePoint.y(); - emit changePosition(QPoint(dx, dy)); + if(e->buttons() & Qt::RightButton) + emit changeLocation(QPoint(dx, dy)); + if(e->buttons() & Qt::LeftButton) + emit changePosition(QPoint(dx, dy)); m_LastMousePoint = newPoint; } e->accept(); @@ -252,6 +255,15 @@ m_PositionDisplay->setDisabled(true); selectorsLayout->addWidget(m_PositionDisplay); + QPushButton *resetXPlanetLocation = new QPushButton(this); + resetXPlanetLocation->setIcon(QIcon::fromTheme("system-reboot")); + resetXPlanetLocation->setAttribute(Qt::WA_LayoutUsesWidgetRect); + resetXPlanetLocation->setMaximumSize(QSize(32,32)); + resetXPlanetLocation->setMinimumSize(QSize(32,32)); + resetXPlanetLocation->setToolTip(i18n("Reset XPlanet Location to the location specified in the XPlanet Options")); + selectorsLayout->addWidget(resetXPlanetLocation); + connect(resetXPlanetLocation, SIGNAL(clicked()), this, SLOT(resetLocation())); + m_FreeRotate = new QPushButton(this); m_FreeRotate->setIcon(QIcon::fromTheme("object-rotate-left")); m_FreeRotate->setAttribute(Qt::WA_LayoutUsesWidgetRect); @@ -262,6 +274,15 @@ selectorsLayout->addWidget(m_FreeRotate); connect(m_FreeRotate, SIGNAL(clicked()), this, SLOT(slotFreeRotate())); + QPushButton *reCenterB = new QPushButton(this); + reCenterB->setIcon(QIcon::fromTheme("snap-bounding-box-center")); + reCenterB->setAttribute(Qt::WA_LayoutUsesWidgetRect); + reCenterB->setMaximumSize(QSize(32,32)); + reCenterB->setMinimumSize(QSize(32,32)); + reCenterB->setToolTip(i18n("Recenters the XPlanet image once it has been moved")); + selectorsLayout->addWidget(reCenterB); + connect(reCenterB, SIGNAL(clicked()), this, SLOT(reCenterXPlanet())); + QPushButton *saveB = new QPushButton(this); saveB->setIcon(QIcon::fromTheme("document-save")); saveB->setAttribute(Qt::WA_LayoutUsesWidgetRect); @@ -472,6 +493,7 @@ connect(m_View, SIGNAL(zoomIn()), this, SLOT(zoomInXPlanetFOV())); connect(m_View, SIGNAL(zoomOut()), this, SLOT(zoomOutXPlanetFOV())); connect(m_View, SIGNAL(changePosition(QPoint)), this, SLOT(changeXPlanetPosition(QPoint))); + connect(m_View, SIGNAL(changeLocation(QPoint)), this, SLOT(changeXPlanetLocation(QPoint))); //Reverse colors QPalette p = palette(); @@ -615,6 +637,11 @@ else args << "-origin" << m_OriginName; + //Centering + //This allows you to recenter the xplanet view + + args << "-center" << "+" + QString::number(Options::xplanetWidth() / 2 + center.x()) + "+" + QString::number(Options::xplanetHeight() / 2 + center.y()); + // Projection if (Options::xplanetProjection()) { @@ -864,6 +891,7 @@ } void XPlanetImageViewer::updateXPlanetObject(int objectIndex){ + center = QPoint(0,0); m_CurrentObjectIndex = objectIndex; m_ObjectName = m_ObjectNames.at(objectIndex); @@ -878,6 +906,7 @@ void XPlanetImageViewer::updateXPlanetOrigin(int originIndex) { + center = QPoint(0,0); m_CurrentOriginIndex = originIndex; m_OriginName = m_ObjectNames.at(originIndex); if(m_CurrentObjectIndex == m_CurrentOriginIndex) @@ -888,7 +917,7 @@ startXplanet(); } -void XPlanetImageViewer::changeXPlanetPosition(QPoint delta) +void XPlanetImageViewer::changeXPlanetLocation(QPoint delta) { if(m_CurrentObjectIndex == m_CurrentOriginIndex) { @@ -905,6 +934,28 @@ } } +void XPlanetImageViewer::changeXPlanetPosition(QPoint delta) +{ + center.setX(center.x() + delta.x()); + center.setY(center.y() + delta.y()); + startXplanet(); +} + +void XPlanetImageViewer::reCenterXPlanet() +{ + center = QPoint(0,0); + startXplanet(); +} + +void XPlanetImageViewer::resetLocation() +{ + m_lat = Options::xplanetLatitude().toDouble(); + m_lon = Options::xplanetLongitude().toDouble(); + m_Radius = 45; + updatePositionDisplay(); + startXplanet(); +} + void XPlanetImageViewer::slotFreeRotate() { if(m_FreeRotate->isChecked()) diff --git a/kstars/xplanet/opsxplanet.h b/kstars/xplanet/opsxplanet.h --- a/kstars/xplanet/opsxplanet.h +++ b/kstars/xplanet/opsxplanet.h @@ -31,6 +31,8 @@ private: KStars *ksw { nullptr }; + QString XPlanetShareDirectory(); + private slots: void showXPlanetMapsDirectory(); void slotConfigFileWidgets(bool on); @@ -42,4 +44,7 @@ void slotProjectionWidgets(int index); void slotBackgroundWidgets(bool on); void toggleXPlanetInternal(); + void slotSelectConfigFile(); + void slotSelectStarMapFile(); + void slotSelectArcFile(); }; diff --git a/kstars/xplanet/opsxplanet.cpp b/kstars/xplanet/opsxplanet.cpp --- a/kstars/xplanet/opsxplanet.cpp +++ b/kstars/xplanet/opsxplanet.cpp @@ -20,6 +20,7 @@ #include "kstarsdata.h" #include "Options.h" #include +#include OpsXplanet::OpsXplanet(KStars *_ks) : QFrame(_ks), ksw(_ks) { @@ -63,8 +64,20 @@ connect(kcfg_XplanetBackground, SIGNAL(toggled(bool)), SLOT(slotBackgroundWidgets(bool))); kcfg_XplanetConfigFilePath->setEnabled(Options::xplanetConfigFile()); + configFileB->setEnabled(Options::xplanetConfigFile()); + configFileB->setIcon(QIcon::fromTheme("document-open-folder")); + configFileB->setAttribute(Qt::WA_LayoutUsesWidgetRect); + connect(configFileB, SIGNAL(clicked()), this, SLOT(slotSelectConfigFile())); kcfg_XplanetStarmapPath->setEnabled(Options::xplanetStarmap()); + starmapFileB->setEnabled(Options::xplanetStarmap()); + starmapFileB->setIcon(QIcon::fromTheme("document-open-folder")); + starmapFileB->setAttribute(Qt::WA_LayoutUsesWidgetRect); + connect(starmapFileB, SIGNAL(clicked()), this, SLOT(slotSelectStarMapFile())); kcfg_XplanetArcFilePath->setEnabled(Options::xplanetArcFile()); + arcFileB->setEnabled(Options::xplanetArcFile()); + arcFileB->setIcon(QIcon::fromTheme("document-open-folder")); + arcFileB->setAttribute(Qt::WA_LayoutUsesWidgetRect); + connect(arcFileB, SIGNAL(clicked()), this, SLOT(slotSelectArcFile())); kcfg_XplanetLabelLocalTime->setEnabled(Options::xplanetLabel()); kcfg_XplanetLabelGMT->setEnabled(Options::xplanetLabel()); textLabelXplanetLabelString->setEnabled(Options::xplanetLabel()); @@ -101,26 +114,29 @@ kcfg_XplanetUseFIFO->setToolTip(i18n("FIFO files are not supported on Windows")); #endif - connect(openXPlanetMaps, SIGNAL(clicked()),this,SLOT(showXPlanetMapsDirectory())); } void OpsXplanet::showXPlanetMapsDirectory() { - QString xplanetMapsDir; - if (Options::xplanetIsInternal()) - xplanetMapsDir = QCoreApplication::applicationDirPath() + "/xplanet/share/xplanet/images"; - else - xplanetMapsDir = Options::xplanetPath() + "../share/xplanet/images"; + QString xplanetMapsDir = XPlanetShareDirectory() + QDir::separator() + "images"; + + QUrl path = QUrl::fromLocalFile(xplanetMapsDir); + QDesktopServices::openUrl(path); +} +QString OpsXplanet::XPlanetShareDirectory() +{ #ifdef Q_OS_WIN const QFileInfo xPlanetLocationInfo(Options::xplanetPath()); - xplanetMapsDir = xPlanetLocationInfo.dir().absolutePath() + QDir::separator() + "xplanet" + QDir::separator() + "images"; + return xPlanetLocationInfo.dir().absolutePath() + QDir::separator() + "xplanet"; #endif - QUrl path = QUrl::fromLocalFile(xplanetMapsDir); - QDesktopServices::openUrl(path); + if (Options::xplanetIsInternal()) + return QCoreApplication::applicationDirPath() + "/xplanet/share/xplanet"; + else + return Options::xplanetPath() + "../share/xplanet"; } void OpsXplanet::toggleXPlanetInternal() @@ -135,16 +151,19 @@ void OpsXplanet::slotConfigFileWidgets(bool on) { kcfg_XplanetConfigFilePath->setEnabled(on); + configFileB->setEnabled(on); } void OpsXplanet::slotStarmapFileWidgets(bool on) { kcfg_XplanetStarmapPath->setEnabled(on); + starmapFileB->setEnabled(on); } void OpsXplanet::slotArcFileWidgets(bool on) { kcfg_XplanetArcFilePath->setEnabled(on); + arcFileB->setEnabled(on); } void OpsXplanet::slotLabelWidgets(bool on) @@ -202,3 +221,39 @@ kcfg_XplanetBackgroundColor->setEnabled(on); kcfg_XplanetBackgroundColorValue->setEnabled(on); } + +void OpsXplanet::slotSelectConfigFile() +{ + QString xplanetConfig = XPlanetShareDirectory() + QDir::separator() + "config"; + QString file = + QFileDialog::getOpenFileName(KStars::Instance(), i18n("Select XPlanet Config File"), xplanetConfig); + + if (!file.isEmpty()) + kcfg_XplanetConfigFilePath->setText(QFileInfo(file).completeBaseName()); + +} + +void OpsXplanet::slotSelectStarMapFile() +{ + QString xplanetStarMap = XPlanetShareDirectory() + QDir::separator() + "stars"; + + QString file = + QFileDialog::getOpenFileName(KStars::Instance(), i18n("Select XPlanet Star Map File"), xplanetStarMap); + + if (!file.isEmpty()) + kcfg_XplanetStarmapPath->setText(QFileInfo(file).completeBaseName()); + +} + +void OpsXplanet::slotSelectArcFile() +{ + + QString xplanetArc = XPlanetShareDirectory() + QDir::separator() + "arcs"; + + QString file = + QFileDialog::getOpenFileName(KStars::Instance(), i18n("Select XPlanet Arc File"), xplanetArc); + + if (!file.isEmpty()) + kcfg_XplanetArcFilePath->setText(QFileInfo(file).completeBaseName()); + +} diff --git a/kstars/xplanet/opsxplanet.ui b/kstars/xplanet/opsxplanet.ui --- a/kstars/xplanet/opsxplanet.ui +++ b/kstars/xplanet/opsxplanet.ui @@ -7,7 +7,7 @@ 0 0 622 - 647 + 665 @@ -207,53 +207,47 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - + + Use kstars's FOV? - If checked, use kstars's FOV. + <html><head/><body><p>If checked, XPlanet will use a FIFO file in the /tmp directory to temporarily save the XPlanet image for KStars to load them and update the view. If not checked, XPlanet will actually save the files to the XPlanet folder in the KStars data directory. Using a FIFO file should save the hard disk from excessive reads/writes and may offer a performance enhancement.</p></body></html> - Use kstars's FOV + Use FIFO File - - - - - + + - Glare of Sun: + (saves to memory instead of a hard disk) - - - - - 0 - 0 - - + + - Radius of the glare around the Sun. + Use kstars's FOV? - Draw a glare around the sun with a radius of the specified value larger than the Sun. The default value is 28. + If checked, use kstars's FOV. + + + Use kstars's FOV - + Base magnitude: - + @@ -269,7 +263,65 @@ - + + + + + + + Config file: + + + + + + + QLayout::SetMaximumSize + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Config file path + + + Use the specified configuration file + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + + + + + + + Use custom star map? @@ -282,85 +334,129 @@ - - - - - 0 - 0 - + + + + QLayout::SetMaximumSize - - Star map file path + + 0 - - Star map file path + + 0 + + + + + + 0 + 0 + + + + Star map file path + + + Star map file path + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + + + + + + + + + + Arc file: - - - - - 0 - 0 - + + + + QLayout::SetMaximumSize - - Arc file path + + 0 - - Specify an arc file to be plotted against the background stars. + + 0 - + + + + + 0 + 0 + + + + Arc file path + + + Specify an arc file to be plotted against the background stars. + + + + + + + + 28 + 28 + + + + + 28 + 28 + + + + + + + + - - + + - + 0 0 - Config file path - - - Use the specified configuration file - - - - - - - Config file: - - - - - - - Arc file: - - - - - - - Use kstars's FOV? + Radius of the glare around the Sun. - <html><head/><body><p>If checked, XPlanet will use a FIFO file in the /tmp directory to temporarily save the XPlanet image for KStars to load them and update the view. If not checked, XPlanet will actually save the files to the XPlanet folder in the KStars data directory. Using a FIFO file should save the hard disk from excessive reads/writes and may offer a performance enhancement.</p></body></html> - - - Use FIFO File + Draw a glare around the sun with a radius of the specified value larger than the Sun. The default value is 28. - - + + - (saves to memory instead of a hard disk) + Glare of Sun: @@ -1029,11 +1125,8 @@ kcfg_XplanetGlare kcfg_XplanetMagnitude kcfg_XplanetConfigFile - kcfg_XplanetConfigFilePath kcfg_XplanetStarmap - kcfg_XplanetStarmapPath kcfg_XplanetArcFile - kcfg_XplanetArcFilePath kcfg_XplanetQuality kcfg_XplanetLabel kcfg_XplanetLabelLocalTime