Merge lp:~stellarium/stellarium/gz_viewportOffset into lp:stellarium

Proposed by gzotti
Status: Merged
Approved by: Alexander Wolf
Approved revision: 7738
Merged at revision: 7746
Proposed branch: lp:~stellarium/stellarium/gz_viewportOffset
Merge into: lp:stellarium
Diff against target: 651 lines (+263/-60)
11 files modified
src/core/StelCore.cpp (+5/-1)
src/core/StelMovementMgr.cpp (+119/-39)
src/core/StelMovementMgr.hpp (+15/-7)
src/core/StelProjector.cpp (+5/-1)
src/core/StelProjector.hpp (+2/-0)
src/gui/ConfigurationDialog.cpp (+2/-0)
src/gui/ViewDialog.cpp (+16/-5)
src/gui/ViewDialog.hpp (+1/-0)
src/gui/viewDialog.ui (+63/-7)
src/scripting/StelMainScriptAPI.cpp (+34/-0)
src/scripting/StelMainScriptAPI.hpp (+1/-0)
To merge this branch: bzr merge lp:~stellarium/stellarium/gz_viewportOffset
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
gzotti Needs Resubmitting
Review via email: mp+264395@code.launchpad.net

Description of the change

Introducing the option to have a vertically offset screen center. Useful to have e.g. cylindrical views with straight landcape horizon in lower part of the screen.

Object tracking&centering brings those objects into visible screen center. Centering on coordinates puts those coordinates into the offset projection center now, this is intended.

I hope I have not overlooked something in the view geometry?

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Current implementation has stepwise centering of the object when zooming. Can it be smooth zooming?

review: Needs Fixing
Revision history for this message
gzotti (georg-zotti) wrote :

Oops... yes, I must have a look into that!

7736. By gzotti

add a "galactic" projection mode for scripting.

7737. By gzotti

Smoothed zooming (keep centered object in center for offset view mode), and repaired offset adjusting for all view frame (mount) modes

Revision history for this message
gzotti (georg-zotti) wrote :

OK, zooming now runs smooth, and in all mount modes. Also made galactic mount mode reachable at least for scripting.

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Zooming with movement is not exactly smooth. Please try simple use case for both versions (trunk and gz_viewportOffset): disable atmosphere and ground, select any object on screen near border and press "/" (zoom in). Movement is stepwize yet.

review: Needs Fixing
Revision history for this message
gzotti (georg-zotti) wrote :

Ouch. Again one of the keys/functions I never found in 7 years because they don't work on German keyboards. OK, after reconfiguring I can see what you mean. Practically object is immediately centered, right?

Are there any other ways of zooming/centering? I always only used the mouse or PgUp/Down.

review: Needs Information
7738. By gzotti

zoom+movement (default key "/") now also smoothened.

Revision history for this message
gzotti (georg-zotti) wrote :

OK, next try please? The selected object is now not immediately centered. I hope it was what you meant?

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Apparently he is not broke a frequently used features now.

review: Approve
Revision history for this message
Alexander Wolf (alexwolf) wrote :

P.S. This feature introduced an issue in projection of the sky (artifacts at the bottom side of the screen).

Revision history for this message
gzotti (georg-zotti) wrote :

