StelMovementMgr.cpp   StelMovementMgr.cpp 
skipping to change at line 26 skipping to change at line 26
* 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.
*/ */
#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 "ConstellationMgr.hpp"
#include <cmath>
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
StelMovementMgr::StelMovementMgr(StelCore* acore) : core(acore), StelMovementMgr::StelMovementMgr(StelCore* acore)
flagLockEquPos(false), : currentFov(60.)
flagTracking(false), , initFov(60.)
isMouseMovingHoriz(false), , minFov(0.0001)
isMouseMovingVert(false), , maxFov(100.)
flagEnableMouseNavigation(true), , initConstellationIntensity(0.45)
keyMoveSpeed(0.00025), , core(acore)
flagMoveSlow(false), , objectMgr(NULL)
flagAutoMove(false), , flagLockEquPos(false)
deltaFov(0.), , flagTracking(false)
deltaAlt(0.), , isMouseMovingHoriz(false)
deltaAz(0.), , isMouseMovingVert(false)
dragTimeMode(false), , flagEnableMoveAtScreenEdge(false)
flagAutoZoom(0), , flagEnableMouseNavigation(true)
flagAutoZoomOutResetsDirection(0), , mouseZoomSpeed(30)
dragTriggerDistance(4.f) , flagEnableZoomKeys(true)
, flagEnableMoveKeys(true)
, keyMoveSpeed(0.00025)
, keyZoomSpeed(0.00025)
, flagMoveSlow(false)
, movementsSpeedFactor(1.5)
, flagAutoMove(false)
, zoomingMode(0)
, deltaFov(0.)
, deltaAlt(0.)
, deltaAz(0.)
, flagManualZoom(false)
, autoMoveDuration(1.5)
, hasDragged(false)
, previousX(0)
, previousY(0)
, beforeTimeDragTimeRate(0.)
, dragTimeMode(false)
, zoomMove()
, flagAutoZoom(0)
, flagAutoZoomOutResetsDirection(0)
, dragTriggerDistance(4.f)
{ {
setObjectName("StelMovementMgr"); setObjectName("StelMovementMgr");
isDragging = false; isDragging = false;
mountMode = MountAltAzimuthal; // default mountMode = MountAltAzimuthal; // default
upVectorMountFrame.set(0,0,1); upVectorMountFrame.set(0,0,1);
} }
StelMovementMgr::~StelMovementMgr() StelMovementMgr::~StelMovementMgr()
{ {
} }
skipping to change at line 85 skipping to change at line 109
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 = 0.0001; minFov = 0.0001;
maxFov = 100.; maxFov = 100.;
initFov = conf->value("navigation/init_fov",60.f).toFloat(); initFov = conf->value("navigation/init_fov",60.f).toFloat();
currentFov = initFov; currentFov = initFov;
setInitConstellationIntensity(conf->value("viewing/constellation_art _intensity", 0.5f).toFloat());
Vec3f tmp = StelUtils::strToVec3f(conf->value("navigation/init_view_ pos").toString()); Vec3f tmp = StelUtils::strToVec3f(conf->value("navigation/init_view_ pos").toString());
initViewPos.set(tmp[0], tmp[1], tmp[2]); initViewPos.set(tmp[0], tmp[1], tmp[2]);
viewDirectionJ2000 = core->altAzToJ2000(initViewPos, StelCore::Refra ctionOff); viewDirectionJ2000 = core->altAzToJ2000(initViewPos, StelCore::Refra ctionOff);
QString tmpstr = conf->value("navigation/viewing_mode", "horizon").t oString(); QString tmpstr = conf->value("navigation/viewing_mode", "horizon").t oString();
if (tmpstr=="equator") if (tmpstr=="equator")
setMountMode(StelMovementMgr::MountEquinoxEquatorial); setMountMode(StelMovementMgr::MountEquinoxEquatorial);
else else
{ {
if (tmpstr=="horizon") if (tmpstr=="horizon")
setMountMode(StelMovementMgr::MountAltAzimuthal); setMountMode(StelMovementMgr::MountAltAzimuthal);
else else
{ {
qWarning() << "ERROR : Unknown viewing mode type : " << tmpstr; qWarning() << "ERROR : Unknown viewing mode type : " << tmpstr;
setMountMode(StelMovementMgr::MountEquinoxEquatorial ); setMountMode(StelMovementMgr::MountEquinoxEquatorial );
} }
} }
QString movementGroup = N_("Movement and Selection");
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("actionZoom_In_Auto", movementGroup, N_("Zoom in on select
ed object"), "autoZoomIn()", "/");
addAction("actionZoom_Out_Auto", movementGroup, N_("Zoom out"), "aut
oZoomOut()", "\\");
addAction("actionSet_Tracking", movementGroup, N_("Track object"), "
tracking", "T");
} }
void StelMovementMgr::setMountMode(MountMode m) void StelMovementMgr::setMountMode(MountMode m)
{ {
mountMode = m; mountMode = m;
setViewDirectionJ2000(viewDirectionJ2000); setViewDirectionJ2000(viewDirectionJ2000);
} }
void StelMovementMgr::setFlagLockEquPos(bool b) void StelMovementMgr::setFlagLockEquPos(bool b)
{ {
skipping to change at line 264 skipping to change at line 296
} }
} }
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;
int numDegrees = event->delta() / 8;
int numSteps = numDegrees / 15; // Manage only vertical wheel event
zoomTo(getAimFov()-mouseZoomSpeed*numSteps*getAimFov()/60., 0.2); if (event->orientation() != Qt::Vertical)
return;
const float numSteps = event->delta() / 120.f;
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->getJDay(); e.jd=core->getJDay();
e.x=x; e.x=x;
e.y=y; e.y=y;
timeDragHistory.append(e); timeDragHistory.append(e);
if (timeDragHistory.size()>3) if (timeDragHistory.size()>3)
timeDragHistory.removeFirst(); timeDragHistory.removeFirst();
} }
bool StelMovementMgr::handlePinch(qreal scale, bool started)
{
static double previousFov = 0;
if (started)
previousFov = getAimFov();
if (scale>0)
zoomTo(previousFov/scale, 0);
return true;
}
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();
skipping to change at line 372 skipping to change at line 421
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);
#else #else
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::ControlModifier) ? StelModule::AddToSelection : StelModule::ReplaceSele ction); event->modifiers().testFlag( Qt::ControlModifier) ? StelModule::AddToSelection : StelModule::ReplaceSele ction);
#endif #endif
if (StelApp::getInstance().getStelOb jectMgr().getWasSelected()) if (StelApp::getInstance().getStelOb jectMgr().getWasSelected())
{ {
setFlagTracking(false); setFlagTracking(false);
} }
event->accept(); //GZ: You must comment out this line
for testing Landscape transparency debug prints.
//event->accept();
return; return;
} }
} }
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);
skipping to change at line 836 skipping to change at line 886
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();
v2[2]=0; v2.normalize(); v2[2]=0; v2.normalize();
double angle = (v2^v1)[2]; double angle = (v2^v1)[2];
double deltaDay = angle/(2.*M_PI)*core->getLocalSideralDayLe ngth(); double deltaDay = angle/(2.*M_PI)*core->getLocalSiderealDayL ength();
core->setJDay(core->getJDay()+deltaDay); core->setJDay(core->getJDay()+deltaDay);
addTimeDragPoint(x2, y2); addTimeDragPoint(x2, y2);
} }
else else
{ {
Vec3d tempvec1, tempvec2; Vec3d tempvec1, tempvec2;
const StelProjectorP prj = core->getProjection(StelCore::Fra meJ2000); const StelProjectorP prj = core->getProjection(StelCore::Fra meJ2000);
prj->unProject(x2,y2, tempvec2); prj->unProject(x2,y2, tempvec2);
prj->unProject(x1,y1, tempvec1); prj->unProject(x1,y1, tempvec1);
double az1, alt1, az2, alt2; double az1, alt1, az2, alt2;
skipping to change at line 903 skipping to change at line 953
flagAutoZoom = true; flagAutoZoom = true;
} }
void StelMovementMgr::changeFov(double deltaFov) void StelMovementMgr::changeFov(double deltaFov)
{ {
// if we are zooming in or out // if we are zooming in or out
if (deltaFov) if (deltaFov)
setFov(currentFov + deltaFov); setFov(currentFov + deltaFov);
} }
void StelMovementMgr::changeConstellationArtIntensity()
{
ConstellationMgr *cmgr = GETSTELMODULE(ConstellationMgr);
if (cmgr->getFlagArt())
{
double artInt = getInitConstellationIntensity();
// Fade out constellation art when FOV less 2 degrees
if (currentFov<=2.)
artInt *= currentFov>1.? (currentFov-1.) : 0. ;
cmgr->setArtIntensity(artInt);
}
}
double StelMovementMgr::getAimFov(void) const double StelMovementMgr::getAimFov(void) const
{ {
return (flagAutoZoom ? zoomMove.aim : currentFov); return (flagAutoZoom ? zoomMove.aim : currentFov);
} }
void StelMovementMgr::setMaxFov(double max) void StelMovementMgr::setMaxFov(double max)
{ {
maxFov = max; maxFov = max;
if (currentFov > max) if (currentFov > max)
{ {
 End of changes. 10 change blocks. 
21 lines changed or deleted 93 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/