Kstars

detailstable.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Rafał Kułaga <rl.kulaga@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "detailstable.h"
8
9#include <QTextDocument>
10#include <QTextTable>
11
12#include "kstars.h"
13#include "kstarsdata.h"
14#include "ksplanetbase.h"
15#include "starobject.h"
16#include "skymapcomposite.h"
17#include "constellationboundarylines.h"
18#include "catalogobject.h"
19#include "ksmoon.h"
20#include "ksasteroid.h"
21#include "kscomet.h"
22#include "Options.h"
23#include "catalogsdb.h"
24
26{
27 m_Document = new QTextDocument(KStars::Instance());
28
29 setDefaultFormatting();
30}
31
33{
34 if (m_Document)
35 {
36 delete m_Document;
37 }
38}
39
41{
43
44 QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();
45
46 //Fill in the data fields
47 //Contents depend on type of object
48 StarObject *s = nullptr;
49 CatalogObject *dso = nullptr;
50 KSPlanetBase *ps = nullptr;
51 QString pname, oname;
52
53 QString objNamesVal, objTypeVal, objDistVal, objSizeVal, objMagVal, objBvVal, objIllumVal;
54 QString objSizeLabel, objMagLabel;
55
56 switch (obj->type())
57 {
58 case SkyObject::STAR:
59 {
60 s = (StarObject *)obj;
61
62 objNamesVal = s->longname();
63
64 if (s->getHDIndex() != 0)
65 {
66 if (!s->longname().isEmpty())
67 {
68 objNamesVal = s->longname() + QString(", HD%1").arg(QString::number(s->getHDIndex()));
69 }
70
71 else
72 {
73 objNamesVal = QString(", HD%1").arg(QString::number(s->getHDIndex()));
74 }
75 }
76
77 objTypeVal = s->sptype() + ' ' + i18n("star");
78 objMagVal = i18nc("number in magnitudes", "%1 mag", QLocale().toString(s->mag(), 1)); //show to tenths place
79
80 if (s->getBVIndex() < 30.0)
81 {
82 objBvVal = QString::number(s->getBVIndex(), 'g', 2);
83 }
84
85 //distance
86 if (s->distance() > 2000. || s->distance() < 0.) // parallax < 0.5 mas
87 {
88 objDistVal = i18nc("larger than 2000 parsecs", "> 2000 pc");
89 }
90
91 else if (s->distance() > 50.0) //show to nearest integer
92 {
93 objDistVal = i18nc("number in parsecs", "%1 pc", QLocale().toString(s->distance(), 0));
94 }
95
96 else if (s->distance() > 10.0) //show to tenths place
97 {
98 objDistVal = i18nc("number in parsecs", "%1 pc", QLocale().toString(s->distance(), 1));
99 }
100
101 else //show to hundredths place
102 {
103 objDistVal = i18nc("number in parsecs", "%1 pc", QLocale().toString(s->distance(), 2));
104 }
105
106 //Note multiplicity/variability in angular size label
107 if (s->isMultiple() && s->isVariable())
108 {
109 objSizeLabel = i18nc("the star is a multiple star", "multiple") + ',';
110 objSizeVal = i18nc("the star is a variable star", "variable");
111 }
112
113 else if (s->isMultiple())
114 {
115 objSizeLabel = i18nc("the star is a multiple star", "multiple");
116 }
117
118 else if (s->isVariable())
119 {
120 objSizeLabel = i18nc("the star is a variable star", "variable");
121 }
122
123 objIllumVal = "--";
124
125 break; //End of stars case
126 }
127
128 case SkyObject::ASTEROID: //[fall through to planets]
129
130 case SkyObject::COMET: //[fall through to planets]
131
132 case SkyObject::MOON: //[fall through to planets]
133
134 case SkyObject::PLANET:
135 {
136 ps = dynamic_cast<KSPlanetBase *>(obj);
137
138 objNamesVal = ps->longname();
139 //Type is "G5 star" for Sun
140 if (ps->name() == i18n("Sun"))
141 {
142 objTypeVal = i18n("G5 star");
143 }
144
145 else if (ps->name() == i18n("Moon"))
146 {
147 objTypeVal = ps->translatedName();
148 }
149
150 else if (ps->name() == i18nc("Asteroid name (optional)", "Pluto") || ps->name() == i18nc("Asteroid name (optional)", "Ceres") ||
151 ps->name() == i18nc("Asteroid name (optional)", "Eris")) // TODO: Check if Ceres / Eris have translations and i18n() them
152 {
153 objTypeVal = i18n("Dwarf planet");
154 }
155
156 else
157 {
158 objTypeVal = ps->typeName();
159 }
160
161 //Magnitude: The moon displays illumination fraction instead
162 if (obj->name() == i18n("Moon"))
163 {
164 KSMoon * const m = dynamic_cast<KSMoon *>(obj);
165 if (m)
166 objIllumVal = QString("%1 %").arg(QLocale().toString(m->illum() * 100., 0));
167 }
168
169 objMagVal =
170 i18nc("number in magnitudes", "%1 mag", QLocale().toString(ps->mag(), 1)); //show to tenths place
171
172 //Distance from Earth. The moon requires a unit conversion
173 if (ps->name() == i18n("Moon"))
174 {
175 objDistVal = i18nc("distance in kilometers", "%1 km", QLocale().toString(ps->rearth() * AU_KM));
176 }
177
178 else
179 {
180 objDistVal = i18nc("distance in Astronomical Units", "%1 AU", QLocale().toString(ps->rearth()));
181 }
182
183 //Angular size; moon and sun in arcmin, others in arcsec
184 if (ps->angSize())
185 {
186 if (ps->name() == i18n("Sun") || ps->name() == i18n("Moon"))
187 {
188 // Needn't be a plural form because sun / moon will never contract to 1 arcminute
189 objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", QLocale().toString(ps->angSize()));
190 }
191
192 else
193 {
194 objSizeVal =
195 i18nc("angular size in arcseconds", "%1 arcsec", QLocale().toString(ps->angSize() * 60.0));
196 }
197 }
198
199 else
200 {
201 objSizeVal = "--";
202 }
203
204 break; //End of planets/comets/asteroids case
205 }
206
207 default: //Deep-sky objects
208 {
209 dso = (CatalogObject *)obj;
210
211 //Show all names recorded for the object
212 if (!dso->longname().isEmpty() && dso->longname() != dso->name())
213 {
214 pname = dso->translatedLongName();
215 class="code hl_function" href="classSkyObject.html#a2393437cef66dfd67806b7fc0252f0b8">translatedName();
216 }
217
218 else
219 {
220 pname = dso->translatedName();
221 }
222
223 if (!dso->translatedName2().isEmpty())
224 {
225 if (oname.isEmpty())
226 {
227 class="code hl_function" href="classSkyObject.html#a4f90af506861fd3c27ce655661f27055">translatedName2();
228 }
229
230 else
231 {
232 oname += ", " + dso->translatedName2();
233 }
234 }
235
236
237 if (!oname.isEmpty())
238 {
239 pname += ", " + oname;
240 }
241
242 objNamesVal = pname;
243
244 objTypeVal = dso->typeName();
245
246 if (dso->type() == SkyObject::RADIO_SOURCE)
247 {
248 objMagLabel =
249 i18nc("integrated flux at a frequency", "Flux(%1):", CatalogsDB::flux_frequency);
250 objMagVal = i18nc("integrated flux value", "%1 %2", QLocale().toString(dso->flux(), 1),
251 CatalogsDB::flux_unit); //show to tenths place
252 }
253
254 if (dso->mag() > 90.0)
255 {
256 objMagVal = "--";
257 }
258
259 else
260 {
261 objMagVal =
262 i18nc("number in magnitudes", "%1 mag", QLocale().toString(dso->mag(), 1)); //show to tenths place
263 }
264
265 //No distances at this point...
266 objDistVal = "--";
267
268 //Only show decimal place for small angular sizes
269 if (dso->a() > 10.0)
270 {
271 objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", QLocale().toString(dso->a(), 0));
272 }
273
274 else if (dso->a())
275 {
276 objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", QLocale().toString(dso->a(), 1));
277 }
278
279 else
280 {
281 objSizeVal = "--";
282 }
283
284 break; //End of deep-space objects case
285 }
286 }
287
288 //Common to all types:
289 if (obj->type() == SkyObject::CONSTELLATION)
290 {
291 objTypeVal = KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName(obj);
292 }
293
294 else
295 {
296 objTypeVal =
297 i18nc("%1 type of sky object (planet, asteroid etc), %2 name of a constellation", "%1 in %2", objTypeVal,
298 KStarsData::Instance()->skyComposite()->constellationBoundary()->constellationName(obj));
299 }
300
301 QVector<QTextLength> constraints;
304 m_TableFormat.setColumnWidthConstraints(constraints);
305
306 QTextTable *table = cursor.insertTable(5, 4, m_TableFormat);
307 table->mergeCells(0, 0, 1, 4);
308 QTextBlockFormat centered;
310 table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
311 table->cellAt(0, 0).firstCursorPosition().insertText(i18n("General"), m_TableTitleCharFormat);
312
313 table->mergeCells(1, 1, 1, 3);
314 table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Names:"), m_ItemNameCharFormat);
315 table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
316 table->cellAt(1, 1).firstCursorPosition().insertText(objNamesVal, m_ItemValueCharFormat);
317
318 table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Type:"), m_ItemNameCharFormat);
319 table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
320 table->cellAt(2, 1).firstCursorPosition().insertText(objTypeVal, m_ItemValueCharFormat);
321
322 table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Distance:"), m_ItemNameCharFormat);
323 table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
324 table->cellAt(3, 1).firstCursorPosition().insertText(objDistVal, m_ItemValueCharFormat);
325
326 table->cellAt(4, 0).firstCursorPosition().insertText(i18n("Size:"), m_ItemNameCharFormat);
327 table->cellAt(4, 0).firstCursorPosition().setBlockFormat(centered);
328 table->cellAt(4, 1).firstCursorPosition().insertText(objSizeVal, m_ItemValueCharFormat);
329
330 table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Magnitude:"), m_ItemNameCharFormat);
331 table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
332 table->cellAt(2, 3).firstCursorPosition().insertText(objMagVal, m_ItemValueCharFormat);
333
334 table->cellAt(3, 2).firstCursorPosition().insertText(i18n("B-V index:"), m_ItemNameCharFormat);
335 table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
336 table->cellAt(3, 3).firstCursorPosition().insertText(objBvVal, m_ItemValueCharFormat);
337
338 table->cellAt(4, 2).firstCursorPosition().insertText(i18n("Illumination:"), m_ItemNameCharFormat);
339 table->cellAt(4, 2).firstCursorPosition().setBlockFormat(centered);
340 table->cellAt(4, 3).firstCursorPosition().insertText(objIllumVal, m_ItemValueCharFormat);
341}
342
344{
346
347 QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();
348
349 QString perihelionVal, orbitIdVal, neoVal, diamVal, rotPeriodVal, moidVal;
350 QString orbitClassVal, albedoVal, dimVal, periodVal;
351
352 // Add specifics data
353 switch (obj->type())
354 {
355 case SkyObject::ASTEROID:
356 {
357 KSAsteroid *ast = (KSAsteroid *)obj;
358
359 // Perihelion
360 perihelionVal = QString::number(ast->getPerihelion()) + " AU";
361
362 // Earth MOID
363 moidVal = ast->getEarthMOID() == 0 ? QString("--") : QString::number(ast->getEarthMOID()) + QString(" AU");
364
365 // Orbit ID
366 orbitIdVal = ast->getOrbitID();
367
368 // Orbit Class
369 orbitClassVal = ast->getOrbitClass();
370
371 // NEO
372 neoVal = ast->isNEO() ? i18n("Yes") : i18n("No");
373
374 // Albedo
375 albedoVal = ast->getAlbedo() == 0 ? QString("--") : QString::number(ast->getAlbedo());
376
377 // Diameter
378 diamVal = ast->getDiameter() == 0 ? QString("--") : QString::number(ast->getDiameter()) + QString(" km");
379
380 // Dimensions
381 dimVal = ast->getDimensions().isEmpty() ? QString("--") : ast->getDimensions() + QString(" km");
382
383 // Rotation period
384 rotPeriodVal = ast->getRotationPeriod() == 0 ? QString("--") :
386
387 // Period
388 periodVal = ast->getPeriod() == 0 ? QString("--") : QString::number(ast->getPeriod()) + QString(" y");
389
390 break;
391 }
392
393 case SkyObject::COMET:
394 {
395 KSComet *com = (KSComet *)obj;
396
397 // Perihelion
398 perihelionVal = QString::number(com->getPerihelion()) + " AU";
399
400 // Earth MOID
401 moidVal = com->getEarthMOID() == 0 ? QString("--") : QString::number(com->getEarthMOID()) + QString(" AU");
402
403 // Orbit ID
404 orbitIdVal = com->getOrbitID();
405
406 // Orbit Class
407 orbitClassVal = com->getOrbitClass();
408
409 // NEO
410 neoVal = com->isNEO() ? i18n("Yes") : i18n("No");
411
412 // Albedo
413 albedoVal = com->getAlbedo() == 0 ? QString("--") : QString::number(com->getAlbedo());
414
415 // Diameter
416 diamVal = com->getDiameter() == 0 ? QString("--") : QString::number(com->getDiameter()) + QString(" km");
417
418 // Dimensions
419 dimVal = com->getDimensions().isEmpty() ? QString("--") : com->getDimensions() + QString(" km");
420
421 // Rotation period
422 rotPeriodVal = com->getRotationPeriod() == 0 ? QString("--") :
424
425 // Period
426 periodVal = com->getPeriod() == 0 ? QString("--") : QString::number(com->getPeriod()) + QString(" y");
427
428 break;
429 }
430
431 default:
432 {
433 return;
434 }
435 }
436
437 // Set column width constraints
438 QVector<QTextLength> constraints;
441 m_TableFormat.setColumnWidthConstraints(constraints);
442
443 QTextTable *table = cursor.insertTable(6, 4, m_TableFormat);
444 table->mergeCells(0, 0, 1, 4);
445 QTextBlockFormat centered;
447 table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
448 table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Asteroid/Comet details"), m_TableTitleCharFormat);
449
450 table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Perihelion:"), m_ItemNameCharFormat);
451 table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
452 table->cellAt(1, 1).firstCursorPosition().insertText(perihelionVal, m_ItemValueCharFormat);
453
454 table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Orbit ID:"), m_ItemNameCharFormat);
455 table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
456 table->cellAt(2, 1).firstCursorPosition().insertText(orbitIdVal, m_ItemValueCharFormat);
457
458 table->cellAt(3, 0).firstCursorPosition().insertText(i18n("NEO:"), m_ItemNameCharFormat);
459 table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
460 table->cellAt(3, 1).firstCursorPosition().insertText(neoVal, m_ItemValueCharFormat);
461
462 table->cellAt(4, 0).firstCursorPosition().insertText(i18n("Diameter:"), m_ItemNameCharFormat);
463 table->cellAt(4, 0).firstCursorPosition().setBlockFormat(centered);
464 table->cellAt(4, 1).firstCursorPosition().insertText(diamVal, m_ItemValueCharFormat);
465
466 table->cellAt(5, 0).firstCursorPosition().insertText(i18n("Rotation period:"), m_ItemNameCharFormat);
467 table->cellAt(5, 0).firstCursorPosition().setBlockFormat(centered);
468 table->cellAt(5, 1).firstCursorPosition().insertText(rotPeriodVal, m_ItemValueCharFormat);
469
470 table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Earth MOID:"), m_ItemNameCharFormat);
471 table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
472 table->cellAt(1, 3).firstCursorPosition().insertText(moidVal, m_ItemValueCharFormat);
473
474 table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Orbit class:"), m_ItemNameCharFormat);
475 table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
476 table->cellAt(2, 3).firstCursorPosition().insertText(orbitClassVal, m_ItemValueCharFormat);
477
478 table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Albedo:"), m_ItemNameCharFormat);
479 table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
480 table->cellAt(3, 3).firstCursorPosition().insertText(albedoVal, m_ItemValueCharFormat);
481
482 table->cellAt(4, 2).firstCursorPosition().insertText(i18n("Dimensions:"), m_ItemNameCharFormat);
483 table->cellAt(4, 2).firstCursorPosition().setBlockFormat(centered);
484 table->cellAt(4, 3).firstCursorPosition().insertText(dimVal, m_ItemValueCharFormat);
485
486 table->cellAt(5, 2).firstCursorPosition().insertText(i18n("Period:"), m_ItemNameCharFormat);
487 table->cellAt(5, 2).firstCursorPosition().setBlockFormat(centered);
488 table->cellAt(5, 3).firstCursorPosition().insertText(periodVal, m_ItemValueCharFormat);
489}
490
491void DetailsTable::createCoordinatesTable(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
492{
494
495 QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();
496
497 // Set column width constraints
498 QVector<QTextLength> constraints;
501 m_TableFormat.setColumnWidthConstraints(constraints);
502
503 // Insert table & row containing table name
504 QTextTable *table = cursor.insertTable(4, 4, m_TableFormat);
505 table->mergeCells(0, 0, 1, 4);
506 QTextBlockFormat centered;
508 table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
509 table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Coordinates"), m_TableTitleCharFormat);
510
511 //Coordinates Section:
512 //Don't use KLocale::formatNumber() for the epoch string,
513 //because we don't want a thousands-place separator!
514 QString sEpoch = QString::number(ut.epoch(), 'f', 1);
515 //Replace the decimal point with localized decimal symbol
516 sEpoch.replace('.', QLocale().decimalPoint());
517
518 table->cellAt(1, 0).firstCursorPosition().insertText(i18n("RA (%1):", sEpoch), m_ItemNameCharFormat);
519 table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
520 table->cellAt(1, 1).firstCursorPosition().insertText(obj->ra().toHMSString(), m_ItemValueCharFormat);
521
522 table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Dec (%1):", sEpoch), m_ItemNameCharFormat);
523 table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
524 table->cellAt(2, 1).firstCursorPosition().insertText(obj->dec().toDMSString(), m_ItemValueCharFormat);
525
526 table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Hour angle:"), m_ItemNameCharFormat);
527 table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
528 //Hour Angle can be negative, but dms HMS expressions cannot.
529 //Here's a kludgy workaround:
530 dms lst = geo->GSTtoLST(ut.gst());
531 dms ha(lst.Degrees() - obj->ra().Degrees());
532 QChar sgn('+');
533 if (ha.Hours() > 12.0)
534 {
535 ha.setH(24.0 - ha.Hours());
536 sgn = '-';
537 }
538 table->cellAt(3, 1).firstCursorPosition().insertText(QString("%1%2").arg(sgn).arg(ha.toHMSString()),
539 m_ItemValueCharFormat);
540
541 table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth:"), m_ItemNameCharFormat);
542 table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
543 table->cellAt(1, 3).firstCursorPosition().insertText(obj->az().toDMSString(), m_ItemValueCharFormat);
544
545 table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude:"), m_ItemNameCharFormat);
546 table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
547 dms a;
548 if (Options::useAltAz())
549 {
550 a = obj->alt();
551 }
552
553 else
554 {
555 a = obj->altRefracted();
556 }
557 table->cellAt(2, 3).firstCursorPosition().insertText(a.toDMSString(), m_ItemValueCharFormat);
558
559 table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Airmass:"), m_ItemNameCharFormat);
560 table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
561 //Airmass is approximated as the secant of the zenith distance,
562 //equivalent to 1./sin(Alt). Beware of Inf at Alt=0!
563 QString aMassStr;
564 if (obj->alt().Degrees() > 0.0)
565 {
566 aMassStr = QLocale().toString(1. / sin(obj->alt().radians()), 2);
567 }
568
569 else
570 {
571 aMassStr = "--";
572 }
573 table->cellAt(3, 3).firstCursorPosition().insertText(aMassStr, m_ItemValueCharFormat);
574
575 // Restore the position and other time-dependent parameters
576 obj->recomputeCoords(ut, geo);
577}
578
579void DetailsTable::createRSTTAble(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
580{
582
583 QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();
584
585 QString rtValue, stValue; // Rise/Set time values
586 QString azRValue, azSValue; // Rise/Set azimuth values
587
588 //Prepare time/position variables
589 QTime rt = obj->riseSetTime(ut, geo, true); //true = use rise time
590 dms raz = obj->riseSetTimeAz(ut, geo, true); //true = use rise time
591
592 //If transit time is before rise time, use transit time for tomorrow
593 QTime tt = obj->transitTime(ut, geo);
594 dms talt = obj->transitAltitude(ut, geo);
595 if (tt < rt)
596 {
597 tt = obj->transitTime(ut.addDays(1), geo);
598 talt = obj->transitAltitude(ut.addDays(1), geo);
599 }
600
601 //If set time is before rise time, use set time for tomorrow
602 QTime st = obj->riseSetTime(ut, geo, false); //false = use set time
603 dms saz = obj->riseSetTimeAz(ut, geo, false); //false = use set time
604 if (st < rt)
605 {
606 st = obj->riseSetTime(ut.addDays(1), geo, false); //false = use set time
607 saz = obj->riseSetTimeAz(ut.addDays(1), geo, false); //false = use set time
608 }
609
610 if (rt.isValid())
611 {
612 rtValue = QString::asprintf("%02d:%02d", rt.hour(), rt.minute());
613 stValue = QString::asprintf("%02d:%02d", st.hour(), st.minute());
614 azRValue = raz.toDMSString();
615 azSValue = saz.toDMSString();
616 }
617
618 else
619 {
620 if (obj->alt().Degrees() > 0.0)
621 {
622 rtValue = i18n("Circumpolar");
623 stValue = i18n("Circumpolar");
624 }
625
626 else
627 {
628 rtValue = i18n("Never rises");
629 stValue = i18n("Never rises");
630 }
631
632 azRValue = i18nc("Not Applicable", "N/A");
633 azSValue = i18nc("Not Applicable", "N/A");
634 }
635
636 // Set column width constraints
637 QVector<QTextLength> constraints;
640 m_TableFormat.setColumnWidthConstraints(constraints);
641
642 // Insert table & row containing table name
643 QTextTable *table = cursor.insertTable(4, 4, m_TableFormat);
644 table->mergeCells(0, 0, 1, 4);
645 QTextBlockFormat centered;
647 table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
648 table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Rise/Set/Transit"), m_TableTitleCharFormat);
649
650 // Insert cell names & values
651 table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Rise time:"), m_ItemNameCharFormat);
652 table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
653 table->cellAt(1, 1).firstCursorPosition().insertText(rtValue, m_ItemValueCharFormat);
654
655 table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Transit time:"), m_ItemNameCharFormat);
656 table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
657 table->cellAt(2, 1).firstCursorPosition().insertText(QString::asprintf("%02d:%02d", tt.hour(), tt.minute()),
658 m_ItemValueCharFormat);
659
660 table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Set time:"), m_ItemNameCharFormat);
661 table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
662 table->cellAt(3, 1).firstCursorPosition().insertText(stValue, m_ItemValueCharFormat);
663
664 table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth at rise:"), m_ItemNameCharFormat);
665 table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
666 table->cellAt(1, 3).firstCursorPosition().insertText(azRValue, m_ItemValueCharFormat);
667
668 table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude at transit:"), m_ItemNameCharFormat);
669 table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
670 table->cellAt(2, 3).firstCursorPosition().insertText(talt.toDMSString(), m_ItemValueCharFormat);
671
672 table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Azimuth at set:"), m_ItemNameCharFormat);
673 table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
674 table->cellAt(3, 3).firstCursorPosition().insertText(azSValue, m_ItemValueCharFormat);
675
676 // Restore the position and other time-dependent parameters
677 obj->recomputeCoords(ut, geo);
678}
679
681{
682 m_Document->clear();
683}
684
685void DetailsTable::setDefaultFormatting()
686{
687 // Set default table format
688 m_TableFormat.setAlignment(Qt::AlignCenter);
689 m_TableFormat.setBorder(4);
690 m_TableFormat.setCellPadding(2);
691 m_TableFormat.setCellSpacing(2);
692
693 // Set default table title character format
694 m_TableTitleCharFormat.setFont(QFont("Times", 12, QFont::Bold));
695 m_TableTitleCharFormat.setFontCapitalization(QFont::Capitalize);
696
697 // Set default table item name character format
698 m_ItemNameCharFormat.setFont(QFont("Times", 10, QFont::Bold));
699
700 // Set default table item value character format
701 m_ItemValueCharFormat.setFont(QFont("Times", 10));
702}
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
float flux() const
float a() const
void createRSTTAble(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
Create Rise/Set/Transit details table.
DetailsTable()
Default constructor - creates empty details table.
void createAsteroidCometTable(SkyObject *obj)
Create Asteroid/Comet details table.
void createGeneralTable(SkyObject *obj)
Create general details table.
void createCoordinatesTable(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
Create coordinates details table.
~DetailsTable()
Destructor.
void clearContents()
Clear current table.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
A subclass of KSPlanetBase that implements asteroids.
Definition ksasteroid.h:42
QString getOrbitClass() const
Definition ksasteroid.h:118
bool isNEO() const
Definition ksasteroid.h:128
QString getOrbitID() const
Definition ksasteroid.h:108
double getEarthMOID() const
Definition ksasteroid.h:98
float getRotationPeriod() const
Definition ksasteroid.h:168
double getPerihelion() const
Definition ksasteroid.h:88
float getDiameter() const
Definition ksasteroid.h:148
QString getDimensions() const
Definition ksasteroid.h:158
float getPeriod() const
Definition ksasteroid.h:178
float getAlbedo() const
Definition ksasteroid.h:138
A subclass of KSPlanetBase that implements comets.
Definition kscomet.h:44
double getEarthMOID()
Definition kscomet.h:118
float getAlbedo()
Definition kscomet.h:142
float getRotationPeriod()
Definition kscomet.h:160
bool isNEO()
Definition kscomet.h:136
double getPerihelion()
Returns Perihelion distance.
Definition kscomet.h:85
QString getOrbitClass()
Definition kscomet.h:130
QString getDimensions()
Definition kscomet.h:154
float getDiameter()
Definition kscomet.h:148
float getPeriod()
Definition kscomet.h:166
QString getOrbitID()
Definition kscomet.h:124
Provides necessary information about the Moon.
Definition ksmoon.h:26
double illum() const
Definition ksmoon.h:49
A subclass of TrailObject that provides additional information needed for most solar system objects.
double angSize() const
double rearth() const
SkyMapComposite * skyComposite()
Definition kstarsdata.h:168
static KStars * Instance()
Definition kstars.h:121
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
QString translatedName() const
Definition skyobject.h:149
dms riseSetTimeAz(const KStarsDateTime &dt, const GeoLocation *geo, bool rst) const
virtual QString name(void) const
Definition skyobject.h:146
dms transitAltitude(const KStarsDateTime &dt, const GeoLocation *geo) const
QString translatedName2() const
Definition skyobject.h:160
QString translatedLongName() const
Definition skyobject.h:170
virtual QString longname(void) const
Definition skyobject.h:165
QTime transitTime(const KStarsDateTime &dt, const GeoLocation *geo) const
The same iteration technique described in riseSetTime() is used here.
QTime riseSetTime(const KStarsDateTime &dt, const GeoLocation *geo, bool rst, bool exact=true) const
Determine the time at which the point will rise or set.
Definition skyobject.cpp:93
static QString typeName(const int t)
int type(void) const
Definition skyobject.h:189
float mag() const
Definition skyobject.h:207
SkyPoint recomputeCoords(const KStarsDateTime &dt, const GeoLocation *geo=nullptr) const
The equatorial coordinates for the object on date dt are computed and returned, but the object's inte...
const CachingDms & dec() const
Definition skypoint.h:269
const CachingDms & ra() const
Definition skypoint.h:263
dms altRefracted() const
const dms & az() const
Definition skypoint.h:275
const dms & alt() const
Definition skypoint.h:281
This is a subclass of SkyObject.
Definition starobject.h:33
QString longname(void) const override
If star is unnamed return "star" otherwise return the longname.
Definition starobject.h:133
double distance() const
Definition starobject.h:242
float getBVIndex() const
Definition starobject.h:287
int getHDIndex() const
Definition starobject.h:254
bool isMultiple() const
Definition starobject.h:251
bool isVariable() const
Definition starobject.h:264
QString sptype(void) const
Returns entire spectral type string.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString toString(QDate date, FormatType format) const const
QString arg(Args &&... args) const const
QString asprintf(const char *cformat,...)
bool isEmpty() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
AlignCenter
void setAlignment(Qt::Alignment alignment)
void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior)
void setFontCapitalization(QFont::Capitalization capitalization)
QTextTable * insertTable(int rows, int columns)
void insertText(const QString &text)
void setBlockFormat(const QTextBlockFormat &format)
virtual void clear()
QTextFrame * rootFrame() const const
QTextCursor firstCursorPosition() const const
void setBorder(qreal width)
QTextTableCell cellAt(const QTextCursor &cursor) const const
void mergeCells(const QTextCursor &cursor)
QTextCursor firstCursorPosition() const const
void setAlignment(Qt::Alignment alignment)
void setCellPadding(qreal padding)
void setCellSpacing(qreal spacing)
void setColumnWidthConstraints(const QList< QTextLength > &constraints)
int hour() const const
bool isValid(int h, int m, int s, int ms)
int minute() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:47:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.