StelMovementMgr.cpp   StelMovementMgr.cpp 
skipping to change at line 22 skipping to change at line 22
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
skipping to change at line 59 skipping to change at line 60
isDragging = false; isDragging = false;
} }
StelMovementMgr::~StelMovementMgr() StelMovementMgr::~StelMovementMgr()
{ {
} }
void StelMovementMgr::init() void StelMovementMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
objectMgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(conf); Q_ASSERT(conf);
Q_ASSERT(objectMgr);
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.0004).toDouble( ); keyMoveSpeed = conf->value("navigation/move_speed",0.0004).toDouble( );
keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004).toDouble (); keyZoomSpeed = conf->value("navigation/zoom_speed", 0.0004).toDouble ();
autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5) .toDouble(); autoMoveDuration = conf->value ("navigation/auto_move_duration",1.5) .toDouble();
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();
skipping to change at line 234 skipping to change at line 237
return; return;
} }
else else
return; return;
} }
} }
break; break;
case Qt::MidButton : case Qt::MidButton :
if (event->type()==QEvent::MouseButtonRelease) if (event->type()==QEvent::MouseButtonRelease)
{ {
if (StelApp::getInstance().getStelObjectMgr( ).getWasSelected()) if (objectMgr->getWasSelected())
{ {
moveTo(StelApp::getInstance().getSte lObjectMgr().getSelectedObject()[0]->getEquinoxEquatorialPos(core->getNavig ator()),autoMoveDuration); moveTo(objectMgr->getSelectedObject( )[0]->getEquinoxEquatorialPos(core->getNavigator()),autoMoveDuration);
setFlagTracking(true); setFlagTracking(true);
} }
} }
break; break;
default: break; default: break;
} }
return; return;
} }
/************************************************************************* /*************************************************************************
The selected objects changed, follow it it we were already following anoth er one The selected objects changed, follow it it we were already following anoth er one
*************************************************************************/ *************************************************************************/
void StelMovementMgr::selectedObjectChangeCallBack(StelModuleSelectAction a ction) void StelMovementMgr::selectedObjectChangeCallBack(StelModuleSelectAction a ction)
{ {
// If an object was selected keep the earth following // If an object was selected keep the earth following
if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) if (objectMgr->getWasSelected())
{ {
if (getFlagTracking()) if (getFlagTracking())
setFlagLockEquPos(true); setFlagLockEquPos(true);
setFlagTracking(false); setFlagTracking(false);
} }
} }
void StelMovementMgr::turnRight(bool s) void StelMovementMgr::turnRight(bool s)
{ {
if (s && flagEnableMoveKeys) if (s && flagEnableMoveKeys)
skipping to change at line 395 skipping to change at line 398
{ {
changeFov(deltaFov); changeFov(deltaFov);
} }
panView(deltaAz, deltaAlt); panView(deltaAz, deltaAlt);
updateAutoZoom(deltaTime); updateAutoZoom(deltaTime);
} }
// Go and zoom to the selected object. // Go and zoom to the selected object.
void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom) void StelMovementMgr::autoZoomIn(float moveDuration, bool allowManualZoom)
{ {
if (!StelApp::getInstance().getStelObjectMgr().getWasSelected()) if (!objectMgr->getWasSelected())
return; return;
float manualMoveDuration; float manualMoveDuration;
if (!getFlagTracking()) if (!getFlagTracking())
{ {
setFlagTracking(true); setFlagTracking(true);
moveTo(StelApp::getInstance().getStelObjectMgr().getSelected Object()[0]->getEquinoxEquatorialPos(core->getNavigator()), moveDuration, f alse, 1); moveTo(objectMgr->getSelectedObject()[0]->getEquinoxEquatori alPos(core->getNavigator()), moveDuration, false, 1);
manualMoveDuration = moveDuration; manualMoveDuration = moveDuration;
} }
else else
{ {
// faster zoom in manual zoom mode once object is centered // faster zoom in manual zoom mode once object is centered
manualMoveDuration = moveDuration*.66f; manualMoveDuration = moveDuration*.66f;
} }
if( allowManualZoom && flagManualZoom ) if( allowManualZoom && flagManualZoom )
{ {
// if manual zoom mode, user can zoom in incrementally // if manual zoom mode, user can zoom in incrementally
float newfov = currentFov*0.5f; float newfov = currentFov*0.5f;
zoomTo(newfov, manualMoveDuration); zoomTo(newfov, manualMoveDuration);
} }
else else
{ {
float satfov = StelApp::getInstance().getStelObjectMgr().get SelectedObject()[0]->getSatellitesFov(core->getNavigator()); float satfov = objectMgr->getSelectedObject()[0]->getSatelli tesFov(core->getNavigator());
if (satfov>0.0 && currentFov*0.9>satfov) if (satfov>0.0 && currentFov*0.9>satfov)
zoomTo(satfov, moveDuration); zoomTo(satfov, moveDuration);
else else
{ {
float closefov = StelApp::getInstance().getStelObjec tMgr().getSelectedObject()[0]->getCloseViewFov(core->getNavigator()); float closefov = objectMgr->getSelectedObject()[0]-> getCloseViewFov(core->getNavigator());
if (currentFov>closefov) if (currentFov>closefov)
zoomTo(closefov, moveDuration); zoomTo(closefov, moveDuration);
} }
} }
} }
// Unzoom and go to the init position // Unzoom and go to the init position
void StelMovementMgr::autoZoomOut(float moveDuration, bool full) void StelMovementMgr::autoZoomOut(float moveDuration, bool full)
{ {
StelNavigator* nav = core->getNavigator(); StelNavigator* nav = core->getNavigator();
if (StelApp::getInstance().getStelObjectMgr().getWasSelected() && !f ull) if (objectMgr->getWasSelected() && !full)
{ {
// If the selected object has satellites, unzoom to satellit es view // If the selected object has satellites, unzoom to satellit es view
// unless specified otherwise // unless specified otherwise
float satfov = StelApp::getInstance().getStelObjectMgr().get SelectedObject()[0]->getSatellitesFov(core->getNavigator()); float satfov = objectMgr->getSelectedObject()[0]->getSatelli tesFov(core->getNavigator());
if (satfov>0.0 && currentFov<=satfov*0.9) if (satfov>0.0 && currentFov<=satfov*0.9)
{ {
zoomTo(satfov, moveDuration); zoomTo(satfov, moveDuration);
return; return;
} }
// If the selected object is part of a Planet subsystem (oth er than sun), // If the selected object is part of a Planet subsystem (oth er than sun),
// unzoom to subsystem view // unzoom to subsystem view
satfov = StelApp::getInstance().getStelObjectMgr().getSelect edObject()[0]->getParentSatellitesFov((core->getNavigator())); satfov = objectMgr->getSelectedObject()[0]->getParentSatelli tesFov((core->getNavigator()));
if (satfov>0.0 && currentFov<=satfov*0.9) if (satfov>0.0 && currentFov<=satfov*0.9)
{ {
zoomTo(satfov, moveDuration); zoomTo(satfov, moveDuration);
return; return;
} }
} }
zoomTo(initFov, moveDuration); zoomTo(initFov, moveDuration);
if (flagAutoZoomOutResetsDirection) if (flagAutoZoomOutResetsDirection)
moveTo(nav->getInitViewingDirection(), moveDuration, true, - 1); moveTo(nav->getInitViewingDirection(), moveDuration, true, - 1);
setFlagTracking(false); setFlagTracking(false);
setFlagLockEquPos(false); setFlagLockEquPos(false);
} }
void StelMovementMgr::setFlagTracking(bool b) void StelMovementMgr::setFlagTracking(bool b)
{ {
if(!b || !StelApp::getInstance().getStelObjectMgr().getWasSelected() ) if(!b || !objectMgr->getWasSelected())
{ {
flagTracking=false; flagTracking=false;
} }
else else
{ {
moveTo(StelApp::getInstance().getStelObjectMgr().getSelected Object()[0]->getEquinoxEquatorialPos(core->getNavigator()), getAutoMoveDura tion()); moveTo(objectMgr->getSelectedObject()[0]->getEquinoxEquatori alPos(core->getNavigator()), getAutoMoveDuration());
flagTracking=true; flagTracking=true;
} }
} }
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// Move to the given equatorial position // Move to the given equatorial position
void StelMovementMgr::moveTo(const Vec3d& _aim, float moveDuration, bool _l ocalPos, int zooming) void StelMovementMgr::moveTo(const Vec3d& _aim, float moveDuration, bool _l ocalPos, int zooming)
{ {
StelNavigator* nav = core->getNavigator(); StelNavigator* nav = core->getNavigator();
zoomingMode = zooming; zoomingMode = zooming;
skipping to change at line 512 skipping to change at line 515
} }
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
void StelMovementMgr::updateVisionVector(double deltaTime) void StelMovementMgr::updateVisionVector(double deltaTime)
{ {
StelNavigator* nav = core->getNavigator(); StelNavigator* nav = core->getNavigator();
if (flagAutoMove) if (flagAutoMove)
{ {
double ra_aim, de_aim, ra_start, de_start, ra_now, de_now; double ra_aim, de_aim, ra_start, de_start, ra_now, de_now;
if( zoomingMode == 1 && StelApp::getInstance().getStelObject Mgr().getWasSelected()) if( zoomingMode == 1 && objectMgr->getWasSelected())
{ {
// if zooming in, object may be moving so be sure to zoom to latest position // if zooming in, object may be moving so be sure to zoom to latest position
move.aim = StelApp::getInstance().getStelObjectMgr() .getSelectedObject()[0]->getEquinoxEquatorialPos(core->getNavigator()); move.aim = objectMgr->getSelectedObject()[0]->getEqu inoxEquatorialPos(core->getNavigator());
move.aim.normalize(); move.aim.normalize();
move.aim*=2.; move.aim*=2.;
} }
// Use a smooth function // Use a smooth function
float smooth = 4.f; float smooth = 4.f;
double c; double c;
if (zoomingMode == 1) if (zoomingMode == 1)
{ {
skipping to change at line 604 skipping to change at line 607
nav->setAltAzVisionDirection(move.aim); nav->setAltAzVisionDirection(move.aim);
} }
else else
{ {
nav->setEquinoxEquVisionDirection(move.aim); nav->setEquinoxEquVisionDirection(move.aim);
} }
} }
} }
else else
{ {
if (flagTracking && StelApp::getInstance().getStelObjectMgr( ).getWasSelected()) // Equatorial vision vector locked on selected object if (flagTracking && objectMgr->getWasSelected()) // Equatori al vision vector locked on selected object
{ {
nav->setEquinoxEquVisionDirection(StelApp::getInstan ce().getStelObjectMgr().getSelectedObject()[0]->getEquinoxEquatorialPos(cor e->getNavigator())); nav->setEquinoxEquVisionDirection(objectMgr->getSele ctedObject()[0]->getEquinoxEquatorialPos(core->getNavigator()));
} }
else else
{ {
if (flagLockEquPos) // Equatorial vision vector lock ed if (flagLockEquPos) // Equatorial vision vector lock ed
{ {
// Recalc local vision vector // Recalc local vision vector
nav->setAltAzVisionDirection(nav->equinoxEqu ToAltAz(nav->getEquinoxEquVisionDirection())); nav->setAltAzVisionDirection(nav->equinoxEqu ToAltAz(nav->getEquinoxEquVisionDirection()));
} }
else // Local vision vector locked else // Local vision vector locked
{ {
 End of changes. 19 change blocks. 
16 lines changed or deleted 19 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/