Advertisement
marbledeveloper

ViewportParams_cpp.diff

May 23rd, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. --- ViewportParams_original.cpp 2011-12-20 20:19:12.000000000 +0100
  2. +++ ViewportParams.cpp 2012-05-23 19:51:56.557246800 +0200
  3. @@ -22,7 +22,9 @@
  4. #include "SphericalProjection.h"
  5. #include "EquirectProjection.h"
  6. #include "MercatorProjection.h"
  7. +//#include <MarbleClock.h>
  8.  
  9. +#define earthAngularSpeed 0.004167
  10.  
  11. namespace Marble
  12. {
  13. @@ -32,7 +34,7 @@
  14. public:
  15. ViewportParamsPrivate();
  16.  
  17. - void setPlanetAxis( const Quaternion &newAxis );
  18. + void setPlanetAxis( const Quaternion &newAxis);
  19.  
  20. // These two go together. m_currentProjection points to one of
  21. // the static Projection classes at the bottom.
  22. @@ -43,7 +45,9 @@
  23. qreal m_centerLongitude;
  24. qreal m_centerLatitude;
  25. Quaternion m_planetAxis; // Position, coded in a quaternion
  26. + Quaternion m_planetInertialAxis; // Position, coded in a quaternion
  27. mutable matrix m_planetAxisMatrix;
  28. + mutable matrix m_planetInertialAxisMatrix;
  29. int m_radius; // Zoom level (pixels / globe radius)
  30. qreal m_angularResolution;
  31.  
  32. @@ -59,6 +63,9 @@
  33.  
  34. GeoDataCoordinates m_focusPoint;
  35. bool m_hasFocusPoint;
  36. + //MarbleClock* m_clock;
  37. + mutable double m_time;
  38. + mutable bool m_old;
  39.  
  40. };
  41.  
  42. @@ -68,15 +75,21 @@
  43. m_centerLongitude( 0 ),
  44. m_centerLatitude( 0 ),
  45. m_planetAxis( 1.0, 0.0, 0.0, 0.0 ), // Default view
  46. + m_planetInertialAxis( 1.0, 0.0, 0.0, 0.0 ),
  47. m_planetAxisMatrix(),
  48. + m_planetInertialAxisMatrix(),
  49. m_radius( 2000 ),
  50. m_angularResolution( 0.25 * M_PI / fabs( (qreal)( m_radius ) ) ),
  51. m_size( 100, 100 ),
  52. m_dirtyBox( true ),
  53. m_viewLatLonAltBox(),
  54. - m_hasFocusPoint(false)
  55. + m_hasFocusPoint(false),
  56. + //m_clock( 0 ),
  57. + m_time( 0 ),
  58. + m_old( false )
  59. {
  60. m_planetAxis.inverse().toMatrix( m_planetAxisMatrix );
  61. + m_planetInertialAxis.inverse().toMatrix( m_planetInertialAxisMatrix );
  62. }
  63.  
  64.  
  65. @@ -248,13 +261,44 @@
  66. m_dirtyBox = true;
  67. m_planetAxis = newAxis;
  68. m_planetAxis.inverse().toMatrix( m_planetAxisMatrix );
  69. + qreal lon;
  70. + qreal lat;
  71. + m_planetInertialAxis.getSpherical(lon, lat); // takes the normal axis and retrieve lon and lat from it
  72. + // Enter your lat-lon-Fixed-To-Inertial coordinate conversion code here and apply the new values to lat and lon
  73. + if (m_old){
  74. + //Qt::DateFormat format = Qt::ISODate;
  75. + //QString dateString("2000-01-01T00:00:00");
  76. + //QDateTime someFixedTimeBack = QDateTime::fromString(dateString, format);
  77. + //double timeDelta = m_clock->dateTime().toTime_t() - someFixedTimeBack.toTime_t();
  78. + lon = lon - (earthAngularSpeed * m_time);
  79. + }
  80. + Quaternion axis = Quaternion::fromEuler( -lat, lon, 0.0 );
  81. + axis.normalize();
  82. + m_planetInertialAxis = axis;
  83. +}
  84. +
  85. +void ViewportParams::setTime(const double time) const
  86. +{
  87. + d->m_time = time;
  88. }
  89.  
  90. -const matrix * ViewportParams::planetAxisMatrix() const
  91. +void ViewportParams::setOld(const bool old) const
  92. {
  93. - return &d->m_planetAxisMatrix;
  94. + d->m_old = old;
  95. }
  96.  
  97. +const matrix * ViewportParams::planetAxisMatrix(const int type) const
  98. +{
  99. + if (!type)
  100. + return &d->m_planetAxisMatrix;
  101. + return &d->m_planetInertialAxisMatrix;
  102. +}
  103. +
  104. +/*const matrix * ViewportParams::planetInertialAxisMatrix() const
  105. +{
  106. + return &d->m_planetInertialAxisMatrix;
  107. +}*/
  108. +
  109. int ViewportParams::width() const
  110. {
  111. return d->m_size.width();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement