-
-
Notifications
You must be signed in to change notification settings - Fork 865
/
Copy pathStelCore.cpp
3063 lines (2741 loc) · 120 KB
/
StelCore.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2003 Fabien Chereau
* Copyright (C) 2012 Matthew Gates
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/
#include "StelCore.hpp"
#include "StelProjector.hpp"
#include "StelProjectorClasses.hpp"
#include "StelToneReproducer.hpp"
#include "StelApp.hpp"
#include "StelUtils.hpp"
#include "StelGeodesicGrid.hpp"
#include "StelMovementMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelPainter.hpp"
#include "StelLocationMgr.hpp"
#include "StelObserver.hpp"
#include "StelObjectMgr.hpp"
#include "Planet.hpp"
#include "SolarSystem.hpp"
#include "LandscapeMgr.hpp"
#include "StelTranslator.hpp"
#include "StelActionMgr.hpp"
#include "StelFileMgr.hpp"
#include "StelMainView.hpp"
#include "EphemWrapper.hpp"
#include "NomenclatureItem.hpp"
#include "precession.h"
#include <QSettings>
#include <QDebug>
#include <QMetaEnum>
#include <QTimeZone>
#include <QFile>
#include <QDir>
#include <QRegularExpression>
#include <QOpenGLShaderProgram>
#include <iostream>
#include <fstream>
// Init static transfo matrices
// See vsop87.doc:
const Mat4d StelCore::matJ2000ToVsop87(Mat4d::xrotation(-23.4392803055555555556*M_PI_180) * Mat4d::zrotation(0.0000275*M_PI_180));
const Mat4d StelCore::matVsop87ToJ2000(matJ2000ToVsop87.transpose());
const Mat4d StelCore::matJ2000ToGalactic(-0.054875539726, 0.494109453312, -0.867666135858, 0, -0.873437108010, -0.444829589425, -0.198076386122, 0, -0.483834985808, 0.746982251810, 0.455983795705, 0, 0, 0, 0, 1);
const Mat4d StelCore::matGalacticToJ2000(matJ2000ToGalactic.transpose());
const Mat4d StelCore::matJ2000ToSupergalactic(0.37501548, -0.89832046, 0.22887497, 0, 0.34135896, -0.09572714, -0.93504565, 0, 0.86188018, 0.42878511, 0.27075058, 0, 0, 0, 0, 1);
const Mat4d StelCore::matSupergalacticToJ2000(matJ2000ToSupergalactic.transpose());
Mat4d StelCore::matJ2000ToJ1875; // gets to be initialized in constructor.
const double StelCore::JD_SECOND = 0.000011574074074074074074; // 1/(24*60*60)=1/86400
const double StelCore::JD_MINUTE = 0.00069444444444444444444; // 1/(24*60) =1/1440
const double StelCore::JD_HOUR = 0.041666666666666666666; // 1/24
const double StelCore::JD_DAY = 1.;
const double StelCore::ONE_OVER_JD_SECOND = 86400; // 86400
const double StelCore::TZ_ERA_BEGINNING = 2395996.5; // December 1, 1847
StelCore::StelCore()
: skyDrawer(Q_NULLPTR)
, movementMgr(Q_NULLPTR)
, propMgr(Q_NULLPTR)
, geodesicGrid(Q_NULLPTR)
, currentProjectionType(ProjectionStereographic)
, currentDeltaTAlgorithm(EspenakMeeus)
, position(Q_NULLPTR)
, flagUseNutation(true)
, flagUseAberration(true)
, aberrationFactor(1.0)
, flagUseTopocentricCoordinates(true)
, timeSpeed(JD_SECOND)
, JD(0.,0.)
, presetSkyTime(0.)
, milliSecondsOfLastJDUpdate(0)
, jdOfLastJDUpdate(0.)
, flagUseDST(true)
, flagUseCTZ(false)
, startupTimeStop(false)
, deltaTCustomNDot(-26.0)
, deltaTCustomYear(1820.0)
, deltaTnDot(-26.0)
, deltaTdontUseMoon(false)
, deltaTfunc(StelUtils::getDeltaTByEspenakMeeus)
, deltaTstart(-1999)
, deltaTfinish(3000)
, de430Available(false)
, de431Available(false)
, de430Active(false)
, de431Active(false)
, de440Available(false)
, de441Available(false)
, de440Active(false)
, de441Active(false)
, flagClearSky(true)
{
setObjectName("StelCore");
registerMathMetaTypes();
toneReproducer = new StelToneReproducer();
milliSecondsOfLastJDUpdate = QDateTime::currentMSecsSinceEpoch();
QSettings* conf = StelApp::getInstance().getSettings();
// Create and initialize the default projector params
QString tmpstr = conf->value("projection/viewport").toString();
currentProjectorParams.maskType = StelProjector::stringToMaskType(tmpstr);
const int viewport_width = conf->value("projection/viewport_width", currentProjectorParams.viewportXywh[2]).toInt();
const int viewport_height = conf->value("projection/viewport_height", currentProjectorParams.viewportXywh[3]).toInt();
const int viewport_x = conf->value("projection/viewport_x", 0).toInt();
const int viewport_y = conf->value("projection/viewport_y", 0).toInt();
currentProjectorParams.viewportXywh.set(viewport_x,viewport_y,viewport_width,viewport_height);
const qreal viewportCenterX = conf->value("projection/viewport_center_x",0.5*viewport_width).toDouble();
const qreal viewportCenterY = conf->value("projection/viewport_center_y",0.5*viewport_height).toDouble();
currentProjectorParams.viewportCenter.set(viewportCenterX, viewportCenterY);
const qreal viewportCenterOffsetX = conf->value("projection/viewport_center_offset_x",0.).toDouble();
const qreal viewportCenterOffsetY = conf->value("projection/viewport_center_offset_y",0.).toDouble();
currentProjectorParams.viewportCenterOffset.set(viewportCenterOffsetX, viewportCenterOffsetY);
currentProjectorParams.viewportFovDiameter = conf->value("projection/viewport_fov_diameter", qMin(viewport_width,viewport_height)).toDouble();
currentProjectorParams.flipHorz = conf->value("projection/flip_horz",false).toBool();
currentProjectorParams.flipVert = conf->value("projection/flip_vert",false).toBool();
currentProjectorParams.gravityLabels = conf->value("viewing/flag_gravity_labels").toBool();
currentProjectorParams.devicePixelsPerPixel = StelApp::getInstance().getDevicePixelsPerPixel();
flagUseNutation=conf->value("astro/flag_nutation", true).toBool();
flagUseAberration=conf->value("astro/flag_aberration", true).toBool();
aberrationFactor=conf->value("astro/aberration_factor", 1.0).toDouble();
flagUseTopocentricCoordinates=conf->value("astro/flag_topocentric_coordinates", true).toBool();
flagUseDST=conf->value("localization/flag_dst", true).toBool();
// Initialize matJ2000ToJ1875 matrix
double eps1875, chi1875, omega1875, psi1875;
const double jdB1875 = StelUtils::getJDFromBesselianEpoch(1875.0);
getPrecessionAnglesVondrak(jdB1875, &eps1875, &chi1875, &omega1875, &psi1875);
matJ2000ToJ1875 = Mat4d::xrotation(84381.406*1./3600.*M_PI/180.) * Mat4d::zrotation(-psi1875) * Mat4d::xrotation(-omega1875) * Mat4d::zrotation(chi1875);
matJ2000ToJ1875 = matJ2000ToJ1875.transpose();
}
StelCore::~StelCore()
{
delete toneReproducer; toneReproducer=Q_NULLPTR;
delete geodesicGrid; geodesicGrid=Q_NULLPTR;
delete skyDrawer; skyDrawer=Q_NULLPTR;
delete position; position=Q_NULLPTR;
}
DitheringMode StelCore::parseDitheringMode(const QString& str)
{
const auto s=str.trimmed().toLower();
static const QMap<QString, DitheringMode>dMap={
{"disabled" , DitheringMode::Disabled},
{"color565" , DitheringMode::Color565},
{"color666" , DitheringMode::Color666},
{"color888" , DitheringMode::Color888},
{"color101010", DitheringMode::Color101010}};
return dMap.value(s, DitheringMode::Disabled);
}
/*************************************************************************
Load core data and initialize with default values
*************************************************************************/
void StelCore::init()
{
QSettings* conf = StelApp::getInstance().getSettings();
const char ditheringModeKey[] = "video/dithering_mode";
QVariant selectedDitherFormat = conf->value(ditheringModeKey);
if(!selectedDitherFormat.isValid())
{
constexpr char defaultValue[] = "color888";
selectedDitherFormat = defaultValue;
conf->setValue(ditheringModeKey, defaultValue);
}
ditheringMode = parseDitheringMode(selectedDitherFormat.toString());
if (conf->childGroups().contains("location_run_once"))
defaultLocationID = "stellarium_cli";
else
defaultLocationID = conf->value("init_location/location", "auto").toString();
bool ok;
StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMgr();
StelLocation location=locationMgr->getLastResortLocation(); // first location: Paris. Required if no IP connection on first launch!
if (defaultLocationID == "auto")
{
locationMgr->locationFromIP();
}
else if (defaultLocationID == "stellarium_cli")
{
location = locationMgr->locationFromCLI();
}
else if (defaultLocationID.startsWith("GPS", Qt::CaseInsensitive))
{
// The location is obtained already from init_location/last_resort_location
location.name = conf->value("init_location/location").toString();
}
else
{
location = locationMgr->locationForString(defaultLocationID);
}
if (!location.isValid())
{
qWarning() << "Warning: location" << defaultLocationID << "is unknown.";
location = locationMgr->getLastResortLocation();
}
position = new StelObserver(location);
QString ctz = conf->value("localization/time_zone", "").toString();
if (!ctz.isEmpty())
setUseCustomTimeZone(true);
else
ctz = getCurrentLocation().ianaTimeZone;
setCurrentTimeZone(ctz);
// Delta-T stuff
// Define default algorithm for time correction (Delta T)
QString tmpDT = conf->value("navigation/time_correction_algorithm", "EspenakMeeusModified").toString();
setCurrentDeltaTAlgorithmKey(tmpDT);
// Define variables of custom equation for calculation of Delta T
// Default: ndot = -26.0 "/cy/cy; year = 1820; DeltaT = -20 + 32*u^2, where u = (currentYear-1820)/100
setDeltaTCustomYear(conf->value("custom_time_correction/year", 1820.0).toDouble());
setDeltaTCustomNDot(conf->value("custom_time_correction/ndot", -26.0).toDouble());
setDeltaTCustomEquationCoefficients(Vec3d(conf->value("custom_time_correction/coefficients", "-20,0,32").toString()));
// Time stuff
setTimeNow();
// We want to be able to handle the old style preset time, recorded as a double
// jday, or as a more human readable string...
QString presetTimeStr = conf->value("navigation/preset_sky_time",2451545.).toString();
presetSkyTime = presetTimeStr.toDouble(&ok);
if (ok)
{
qDebug().noquote() << "navigation/preset_sky_time is a double - treating as jday:" << QString::number(presetSkyTime, 'f', 5);
}
else
{
qDebug().noquote() << "navigation/preset_sky_time was not a double, treating as string date:" << presetTimeStr;
presetSkyTime = StelUtils::qDateTimeToJd(QDateTime::fromString(presetTimeStr));
}
setInitTodayTime(QTime::fromString(conf->value("navigation/today_time", "22:00").toString()));
startupTimeMode = conf->value("navigation/startup_time_mode", "actual").toString().toLower();
if (startupTimeMode=="preset")
setJD(presetSkyTime - static_cast<double>(getUTCOffset(presetSkyTime)) * JD_HOUR);
else if (startupTimeMode=="today")
setTodayTime(getInitTodayTime());
startupTimeStop = conf->value("navigation/startup_time_stop", false).toBool();
if (startupTimeStop)
setZeroTimeSpeed();
// Compute transform matrices between coordinates systems
updateTransformMatrices();
updateFixedEquatorialTransformMatrices();
connect(this, SIGNAL(locationChanged(const StelLocation&)), this, SLOT(updateFixedEquatorialTransformMatrices()));
movementMgr = new StelMovementMgr(this);
movementMgr->init();
currentProjectorParams.fov = static_cast<float>(movementMgr->getInitFov());
StelApp::getInstance().getModuleMgr().registerModule(movementMgr);
skyDrawer = new StelSkyDrawer(this);
skyDrawer->init();
propMgr = StelApp::getInstance().getStelPropertyManager();
propMgr->registerObject(skyDrawer);
propMgr->registerObject(this);
propMgr->registerObject(toneReproducer);
setCurrentProjectionTypeKey(getDefaultProjectionTypeKey());
updateMaximumFov();
// activate DE430/431
initEphemeridesFunctions();
// Register all the core actions.
QString timeGroup = N_("Date and Time");
QString movementGroup = N_("Movement and Selection");
QString displayGroup = N_("Display Options");
StelActionMgr* actionsMgr = StelApp::getInstance().getStelActionManager();
actionsMgr->addAction("actionIncrease_Time_Speed", timeGroup, N_("Increase time speed"), this, "increaseTimeSpeed()", "L");
actionsMgr->addAction("actionDecrease_Time_Speed", timeGroup, N_("Decrease time speed"), this, "decreaseTimeSpeed()", "J");
actionsMgr->addAction("actionIncrease_Time_Speed_Less", timeGroup, N_("Increase time speed (a little)"), this, "increaseTimeSpeedLess()", "Shift+L");
actionsMgr->addAction("actionDecrease_Time_Speed_Less", timeGroup, N_("Decrease time speed (a little)"), this, "decreaseTimeSpeedLess()", "Shift+J");
actionsMgr->addAction("actionSet_Real_Time_Speed", timeGroup, N_("Set normal time rate"), this, "toggleRealTimeSpeed()", "K");
actionsMgr->addAction("actionSet_Time_Rate_Zero", timeGroup, N_("Set time rate to zero"), this, "setZeroTimeSpeed()", "7");
actionsMgr->addAction("actionSet_Time_Reverse", timeGroup, N_("Set reverse time direction"), this, "revertTimeDirection()", "0");
actionsMgr->addAction("actionReturn_To_Current_Time", timeGroup, N_("Set time to now"), this, "setTimeNow()", "8");
actionsMgr->addAction("actionAdd_Solar_Minute", timeGroup, N_("Add 1 solar minute"), this, "addMinute()");
actionsMgr->addAction("actionAdd_Solar_Hour", timeGroup, N_("Add 1 solar hour"), this, "addHour()", "Ctrl+=");
actionsMgr->addAction("actionAdd_Solar_Day", timeGroup, N_("Add 1 solar day"), this, "addDay()", "=");
actionsMgr->addAction("actionAdd_Solar_Week", timeGroup, N_("Add 7 solar days"), this, "addWeek()", "]");
actionsMgr->addAction("actionSubtract_Solar_Minute", timeGroup, N_("Subtract 1 solar minute"), this, "subtractMinute()");
actionsMgr->addAction("actionSubtract_Solar_Hour", timeGroup, N_("Subtract 1 solar hour"), this, "subtractHour()", "Ctrl+-");
actionsMgr->addAction("actionSubtract_Solar_Day", timeGroup, N_("Subtract 1 solar day"), this, "subtractDay()", "-");
actionsMgr->addAction("actionSubtract_Solar_Week", timeGroup, N_("Subtract 7 solar days"), this, "subtractWeek()", "[");
actionsMgr->addAction("actionAdd_Sidereal_Day", timeGroup, N_("Add 1 sidereal day"), this, "addSiderealDay()", "Alt+=");
actionsMgr->addAction("actionAdd_Sidereal_Week", timeGroup, N_("Add 7 sidereal days"), this, "addSiderealWeek()");
actionsMgr->addAction("actionAdd_Sidereal_Year", timeGroup, N_("Add 1 sidereal year"), this, "addSiderealYear()", "Ctrl+Alt+Shift+]");
actionsMgr->addAction("actionAdd_Sidereal_Century", timeGroup, N_("Add 100 sidereal years"), this, "addSiderealYears()");
actionsMgr->addAction("actionAdd_Synodic_Month", timeGroup, N_("Add 1 synodic month"), this, "addSynodicMonth()");
actionsMgr->addAction("actionAdd_Saros", timeGroup, N_("Add 1 saros"), this, "addSaros()");
actionsMgr->addAction("actionAdd_Draconic_Month", timeGroup, N_("Add 1 draconic month"), this, "addDraconicMonth()");
actionsMgr->addAction("actionAdd_Draconic_Year", timeGroup, N_("Add 1 draconic year"), this, "addDraconicYear()");
actionsMgr->addAction("actionAdd_Anomalistic_Month", timeGroup, N_("Add 1 anomalistic month"), this, "addAnomalisticMonth()");
actionsMgr->addAction("actionAdd_Anomalistic_Year", timeGroup, N_("Add 1 anomalistic year"), this, "addAnomalisticYear()");
actionsMgr->addAction("actionAdd_Anomalistic_Century", timeGroup, N_("Add 100 anomalistic years"), this, "addAnomalisticYears()");
actionsMgr->addAction("actionAdd_Mean_Tropical_Month", timeGroup, N_("Add 1 mean tropical month"), this, "addMeanTropicalMonth()");
actionsMgr->addAction("actionAdd_Mean_Tropical_Year", timeGroup, N_("Add 1 mean tropical year"), this, "addMeanTropicalYear()");
actionsMgr->addAction("actionAdd_Mean_Tropical_Century", timeGroup, N_("Add 100 mean tropical years"), this, "addMeanTropicalYears()");
actionsMgr->addAction("actionAdd_Tropical_Year", timeGroup, N_("Add 1 tropical year"), this, "addTropicalYear()");
actionsMgr->addAction("actionAdd_Julian_Year", timeGroup, N_("Add 1 Julian year"), this, "addJulianYear()");
actionsMgr->addAction("actionAdd_Julian_Century", timeGroup, N_("Add 1 Julian century"), this, "addJulianYears()");
actionsMgr->addAction("actionAdd_Gaussian_Year", timeGroup, N_("Add 1 Gaussian year"), this, "addGaussianYear()");
actionsMgr->addAction("actionAdd_Calendric_Month", timeGroup, N_("Add 1 calendric month"), this, "addCalendricMonth()");
actionsMgr->addAction("actionSubtract_Sidereal_Day", timeGroup, N_("Subtract 1 sidereal day"), this, "subtractSiderealDay()", "Alt+-");
actionsMgr->addAction("actionSubtract_Sidereal_Week", timeGroup, N_("Subtract 7 sidereal days"), this, "subtractSiderealWeek()");
actionsMgr->addAction("actionSubtract_Sidereal_Year", timeGroup, N_("Subtract 1 sidereal year"), this, "subtractSiderealYear()", "Ctrl+Alt+Shift+[");
actionsMgr->addAction("actionSubtract_Sidereal_Century", timeGroup, N_("Subtract 100 sidereal years"), this, "subtractSiderealYears()");
actionsMgr->addAction("actionSubtract_Synodic_Month", timeGroup, N_("Subtract 1 synodic month"), this, "subtractSynodicMonth()");
actionsMgr->addAction("actionSubtract_Saros", timeGroup, N_("Subtract 1 saros"), this, "subtractSaros()");
actionsMgr->addAction("actionSubtract_Draconic_Month", timeGroup, N_("Subtract 1 draconic month"), this, "subtractDraconicMonth()");
actionsMgr->addAction("actionSubtract_Draconic_Year", timeGroup, N_("Subtract 1 draconic year"), this, "subtractDraconicYear()");
actionsMgr->addAction("actionSubtract_Anomalistic_Month", timeGroup, N_("Subtract 1 anomalistic month"), this, "subtractAnomalisticMonth()");
actionsMgr->addAction("actionSubtract_Anomalistic_Year", timeGroup, N_("Subtract 1 anomalistic year"), this, "subtractAnomalisticYear()");
actionsMgr->addAction("actionSubtract_Anomalistic_Century", timeGroup, N_("Subtract 100 anomalistic years"), this, "subtractAnomalisticYears()");
actionsMgr->addAction("actionSubtract_Mean_Tropical_Month", timeGroup, N_("Subtract 1 mean tropical month"), this, "subtractMeanTropicalMonth()");
actionsMgr->addAction("actionSubtract_Mean_Tropical_Year", timeGroup, N_("Subtract 1 mean tropical year"), this, "subtractMeanTropicalYear()");
actionsMgr->addAction("actionSubtract_Mean_Tropical_Century", timeGroup, N_("Subtract 100 mean tropical years"), this, "subtractMeanTropicalYears()");
actionsMgr->addAction("actionSubtract_Tropical_Year", timeGroup, N_("Subtract 1 tropical year"), this, "subtractTropicalYear()");
actionsMgr->addAction("actionSubtract_Julian_Year", timeGroup, N_("Subtract 1 Julian year"), this, "subtractJulianYear()");
actionsMgr->addAction("actionSubtract_Julian_Century", timeGroup, N_("Subtract 1 Julian century"), this, "subtractJulianYears()");
actionsMgr->addAction("actionSubtract_Gaussian_Year", timeGroup, N_("Subtract 1 Gaussian year"), this, "subtractGaussianYear()");
actionsMgr->addAction("actionSubtract_Calendric_Month", timeGroup, N_("Subtract 1 calendric month"), this, "subtractCalendricMonth()");
actionsMgr->addAction("actionSet_Home_Planet_To_Selected", movementGroup, N_("Set home planet to selected planet"), this, "moveObserverToSelected()", "Ctrl+G");
actionsMgr->addAction("actionGo_Home_Global", movementGroup, N_("Go to home"), this, "returnToHome()", "Ctrl+H");
actionsMgr->addAction("actionHorizontal_Flip", displayGroup, N_("Flip scene horizontally"), this, "flipHorz", "Ctrl+Shift+H", "", true);
actionsMgr->addAction("actionVertical_Flip", displayGroup, N_("Flip scene vertically"), this, "flipVert", "Ctrl+Shift+V", "", true);
actionsMgr->addAction("actionClear_Background", displayGroup, N_("Toggle background clearing"), this, "flagClearSky", "Ctrl+Alt+C", "", true);
}
QString StelCore::getDefaultProjectionTypeKey() const
{
QSettings* conf = StelApp::getInstance().getSettings();
return conf->value("projection/type", "ProjectionStereographic").toString();
}
// Get the shared instance of StelGeodesicGrid.
// The returned instance is guaranteed to allow for at least maxLevel levels
const StelGeodesicGrid* StelCore::getGeodesicGrid(int maxLevel) const
{
if (geodesicGrid==Q_NULLPTR)
{
geodesicGrid = new StelGeodesicGrid(maxLevel);
}
else if (maxLevel>geodesicGrid->getMaxLevel())
{
delete geodesicGrid;
geodesicGrid = new StelGeodesicGrid(maxLevel);
}
return geodesicGrid;
}
StelProjectorP StelCore::getProjection2d() const
{
StelProjectorP prj(new StelProjector2d());
prj->init(currentProjectorParams);
return prj;
}
StelProjectorP StelCore::getProjection(StelProjector::ModelViewTranformP modelViewTransform, ProjectionType projType) const
{
if (projType==static_cast<ProjectionType>(1000))
projType = currentProjectionType;
StelProjectorP prj;
switch (projType)
{
case ProjectionPerspective:
prj = StelProjectorP(new StelProjectorPerspective(modelViewTransform));
break;
case ProjectionEqualArea:
prj = StelProjectorP(new StelProjectorEqualArea(modelViewTransform));
break;
case ProjectionStereographic:
prj = StelProjectorP(new StelProjectorStereographic(modelViewTransform));
break;
case ProjectionFisheye:
prj = StelProjectorP(new StelProjectorFisheye(modelViewTransform));
break;
case ProjectionHammer:
prj = StelProjectorP(new StelProjectorHammer(modelViewTransform));
break;
case ProjectionCylinder:
prj = StelProjectorP(new StelProjectorCylinder(modelViewTransform));
break;
case ProjectionCylinderFill:
prj = StelProjectorP(new StelProjectorCylinderFill(modelViewTransform));
break;
case ProjectionMercator:
prj = StelProjectorP(new StelProjectorMercator(modelViewTransform));
break;
case ProjectionOrthographic:
prj = StelProjectorP(new StelProjectorOrthographic(modelViewTransform));
break;
case ProjectionSinusoidal:
prj = StelProjectorP(new StelProjectorSinusoidal(modelViewTransform));
break;
case ProjectionMiller:
prj = StelProjectorP(new StelProjectorMiller(modelViewTransform));
break;
default:
qWarning() << "Unknown projection type: " << static_cast<int>(projType) << "using ProjectionStereographic instead";
prj = StelProjectorP(new StelProjectorStereographic(modelViewTransform));
Q_ASSERT(0);
}
prj->init(currentProjectorParams);
return prj;
}
// Get an instance of projector using the current display parameters from Navigation, StelMovementMgr
StelProjectorP StelCore::getProjection(FrameType frameType, RefractionMode refractionMode) const
{
switch (frameType)
{
case FrameAltAz:
return getProjection(getAltAzModelViewTransform(refractionMode));
case FrameHeliocentricEclipticJ2000:
return getProjection(getHeliocentricEclipticModelViewTransform(refractionMode));
case FrameObservercentricEclipticJ2000:
return getProjection(getObservercentricEclipticJ2000ModelViewTransform(refractionMode));
case FrameObservercentricEclipticOfDate:
return getProjection(getObservercentricEclipticOfDateModelViewTransform(refractionMode));
case FrameEquinoxEqu:
return getProjection(getEquinoxEquModelViewTransform(refractionMode));
case FrameFixedEquatorial:
return getProjection(getFixedEquatorialModelViewTransform(refractionMode));
case FrameJ2000:
return getProjection(getJ2000ModelViewTransform(refractionMode));
case FrameGalactic:
return getProjection(getGalacticModelViewTransform(refractionMode));
case FrameSupergalactic:
return getProjection(getSupergalacticModelViewTransform(refractionMode));
default:
qDebug() << "Unknown reference frame type: " << static_cast<int>(frameType) << ".";
}
Q_ASSERT(0);
return getProjection2d();
}
SphericalCap StelCore::getVisibleSkyArea() const
{
const LandscapeMgr* landscapeMgr = GETSTELMODULE(LandscapeMgr);
Vec3d up(0, 0, 1);
up = altAzToJ2000(up, RefractionOff);
// Limit star drawing to above landscape's minimal altitude (was const=-0.035, Bug lp:1469407)
if (landscapeMgr->getIsLandscapeFullyVisible())
{
return SphericalCap(up, landscapeMgr->getLandscapeSinMinAltitudeLimit());
}
return SphericalCap(up, -1.);
}
// Handle the resizing of the window
void StelCore::windowHasBeenResized(qreal x, qreal y, qreal width, qreal height)
{
// Maximize display when resized since it invalidates previous options anyway
currentProjectorParams.viewportXywh.set(qRound(x), qRound(y), qRound(width), qRound(height));
currentProjectorParams.viewportCenter.set(x+(0.5+currentProjectorParams.viewportCenterOffset.v[0])*width, y+(0.5+currentProjectorParams.viewportCenterOffset.v[1])*height);
currentProjectorParams.viewportFovDiameter = qMin(width,height);
if (currentProjectionType==ProjectionType::ProjectionCylinderFill)
{
currentProjectorParams.widthStretch=0.5*width/height;
currentProjectorParams.viewportFovDiameter = height;
}
}
/*************************************************************************
Update all the objects in function of the time
*************************************************************************/
void StelCore::update(double deltaTime)
{
// Update the position of observation and time and recompute planet positions etc...
updateTime(deltaTime);
// Transform matrices between coordinates systems
updateTransformMatrices();
// Update direction of vision/Zoom level
movementMgr->updateMotion(deltaTime);
currentProjectorParams.fov = static_cast<float>(movementMgr->getCurrentFov());
skyDrawer->update(deltaTime);
}
/*************************************************************************
Execute all the pre-drawing functions
*************************************************************************/
void StelCore::preDraw()
{
// Init openGL viewing with fov, screen size and clip planes
currentProjectorParams.zNear = 0.000001;
currentProjectorParams.zFar = 500.;
// Clear the render buffer.
// Here we can set a sky background color if really wanted (art
// applications. Astronomical sky should be 0/0/0/0)
Vec3f backColor = StelMainView::getInstance().getSkyBackgroundColor();
QOpenGLFunctions* gl = QOpenGLContext::currentContext()->functions();
gl->glClearColor(backColor[0], backColor[1], backColor[2], 0.f);
if (flagClearSky)
gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
else
{
// TODO: dim whole framebuffer to 90%, else we are overexposed much too fast.
gl->glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
skyDrawer->preDraw();
}
/*************************************************************************
Update core state after drawing modules
*************************************************************************/
void StelCore::postDraw()
{
StelPainter sPainter(getProjection(StelCore::FrameJ2000));
sPainter.drawViewportShape();
}
void StelCore::updateMaximumFov()
{
const float savedFov = currentProjectorParams.fov;
currentProjectorParams.fov = 0.0001f; // Avoid crash
const float newMaxFov = getProjection(StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(Mat4d::identity(),Mat4d::identity())))->getMaxFov();
movementMgr->setMaxFov(static_cast<double>(newMaxFov));
currentProjectorParams.fov = qMin(newMaxFov, savedFov);
}
void StelCore::setCurrentProjectionType(ProjectionType type)
{
if(type!=currentProjectionType)
{
QSettings* conf = StelApp::getInstance().getSettings();
currentProjectionType=type;
updateMaximumFov();
if (currentProjectionType==ProjectionType::ProjectionCylinderFill)
{
// Save whatever stretch is present into config.ini. This value is saved just temporarily until switching back to another projection and will not be loaded on startup.
// (To configure a stretch at startup, use startup.ssc script.)
conf->setValue("projection/width_stretch", currentProjectorParams.widthStretch);
currentProjectorParams.fov=180.f;
currentProjectorParams.widthStretch=0.5*currentProjectorParams.viewportXywh[2]/currentProjectorParams.viewportXywh[3];
currentProjectorParams.viewportFovDiameter = currentProjectorParams.viewportXywh[3];
Q_ASSERT(movementMgr);
movementMgr->setViewportVerticalOffsetTarget(0.);
movementMgr->zoomTo(180., 0.5);
}
else
{
// reset to what is stored in config.ini
currentProjectorParams.widthStretch=conf->value("projection/width_stretch", 1.0).toDouble();
}
emit currentProjectionTypeChanged(type);
emit currentProjectionTypeKeyChanged(getCurrentProjectionTypeKey());
emit currentProjectionNameI18nChanged(getCurrentProjectionNameI18n());
}
}
StelCore::ProjectionType StelCore::getCurrentProjectionType() const
{
return currentProjectionType;
}
//! Set the current projection type to use
void StelCore::setCurrentProjectionTypeKey(QString key)
{
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOfEnumerator("ProjectionType"));
ProjectionType newType = static_cast<ProjectionType>(en.keyToValue(key.toLatin1().data()));
if (newType<0)
{
qWarning() << "Unknown projection type: " << key << "setting \"ProjectionStereographic\" instead";
newType = ProjectionStereographic;
}
setCurrentProjectionType(newType);
}
//! Get the current Mapping used by the Projection
QString StelCore::getCurrentProjectionTypeKey(void) const
{
return metaObject()->enumerator(metaObject()->indexOfEnumerator("ProjectionType")).key(currentProjectionType);
}
QString StelCore::getCurrentProjectionNameI18n() const
{
return projectionTypeKeyToNameI18n(getCurrentProjectionTypeKey());
}
//! Get the list of all the available projections
QStringList StelCore::getAllProjectionTypeKeys() const
{
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOfEnumerator("ProjectionType"));
QStringList l;
for (int i=0;i<en.keyCount();++i)
l << en.key(i);
return l;
}
void StelCore::setMaskType(StelProjector::StelProjectorMaskType m)
{
currentProjectorParams.maskType = m;
}
void StelCore::setFlagGravityLabels(bool gravity)
{
currentProjectorParams.gravityLabels = gravity;
emit flagGravityLabelsChanged(gravity);
}
bool StelCore::getFlagGravityLabels() const
{
return currentProjectorParams.gravityLabels;
}
void StelCore::setDefaultAngleForGravityText(float a)
{
currentProjectorParams.defaultAngleForGravityText = a;
}
void StelCore::setFlipHorz(bool flip)
{
if (currentProjectorParams.flipHorz != flip)
{
currentProjectorParams.flipHorz = flip;
emit flipHorzChanged(flip);
}
}
void StelCore::setFlipVert(bool flip)
{
if (currentProjectorParams.flipVert != flip)
{
currentProjectorParams.flipVert = flip;
emit flipVertChanged(flip);
}
}
bool StelCore::getFlipHorz(void) const
{
return currentProjectorParams.flipHorz;
}
bool StelCore::getFlipVert(void) const
{
return currentProjectorParams.flipVert;
}
// Get current value for horizontal viewport offset [-50...50]
double StelCore::getViewportHorizontalOffset(void) const
{
return (currentProjectorParams.viewportCenterOffset[0] * 100.0);
}
// Set horizontal viewport offset. Argument will be clamped to be inside [-50...50]
void StelCore::setViewportHorizontalOffset(double newOffsetPct)
{
currentProjectorParams.viewportCenterOffset[0]=0.01* qBound(-50., newOffsetPct, 50.);
currentProjectorParams.viewportCenter.set(currentProjectorParams.viewportXywh[0]+(0.5+currentProjectorParams.viewportCenterOffset.v[0])*currentProjectorParams.viewportXywh[2],
currentProjectorParams.viewportXywh[1]+(0.5+currentProjectorParams.viewportCenterOffset.v[1])*currentProjectorParams.viewportXywh[3]);
}
// Get current value for vertical viewport offset [-50...50]
double StelCore::getViewportVerticalOffset(void) const
{
return (currentProjectorParams.viewportCenterOffset[1] * 100.0);
}
// Set vertical viewport offset. Argument will be clamped to be inside [-50...50]
void StelCore::setViewportVerticalOffset(double newOffsetPct)
{
currentProjectorParams.viewportCenterOffset[1]=0.01* qBound(-50., newOffsetPct, 50.);
currentProjectorParams.viewportCenter.set(currentProjectorParams.viewportXywh[0]+(0.5+currentProjectorParams.viewportCenterOffset.v[0])*currentProjectorParams.viewportXywh[2],
currentProjectorParams.viewportXywh[1]+(0.5+currentProjectorParams.viewportCenterOffset.v[1])*currentProjectorParams.viewportXywh[3]);
}
// Set both viewport offsets. Arguments will be clamped to be inside [-50...50]. I (GZ) hope this will avoid some of the shaking.
void StelCore::setViewportOffset(double newHorizontalOffsetPct, double newVerticalOffsetPct)
{
currentProjectorParams.viewportCenterOffset[0]=0.01* qBound(-50., newHorizontalOffsetPct, 50.);
currentProjectorParams.viewportCenterOffset[1]=0.01* qBound(-50., newVerticalOffsetPct, 50.);
currentProjectorParams.viewportCenter.set(currentProjectorParams.viewportXywh[0]+(0.5+currentProjectorParams.viewportCenterOffset.v[0])*currentProjectorParams.viewportXywh[2],
currentProjectorParams.viewportXywh[1]+(0.5+currentProjectorParams.viewportCenterOffset.v[1])*currentProjectorParams.viewportXywh[3]);
}
void StelCore::setViewportStretch(float stretch)
{
currentProjectorParams.widthStretch=static_cast<qreal>(qMax(0.001f, stretch));
}
QString StelCore::getDefaultLocationID() const
{
return defaultLocationID;
}
QString StelCore::projectionTypeKeyToNameI18n(const QString& key) const
{
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOfEnumerator("ProjectionType"));
QString s(getProjection(StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(Mat4d::identity(),Mat4d::identity())), static_cast<ProjectionType>(en.keyToValue(key.toLatin1())))->getNameI18());
return s;
}
QString StelCore::projectionNameI18nToTypeKey(const QString& nameI18n) const
{
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOfEnumerator("ProjectionType"));
for (int i=0;i<en.keyCount();++i)
{
if (getProjection(StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(Mat4d::identity(),Mat4d::identity())), static_cast<ProjectionType>(i))->getNameI18()==nameI18n)
return en.valueToKey(i);
}
// Unknown translated name
Q_ASSERT(0);
return en.valueToKey(ProjectionStereographic);
}
StelProjector::StelProjectorParams StelCore::getCurrentStelProjectorParams() const
{
return currentProjectorParams;
}
void StelCore::setCurrentStelProjectorParams(const StelProjector::StelProjectorParams& newParams)
{
currentProjectorParams=newParams;
}
void StelCore::lookAtJ2000(const Vec3d& pos, const Vec3d& aup)
{
Vec3d f(j2000ToAltAz(pos, RefractionOff));
Vec3d up(j2000ToAltAz(aup, RefractionOff));
f.normalize();
up.normalize();
// Update the model view matrix
Vec3d s(f^up); // y vector
s.normalize();
Vec3d u(s^f); // Up vector in AltAz coordinates
u.normalize();
matAltAzModelView.set(s[0],u[0],-f[0],0.,
s[1],u[1],-f[1],0.,
s[2],u[2],-f[2],0.,
0.,0.,0.,1.);
invertMatAltAzModelView = matAltAzModelView.inverse();
}
void StelCore::setMatAltAzModelView(const Mat4d& mat)
{
matAltAzModelView = mat;
invertMatAltAzModelView = matAltAzModelView.inverse();
}
Vec3d StelCore::altAzToEquinoxEqu(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matAltAzToEquinoxEqu*v;
Vec3d r(v);
skyDrawer->getRefraction().backward(r);
r.transfo4d(matAltAzToEquinoxEqu);
return r;
}
Vec3d StelCore::equinoxEquToAltAz(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquToAltAz*v;
Vec3d r(v);
r.transfo4d(matEquinoxEquToAltAz);
skyDrawer->getRefraction().forward(r);
return r;
}
Vec3d StelCore::altAzToJ2000(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquDateToJ2000*matAltAzToEquinoxEqu*v;
Vec3d r(v);
skyDrawer->getRefraction().backward(r);
r.transfo4d(matEquinoxEquDateToJ2000*matAltAzToEquinoxEqu);
return r;
}
Vec3d StelCore::j2000ToAltAz(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matJ2000ToAltAz*v;
Vec3d r(v);
r.transfo4d(matJ2000ToAltAz);
skyDrawer->getRefraction().forward(r);
return r;
}
Vec3d StelCore::galacticToJ2000(const Vec3d& v) const
{
return matGalacticToJ2000*v;
}
Vec3d StelCore::supergalacticToJ2000(const Vec3d& v) const
{
return matSupergalacticToJ2000*v;
}
Vec3d StelCore::equinoxEquToJ2000(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matEquinoxEquDateToJ2000*v;
Vec3d r(v);
r.transfo4d(matEquinoxEquToAltAz);
skyDrawer->getRefraction().backward(r);
r.transfo4d(matAltAzToJ2000);
return r;
}
Vec3d StelCore::j2000ToEquinoxEqu(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matJ2000ToEquinoxEqu*v;
Vec3d r(v);
r.transfo4d(matJ2000ToAltAz);
skyDrawer->getRefraction().forward(r);
r.transfo4d(matAltAzToEquinoxEqu);
return r;
}
Vec3d StelCore::j2000ToJ1875(const Vec3d& v) const
{
return matJ2000ToJ1875*v;
}
Vec3d StelCore::j2000ToGalactic(const Vec3d& v) const
{
return matJ2000ToGalactic*v;
}
Vec3d StelCore::j2000ToSupergalactic(const Vec3d& v) const
{
return matJ2000ToSupergalactic*v;
}
//! Transform vector from heliocentric ecliptic coordinate to altazimuthal
Vec3d StelCore::heliocentricEclipticToAltAz(const Vec3d& v, RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return matHeliocentricEclipticJ2000ToAltAz*v;
Vec3d r(v);
r.transfo4d(matHeliocentricEclipticJ2000ToAltAz);
skyDrawer->getRefraction().forward(r);
return r;
}
//! Transform from heliocentric coordinate to equatorial at current equinox (for the planet where the observer stands)
Vec3d StelCore::heliocentricEclipticToEquinoxEqu(const Vec3d& v) const
{
return matHeliocentricEclipticToEquinoxEqu*v;
}
/*
//! Transform vector from heliocentric coordinate to false equatorial : equatorial
//! coordinate but centered on the observer position (useful for objects close to earth)
//! Unused as of V0.13
Vec3d StelCore::heliocentricEclipticToEarthPosEquinoxEqu(const Vec3d& v) const
{
return matAltAzToEquinoxEqu*matHeliocentricEclipticToAltAz*v;
}
*/
StelProjector::ModelViewTranformP StelCore::getHeliocentricEclipticModelViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,matHeliocentricEclipticJ2000ToAltAz));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPreTransfoMat(matHeliocentricEclipticJ2000ToAltAz);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric ecliptic J2000 (Vsop87A) drawing
StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticJ2000ModelViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,matJ2000ToAltAz*matVsop87ToJ2000));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPreTransfoMat(matJ2000ToAltAz*matVsop87ToJ2000);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric ecliptic-of-date drawing
StelProjector::ModelViewTranformP StelCore::getObservercentricEclipticOfDateModelViewTransform(RefractionMode refMode) const
{
double eps_A=getPrecessionAngleVondrakCurrentEpsilonA();
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,matEquinoxEquToAltAz* Mat4d::xrotation(eps_A)));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPreTransfoMat(matEquinoxEquToAltAz* Mat4d::xrotation(eps_A));
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric equatorial at equinox drawing
StelProjector::ModelViewTranformP StelCore::getEquinoxEquModelViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,matEquinoxEquToAltAz));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPreTransfoMat(matEquinoxEquToAltAz);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric fixed equatorial drawing
StelProjector::ModelViewTranformP StelCore::getFixedEquatorialModelViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,matFixedEquatorialToAltAz));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPreTransfoMat(matFixedEquatorialToAltAz);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric altazimuthal drawing
StelProjector::ModelViewTranformP StelCore::getAltAzModelViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
{
// Catch problem with improperly initialized matAltAzModelView
Q_ASSERT(matAltAzModelView[0]==matAltAzModelView[0]);
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,Mat4d::identity()));
}
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric J2000 equatorial drawing
StelProjector::ModelViewTranformP StelCore::getJ2000ModelViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,matEquinoxEquToAltAz*matJ2000ToEquinoxEqu));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPreTransfoMat(matEquinoxEquToAltAz*matJ2000ToEquinoxEqu);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric Galactic equatorial drawing
StelProjector::ModelViewTranformP StelCore::getGalacticModelViewTransform(RefractionMode refMode) const
{
if (refMode==RefractionOff || skyDrawer==Q_NULLPTR || (refMode==RefractionAuto && skyDrawer->getFlagHasAtmosphere()==false))
return StelProjector::ModelViewTranformP(new StelProjector::Mat4dTransform(matAltAzModelView,matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*matGalacticToJ2000));
Refraction* refr = new Refraction(skyDrawer->getRefraction());
// The pretransform matrix will convert from input coordinates to AltAz needed by the refraction function.
refr->setPreTransfoMat(matEquinoxEquToAltAz*matJ2000ToEquinoxEqu*matGalacticToJ2000);
refr->setPostTransfoMat(matAltAzModelView);
return StelProjector::ModelViewTranformP(refr);
}
//! Get the modelview matrix for observer-centric Supergalactic equatorial drawing