StelMovementMgr.cpp   StelMovementMgr.cpp 
skipping to change at line 19 skipping to change at line 19
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ *
* TODO: Rewrite this class. It has been much of the easy feel of Stellariu
m, but is terribly complicated to maintain.
* Very likely some things can be made clearer, more efficient, use modern
Qt things instead of manual solutions, etc.
* Esp. the up-vector requirements for zenith views cause lots of headache.
* In case we want to have other mount modes (ecliptical, galactical, ...),
several parts have to be extended.
*/
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include <cmath> #include <cmath>
skipping to change at line 41 skipping to change at line 46
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
StelMovementMgr::StelMovementMgr(StelCore* acore) StelMovementMgr::StelMovementMgr(StelCore* acore)
: currentFov(60.) : currentFov(60.)
, initFov(60.) , initFov(60.)
, minFov(0.001389) , minFov(0.001389)
, maxFov(100.) , maxFov(100.)
, deltaFov(0.)
, core(acore) , core(acore)
, objectMgr(NULL) , objectMgr(NULL)
, flagLockEquPos(false) , flagLockEquPos(false)
, flagTracking(false) , flagTracking(false)
, flagInhibitAllAutomoves(false) , flagInhibitAllAutomoves(false)
, isMouseMovingHoriz(false) , isMouseMovingHoriz(false)
, isMouseMovingVert(false) , isMouseMovingVert(false)
, flagEnableMoveAtScreenEdge(false) , flagEnableMoveAtScreenEdge(false)
, flagEnableMouseNavigation(true) , flagEnableMouseNavigation(true)
, mouseZoomSpeed(30) , mouseZoomSpeed(30)
, flagEnableZoomKeys(true) , flagEnableZoomKeys(true)
, flagEnableMoveKeys(true) , flagEnableMoveKeys(true)
, keyMoveSpeed(0.00025) , keyMoveSpeed(0.00025)
, keyZoomSpeed(0.00025) , keyZoomSpeed(0.00025)
, flagMoveSlow(false) , flagMoveSlow(false)
, movementsSpeedFactor(1.5) , movementsSpeedFactor(1.0)
, move()
, flagAutoMove(false) , flagAutoMove(false)
, zoomingMode(ZoomNone) , zoomingMode(ZoomNone)
, deltaFov(0.)
, deltaAlt(0.) , deltaAlt(0.)
, deltaAz(0.) , deltaAz(0.)
, flagManualZoom(false) , flagManualZoom(false)
, autoMoveDuration(1.5) , autoMoveDuration(1.5)
, isDragging(false)
, hasDragged(false) , hasDragged(false)
, previousX(0) , previousX(0)
, previousY(0) , previousY(0)
, beforeTimeDragTimeRate(0.) , beforeTimeDragTimeRate(0.)
, dragTimeMode(false) , dragTimeMode(false)
, zoomMove() , zoomMove()
, flagAutoZoom(0) , flagAutoZoom(false)
, flagAutoZoomOutResetsDirection(0) , flagAutoZoomOutResetsDirection(false)
, mountMode(MountAltAzimuthal)
, initViewPos(1., 0., 0.)
, initViewUp(0., 0., 1.)
, viewDirectionJ2000(0., 1., 0.)
, viewDirectionMountFrame(0., 1., 0.)
, upVectorMountFrame(0.,0.,1.)
, dragTriggerDistance(4.f) , dragTriggerDistance(4.f)
, viewportOffsetTimeline(NULL) , viewportOffsetTimeline(NULL)
, oldViewportOffset(0.0f, 0.0f)
, targetViewportOffset(0.0f, 0.0f)
{ {
setObjectName("StelMovementMgr"); setObjectName("StelMovementMgr");
isDragging = false;
mountMode = MountAltAzimuthal; // default
upVectorMountFrame.set(0.,0.,1.);
} }
StelMovementMgr::~StelMovementMgr() StelMovementMgr::~StelMovementMgr()
{ {
if (viewportOffsetTimeline) delete viewportOffsetTimeline; viewportO if (viewportOffsetTimeline)
ffsetTimeline=NULL; {
delete viewportOffsetTimeline;
viewportOffsetTimeline=NULL;
}
} }
void StelMovementMgr::init() void StelMovementMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
objectMgr = GETSTELMODULE(StelObjectMgr); objectMgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(conf); Q_ASSERT(conf);
Q_ASSERT(objectMgr); Q_ASSERT(objectMgr);
connect(objectMgr, SIGNAL(selectedObjectChanged(StelModule::StelModu leSelectAction)), connect(objectMgr, SIGNAL(selectedObjectChanged(StelModule::StelModu leSelectAction)),
this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction))); this, SLOT(selectedObjectChange(StelModule::StelModuleSelect Action)));
movementsSpeedFactor=1.;
flagEnableMoveAtScreenEdge = conf->value("navigation/flag_enable_mov e_at_screen_edge",false).toBool(); flagEnableMoveAtScreenEdge = conf->value("navigation/flag_enable_mov e_at_screen_edge",false).toBool();
mouseZoomSpeed = conf->value("navigation/mouse_zoom",30).toInt(); mouseZoomSpeed = conf->value("navigation/mouse_zoom",30).toInt();
flagEnableZoomKeys = conf->value("navigation/flag_enable_zoom_keys") .toBool(); flagEnableZoomKeys = conf->value("navigation/flag_enable_zoom_keys") .toBool();
flagEnableMoveKeys = conf->value("navigation/flag_enable_move_keys") .toBool(); flagEnableMoveKeys = conf->value("navigation/flag_enable_move_keys") .toBool();
keyMoveSpeed = conf->value("navigation/move_speed",0.0004f).toFloat( ); keyMoveSpeed = conf->value("navigation/move_speed",0.0004f).toFloat( );
keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004f).toFloat (); keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004f).toFloat ();
autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5f ).toFloat(); autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5f ).toFloat();
flagManualZoom = conf->value("navigation/flag_manual_zoom").toBool() ; flagManualZoom = conf->value("navigation/flag_manual_zoom").toBool() ;
flagAutoZoomOutResetsDirection = conf->value("navigation/auto_zoom_o ut_resets_direction", true).toBool(); flagAutoZoomOutResetsDirection = conf->value("navigation/auto_zoom_o ut_resets_direction", true).toBool();
flagEnableMouseNavigation = conf->value("navigation/flag_enable_mous e_navigation",true).toBool(); flagEnableMouseNavigation = conf->value("navigation/flag_enable_mous e_navigation",true).toBool();
minFov = conf->value("navigation/min_fov",0.001389).toDouble(); // d efault: minimal FOV = 5" minFov = conf->value("navigation/min_fov",0.001389).toDouble(); // d efault: minimal FOV = 5"
maxFov = 100.;
initFov = conf->value("navigation/init_fov",60.f).toFloat(); initFov = conf->value("navigation/init_fov",60.f).toFloat();
currentFov = initFov; currentFov = initFov;
// we must set mount mode before potentially loading zenith views et
c.
QString tmpstr = conf->value("navigation/viewing_mode", "horizon").t
oString();
if (tmpstr=="equator")
setMountMode(StelMovementMgr::MountEquinoxEquatorial);
else
{
if (tmpstr=="horizon")
setMountMode(StelMovementMgr::MountAltAzimuthal);
else
{
qWarning() << "ERROR: Unknown viewing mode type: " <
< tmpstr;
setMountMode(StelMovementMgr::MountEquinoxEquatorial
);
}
}
// With a special code of init_view_position=x/y/1 (or actually, any thing equal or larger to 1) you can set zenith into the center and atan2(x/ y) to bottom of screen. // With a special code of init_view_position=x/y/1 (or actually, any thing equal or larger to 1) you can set zenith into the center and atan2(x/ y) to bottom of screen.
// examples: 1/0->0 NORTH is bottom // examples: 1/0 ->0 NORTH is bottom
// -1/0 ->180 SOUTH is bottom // -1/0 ->180 SOUTH is bottom
// 0/-1 --> 90 EAST is bottom // 0/-1 -> 90 EAST is bottom
// 0/1 ->270 WEST is bottom // 0/1 ->270 WEST is bottom
Vec3f tmp = StelUtils::strToVec3f(conf->value("navigation/init_view_ Vec3f tmp = StelUtils::strToVec3f(conf->value("navigation/init_view_
pos").toString()); pos", "1,0,0").toString());
//qDebug() << "initViewPos" << tmp[0] << "/" << tmp[1] << "/" << tmp
[2];
if (tmp[2]>=1) if (tmp[2]>=1)
{ {
//qDebug() << "Special zenith setup:"; //qDebug() << "Special zenith setup:";
setViewDirectionJ2000(mountFrameToJ2000(Vec3d(0., 0., 1.))); setViewDirectionJ2000(mountFrameToJ2000(Vec3d(0., 0., 1.)));
initViewPos.set(0., 0., 1.); initViewPos.set(0., 0., 1.);
// It is not good to code 0/0/1 as view vector: bottom azimu th is undefined. Use default-south: // It is not good to code 0/0/1 as view vector: bottom azimu th is undefined. Use default-south:
if ((tmp[0]==0.) && (tmp[1]==0.)) if ((tmp[0]==0.) && (tmp[1]==0.))
tmp[0]=-1.; tmp[0]=-1.;
upVectorMountFrame.set(tmp[0], tmp[1], 0.); upVectorMountFrame.set(tmp[0], tmp[1], 0.);
upVectorMountFrame.normalize(); upVectorMountFrame.normalize();
initViewUp=upVectorMountFrame; initViewUp=upVectorMountFrame;
//qDebug() << "InitViewUp: " << initViewUp;
} }
else else
{ {
//qDebug() << "simpler view vectors...";
//qDebug() << " initViewPos becomes " << tmp[0] << "/" <<
tmp[1] << "/" << tmp[2];
initViewPos.set(tmp[0], tmp[1], tmp[2]); initViewPos.set(tmp[0], tmp[1], tmp[2]);
initViewUp.set(0., 0., 1.); //qDebug() << " initViewPos is " << initViewPos[0] << "/" << initViewPos[1] << "/" << initViewPos[2];
viewDirectionJ2000 = core->altAzToJ2000(initViewPos, StelCor e::RefractionOff); viewDirectionJ2000 = core->altAzToJ2000(initViewPos, StelCor e::RefractionOff);
} //qDebug() << "viewDirectionJ2000: " << viewDirectionJ2000[0
] << "/" << viewDirectionJ2000[1] << "/" << viewDirectionJ2000[2];
setViewDirectionJ2000(viewDirectionJ2000);
//qDebug() << " up2000 initViewUp becomes " << initViewUp[
0] << "/" << initViewUp[1] << "/" << initViewUp[2];
setViewUpVector(initViewUp);
QString tmpstr = conf->value("navigation/viewing_mode", "horizon").t //qDebug() << " upVectorMountFrame becomes " << upVectorMo
oString(); untFrame[0] << "/" << upVectorMountFrame[1] << "/" << upVectorMountFrame[2]
if (tmpstr=="equator") ;
setMountMode(StelMovementMgr::MountEquinoxEquatorial);
else
{
if (tmpstr=="horizon")
setMountMode(StelMovementMgr::MountAltAzimuthal);
else
{
qWarning() << "ERROR: Unknown viewing mode type: " <
< tmpstr;
setMountMode(StelMovementMgr::MountEquinoxEquatorial
);
}
} }
QString movementGroup = N_("Movement and Selection"); QString movementGroup = N_("Movement and Selection");
addAction("actionSwitch_Equatorial_Mount", N_("Miscellaneous"), N_(" Switch between equatorial and azimuthal mount"), "equatorialMount", "Ctrl+M "); addAction("actionSwitch_Equatorial_Mount", N_("Miscellaneous"), N_(" Switch between equatorial and azimuthal mount"), "equatorialMount", "Ctrl+M ");
addAction("actionGoto_Selected_Object", movementGroup, N_("Center on selected object"), "setFlagTracking()", "Space"); addAction("actionGoto_Selected_Object", movementGroup, N_("Center on selected object"), "setFlagTracking()", "Space");
addAction("actionZoom_In_Auto", movementGroup, N_("Zoom in on select ed object"), "autoZoomIn()", "/"); addAction("actionZoom_In_Auto", movementGroup, N_("Zoom in on select ed object"), "autoZoomIn()", "/");
addAction("actionZoom_Out_Auto", movementGroup, N_("Zoom out"), "aut oZoomOut()", "\\"); addAction("actionZoom_Out_Auto", movementGroup, N_("Zoom out"), "aut oZoomOut()", "\\");
addAction("actionSet_Tracking", movementGroup, N_("Track object"), " tracking", "T"); addAction("actionSet_Tracking", movementGroup, N_("Track object"), " tracking", "T");
// Implementation of quick turning to different directions (examples : CdC, HNSKY) // Implementation of quick turning to different directions (examples : CdC, HNSKY)
addAction("actionLook_Towards_East", movementGroup, N_("Look towards East"), "lookEast()", "Shift+E"); addAction("actionLook_Towards_East", movementGroup, N_("Look towards East"), "lookEast()", "Shift+E");
addAction("actionLook_Towards_West", movementGroup, N_("Look towards West"), "lookWest()", "Shift+W"); addAction("actionLook_Towards_West", movementGroup, N_("Look towards West"), "lookWest()", "Shift+W");
addAction("actionLook_Towards_North", movementGroup, N_("Look toward s North"), "lookNorth()", "Shift+N"); addAction("actionLook_Towards_North", movementGroup, N_("Look toward s North"), "lookNorth()", "Shift+N");
addAction("actionLook_Towards_South", movementGroup, N_("Look toward s South"), "lookSouth()", "Shift+S"); addAction("actionLook_Towards_South", movementGroup, N_("Look toward s South"), "lookSouth()", "Shift+S");
addAction("actionLook_Towards_Zenith", movementGroup, N_("Look towar ds Zenith"), "lookZenith()", "Shift+Z"); addAction("actionLook_Towards_Zenith", movementGroup, N_("Look towar ds Zenith"), "lookZenith()", "Shift+Z");
// Additional hooks
addAction("actionLook_Towards_NCP", movementGroup, N_("Look towards
North Celestial pole"), "lookTowardsNCP()", "Alt+Shift+N");
addAction("actionLook_Towards_SCP", movementGroup, N_("Look towards
South Celestial pole"), "lookTowardsSCP()", "Alt+Shift+S");
viewportOffsetTimeline=new QTimeLine(1000, this); viewportOffsetTimeline=new QTimeLine(1000, this);
viewportOffsetTimeline->setFrameRange(0, 100); viewportOffsetTimeline->setFrameRange(0, 100);
connect(viewportOffsetTimeline, SIGNAL(valueChanged(qreal)), this, S LOT(handleViewportOffsetMovement(qreal))); connect(viewportOffsetTimeline, SIGNAL(valueChanged(qreal)), this, S LOT(handleViewportOffsetMovement(qreal)));
targetViewportOffset.set(core->getViewportHorizontalOffset(), core-> getViewportVerticalOffset()); targetViewportOffset.set(core->getViewportHorizontalOffset(), core-> getViewportVerticalOffset());
} }
void StelMovementMgr::setMountMode(MountMode m) void StelMovementMgr::setMountMode(MountMode m)
{ {
mountMode = m; mountMode = m;
skipping to change at line 189 skipping to change at line 217
emit equatorialMountChanged(m==MountEquinoxEquatorial); emit equatorialMountChanged(m==MountEquinoxEquatorial);
} }
void StelMovementMgr::setFlagLockEquPos(bool b) void StelMovementMgr::setFlagLockEquPos(bool b)
{ {
flagLockEquPos=b; flagLockEquPos=b;
} }
void StelMovementMgr::setViewUpVectorJ2000(const Vec3d& up) void StelMovementMgr::setViewUpVectorJ2000(const Vec3d& up)
{ {
//qDebug() << "setViewUpvectorJ2000()";
upVectorMountFrame = j2000ToMountFrame(up); upVectorMountFrame = j2000ToMountFrame(up);
} }
// For simplicity you can set this directly. Take care when looking into po les like zenith in altaz mode: // For simplicity you can set this directly. Take care when looking into po les like zenith in altaz mode:
// We have a problem if alt=+/-90degrees: view and up angles are ill-define d (actually, angle between them=0 and therefore we saw shaky rounding effec ts), therefore Bug LP:1068529 // We have a problem if alt=+/-90degrees: view and up angles are ill-define d (actually, angle between them=0 and therefore we saw shaky rounding effec ts), therefore Bug LP:1068529
void StelMovementMgr::setViewUpVector(const Vec3d& up) void StelMovementMgr::setViewUpVector(const Vec3d& up)
{ {
//qDebug() << "setViewUpvector()";
upVectorMountFrame = up; upVectorMountFrame = up;
} }
Vec3d StelMovementMgr::getViewUpVectorJ2000() const Vec3d StelMovementMgr::getViewUpVectorJ2000() const
{ {
return mountFrameToJ2000(upVectorMountFrame); return mountFrameToJ2000(upVectorMountFrame);
} }
bool StelMovementMgr::handleMouseMoves(int x, int y, Qt::MouseButtons) bool StelMovementMgr::handleMouseMoves(int x, int y, Qt::MouseButtons)
{ {
// Turn if the mouse is at the edge of the screen unless config asks otherwise // Turn if the mouse is at the edge of the screen unless config asks otherwise
if (flagEnableMoveAtScreenEdge) if (flagEnableMoveAtScreenEdge)
{ {
if (x <= 1) if (x <= 1)
{ {
turnLeft(1); turnLeft(true);
isMouseMovingHoriz = true; isMouseMovingHoriz = true;
} }
else if (x >= core->getProjection2d()->getViewportWidth() - 2) else if (x >= core->getProjection2d()->getViewportWidth() - 2)
{ {
turnRight(1); turnRight(true);
isMouseMovingHoriz = true; isMouseMovingHoriz = true;
} }
else if (isMouseMovingHoriz) else if (isMouseMovingHoriz)
{ {
turnLeft(0); turnLeft(false);
isMouseMovingHoriz = false; isMouseMovingHoriz = false;
} }
if (y <= 1) if (y <= 1)
{ {
turnUp(1); turnUp(true);
isMouseMovingVert = true; isMouseMovingVert = true;
} }
else if (y >= core->getProjection2d()->getViewportHeight() - 2) else if (y >= core->getProjection2d()->getViewportHeight() - 2)
{ {
turnDown(1); turnDown(true);
isMouseMovingVert = true; isMouseMovingVert = true;
} }
else if (isMouseMovingVert) else if (isMouseMovingVert)
{ {
turnUp(0); turnUp(false);
isMouseMovingVert = false; isMouseMovingVert = false;
} }
} }
// We can hardly use the mouse exactly enough to go to the zenith/po
le. Any mouse motion can safely reset the simplified up vector.
setViewUpVector(Vec3d(0., 0., 1.));
if (isDragging && flagEnableMouseNavigation) if (isDragging && flagEnableMouseNavigation)
{ {
if (hasDragged || (std::sqrt((float)((x-previousX)*(x-previo usX) +(y-previousY)*(y-previousY)))>dragTriggerDistance)) if (hasDragged || (std::sqrt((float)((x-previousX)*(x-previo usX) +(y-previousY)*(y-previousY)))>dragTriggerDistance))
{ {
hasDragged = true; hasDragged = true;
setFlagTracking(false); setFlagTracking(false);
dragView(previousX, previousY, x, y); dragView(previousX, previousY, x, y);
previousX = x; previousX = x;
previousY = y; previousY = y;
// We can hardly use the mouse exactly enough to go
to the zenith/pole. Any mouse motion can safely reset the simplified up vec
tor.
//qDebug() << "handleMouseMoves: resetting Up vector
.";
setViewUpVector(Vec3d(0., 0., 1.));
return true; return true;
} }
} }
return false; return false;
} }
double StelMovementMgr::getCallOrder(StelModuleActionName actionName) const double StelMovementMgr::getCallOrder(StelModuleActionName actionName) const
{ {
// GZ: allow a few plugins to intercept keys! // allow plugins to intercept keys by using a lower number than this !
if (actionName == StelModule::ActionHandleKeys) if (actionName == StelModule::ActionHandleKeys)
return 5; return 5;
return 0; return 0;
} }
void StelMovementMgr::handleKeys(QKeyEvent* event) void StelMovementMgr::handleKeys(QKeyEvent* event)
{ {
if (event->type() == QEvent::KeyPress) if (event->type() == QEvent::KeyPress)
{ {
// Direction and zoom deplacements // Direction and zoom deplacements
skipping to change at line 299 skipping to change at line 329
} else { } else {
turnDown(true); turnDown(true);
} }
break; break;
case Qt::Key_PageUp: case Qt::Key_PageUp:
zoomIn(true); break; zoomIn(true); break;
case Qt::Key_PageDown: case Qt::Key_PageDown:
zoomOut(true); break; zoomOut(true); break;
case Qt::Key_Shift: case Qt::Key_Shift:
moveSlow(true); break; moveSlow(true); break;
case Qt::Key_Space:
if (event->modifiers().testFlag(Qt::ControlM
odifier))
setDragTimeMode(true);
break;
default: default:
return; return;
} }
} }
else else
{ {
// When a deplacement key is released stop moving // When a deplacement key is released stop moving
switch (event->key()) switch (event->key())
{ {
case Qt::Key_Left: case Qt::Key_Left:
skipping to change at line 339 skipping to change at line 365
moveSlow(false); break; moveSlow(false); break;
case Qt::Key_Control: case Qt::Key_Control:
// This can be all that is seen for anything with control, so stop them all. // This can be all that is seen for anything with control, so stop them all.
// This is true for 4.8.1 // This is true for 4.8.1
turnRight(false); turnRight(false);
turnLeft(false); turnLeft(false);
zoomIn(false); zoomIn(false);
zoomOut(false); zoomOut(false);
turnDown(false); turnDown(false);
turnUp(false); turnUp(false);
setDragTimeMode(false); dragTimeMode=false;
break; break;
default: default:
return; return;
} }
} }
event->accept(); event->accept();
} }
//! Handle mouse wheel events. //! Handle mouse wheel events.
void StelMovementMgr::handleMouseWheel(QWheelEvent* event) void StelMovementMgr::handleMouseWheel(QWheelEvent* event)
{ {
if (flagEnableMouseNavigation==false) if (flagEnableMouseNavigation==false)
return; return;
// Manage only vertical wheel event // This managed only vertical wheel events.
if (event->orientation() != Qt::Vertical) // However, Alt-wheel switches this to horizontal, so allow alt-whee
return; l and handle angles properly!
const float numSteps = (event->angleDelta().x() + event->angleDelta(
const float numSteps = event->delta() / 120.f; ).y()) / 120.f;
const float zoomFactor = std::exp(-mouseZoomSpeed * numSteps / 60.f)
; if (event->modifiers() & Qt::ControlModifier)
const float zoomDuration = 0.2f * qAbs(numSteps); {
zoomTo(getAimFov() * zoomFactor, zoomDuration); if ((event->modifiers() & Qt::AltModifier) && (event->modifi
ers() & Qt::ShiftModifier))
{
// move time by years
double jdNow=core->getJD();
int year, month, day, hour, min, sec, millis;
StelUtils::getDateFromJulianDay(jdNow, &year, &month
, &day);
StelUtils::getTimeFromJulianDay(jdNow, &hour, &min,
&sec, &millis);
double jdNew;
StelUtils::getJDFromDate(&jdNew, year+floor(numSteps
), month, day, hour, min, sec);
core->setJD(jdNew);
emit core->dateChanged();
}
else if (event->modifiers() & Qt::AltModifier)
{
// move time by days
core->setJD(core->getJD()+floor(numSteps));
emit core->dateChanged();
}
else if (event->modifiers() & Qt::ShiftModifier)
{
// move time by hours
core->setJD(core->getJD()+floor(numSteps)/(24.f));
}
else
{
// move time by minutes
core->setJD(core->getJD()+floor(numSteps)/(24.f*60.f
));
}
}
else
{
const float zoomFactor = std::exp(-mouseZoomSpeed * numSteps
/ 60.f);
const float zoomDuration = 0.2f * qAbs(numSteps);
zoomTo(getAimFov() * zoomFactor, zoomDuration);
}
event->accept(); event->accept();
} }
void StelMovementMgr::addTimeDragPoint(int x, int y) void StelMovementMgr::addTimeDragPoint(int x, int y)
{ {
DragHistoryEntry e; DragHistoryEntry e;
e.runTime=StelApp::getInstance().getTotalRunTime(); e.runTime=StelApp::getInstance().getTotalRunTime();
e.jd=core->getJD(); e.jd=core->getJD();
e.x=x; e.x=x;
e.y=y; e.y=y;
skipping to change at line 403 skipping to change at line 461
void StelMovementMgr::handleMouseClicks(QMouseEvent* event) void StelMovementMgr::handleMouseClicks(QMouseEvent* event)
{ {
switch (event->button()) switch (event->button())
{ {
case Qt::RightButton: case Qt::RightButton:
{ {
if (event->type()==QEvent::MouseButtonRelease) if (event->type()==QEvent::MouseButtonRelease)
{ {
// Deselect the selected object // Deselect the selected object
StelApp::getInstance().getStelObjectMgr().un Select(); StelApp::getInstance().getStelObjectMgr().un Select();
setFlagLockEquPos(false);
event->accept(); event->accept();
return; return;
} }
break; break;
} }
case Qt::LeftButton : case Qt::LeftButton :
if (event->type()==QEvent::MouseButtonPress) if (event->type()==QEvent::MouseButtonPress)
{ {
if (event->modifiers() & Qt::ControlModifier
)
{
dragTimeMode=true;
beforeTimeDragTimeRate=core->getTime
Rate();
timeDragHistory.clear();
addTimeDragPoint(event->x(), event->
y());
}
isDragging = true; isDragging = true;
hasDragged = false; hasDragged = false;
previousX = event->x(); previousX = event->x();
previousY = event->y(); previousY = event->y();
beforeTimeDragTimeRate=core->getTimeRate();
if (dragTimeMode)
{
timeDragHistory.clear();
addTimeDragPoint(event->pos().x(), e
vent->pos().y());
}
event->accept(); event->accept();
return; return;
} }
else else if (event->type()==QEvent::MouseButtonRelease)
{ {
isDragging = false; isDragging = false;
if (hasDragged) if (hasDragged)
{ {
event->accept(); event->accept();
if (dragTimeMode) if (dragTimeMode)
{ {
if (timeDragHistory.size()>= 3) if (timeDragHistory.size()>= 3)
{ {
const double deltaT = timeDragHistory.last().runTime-timeDragHistory.first().runTime; const double deltaT = timeDragHistory.last().runTime-timeDragHistory.first().runTime;
skipping to change at line 460 skipping to change at line 520
} }
else else
core ->setTimeRate(beforeTimeDragTimeRate); core ->setTimeRate(beforeTimeDragTimeRate);
} }
} }
else else
core->setTimeRate(be foreTimeDragTimeRate); core->setTimeRate(be foreTimeDragTimeRate);
} }
return; return;
} }
else else // has not dragged...
{ {
// It's a normal click release // It's a normal click release
// TODO: Leave time dragging in Natu ral speed or zero speed (config option?) if mouse was resting // TODO: Leave time dragging in Natu ral speed or zero speed (config option?) if mouse was resting
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
// CTRL + left clic = right clic for 1 button mouse // CTRL + left click = right click f or 1 button mouse
if (event->modifiers().testFlag(Qt:: ControlModifier)) if (event->modifiers().testFlag(Qt:: ControlModifier))
{ {
StelApp::getInstance().getSt elObjectMgr().unSelect(); StelApp::getInstance().getSt elObjectMgr().unSelect();
event->accept(); event->accept();
return; return;
} }
// Try to select object at that posi tion // Try to select object at that posi tion
StelApp::getInstance().getStelObject Mgr().findAndSelect(StelApp::getInstance().getCore(), event->x(), event->y( ), StelApp::getInstance().getStelObject Mgr().findAndSelect(StelApp::getInstance().getCore(), event->x(), event->y( ),
event->modifiers().testFlag( Qt::MetaModifier) ? StelModule::AddToSelection : StelModule::ReplaceSelecti on); event->modifiers().testFlag( Qt::MetaModifier) ? StelModule::AddToSelection : StelModule::ReplaceSelecti on);
skipping to change at line 489 skipping to change at line 549
#endif #endif
if (StelApp::getInstance().getStelOb jectMgr().getWasSelected()) if (StelApp::getInstance().getStelOb jectMgr().getWasSelected())
{ {
setFlagTracking(false); setFlagTracking(false);
} }
//GZ: You must comment out this line for testing Landscape transparency debug prints. //GZ: You must comment out this line for testing Landscape transparency debug prints.
//event->accept(); //event->accept();
return; return;
} }
} }
else
{
qDebug() << "StelMovementMgr::handleMouseCli
cks: unknown mouse event type, skipping: " << event->type();
}
break; break;
case Qt::MidButton : case Qt::MidButton :
if (event->type()==QEvent::MouseButtonRelease) if (event->type()==QEvent::MouseButtonRelease)
{ {
if (objectMgr->getWasSelected()) if (objectMgr->getWasSelected())
{ {
moveToObject(objectMgr->getSelectedO bject()[0],autoMoveDuration); moveToObject(objectMgr->getSelectedO bject()[0],autoMoveDuration);
setFlagTracking(true); setFlagTracking(true);
} }
} }
break; break;
default: break; default: break;
} }
return; return;
} }
void StelMovementMgr::setInitViewDirectionToCurrent() void StelMovementMgr::setInitViewDirectionToCurrent()
{ {
// 2016-12 TODO: Create azimuth indication for zenith views.
initViewPos = core->j2000ToAltAz(viewDirectionJ2000, StelCore::Refra ctionOff); initViewPos = core->j2000ToAltAz(viewDirectionJ2000, StelCore::Refra ctionOff);
QString dirStr = QString("%1,%2,%3").arg(initViewPos[0]).arg(initVie wPos[1]).arg(initViewPos[2]); QString dirStr = QString("%1,%2,%3").arg(initViewPos[0]).arg(initVie wPos[1]).arg(initViewPos[2]);
StelApp::getInstance().getSettings()->setValue("navigation/init_view _pos", dirStr); StelApp::getInstance().getSettings()->setValue("navigation/init_view _pos", dirStr);
} }
/************************************************************************* /*************************************************************************
The selected objects changed, follow it if we were already following anoth er one The selected objects changed, follow it if we were already following anoth er one
*************************************************************************/ *************************************************************************/
void StelMovementMgr::selectedObjectChange(StelModule::StelModuleSelectActi on) void StelMovementMgr::selectedObjectChange(StelModule::StelModuleSelectActi on)
{ {
skipping to change at line 594 skipping to change at line 659
} }
void StelMovementMgr::lookEast(void) void StelMovementMgr::lookEast(void)
{ {
float cx, cy; float cx, cy;
Vec3f dir; Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff)); StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff));
cy = M_PI/2.; cy = M_PI/2.;
StelUtils::spheToRect(cy, cx, dir); StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff)); setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff));
//qDebug() << "Setting East at Alt:" << cx*180./M_PI;
if ((mountMode==MountAltAzimuthal) && (cx>M_PI/2-0.0001) && (upVecto
rMountFrame[2]<0.001))
{
// Special case: we already look into zenith (with rounding
tolerance). Bring East to bottom of screen.
upVectorMountFrame.set(0., -1., 0.);
//qDebug() << "lookEast: better Up is " << upVectorMountFram
e[0] << "/" << upVectorMountFrame[1] << "/" << upVectorMountFrame[2];
}
} }
void StelMovementMgr::lookWest(void) void StelMovementMgr::lookWest(void)
{ {
float cx, cy; float cx, cy;
Vec3f dir; Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff)); StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff));
cy = 3.*M_PI/2.; cy = 3.*M_PI/2.;
StelUtils::spheToRect(cy, cx, dir); StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff)); setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff));
//qDebug() << "Setting West at Alt:" << cx*180./M_PI;
if ((mountMode==MountAltAzimuthal) && (cx>M_PI/2-0.0001) && (upVect
orMountFrame[2]<0.001))
{
// Special case: we already look into zenith (with rounding
tolerance). Bring West to bottom of screen.
upVectorMountFrame.set(0., 1., 0.);
//qDebug() << "lookEast: better Up is " << upVectorMountFram
e[0] << "/" << upVectorMountFrame[1] << "/" << upVectorMountFrame[2];
}
} }
void StelMovementMgr::lookNorth(void) void StelMovementMgr::lookNorth(void)
{ {
float cx, cy; float cx, cy;
Vec3f dir; Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff)); StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff));
cy = M_PI; cy = M_PI;
StelUtils::spheToRect(cy, cx, dir); StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff)); setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff));
//qDebug() << "Setting North at Alt:" << cx*180./M_PI;
if ((mountMode==MountAltAzimuthal) && (cx>M_PI/2-0.0001) && (upVect
orMountFrame[2]<0.001))
{
// Special case: we already look into zenith (with rounding
tolerance). Bring North to bottom of screen.
upVectorMountFrame.set(1., 0., 0.);
//qDebug() << "lookNorth: better Up is " << upVectorMountFra
me[0] << "/" << upVectorMountFrame[1] << "/" << upVectorMountFrame[2];
}
} }
void StelMovementMgr::lookSouth(void) void StelMovementMgr::lookSouth(void)
{ {
float cx, cy; float cx, cy;
Vec3f dir; Vec3f dir;
StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff)); StelUtils::rectToSphe(&cy,&cx,core->j2000ToAltAz(getViewDirectionJ20 00(), StelCore::RefractionOff));
cy = 0.; cy = 0.;
StelUtils::spheToRect(cy, cx, dir); StelUtils::spheToRect(cy, cx, dir);
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff)); setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff));
//qDebug() << "Setting South at Alt:" << cx*180./M_PI;
if ((mountMode==MountAltAzimuthal) && (cx>M_PI/2-0.0001) && (upVect
orMountFrame[2]<0.001))
{
// Special case: we already look into zenith (with rounding
tolerance). Bring South to bottom of screen.
upVectorMountFrame.set(-1., 0., 0.);
//qDebug() << "lookSouth: better Up is " << upVectorMountFra
me[0] << "/" << upVectorMountFrame[1] << "/" << upVectorMountFrame[2];
}
} }
void StelMovementMgr::lookZenith(void) void StelMovementMgr::lookZenith(void)
{ {
Vec3f dir; Vec3f dir;
StelUtils::spheToRect(M_PI, M_PI/2., dir); StelUtils::spheToRect(M_PI, M_PI/2., dir);
//qDebug() << "lookZenith: Up is " << upVectorMountFrame[0] << "/" < < upVectorMountFrame[1] << "/" << upVectorMountFrame[2];
setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff)); setViewDirectionJ2000(core->altAzToJ2000(Vec3d(dir[0], dir[1], dir[2 ]), StelCore::RefractionOff));
//qDebug() << "lookZenith: View is " << viewDirectionMountFrame[0] <
< "/" << viewDirectionMountFrame[1] << "/" << viewDirectionMountFrame[2];
if (mountMode==MountAltAzimuthal)
{ // ensure a stable up vector that makes the bottom of the sc
reen point south.
upVectorMountFrame.set(-1., 0., 0.);
//qDebug() << "lookZenith: better Up is " << upVectorMountFr
ame[0] << "/" << upVectorMountFrame[1] << "/" << upVectorMountFrame[2];
}
}
void StelMovementMgr::lookTowardsNCP(void)
{
setViewDirectionJ2000(core->equinoxEquToJ2000(Vec3d(0,0,1)));
}
void StelMovementMgr::lookTowardsSCP(void)
{
setViewDirectionJ2000(core->equinoxEquToJ2000(Vec3d(0,0,-1)));
} }
// Increment/decrement smoothly the vision field and position // Increment/decrement smoothly the vision field and position
void StelMovementMgr::updateMotion(double deltaTime) void StelMovementMgr::updateMotion(double deltaTime)
{ {
updateVisionVector(deltaTime); updateVisionVector(deltaTime);
const StelProjectorP proj = core->getProjection(StelCore::FrameJ2000 ); const StelProjectorP proj = core->getProjection(StelCore::FrameJ2000 );
// the more it is zoomed, the lower the moving speed is (in angle) // the more it is zoomed, the lower the moving speed is (in angle)
double depl=keyMoveSpeed*deltaTime*1000*currentFov; double depl=keyMoveSpeed*deltaTime*1000*currentFov;
skipping to change at line 677 skipping to change at line 792
} }
else if (deltaAlt>0) else if (deltaAlt>0)
{ {
deltaAlt = depl/30; deltaAlt = depl/30;
if (deltaAlt>0.2) if (deltaAlt>0.2)
deltaAlt = 0.2; deltaAlt = 0.2;
} }
if (deltaFov<0) if (deltaFov<0)
{ {
deltaFov = -deplzoom*5; // deltaFov = -deplzoom*5;
if (deltaFov<-0.15*currentFov) // if (deltaFov<-0.15*currentFov)
deltaFov = -0.15*currentFov; // deltaFov = -0.15*currentFov;
deltaFov=qMax(-0.15*currentFov, -deplzoom*5);
} }
else if (deltaFov>0) else if (deltaFov>0)
{ {
deltaFov = deplzoom*5; deltaFov = qMin(20., deplzoom*5.);
if (deltaFov>20)
deltaFov = 20;
} }
if (deltaFov != 0 ) if (deltaFov != 0 )
{ {
changeFov(deltaFov); changeFov(deltaFov);
} }
panView(deltaAz, deltaAlt); panView(deltaAz, deltaAlt);
updateAutoZoom(deltaTime); updateAutoZoom(deltaTime);
} }
// called at begin of updateMotion()
void StelMovementMgr::updateVisionVector(double deltaTime) void StelMovementMgr::updateVisionVector(double deltaTime)
{ {
// Specialized setups cannot use this functionality! // Specialized setups cannot use this functionality!
if (flagInhibitAllAutomoves) if (flagInhibitAllAutomoves)
return; return;
if (flagAutoMove) if (flagAutoMove)
{ {
if (!move.targetObject.isNull()) if (!move.targetObject.isNull())
{ {
skipping to change at line 722 skipping to change at line 837
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
v = move.targetObject->getAltAzPosAu to(core); v = move.targetObject->getAltAzPosAu to(core);
break; break;
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
v = move.targetObject->getEquinoxEqu atorialPos(core); v = move.targetObject->getEquinoxEqu atorialPos(core);
break; break;
case MountGalactic: case MountGalactic:
v = move.targetObject->getGalacticPo s(core); v = move.targetObject->getGalacticPo s(core);
break; break;
case MountSupergalactic:
v = move.targetObject->getSupergalac
ticPos(core);
break;
default: default:
qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode; qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode;
Q_ASSERT(0); Q_ASSERT(0);
v = move.targetObject->getAltAzPosAu to(core); // still do something useful v = move.targetObject->getAltAzPosAu to(core); // still do something useful
} }
double lat, lon; double lat, lon;
StelUtils::rectToSphe(&lon, &lat, v); StelUtils::rectToSphe(&lon, &lat, v);
float altOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f; float altOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f;
lat+=altOffset; lat+=altOffset;
StelUtils::spheToRect(lon, lat, v); StelUtils::spheToRect(lon, lat, v);
move.aim=mountFrameToJ2000(v); move.aim=mountFrameToJ2000(v);
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
// For aiming at objects, we can assume simple up ve ctor. // For aiming at objects, we can assume simple up ve ctor.
move.startUp=getViewUpVectorJ2000(); move.startUp=getViewUpVectorJ2000();
move.aimUp=mountFrameToJ2000(Vec3d(0., 0., 1.)); move.aimUp=mountFrameToJ2000(Vec3d(0., 0., 1.));
} }
else else // no targetObject:
{ {
// if (move.mountMode == MountAltAzimuthal) // if (move.mountMode == MountAltAzimuthal)
// { // {
// move.startUp=Vec3d(0., 0., 1.); // move.startUp=Vec3d(0., 0., 1.);
// move.aimUp=Vec3d(0., 0., 1.); // move.aimUp=Vec3d(0., 0., 1.);
// } // }
// else // else
// { // March 2016 // { // March 2016
move.startUp=getViewUpVectorJ2000(); move.startUp=getViewUpVectorJ2000();
move.aimUp=mountFrameToJ2000(Vec3d(0., 0., 1 .)); move.aimUp=mountFrameToJ2000(Vec3d(0., 0., 1 .));
// } // }
} }
move.coef+=move.speed*deltaTime*1000; move.coef+=move.speed*deltaTime*1000;
//qDebug() << "updateVisionVector: setViewUpvectorJ2000 L813
";
setViewUpVectorJ2000(move.aimUp);
if (move.coef>=1.) if (move.coef>=1.)
{ {
setViewUpVectorJ2000(move.aimUp);
//qDebug() << "AutoMove finished. Setting Up vector (in mount frame) to " << upVectorMountFrame.v[0] << "/" << upVectorMountFra me.v[1] << "/" << upVectorMountFrame.v[2]; //qDebug() << "AutoMove finished. Setting Up vector (in mount frame) to " << upVectorMountFrame.v[0] << "/" << upVectorMountFra me.v[1] << "/" << upVectorMountFrame.v[2];
flagAutoMove=false; flagAutoMove=false;
move.coef=1.; move.coef=1.;
} }
else
{ // 2016-03 Maybe this is the culprit?
//setViewUpVectorJ2000(move.startUp*(1.-move.coef) +
move.aimUp*move.coef);
setViewUpVectorJ2000(move.aimUp);
}
// Use a smooth function // Use a smooth function
float smooth = 4.f; const float smooth = 4.f; // (empirically tested)
double c; double c;
if (zoomingMode==ZoomIn) switch (zoomingMode){
{ case ZoomIn:
if (move.coef>.9) c=(move.coef>.9 ? 1. : 1. - pow(1.-1.11*move
{ .coef,3.)); break;
c = 1.; case ZoomOut:
}
else
{
c = 1. - pow(1.-1.11*move.coef,3.);
}
}
else if (zoomingMode==ZoomOut)
{
if (move.coef<0.1)
{
// keep in view at first as zoom out // keep in view at first as zoom out
c = 0; c=(move.coef<0.1 ? 0. : pow(1.11*(move.coef-
} .1),3.)); break;
else default:
{ c = std::atan(smooth * 2.*move.coef-smooth)/
c = pow(1.11*(move.coef-.1),3.); std::atan(smooth)/2+0.5;
}
} }
else
c = std::atan(smooth * 2.*move.coef-smooth)/std::ata
n(smooth)/2+0.5;
// 2016-03: In case of azimuthal moves, it is not useful to compute anything from J2000 coordinates. // 2016-03: In case of azimuthal moves, it is not useful to compute anything from J2000 coordinates.
// Imagine a slow AltAz move during speedy timelapse: Aim wi ll move! // Imagine a slow AltAz move during speedy timelapse: Aim wi ll move!
// TODO: all variants... // TODO: all variants...
Vec3d tmpStart; Vec3d tmpStart;
Vec3d tmpAim; Vec3d tmpAim;
if (move.mountMode==MountAltAzimuthal) if (move.mountMode==MountAltAzimuthal)
{ {
tmpStart=move.start; tmpStart=move.start;
tmpAim=move.aim; tmpAim=move.aim;
skipping to change at line 842 skipping to change at line 941
// } // }
// else // else
setViewDirectionJ2000(mountFrameToJ2000(tmp)); setViewDirectionJ2000(mountFrameToJ2000(tmp));
// if (move.mountMode==MountAltAzimuthal) // if (move.mountMode==MountAltAzimuthal)
// { // {
// setViewUpVector(Vec3d(0., 0., 1.)); // setViewUpVector(Vec3d(0., 0., 1.));
// qDebug() << "We do indeed set this"; // qDebug() << "We do indeed set this";
// } // }
// qDebug() << "setting view direction to " << tmp.v[0] << " /" << tmp.v[1] << "/" << tmp.v[2]; // qDebug() << "setting view direction to " << tmp.v[0] << " /" << tmp.v[1] << "/" << tmp.v[2];
} }
else else // no autoMove
{ {
if (flagTracking && objectMgr->getWasSelected()) // Equatori al vision vector locked on selected object if (flagTracking && objectMgr->getWasSelected()) // Equatori al vision vector locked on selected object
{ {
Vec3d v; Vec3d v;
switch (mountMode) switch (mountMode)
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core); v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core);
break; break;
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core); v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core);
break; break;
case MountGalactic: case MountGalactic:
v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core); v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core);
break; break;
case MountSupergalactic:
v = objectMgr->getSelectedObject()[0
]->getSupergalacticPos(core);
break;
default: default:
qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode; qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode;
Q_ASSERT(0); Q_ASSERT(0);
v = move.targetObject->getAltAzPosAu to(core); // still do something useful in release build v = move.targetObject->getAltAzPosAu to(core); // still do something useful in release build
} }
double lat, lon; // general: longitudinal, latitudin al double lat, lon; // general: longitudinal, latitudin al
StelUtils::rectToSphe(&lon, &lat, v); StelUtils::rectToSphe(&lon, &lat, v);
float latOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f; float latOffset=core->getCurrentStelProjectorParams( ).viewportCenterOffset[1]*currentFov*M_PI/180.0f;
lat+=latOffset; lat+=latOffset;
StelUtils::spheToRect(lon, lat, v); StelUtils::spheToRect(lon, lat, v);
setViewDirectionJ2000(mountFrameToJ2000(v)); setViewDirectionJ2000(mountFrameToJ2000(v));
//qDebug() << "setViewUpVector() L930";
setViewUpVectorJ2000(mountFrameToJ2000(Vec3d(0., 0., 1.))); // Does not disturb to reassure this former default. setViewUpVectorJ2000(mountFrameToJ2000(Vec3d(0., 0., 1.))); // Does not disturb to reassure this former default.
} }
else else // not tracking or no selection
{ {
if (flagLockEquPos) // Equatorial vision vector lock ed if (flagLockEquPos) // Equatorial vision vector lock ed
{ {
// Recalc local vision vector // Recalc local vision vector
setViewDirectionJ2000(viewDirectionJ2000); setViewDirectionJ2000(viewDirectionJ2000);
} }
else else
{ {
// Vision vector locked to its position in t he mountFrame // Vision vector locked to its position in t he mountFrame
setViewDirectionJ2000(mountFrameToJ2000(view DirectionMountFrame)); setViewDirectionJ2000(mountFrameToJ2000(view DirectionMountFrame));
// After setting time, moveToAltAz broke the up vector without this: // After setting time, moveToAltAz broke the up vector without this:
// Make sure this does not now break zenith views! // Make sure this does not now break zenith views!
// Or make sure to call moveToAltAz twice. // Or make sure to call moveToAltAz twice.
setViewUpVectorJ2000(mountFrameToJ2000(Vec3d //qDebug() << "setUpVectorJ2000 woe L947";
(0.,0.,1.))); //setViewUpVectorJ2000(mountFrameToJ2000(Vec
3d(0.,0.,1.)));
setViewUpVectorJ2000(mountFrameToJ2000(upVec
torMountFrame)); // maybe fixes? / < < < < < < < < < < THIS WAS THE BIG ONE
} }
} }
} }
} }
// Go and zoom to the selected object. (Action linked to key, default "/") // Go and zoom to the selected object. (Action linked to key, default "/")
void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom) void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom)
{ {
if (!objectMgr->getWasSelected()) if (!objectMgr->getWasSelected())
return; return;
skipping to change at line 1043 skipping to change at line 1148
move.targetObject = target; move.targetObject = target;
//move.mountMode=mountMode; // Maybe better to have MountEquinoxEqu atorial here? ==> YES, fixed orientation problem. //move.mountMode=mountMode; // Maybe better to have MountEquinoxEqu atorial here? ==> YES, fixed orientation problem.
move.mountMode=MountEquinoxEquatorial; move.mountMode=MountEquinoxEquatorial;
flagAutoMove = true; flagAutoMove = true;
} }
// March 2016: This call does nothing when mount frame is not AltAzi! (TODO later: rethink&fix.) // March 2016: This call does nothing when mount frame is not AltAzi! (TODO later: rethink&fix.)
void StelMovementMgr::moveToAltAzi(const Vec3d& aim, const Vec3d &aimUp, fl oat moveDuration, ZoomingMode zooming) void StelMovementMgr::moveToAltAzi(const Vec3d& aim, const Vec3d &aimUp, fl oat moveDuration, ZoomingMode zooming)
{ {
if (mountMode!=StelMovementMgr::MountAltAzimuthal) if (mountMode!=StelMovementMgr::MountAltAzimuthal)
{
qDebug() << "StelMovementMgr: called moveToAltAzi, but not i
n AltAz mount frame. Ignoring.";
return; return;
}
moveDuration /= movementsSpeedFactor; moveDuration /= movementsSpeedFactor;
// TODO: Specify start and aim vectors in AltAz system! Then the aut o functions should be able to work it out properly with only minor edits. // Specify start and aim vectors in AltAz system! Then the auto func tions can work it out properly.
zoomingMode = zooming; zoomingMode = zooming;
move.aim=aim; move.aim=aim;
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
move.aimUp=aimUp; // the new up vector. We cannot simply keep vertic al axis, there may be the intention to look into the zenith or so. move.aimUp=aimUp; // the new up vector. We cannot simply keep vertic al axis, there may be the intention to look into the zenith or so.
move.aimUp.normalize(); move.aimUp.normalize();
// TODO: Replace by fixed current orientation!
move.start=core->j2000ToAltAz(viewDirectionJ2000, StelCore::Refracti onOff); move.start=core->j2000ToAltAz(viewDirectionJ2000, StelCore::Refracti onOff);
move.start.normalize(); move.start.normalize();
move.startUp.set(0., 0., 1.); move.startUp.set(0., 0., 1.);
move.speed=1.f/(moveDuration*1000); move.speed=1.f/(moveDuration*1000);
move.coef=0.; move.coef=0.;
move.targetObject.clear(); move.targetObject.clear();
move.mountMode=MountAltAzimuthal; // This signals: start and aim are given in AltAz coordinates. move.mountMode=MountAltAzimuthal; // This signals: start and aim are given in AltAz coordinates.
flagAutoMove = true; flagAutoMove = true;
// // debug output if required // // debug output if required
// double currAlt, currAzi, newAlt, newAzi; // double currAlt, currAzi, newAlt, newAzi;
// StelUtils::rectToSphe(&currAzi, &currAlt, move.start); // StelUtils::rectToSphe(&currAzi, &currAlt, move.start);
// StelUtils::rectToSphe(&newAzi, &newAlt, move.aim); // StelUtils::rectToSphe(&newAzi, &newAlt, move.aim);
// qDebug() << "StelMovementMgr::moveToAltAzi() from alt:" << c urrAlt*(180./M_PI) << "/azi" << currAzi*(180./M_PI) << "to alt:" << newAlt *(180./M_PI) << "azi" << newAzi*(180./M_PI) ; // qDebug() << "StelMovementMgr::moveToAltAzi() from alt:" << c urrAlt*(180./M_PI) << "/azi" << currAzi*(180./M_PI) << "to alt:" << newAlt *(180./M_PI) << "azi" << newAzi*(180./M_PI) ;
} }
Vec3d StelMovementMgr::j2000ToMountFrame(const Vec3d& v) const Vec3d StelMovementMgr::j2000ToMountFrame(const Vec3d& v) const
{ {
switch (mountMode) switch (mountMode)
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
return core->j2000ToAltAz(v, StelCore::RefractionOff ); return core->j2000ToAltAz(v, StelCore::RefractionOff ); // TODO: Decide if RefractionAuto?
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
return core->j2000ToEquinoxEqu(v); return core->j2000ToEquinoxEqu(v);
case MountGalactic: case MountGalactic:
return core->j2000ToGalactic(v); return core->j2000ToGalactic(v);
case MountSupergalactic:
return core->j2000ToSupergalactic(v);
} }
Q_ASSERT(0); Q_ASSERT(0);
return Vec3d(0); return Vec3d(0);
} }
Vec3d StelMovementMgr::mountFrameToJ2000(const Vec3d& v) const Vec3d StelMovementMgr::mountFrameToJ2000(const Vec3d& v) const
{ {
switch (mountMode) switch (mountMode)
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
return core->altAzToJ2000(v, StelCore::RefractionOff ); return core->altAzToJ2000(v, StelCore::RefractionOff ); // TODO: Decide if RefractionAuto?
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
return core->equinoxEquToJ2000(v); return core->equinoxEquToJ2000(v);
case MountGalactic: case MountGalactic:
return core->galacticToJ2000(v); return core->galacticToJ2000(v);
case MountSupergalactic:
return core->supergalacticToJ2000(v);
} }
Q_ASSERT(0); Q_ASSERT(0);
return Vec3d(0); return Vec3d(0);
} }
void StelMovementMgr::setViewDirectionJ2000(const Vec3d& v) void StelMovementMgr::setViewDirectionJ2000(const Vec3d& v)
{ {
core->lookAtJ2000(v, getViewUpVectorJ2000()); core->lookAtJ2000(v, getViewUpVectorJ2000());
viewDirectionJ2000 = v; viewDirectionJ2000 = v;
viewDirectionMountFrame = j2000ToMountFrame(v); viewDirectionMountFrame = j2000ToMountFrame(v);
} }
void StelMovementMgr::panView(const double deltaAz, const double deltaAlt) void StelMovementMgr::panView(const double deltaAz, const double deltaAlt)
{ {
// DONE 2016-12 FIX UP VECTOR PROBLEM
// The function is called in update loops, so make a quick check for exit. // The function is called in update loops, so make a quick check for exit.
if ((deltaAz==0.) && (deltaAlt==0.)) if ((deltaAz==0.) && (deltaAlt==0.))
return; return;
double azVision, altVision; double azVision, altVision;
StelUtils::rectToSphe(&azVision,&altVision,j2000ToMountFrame(viewDir ectionJ2000)); StelUtils::rectToSphe(&azVision,&altVision,j2000ToMountFrame(viewDir ectionJ2000));
// Az is counted from South, eastward. // Az is counted from South, eastward.
// qDebug() << "Azimuth:" << azVision * 180./M_PI << "Altitude:" << altVision * 180./M_PI << "Up.X=" << upVectorMountFrame.v[0] << "Up.Y=" << u pVectorMountFrame.v[1] << "Up.Z=" << upVectorMountFrame.v[2]; //qDebug() << "Azimuth:" << azVision * 180./M_PI << "Altitude:" << altVision * 180./M_PI << "Up.X=" << upVectorMountFrame.v[0] << "Up.Y=" << u pVectorMountFrame.v[1] << "Up.Z=" << upVectorMountFrame.v[2];
// if we are just looking into the pole, azimuth can hopefully be re covered from the customized up vector! // if we are just looking into the pole, azimuth can hopefully be re covered from the customized up vector!
// When programmatically centering on a pole, we should have set a b etter up vector for |alt|>0.9*M_PI/2. // When programmatically centering on a pole, we should have set a b etter up vector for |alt|>0.9*M_PI/2.
if (fabs(altVision)> 0.95* M_PI/2.) if (fabs(altVision)> 0.95* M_PI/2.)
{ {
if (upVectorMountFrame.v[2] < 0.9) if (upVectorMountFrame.v[2] < 0.9)
{ {
// qDebug() << "Recovering azimuth..."; //qDebug() << "panView: Recovering azimuth...";
azVision=atan2(-upVectorMountFrame.v[1], -upVectorMo untFrame.v[0]); azVision=atan2(-upVectorMountFrame.v[1], -upVectorMo untFrame.v[0]);
if (altVision < 0.) if (altVision < 0.)
azVision+=M_PI; azVision+=M_PI;
} }
// else // Remove these lines if all is OK.
// { else
// // qDebug() << "UpVector:" << upVectorMountFrame.v[0 {
] << "/" << upVectorMountFrame.v[1] << "/" << upVectorMountFrame.v[2] << "C //qDebug() << "panView: UpVector:" << upVectorMount
annot recover azimuth. Hope it's OK"; Frame.v[0] << "/" << upVectorMountFrame.v[1] << "/" << upVectorMountFrame.v
// } [2] << "Cannot recover azimuth. Hope it's OK";
}
} }
// if we are moving in the Azimuthal angle (left/right) // if we are moving in the Azimuthal angle (left/right)
if (deltaAz) if (deltaAz)
azVision-=deltaAz; azVision-=deltaAz;
if (deltaAlt) if (deltaAlt)
{ {
if (altVision+deltaAlt <= M_PI_2 && altVision+deltaAlt >= -M //if (altVision+deltaAlt <= M_PI_2 && altVision+deltaAlt >=
_PI_2) altVision+=deltaAlt; -M_PI_2)
if (altVision+deltaAlt > M_PI_2) altVision = M_PI_2 - 0.0000 altVision+=deltaAlt;
01; // Prevent bug //if (altVision+deltaAlt > M_PI_2) altVision = M_PI_2 - 0.
if (altVision+deltaAlt < -M_PI_2) altVision = -M_PI_2 + 0.00 000001; // Prevent bug: manual pans (keyboard or mouse!) can never really r
0001; // Prevent bug each the zenith, but we can accept this.
//if (altVision+deltaAlt < -M_PI_2) altVision = -M_PI_2 + 0.
000001;
if (altVision > M_PI_2) altVision = M_PI_2 - 0.000001; //
Prevent bug: manual pans (keyboard or mouse!) can never really reach the ze
nith, but we can accept this.
if (altVision < -M_PI_2) altVision = -M_PI_2 + 0.000001;
} }
// recalc all the position variables // recalc all the position variables
if (deltaAz || deltaAlt) if (deltaAz || deltaAlt)
{ {
setFlagTracking(false); setFlagTracking(false);
Vec3d tmp; Vec3d tmp;
StelUtils::spheToRect(azVision, altVision, tmp); StelUtils::spheToRect(azVision, altVision, tmp);
setViewDirectionJ2000(mountFrameToJ2000(tmp)); setViewDirectionJ2000(mountFrameToJ2000(tmp));
setViewUpVector(Vec3d(0., 0., 1.)); // We ensured above that if (fabs(altVision)>0.95*M_PI/2.)
view vector is never parallel to this simple up vector. { // do something about zenith
setViewUpVector(Vec3d(-cos(azVision), -sin(azVision)
, 0.) * (altVision>0. ? 1. : -1. )); // 2016-12-14: WORKS AGAIN!
}
else
{
setViewUpVector(Vec3d(0., 0., 1.));
}
} }
} }
//! Make the first screen position correspond to the second (useful for mou se dragging) // Make the first screen position correspond to the second (useful for mous e dragging)
void StelMovementMgr::dragView(int x1, int y1, int x2, int y2) void StelMovementMgr::dragView(int x1, int y1, int x2, int y2)
{ {
if (dragTimeMode) if (dragTimeMode)
{ {
core->setTimeRate(0); core->setTimeRate(0);
Vec3d v1, v2; Vec3d v1, v2;
const StelProjectorP prj = core->getProjection(StelCore::Fra meEquinoxEqu); const StelProjectorP prj = core->getProjection(StelCore::Fra meEquinoxEqu);
prj->unProject(x2,y2, v2); prj->unProject(x2,y2, v2);
prj->unProject(x1,y1, v1); prj->unProject(x1,y1, v1);
v1[2]=0; v1.normalize(); v1[2]=0; v1.normalize();
skipping to change at line 1234 skipping to change at line 1357
{ {
case MountAltAzimuthal: case MountAltAzimuthal:
v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core); v = objectMgr->getSelectedObject()[0 ]->getAltAzPosAuto(core);
break; break;
case MountEquinoxEquatorial: case MountEquinoxEquatorial:
v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core); v = objectMgr->getSelectedObject()[0 ]->getEquinoxEquatorialPos(core);
break; break;
case MountGalactic: case MountGalactic:
v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core); v = objectMgr->getSelectedObject()[0 ]->getGalacticPos(core);
break; break;
case MountSupergalactic:
v = objectMgr->getSelectedObject()[0
]->getSupergalacticPos(core);
break;
default: default:
qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode; qWarning() << "StelMovementMgr: unex pected mountMode" << mountMode;
Q_ASSERT(0); Q_ASSERT(0);
} }
double lat, lon; // general: longitudinal, latitudin al double lat, lon; // general: longitudinal, latitudin al
StelUtils::rectToSphe(&lon, &lat, v); // guaranteed to be normalized. StelUtils::rectToSphe(&lon, &lat, v); // guaranteed to be normalized.
// vUp could usually be (0/0/1) in most cases, unles s |lat|==pi/2. We MUST build an adequate Up vector! // vUp could usually be (0/0/1) in most cases, unles s |lat|==pi/2. We MUST build an adequate Up vector!
if (fabs(lat)>0.9*M_PI/2.0) if (fabs(lat)>0.9*M_PI/2.0)
{ {
skipping to change at line 1263 skipping to change at line 1389
{ {
move.aim=mountFrameToJ2000(v); move.aim=mountFrameToJ2000(v);
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
move.aimUp=mountFrameToJ2000(vUp); move.aimUp=mountFrameToJ2000(vUp);
move.aimUp.normalize(); move.aimUp.normalize();
} }
else else
{ {
setViewDirectionJ2000(mountFrameToJ2000(v)); setViewDirectionJ2000(mountFrameToJ2000(v));
//qDebug() << "setViewUpVector L1340";
setViewUpVectorJ2000(mountFrameToJ2000(vUp)) ; setViewUpVectorJ2000(mountFrameToJ2000(vUp)) ;
} }
} }
} }
} }
// Zoom to the given field of view // Zoom to the given field of view
void StelMovementMgr::zoomTo(double aim_fov, float moveDuration) void StelMovementMgr::zoomTo(double aim_fov, float moveDuration)
{ {
moveDuration /= movementsSpeedFactor; moveDuration /= movementsSpeedFactor;
skipping to change at line 1319 skipping to change at line 1446
targetViewportOffset.set(offsetX, offsetY); targetViewportOffset.set(offsetX, offsetY);
if(offsetX != oldTargetViewportOffset[0]) if(offsetX != oldTargetViewportOffset[0])
emit viewportHorizontalOffsetTargetChanged(offsetX); emit viewportHorizontalOffsetTargetChanged(offsetX);
if(offsetY != oldTargetViewportOffset[1]) if(offsetY != oldTargetViewportOffset[1])
emit viewportVerticalOffsetTargetChanged(offsetY); emit viewportVerticalOffsetTargetChanged(offsetY);
if (duration<=0.0f) if (duration<=0.0f)
{ {
//avoid using the timeline to minimize overhead //avoid using the timeline to minimize overhead
core->setViewportHorizontalOffset(targetViewportOffset[0]); core->setViewportOffset(offsetX, offsetY);
core->setViewportVerticalOffset(targetViewportOffset[1]);
return; return;
} }
// Frame will now be 0..100, and we must interpolate in handleViewpo rtOffsetMovement(frame) between old and new offsets. // Frame will now be 0..100, and we must interpolate in handleViewpo rtOffsetMovement(frame) between old and new offsets.
oldViewportOffset.set(core->getViewportHorizontalOffset(), core->get ViewportVerticalOffset()); oldViewportOffset.set(core->getViewportHorizontalOffset(), core->get ViewportVerticalOffset());
viewportOffsetTimeline->stop(); viewportOffsetTimeline->stop();
viewportOffsetTimeline->setDuration(1000.*duration); viewportOffsetTimeline->setDuration(1000.*duration);
//qDebug() << "moveViewport() started, from " << oldViewportOffset.v [0] << "/" << oldViewportOffset.v[1] << " towards " << offsetX << "/" << of fsetY; //qDebug() << "moveViewport() started, from " << oldViewportOffset.v [0] << "/" << oldViewportOffset.v[1] << " towards " << offsetX << "/" << of fsetY;
viewportOffsetTimeline->start(); viewportOffsetTimeline->start();
} }
// slot which is connected to the viewportOffsetTimeline and does the actua l updates. // slot which is connected to the viewportOffsetTimeline and does the actua l updates.
void StelMovementMgr::handleViewportOffsetMovement(qreal value) void StelMovementMgr::handleViewportOffsetMovement(qreal value)
{ {
// value is always 0...1 // value is always 0...1
float offsetX=oldViewportOffset.v[0] + (targetViewportOffset.v[0]-ol dViewportOffset.v[0])*value; float offsetX=oldViewportOffset.v[0] + (targetViewportOffset.v[0]-ol dViewportOffset.v[0])*value;
float offsetY=oldViewportOffset.v[1] + (targetViewportOffset.v[1]-ol dViewportOffset.v[1])*value; float offsetY=oldViewportOffset.v[1] + (targetViewportOffset.v[1]-ol dViewportOffset.v[1])*value;
//qDebug() << "handleViewportOffsetMovement(" << value << "): Settin g viewport offset to " << offsetX << "/" << offsetY; //qDebug() << "handleViewportOffsetMovement(" << value << "): Settin g viewport offset to " << offsetX << "/" << offsetY;
core->setViewportHorizontalOffset(offsetX); core->setViewportOffset(offsetX, offsetY);
core->setViewportVerticalOffset(offsetY);
} }
 End of changes. 86 change blocks. 
141 lines changed or deleted 313 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/