Well, yes, if you zoom out too far, some artifacts/limitations of any projection become apparent even stronger than without offsetting center. I see some disturbing faces or lines when zooming out in stereographic projection near zenith, and faces of the "sphere border", but the "solution" would simply include an fov limit adaptation, but I think it is better like that, and users can zoom in a bit if the weird faces really disturb.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/core/StelCore.cpp'
--- src/core/StelCore.cpp 2015-07-08 10:37:11 +0000
+++ src/core/StelCore.cpp 2015-07-24 14:57:31 +0000
@@ -86,6 +86,10 @@
86 const float viewportCenterX = conf->value("projection/viewport_center_x",0.5f*viewport_width).toFloat();86 const float viewportCenterX = conf->value("projection/viewport_center_x",0.5f*viewport_width).toFloat();
87 const float viewportCenterY = conf->value("projection/viewport_center_y",0.5f*viewport_height).toFloat();87 const float viewportCenterY = conf->value("projection/viewport_center_y",0.5f*viewport_height).toFloat();
88 currentProjectorParams.viewportCenter.set(viewportCenterX, viewportCenterY);88 currentProjectorParams.viewportCenter.set(viewportCenterX, viewportCenterY);
89 const float viewportCenterOffsetX = conf->value("projection/viewport_center_offset_x",0.f).toFloat();
90 const float viewportCenterOffsetY = conf->value("projection/viewport_center_offset_y",0.f).toFloat();
91 currentProjectorParams.viewportCenterOffset.set(viewportCenterOffsetX, viewportCenterOffsetY);
92
89 currentProjectorParams.viewportFovDiameter = conf->value("projection/viewport_fov_diameter", qMin(viewport_width,viewport_height)).toFloat();93 currentProjectorParams.viewportFovDiameter = conf->value("projection/viewport_fov_diameter", qMin(viewport_width,viewport_height)).toFloat();
90 currentProjectorParams.flipHorz = conf->value("projection/flip_horz",false).toBool();94 currentProjectorParams.flipHorz = conf->value("projection/flip_horz",false).toBool();
91 currentProjectorParams.flipVert = conf->value("projection/flip_vert",false).toBool();95 currentProjectorParams.flipVert = conf->value("projection/flip_vert",false).toBool();
@@ -384,7 +388,7 @@
384{388{
385 // Maximize display when resized since it invalidates previous options anyway389 // Maximize display when resized since it invalidates previous options anyway
386 currentProjectorParams.viewportXywh.set(x, y, width, height);390 currentProjectorParams.viewportXywh.set(x, y, width, height);
387 currentProjectorParams.viewportCenter.set(x+0.5*width, y+0.5*height);391 currentProjectorParams.viewportCenter.set(x+(0.5+currentProjectorParams.viewportCenterOffset.v[0])*width, y+(0.5+currentProjectorParams.viewportCenterOffset.v[1])*height);
388 currentProjectorParams.viewportFovDiameter = qMin(width,height);392 currentProjectorParams.viewportFovDiameter = qMin(width,height);
389}393}
390394
391395
=== modified file 'src/core/StelMovementMgr.cpp'
--- src/core/StelMovementMgr.cpp 2015-04-01 14:36:44 +0000
+++ src/core/StelMovementMgr.cpp 2015-07-24 14:57:31 +0000
@@ -1,6 +1,7 @@
1/*1/*
2 * Stellarium2 * Stellarium
3 * Copyright (C) 2007 Fabien Chereau3 * Copyright (C) 2007 Fabien Chereau
4 * Copyright (C) 2015 Georg Zotti (offset view adaptations)
4 *5 *
5 * This program is free software; you can redistribute it and/or6 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License7 * modify it under the terms of the GNU General Public License
@@ -102,9 +103,7 @@
102 flagAutoZoomOutResetsDirection = conf->value("navigation/auto_zoom_out_resets_direction", true).toBool();103 flagAutoZoomOutResetsDirection = conf->value("navigation/auto_zoom_out_resets_direction", true).toBool();
103 flagEnableMouseNavigation = conf->value("navigation/flag_enable_mouse_navigation",true).toBool();104 flagEnableMouseNavigation = conf->value("navigation/flag_enable_mouse_navigation",true).toBool();
104105
105 minFov = 0.001389; // minimal FOV = 5"106 minFov = conf->value("navigation/min_fov",0.001389).toDouble(); // default: minimal FOV = 5"
106 // GZ: This value should be configurable! Zooming in too much is useless for archaeoastronomy.
107 minFov = conf->value("navigation/min_fov",minFov).toDouble();
108 maxFov = 100.;107 maxFov = 100.;
109 initFov = conf->value("navigation/init_fov",60.f).toFloat();108 initFov = conf->value("navigation/init_fov",60.f).toFloat();
110 currentFov = initFov;109 currentFov = initFov;
@@ -464,7 +463,7 @@
464}463}
465464
466/*************************************************************************465/*************************************************************************
467 The selected objects changed, follow it it we were already following another one466 The selected objects changed, follow it if we were already following another one
468*************************************************************************/467*************************************************************************/
469void StelMovementMgr::selectedObjectChange(StelModule::StelModuleSelectAction)468void StelMovementMgr::selectedObjectChange(StelModule::StelModuleSelectAction)
470{469{
@@ -561,29 +560,24 @@
561 if (deltaAz<-0.2)560 if (deltaAz<-0.2)
562 deltaAz = -0.2;561 deltaAz = -0.2;
563 }562 }
564 else563 else if (deltaAz>0)
565 {564 {
566 if (deltaAz>0)565 deltaAz = (depl/30);
567 {566 if (deltaAz>0.2)
568 deltaAz = (depl/30);567 deltaAz = 0.2;
569 if (deltaAz>0.2)
570 deltaAz = 0.2;
571 }
572 }568 }
569
573 if (deltaAlt<0)570 if (deltaAlt<0)
574 {571 {
575 deltaAlt = -depl/30;572 deltaAlt = -depl/30;
576 if (deltaAlt<-0.2)573 if (deltaAlt<-0.2)
577 deltaAlt = -0.2;574 deltaAlt = -0.2;
578 }575 }
579 else576 else if (deltaAlt>0)
580 {577 {
581 if (deltaAlt>0)578 deltaAlt = depl/30;
582 {579 if (deltaAlt>0.2)
583 deltaAlt = depl/30;580 deltaAlt = 0.2;
584 if (deltaAlt>0.2)
585 deltaAlt = 0.2;
586 }
587 }581 }
588582
589 if (deltaFov<0)583 if (deltaFov<0)
@@ -592,14 +586,11 @@
592 if (deltaFov<-0.15*currentFov)586 if (deltaFov<-0.15*currentFov)
593 deltaFov = -0.15*currentFov;587 deltaFov = -0.15*currentFov;
594 }588 }
595 else589 else if (deltaFov>0)
596 {590 {
597 if (deltaFov>0)591 deltaFov = deplzoom*5;
598 {592 if (deltaFov>20)
599 deltaFov = deplzoom*5;593 deltaFov = 20;
600 if (deltaFov>20)
601 deltaFov = 20;
602 }
603 }594 }
604595
605 if (deltaFov != 0 )596 if (deltaFov != 0 )
@@ -618,7 +609,32 @@
618 if (!move.targetObject.isNull())609 if (!move.targetObject.isNull())
619 {610 {
620 // if zooming in, object may be moving so be sure to zoom to latest position611 // if zooming in, object may be moving so be sure to zoom to latest position
621 move.aim = core->altAzToJ2000(move.targetObject->getAltAzPosAuto(core), StelCore::RefractionOff);612 // In case we have offset center, we want object still visible in center.
613 // Note that if we do not center on an object, we set view direction of the potentially offset screen center!
614 // This is by design, to allow accurate setting of display coordinates.
615 Vec3d v;
616 switch (mountMode)
617 {
618 case MountAltAzimuthal:
619 v = move.targetObject->getAltAzPosAuto(core);
620 break;
621 case MountEquinoxEquatorial:
622 v = move.targetObject->getEquinoxEquatorialPos(core);
623 break;
624 case MountGalactic:
625 v = move.targetObject->getGalacticPos(core);
626 break;
627 default:
628 qWarning() << "StelMovementMgr: unexpected mountMode" << mountMode;
629 Q_ASSERT(0);
630 }
631
632 double lat, lon;
633 StelUtils::rectToSphe(&lon, &lat, v);
634 float altOffset=core->getCurrentStelProjectorParams().viewportCenterOffset[1]*currentFov*M_PI/180.0f;
635 lat+=altOffset;
636 StelUtils::spheToRect(lon, lat, v);
637 move.aim=mountFrameToJ2000(v);
622 move.aim.normalize();638 move.aim.normalize();
623 move.aim*=2.;639 move.aim*=2.;
624 }640 }
@@ -686,8 +702,30 @@
686 {702 {
687 if (flagTracking && objectMgr->getWasSelected()) // Equatorial vision vector locked on selected object703 if (flagTracking && objectMgr->getWasSelected()) // Equatorial vision vector locked on selected object
688 {704 {
689 Vec3d v = objectMgr->getSelectedObject()[0]->getAltAzPosAuto(core);705 Vec3d v;
690 setViewDirectionJ2000(core->altAzToJ2000(v, StelCore::RefractionOff));706 switch (mountMode)
707 {
708 case MountAltAzimuthal:
709 v = objectMgr->getSelectedObject()[0]->getAltAzPosAuto(core);
710 break;
711 case MountEquinoxEquatorial:
712 v = objectMgr->getSelectedObject()[0]->getEquinoxEquatorialPos(core);
713 break;
714 case MountGalactic:
715 v = objectMgr->getSelectedObject()[0]->getGalacticPos(core);
716 break;
717 default:
718 qWarning() << "StelMovementMgr: unexpected mountMode" << mountMode;
719 Q_ASSERT(0);
720 }
721
722 double lat, lon; // general: longitudinal, latitudinal
723 StelUtils::rectToSphe(&lon, &lat, v);
724 float latOffset=core->getCurrentStelProjectorParams().viewportCenterOffset[1]*currentFov*M_PI/180.0f;
725 lat+=latOffset;
726 StelUtils::spheToRect(lon, lat, v);
727
728 setViewDirectionJ2000(mountFrameToJ2000(v));
691 }729 }
692 else730 else
693 {731 {
@@ -705,7 +743,7 @@
705 }743 }
706}744}
707745
708// Go and zoom to the selected object.746// Go and zoom to the selected object. (Action linked to key, default "/")
709void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom)747void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom)
710{748{
711 if (!objectMgr->getWasSelected())749 if (!objectMgr->getWasSelected())
@@ -716,7 +754,7 @@
716 float manualMoveDuration;754 float manualMoveDuration;
717 if (!getFlagTracking())755 if (!getFlagTracking())
718 {756 {
719 setFlagTracking(true);757 setFlagTracking(true); // includes a call to moveToObject(), but without zooming=1!
720 moveToObject(objectMgr->getSelectedObject()[0], moveDuration, 1);758 moveToObject(objectMgr->getSelectedObject()[0], moveDuration, 1);
721 manualMoveDuration = moveDuration;759 manualMoveDuration = moveDuration;
722 }760 }
@@ -784,7 +822,7 @@
784 }822 }
785}823}
786824
787825// This is called when you press SPACEBAR: slowly centering&tracking object
788void StelMovementMgr::setFlagTracking(bool b)826void StelMovementMgr::setFlagTracking(bool b)
789{827{
790 if (!b || !objectMgr->getWasSelected())828 if (!b || !objectMgr->getWasSelected())
@@ -801,6 +839,7 @@
801839
802////////////////////////////////////////////////////////////////////////////////840////////////////////////////////////////////////////////////////////////////////
803// Move to the given J2000 equatorial position841// Move to the given J2000 equatorial position
842
804void StelMovementMgr::moveToJ2000(const Vec3d& aim, float moveDuration, int zooming)843void StelMovementMgr::moveToJ2000(const Vec3d& aim, float moveDuration, int zooming)
805{844{
806 moveDuration /= movementsSpeedFactor;845 moveDuration /= movementsSpeedFactor;
@@ -935,23 +974,64 @@
935 // Use a smooth function974 // Use a smooth function
936 double c;975 double c;
937976
938 if( zoomMove.start > zoomMove.aim )977 if( zoomMove.startFov > zoomMove.aimFov )
939 {978 {
940 // slow down as approach final view979 // slow down as we approach final view
941 c = 1 - (1-zoomMove.coef)*(1-zoomMove.coef)*(1-zoomMove.coef);980 c = 1 - (1-zoomMove.coef)*(1-zoomMove.coef)*(1-zoomMove.coef);
942 }981 }
943 else982 else
944 {983 {
945 // speed up as leave zoom target984 // speed up as we leave zoom target
946 c = (zoomMove.coef)*(zoomMove.coef)*(zoomMove.coef);985 c = (zoomMove.coef)*(zoomMove.coef)*(zoomMove.coef);
947 }986 }
948987
949 setFov(zoomMove.start + (zoomMove.aim - zoomMove.start) * c);988 double newFov=zoomMove.startFov + (zoomMove.aimFov - zoomMove.startFov) * c;
989
950 zoomMove.coef+=zoomMove.speed*deltaTime*1000;990 zoomMove.coef+=zoomMove.speed*deltaTime*1000;
951 if (zoomMove.coef>=1.)991 if (zoomMove.coef>=1.)
952 {992 {
953 flagAutoZoom = 0;993 flagAutoZoom = 0;
954 setFov(zoomMove.aim);994 newFov=zoomMove.aimFov;
995 }
996
997 setFov(newFov); // updates currentFov->don't use newFov later!
998
999 // In case we have offset center, we want object still visible in center.
1000 if (flagTracking && objectMgr->getWasSelected()) // vision vector locked on selected object
1001 {
1002 Vec3d v;
1003 switch (mountMode)
1004 {
1005 case MountAltAzimuthal:
1006 v = objectMgr->getSelectedObject()[0]->getAltAzPosAuto(core);
1007 break;
1008 case MountEquinoxEquatorial:
1009 v = objectMgr->getSelectedObject()[0]->getEquinoxEquatorialPos(core);
1010 break;
1011 case MountGalactic:
1012 v = objectMgr->getSelectedObject()[0]->getGalacticPos(core);
1013 break;
1014 default:
1015 qWarning() << "StelMovementMgr: unexpected mountMode" << mountMode;
1016 Q_ASSERT(0);
1017 }
1018
1019 double lat, lon; // general: longitudinal, latitudinal
1020 StelUtils::rectToSphe(&lon, &lat, v);
1021 float latOffset=core->getCurrentStelProjectorParams().viewportCenterOffset[1]*currentFov*M_PI/180.0f;
1022 lat+=latOffset;
1023 StelUtils::spheToRect(lon, lat, v);
1024
1025 if (flagAutoMove)
1026 {
1027 move.aim=mountFrameToJ2000(v);
1028 move.aim.normalize();
1029 move.aim*=2.;
1030 }
1031 else
1032 {
1033 setViewDirectionJ2000(mountFrameToJ2000(v));
1034 }
955 }1035 }
956 }1036 }
957}1037}
@@ -961,8 +1041,8 @@
961{1041{
962 moveDuration /= movementsSpeedFactor;1042 moveDuration /= movementsSpeedFactor;
9631043
964 zoomMove.aim=aim_fov;1044 zoomMove.aimFov=aim_fov;
965 zoomMove.start=currentFov;1045 zoomMove.startFov=currentFov;
966 zoomMove.speed=1.f/(moveDuration*1000);1046 zoomMove.speed=1.f/(moveDuration*1000);
967 zoomMove.coef=0.;1047 zoomMove.coef=0.;
968 flagAutoZoom = true;1048 flagAutoZoom = true;
@@ -991,7 +1071,7 @@
9911071
992double StelMovementMgr::getAimFov(void) const1072double StelMovementMgr::getAimFov(void) const
993{1073{
994 return (flagAutoZoom ? zoomMove.aim : currentFov);1074 return (flagAutoZoom ? zoomMove.aimFov : currentFov);
995}1075}
9961076
997void StelMovementMgr::setMaxFov(double max)1077void StelMovementMgr::setMaxFov(double max)
9981078
=== modified file 'src/core/StelMovementMgr.hpp'
--- src/core/StelMovementMgr.hpp 2015-03-25 18:18:33 +0000
+++ src/core/StelMovementMgr.hpp 2015-07-24 14:57:31 +0000
@@ -1,6 +1,7 @@
1/*1/*
2 * Stellarium2 * Stellarium
3 * Copyright (C) 2007 Fabien Chereau3 * Copyright (C) 2007 Fabien Chereau
4 * Copyright (C) 2015 Georg Zotti (offset view adaptations)
4 *5 *
5 * This program is free software; you can redistribute it and/or6 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License7 * modify it under the terms of the GNU General Public License
@@ -38,6 +39,8 @@
38public:39public:
3940
40 //! Possible mount modes defining the reference frame in which head movements occur.41 //! Possible mount modes defining the reference frame in which head movements occur.
42 //! MountGalactic is currently only available via scripting API: core.clear("galactic")
43 // TODO: add others like MountEcliptical
41 enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGalactic};44 enum MountMode { MountAltAzimuthal, MountEquinoxEquatorial, MountGalactic};
4245
43 StelMovementMgr(StelCore* core);46 StelMovementMgr(StelCore* core);
@@ -157,7 +160,7 @@
157160
158 //! Change the zoom level.161 //! Change the zoom level.
159 //! @param aimFov The desired field of view in degrees.162 //! @param aimFov The desired field of view in degrees.
160 //! @param moveDuration The time that the operation should take to complete.163 //! @param moveDuration The time that the operation should take to complete. [seconds]
161 void zoomTo(double aimFov, float moveDuration = 1.);164 void zoomTo(double aimFov, float moveDuration = 1.);
162 //! Get the current Field Of View in degrees165 //! Get the current Field Of View in degrees
163 double getCurrentFov() const {return currentFov;}166 double getCurrentFov() const {return currentFov;}
@@ -221,10 +224,10 @@
221 Vec3d j2000ToMountFrame(const Vec3d& v) const;224 Vec3d j2000ToMountFrame(const Vec3d& v) const;
222 Vec3d mountFrameToJ2000(const Vec3d& v) const;225 Vec3d mountFrameToJ2000(const Vec3d& v) const;
223226
224 double currentFov; // The current FOV in degree227 double currentFov; // The current FOV in degrees
225 double initFov; // The FOV at startup228 double initFov; // The FOV at startup
226 double minFov; // Minimum FOV in degree229 double minFov; // Minimum FOV in degrees
227 double maxFov; // Maximum FOV in degree230 double maxFov; // Maximum FOV in degrees
228 double initConstellationIntensity; // The initial constellation art intensity (level at startup)231 double initConstellationIntensity; // The initial constellation art intensity (level at startup)
229232
230 void setFov(double f)233 void setFov(double f)
@@ -287,7 +290,7 @@
287 double deltaFov,deltaAlt,deltaAz; // View movement290 double deltaFov,deltaAlt,deltaAz; // View movement
288291
289 bool flagManualZoom; // Define whether auto zoom can go further292 bool flagManualZoom; // Define whether auto zoom can go further
290 float autoMoveDuration; // Duration of movement for the auto move to a selected objectin seconds293 float autoMoveDuration; // Duration of movement for the auto move to a selected object in seconds
291294
292 // Mouse control options295 // Mouse control options
293 bool isDragging, hasDragged;296 bool isDragging, hasDragged;
@@ -311,10 +314,15 @@
311314
312 //! @internal315 //! @internal
313 //! Store data for auto-zoom.316 //! Store data for auto-zoom.
317 // Components:
318 // startFov: field of view at start
319 // aimFov: intended field of view at end of zoom move
320 // speed: rate of change. UNITS?
321 // coef: set to 0 at begin of zoom, will increase to 1 during autozoom motion.
314 struct AutoZoom322 struct AutoZoom
315 {323 {
316 double start;324 double startFov;
317 double aim;325 double aimFov;
318 float speed;326 float speed;
319 float coef;327 float coef;
320 };328 };
321329
=== modified file 'src/core/StelProjector.cpp'
--- src/core/StelProjector.cpp 2014-11-06 10:59:07 +0000
+++ src/core/StelProjector.cpp 2015-07-24 14:57:31 +0000
@@ -22,6 +22,8 @@
2222
23#include "StelProjector.hpp"23#include "StelProjector.hpp"
24#include "StelProjectorClasses.hpp"24#include "StelProjectorClasses.hpp"
25#include "StelApp.hpp"
26#include "StelCore.hpp"
2527
26#include <QDebug>28#include <QDebug>
27#include <QString>29#include <QString>
@@ -385,7 +387,9 @@
385void StelProjector::computeBoundingCap()387void StelProjector::computeBoundingCap()
386{388{
387 bool ok = unProject(viewportXywh[0]+0.5f*viewportXywh[2], viewportXywh[1]+0.5f*viewportXywh[3], boundingCap.n);389 bool ok = unProject(viewportXywh[0]+0.5f*viewportXywh[2], viewportXywh[1]+0.5f*viewportXywh[3], boundingCap.n);
388 Q_ASSERT(ok); // The central point should be at a valid position by definition390 // The central point should be at a valid position by definition.
391 // When center is offset, this assumption may not hold however.
392 Q_ASSERT(ok || (StelApp::getInstance().getCore()->getCurrentStelProjectorParams().viewportCenterOffset.lengthSquared()>0.0) );
389 const bool needNormalization = fabs(boundingCap.n.lengthSquared()-1.)>0.00000001;393 const bool needNormalization = fabs(boundingCap.n.lengthSquared()-1.)>0.00000001;
390394
391 // Now need to determine the aperture395 // Now need to determine the aperture
392396
=== modified file 'src/core/StelProjector.hpp'
--- src/core/StelProjector.hpp 2014-11-06 10:59:07 +0000
+++ src/core/StelProjector.hpp 2015-07-24 14:57:31 +0000
@@ -102,6 +102,7 @@
102 , zNear(0.f)102 , zNear(0.f)
103 , zFar(0.f)103 , zFar(0.f)
104 , viewportCenter(128.f, 128.f)104 , viewportCenter(128.f, 128.f)
105 , viewportCenterOffset(0.f, 0.f)
105 , viewportFovDiameter(0.f)106 , viewportFovDiameter(0.f)
106 , flipHorz(false)107 , flipHorz(false)
107 , flipVert(false)108 , flipVert(false)
@@ -114,6 +115,7 @@
114 StelProjectorMaskType maskType; //! The current projector mask115 StelProjectorMaskType maskType; //! The current projector mask
115 float zNear, zFar; //! Near and far clipping planes116 float zNear, zFar; //! Near and far clipping planes
116 Vec2f viewportCenter; //! Viewport center in screen pixel117 Vec2f viewportCenter; //! Viewport center in screen pixel
118 Vec2f viewportCenterOffset; //! GZ: Viewport center's offset in fractions of screen width/height. Usable e.g. in cylindrical projection to move horizon down.
117 float viewportFovDiameter; //! diameter of the FOV disk in pixel119 float viewportFovDiameter; //! diameter of the FOV disk in pixel
118 bool flipHorz, flipVert; //! Whether to flip in horizontal or vertical directions120 bool flipHorz, flipVert; //! Whether to flip in horizontal or vertical directions
119 float devicePixelsPerPixel; //! The number of device pixel per "Device Independent Pixels" (value is usually 1, but 2 for mac retina screens)121 float devicePixelsPerPixel; //! The number of device pixel per "Device Independent Pixels" (value is usually 1, but 2 for mac retina screens)
120122
=== modified file 'src/gui/ConfigurationDialog.cpp'
--- src/gui/ConfigurationDialog.cpp 2015-05-23 20:00:14 +0000
+++ src/gui/ConfigurationDialog.cpp 2015-07-24 14:57:31 +0000
@@ -695,6 +695,8 @@
695 conf->setValue("gui/flag_show_flip_buttons", gui->getFlagShowFlipButtons());695 conf->setValue("gui/flag_show_flip_buttons", gui->getFlagShowFlipButtons());
696 conf->setValue("video/viewport_effect", StelApp::getInstance().getViewportEffect());696 conf->setValue("video/viewport_effect", StelApp::getInstance().getViewportEffect());
697 conf->setValue("projection/viewport", StelProjector::maskTypeToString(proj->getMaskType()));697 conf->setValue("projection/viewport", StelProjector::maskTypeToString(proj->getMaskType()));
698 conf->setValue("projection/viewport_center_offset_x", core->getCurrentStelProjectorParams().viewportCenterOffset[0]);
699 conf->setValue("projection/viewport_center_offset_y", core->getCurrentStelProjectorParams().viewportCenterOffset[1]);
698 conf->setValue("viewing/flag_gravity_labels", proj->getFlagGravityLabels());700 conf->setValue("viewing/flag_gravity_labels", proj->getFlagGravityLabels());
699 conf->setValue("navigation/auto_zoom_out_resets_direction", mvmgr->getFlagAutoZoomOutResetsDirection());701 conf->setValue("navigation/auto_zoom_out_resets_direction", mvmgr->getFlagAutoZoomOutResetsDirection());
700 conf->setValue("gui/flag_mouse_cursor_timeout", StelMainView::getInstance().getFlagCursorTimeout());702 conf->setValue("gui/flag_mouse_cursor_timeout", StelMainView::getInstance().getFlagCursorTimeout());
701703
=== modified file 'src/gui/ViewDialog.cpp'
--- src/gui/ViewDialog.cpp 2015-05-23 20:00:14 +0000
+++ src/gui/ViewDialog.cpp 2015-07-24 14:57:31 +0000
@@ -134,8 +134,11 @@
134 connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));134 connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
135135
136 populateLists();136 populateLists();
137 ui->viewportOffsetSpinBox->setValue((int) round(StelApp::getInstance().getCore()->getCurrentStelProjectorParams().viewportCenterOffset[1] * 100.0f));
138
137 connect(ui->culturesListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(skyCultureChanged(const QString&)));139 connect(ui->culturesListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(skyCultureChanged(const QString&)));
138 connect(ui->projectionListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(projectionChanged(const QString&)));140 connect(ui->projectionListWidget, SIGNAL(currentTextChanged(const QString&)), this, SLOT(projectionChanged(const QString&)));
141 connect(ui->viewportOffsetSpinBox, SIGNAL(valueChanged(int)), this, SLOT(viewportVerticalShiftChanged(int)));
139 connect(ui->landscapesListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(landscapeChanged(QListWidgetItem*)));142 connect(ui->landscapesListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(landscapeChanged(QListWidgetItem*)));
140143
141 // Connect and initialize checkboxes and other widgets144 // Connect and initialize checkboxes and other widgets
@@ -602,6 +605,18 @@
602 ui->projectionTextBrowser->setHtml(core->getProjection(StelCore::FrameJ2000)->getHtmlSummary());605 ui->projectionTextBrowser->setHtml(core->getProjection(StelCore::FrameJ2000)->getHtmlSummary());
603}606}
604607
608void ViewDialog::viewportVerticalShiftChanged(const int shift)
609{
610 StelCore* core = StelApp::getInstance().getCore();
611 StelProjector::StelProjectorParams params=core->getCurrentStelProjectorParams();
612 params.viewportCenterOffset[1]=qMax(-0.5f, qMin(shift/100.0f, 0.5f)); // Sanity check
613
614 params.viewportCenter.set(params.viewportXywh[0]+(0.5f+params.viewportCenterOffset.v[0])*params.viewportXywh[2],
615 params.viewportXywh[1]+(0.5f+params.viewportCenterOffset.v[1])*params.viewportXywh[3]);
616
617 core->setCurrentStelProjectorParams(params);
618}
619
605void ViewDialog::landscapeChanged(QListWidgetItem* item)620void ViewDialog::landscapeChanged(QListWidgetItem* item)
606{621{
607 LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);622 LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
@@ -612,8 +627,7 @@
612 ui->landscapeTextBrowser->setHtml(lmgr->getCurrentLandscapeHtmlDescription());627 ui->landscapeTextBrowser->setHtml(lmgr->getCurrentLandscapeHtmlDescription());
613 ui->useAsDefaultLandscapeCheckBox->setChecked(lmgr->getDefaultLandscapeID()==lmgr->getCurrentLandscapeID());628 ui->useAsDefaultLandscapeCheckBox->setChecked(lmgr->getDefaultLandscapeID()==lmgr->getCurrentLandscapeID());
614 ui->useAsDefaultLandscapeCheckBox->setEnabled(lmgr->getDefaultLandscapeID()!=lmgr->getCurrentLandscapeID());629 ui->useAsDefaultLandscapeCheckBox->setEnabled(lmgr->getDefaultLandscapeID()!=lmgr->getCurrentLandscapeID());
615 //StelSkyDrawer *drawer=StelApp::getInstance().getSkyDrawer();630 // Reset values that might have changed.
616 // GZ: Reset values that might have changed.
617 ui->showFogCheckBox->setChecked(lmgr->getFlagFog());631 ui->showFogCheckBox->setChecked(lmgr->getFlagFog());
618 ui->lightPollutionSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getBortleScaleIndex());632 ui->lightPollutionSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getBortleScaleIndex());
619}633}
@@ -630,9 +644,6 @@
630{644{
631 if(atmosphereDialog == NULL)645 if(atmosphereDialog == NULL)
632 atmosphereDialog = new AtmosphereDialog();646 atmosphereDialog = new AtmosphereDialog();
633 //ui->temperatureDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getAtmosphereTemperature());
634 //ui->extinctionDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getExtinctionCoefficient());
635 //ui->pressureDoubleSpinBox->setValue(StelApp::getInstance().getCore()->getSkyDrawer()->getAtmospherePressure());
636647
637 atmosphereDialog->setVisible(true);648 atmosphereDialog->setVisible(true);
638}649}
639650
=== modified file 'src/gui/ViewDialog.hpp'
--- src/gui/ViewDialog.hpp 2015-04-11 14:08:59 +0000
+++ src/gui/ViewDialog.hpp 2015-07-24 14:57:31 +0000
@@ -50,6 +50,7 @@
50 void populateLists();50 void populateLists();
51 void skyCultureChanged(const QString& cultureName);51 void skyCultureChanged(const QString& cultureName);
52 void projectionChanged(const QString& projectionName);52 void projectionChanged(const QString& projectionName);
53 void viewportVerticalShiftChanged(const int shift);
53 void landscapeChanged(QListWidgetItem* item);54 void landscapeChanged(QListWidgetItem* item);
54 void setZhrFromControls(int zhr);55 void setZhrFromControls(int zhr);
55 void updateZhrDescription();56 void updateZhrDescription();
5657
=== modified file 'src/gui/viewDialog.ui'
--- src/gui/viewDialog.ui 2015-05-23 20:00:14 +0000
+++ src/gui/viewDialog.ui 2015-07-24 14:57:31 +0000
@@ -340,7 +340,7 @@
340 <item row="1" column="0">340 <item row="1" column="0">
341 <widget class="QStackedWidget" name="stackedWidget">341 <widget class="QStackedWidget" name="stackedWidget">
342 <property name="currentIndex">342 <property name="currentIndex">
343 <number>0</number>343 <number>1</number>
344 </property>344 </property>
345 <widget class="QWidget" name="page">345 <widget class="QWidget" name="page">
346 <layout class="QGridLayout" name="gridLayout">346 <layout class="QGridLayout" name="gridLayout">
@@ -1636,11 +1636,68 @@
1636 </widget>1636 </widget>
1637 </item>1637 </item>
1638 <item>1638 <item>
1639 <widget class="QTextBrowser" name="projectionTextBrowser">1639 <layout class="QVBoxLayout" name="projectionDetailsVerticalLayout">
1640 <property name="openExternalLinks">1640 <item>
1641 <bool>true</bool>1641 <widget class="QTextBrowser" name="projectionTextBrowser">
1642 </property>1642 <property name="openExternalLinks">
1643 </widget>1643 <bool>true</bool>
1644 </property>
1645 </widget>
1646 </item>
1647 <item>
1648 <layout class="QHBoxLayout" name="viewportOffsetHorizontalLayout">
1649 <item>
1650 <widget class="QLabel" name="viewportOffsetLabel">
1651 <property name="text">
1652 <string>Vertical viewport offset</string>
1653 </property>
1654 </widget>
1655 </item>
1656 <item>
1657 <widget class="QSpinBox" name="viewportOffsetSpinBox">
1658 <property name="sizePolicy">
1659 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
1660 <horstretch>0</horstretch>
1661 <verstretch>0</verstretch>
1662 </sizepolicy>
1663 </property>
1664 <property name="minimum">
1665 <number>-50</number>
1666 </property>
1667 <property name="maximum">
1668 <number>50</number>
1669 </property>
1670 </widget>
1671 </item>
1672 <item>
1673 <widget class="QLabel" name="percentLabel">
1674 <property name="sizePolicy">
1675 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
1676 <horstretch>0</horstretch>
1677 <verstretch>0</verstretch>
1678 </sizepolicy>
1679 </property>
1680 <property name="text">
1681 <string>%</string>
1682 </property>
1683 </widget>
1684 </item>
1685 <item>
1686 <spacer name="horizontalSpacer">
1687 <property name="orientation">
1688 <enum>Qt::Horizontal</enum>
1689 </property>
1690 <property name="sizeHint" stdset="0">
1691 <size>
1692 <width>40</width>
1693 <height>20</height>
1694 </size>
1695 </property>
1696 </spacer>
1697 </item>
1698 </layout>
1699 </item>
1700 </layout>
1644 </item>1701 </item>
1645 </layout>1702 </layout>
1646 </widget>1703 </widget>
@@ -2171,7 +2228,6 @@
2171 <tabstop>showConstellationBoundariesCheckBox</tabstop>2228 <tabstop>showConstellationBoundariesCheckBox</tabstop>
2172 <tabstop>showConstellationArtCheckBox</tabstop>2229 <tabstop>showConstellationArtCheckBox</tabstop>
2173 <tabstop>constellationArtBrightnessSpinBox</tabstop>2230 <tabstop>constellationArtBrightnessSpinBox</tabstop>
2174 <tabstop>projectionTextBrowser</tabstop>
2175 <tabstop>landscapeTextBrowser</tabstop>2231 <tabstop>landscapeTextBrowser</tabstop>
2176 <tabstop>showGroundCheckBox</tabstop>2232 <tabstop>showGroundCheckBox</tabstop>
2177 <tabstop>showFogCheckBox</tabstop>2233 <tabstop>showFogCheckBox</tabstop>
21782234
=== modified file 'src/scripting/StelMainScriptAPI.cpp'
--- src/scripting/StelMainScriptAPI.cpp 2015-04-21 20:23:14 +0000
+++ src/scripting/StelMainScriptAPI.cpp 2015-07-24 14:57:31 +0000
@@ -1072,6 +1072,40 @@
1072 lmgr->setFlagFog(false);1072 lmgr->setFlagFog(false);
1073 zl->setFlagShow(false);1073 zl->setFlagShow(false);
1074 }1074 }
1075 else if (state.toLower() == "galactic")
1076 {
1077 movmgr->setMountMode(StelMovementMgr::MountGalactic);
1078 skyd->setFlagTwinkle(false);
1079 skyd->setFlagLuminanceAdaptation(false);
1080 ssmgr->setFlagPlanets(false);
1081 ssmgr->setFlagHints(false);
1082 ssmgr->setFlagOrbits(false);
1083 ssmgr->setFlagMoonScale(false);
1084 ssmgr->setFlagTrails(false);
1085 mmgr->setZHR(0);
1086 glmgr->setFlagAzimuthalGrid(false);
1087 glmgr->setFlagGalacticGrid(false);
1088 glmgr->setFlagEquatorGrid(false);
1089 glmgr->setFlagEquatorLine(false);
1090 glmgr->setFlagEclipticLine(false);
1091 glmgr->setFlagMeridianLine(false);
1092 glmgr->setFlagLongitudeLine(false);
1093 glmgr->setFlagHorizonLine(false);
1094 glmgr->setFlagGalacticEquatorLine(false);
1095 glmgr->setFlagEquatorJ2000Grid(false);
1096 lmgr->setFlagCardinalsPoints(false);
1097 cmgr->setFlagLines(false);
1098 cmgr->setFlagLabels(false);
1099 cmgr->setFlagBoundaries(false);
1100 cmgr->setFlagArt(false);
1101 smgr->setFlagLabels(false);
1102 ssmgr->setFlagLabels(false);
1103 nmgr->setFlagHints(false);
1104 lmgr->setFlagLandscape(false);
1105 lmgr->setFlagAtmosphere(false);
1106 lmgr->setFlagFog(false);
1107 zl->setFlagShow(false);
1108 }
1075 else1109 else
1076 {1110 {
1077 qWarning() << "WARNING clear(" << state << ") - state not known";1111 qWarning() << "WARNING clear(" << state << ") - state not known";
10781112
=== modified file 'src/scripting/StelMainScriptAPI.hpp'
--- src/scripting/StelMainScriptAPI.hpp 2015-07-05 19:50:54 +0000
+++ src/scripting/StelMainScriptAPI.hpp 2015-07-24 14:57:31 +0000
@@ -219,6 +219,7 @@
219 //! - starchart : equatorial mount, constellation lines,219 //! - starchart : equatorial mount, constellation lines,
220 //! no landscape, atmosphere etc. labels & markers on.220 //! no landscape, atmosphere etc. labels & markers on.
221 //! - deepspace : like starchart, but no planets, no eq.grid, no markers, no lines.221 //! - deepspace : like starchart, but no planets, no eq.grid, no markers, no lines.
222 //! - galactic : like deepspace, but in galactic coordinate system.
222 //! @param state the name of a preset state.223 //! @param state the name of a preset state.
223 void clear(const QString& state="natural");224 void clear(const QString& state="natural");
224225