Kstars

skymapevents.cpp
1 /*
2  SPDX-FileCopyrightText: 2001 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 //This file contains Event handlers for the SkyMap class.
8 
9 #include "skymap.h"
10 
11 #include "ksplanetbase.h"
12 #include "kspopupmenu.h"
13 #include "kstars.h"
14 #include "observinglist.h"
15 #include "Options.h"
16 #include "skyglpainter.h"
17 #include "skyqpainter.h"
18 #include "printing/simplefovexporter.h"
19 #include "skycomponents/skylabeler.h"
20 #include "skycomponents/skymapcomposite.h"
21 #include "skycomponents/starcomponent.h"
22 #include "skycomponents/mosaiccomponent.h"
23 #ifdef HAVE_INDI
24 #include "skyobjects/mosaictiles.h"
25 #endif
26 #include "widgets/infoboxwidget.h"
27 
28 #include <QGestureEvent>
29 #include <QStatusBar>
30 #include <QToolTip>
31 
33 {
34  computeSkymap = true; // skymap must be new computed
35 
36  //FIXME: No equivalent for this line in Qt4 ??
37  // if ( testWState( Qt::WState_AutoMask ) ) updateMask();
38 
39  // Resize the widget that draws the sky map.
40  // FIXME: The resize event doesn't pass to children. Any better way of doing this?
41  m_SkyMapDraw->resize(size());
42 
43  // Resize infoboxes container.
44  // FIXME: this is not really pretty. Maybe there are some better way to this???
45  m_iboxes->resize(size());
46 }
47 
49 {
50  bool arrowKeyPressed(false);
51  bool shiftPressed(false);
52  float step = 1.0;
53  if (e->modifiers() & Qt::ShiftModifier)
54  {
55  step = 10.0;
56  shiftPressed = true;
57  }
58 
59  //If the DBus resume key is not empty, then DBus processing is
60  //paused while we wait for a keypress
61  if (!data->resumeKey.isEmpty() && QKeySequence(e->key()) == data->resumeKey)
62  {
63  //The resumeKey was pressed. Signal that it was pressed by
64  //resetting it to empty; this will break the loop in
65  //KStars::waitForKey()
66  data->resumeKey = QKeySequence();
67  return;
68  }
69 
70  if (m_previewLegend)
71  {
72  slotCancelLegendPreviewMode();
73  }
74 
75  switch (e->key())
76  {
77  case Qt::Key_Left:
78  if (Options::useAltAz())
79  {
80  focus()->setAz(dms(focus()->az().Degrees() - step * MINZOOM / Options::zoomFactor()).reduce());
81  focus()->HorizontalToEquatorial(data->lst(), data->geo()->lat());
82  }
83  else
84  {
85  focus()->setRA(focus()->ra().Hours() + 0.05 * step * MINZOOM / Options::zoomFactor());
86  focus()->EquatorialToHorizontal(data->lst(), data->geo()->lat());
87  }
88 
89  arrowKeyPressed = true;
90  slewing = true;
91  break;
92 
93  case Qt::Key_Right:
94  if (Options::useAltAz())
95  {
96  focus()->setAz(dms(focus()->az().Degrees() + step * MINZOOM / Options::zoomFactor()).reduce());
97  focus()->HorizontalToEquatorial(data->lst(), data->geo()->lat());
98  }
99  else
100  {
101  focus()->setRA(focus()->ra().Hours() - 0.05 * step * MINZOOM / Options::zoomFactor());
102  focus()->EquatorialToHorizontal(data->lst(), data->geo()->lat());
103  }
104 
105  arrowKeyPressed = true;
106  slewing = true;
107  break;
108 
109  case Qt::Key_Up:
110  if (Options::useAltAz())
111  {
112  focus()->setAltRefracted(focus()->altRefracted().Degrees() + step * MINZOOM / Options::zoomFactor());
113  if (focus()->alt().Degrees() > 90.0)
114  focus()->setAlt(90.0);
115  focus()->HorizontalToEquatorial(data->lst(), data->geo()->lat());
116  }
117  else
118  {
119  focus()->setDec(focus()->dec().Degrees() + step * MINZOOM / Options::zoomFactor());
120  if (focus()->dec().Degrees() > 90.0)
121  focus()->setDec(90.0);
122  focus()->EquatorialToHorizontal(data->lst(), data->geo()->lat());
123  }
124 
125  arrowKeyPressed = true;
126  slewing = true;
127  break;
128 
129  case Qt::Key_Down:
130  if (Options::useAltAz())
131  {
132  focus()->setAltRefracted(focus()->altRefracted().Degrees() - step * MINZOOM / Options::zoomFactor());
133  if (focus()->alt().Degrees() < -90.0)
134  focus()->setAlt(-90.0);
135  focus()->HorizontalToEquatorial(data->lst(), data->geo()->lat());
136  }
137  else
138  {
139  focus()->setDec(focus()->dec().Degrees() - step * MINZOOM / Options::zoomFactor());
140  if (focus()->dec().Degrees() < -90.0)
141  focus()->setDec(-90.0);
142  focus()->EquatorialToHorizontal(data->lst(), data->geo()->lat());
143  }
144 
145  arrowKeyPressed = true;
146  slewing = true;
147  break;
148 
149  case Qt::Key_Plus: //Zoom in
150  case Qt::Key_Equal:
151  zoomInOrMagStep(e->modifiers());
152  break;
153 
154  case Qt::Key_Minus: //Zoom out
155  case Qt::Key_Underscore:
156  zoomOutOrMagStep(e->modifiers());
157  break;
158 
159  case Qt::Key_0: //center on Sun
160  setClickedObject(data->skyComposite()->planet(KSPlanetBase::SUN));
162  slotCenter();
163  break;
164 
165  case Qt::Key_1: //center on Mercury
166  setClickedObject(data->skyComposite()->planet(KSPlanetBase::MERCURY));
168  slotCenter();
169  break;
170 
171  case Qt::Key_2: //center on Venus
172  setClickedObject(data->skyComposite()->planet(KSPlanetBase::VENUS));
174  slotCenter();
175  break;
176 
177  case Qt::Key_3: //center on Moon
178  setClickedObject(data->skyComposite()->planet(KSPlanetBase::MOON));
180  slotCenter();
181  break;
182 
183  case Qt::Key_4: //center on Mars
184  setClickedObject(data->skyComposite()->planet(KSPlanetBase::MARS));
186  slotCenter();
187  break;
188 
189  case Qt::Key_5: //center on Jupiter
190  setClickedObject(data->skyComposite()->planet(KSPlanetBase::JUPITER));
192  slotCenter();
193  break;
194 
195  case Qt::Key_6: //center on Saturn
196  setClickedObject(data->skyComposite()->planet(KSPlanetBase::SATURN));
198  slotCenter();
199  break;
200 
201  case Qt::Key_7: //center on Uranus
202  setClickedObject(data->skyComposite()->planet(KSPlanetBase::URANUS));
204  slotCenter();
205  break;
206 
207  case Qt::Key_8: //center on Neptune
208  setClickedObject(data->skyComposite()->planet(KSPlanetBase::NEPTUNE));
210  slotCenter();
211  break;
212 
213  /*case Qt::Key_9: //center on Pluto
214  setClickedObject( data->skyComposite()->planet( KSPlanetBase::PLUTO ) );
215  setClickedPoint( clickedObject() );
216  slotCenter();
217  break;*/
218 
219  case Qt::Key_BracketLeft: // Begin measuring angular distance
220  if (!rulerMode)
222  break;
223  case Qt::Key_Escape: // Cancel angular distance measurement
224  {
225  if (rulerMode)
227 
228  if (m_fovCaptureMode)
229  slotFinishFovCaptureMode();
230  break;
231  }
232 
233  case Qt::Key_C: //Center clicked object
234  if (clickedObject())
235  slotCenter();
236  break;
237 
238  case Qt::Key_D: //Details window for Clicked/Centered object
239  {
240  SkyObject *orig = nullptr;
241  if (shiftPressed)
242  {
243  orig = clickedObject();
245  }
246 
247  if (clickedObject())
248  {
249  slotDetail();
250  }
251 
252  if (orig)
253  {
254  setClickedObject(orig);
255  }
256  break;
257  }
258 
259  case Qt::Key_P: //Show Popup menu for Clicked/Centered object
260  if (shiftPressed)
261  {
262  if (focusObject())
264  }
265  else
266  {
267  if (clickedObject())
269  }
270  break;
271 
272  case Qt::Key_O: //Add object to Observing List
273  {
274  SkyObject *orig = nullptr;
275  if (shiftPressed)
276  {
277  orig = clickedObject();
279  }
280 
281  if (clickedObject())
282  {
283  data->observingList()->slotAddObject();
284  }
285 
286  if (orig)
287  {
288  setClickedObject(orig);
289  }
290  break;
291  }
292 
293  case Qt::Key_L: //Toggle User label on Clicked/Centered object
294  {
295  SkyObject *orig = nullptr;
296  if (shiftPressed)
297  {
298  orig = clickedObject();
300  }
301 
302  if (clickedObject())
303  {
306  else
308  }
309 
310  if (orig)
311  {
312  setClickedObject(orig);
313  }
314  break;
315  }
316 
317  case Qt::Key_T: //Toggle planet trail on Clicked/Centered object (if solsys)
318  {
319  SkyObject *orig = nullptr;
320  if (shiftPressed)
321  {
322  orig = clickedObject();
324  }
325 
326  KSPlanetBase *planet = dynamic_cast<KSPlanetBase *>(clickedObject());
327  if (planet)
328  {
329  if (planet->hasTrail())
331  else
333  }
334 
335  if (orig)
336  {
337  setClickedObject(orig);
338  }
339  break;
340  }
341 
342  case Qt::Key_R:
343  {
344  // Toggle relativistic corrections
345  Options::setUseRelativistic(!Options::useRelativistic());
346  qDebug() << Q_FUNC_INFO << "Relativistic corrections: " << Options::useRelativistic();
347  forceUpdate();
348  break;
349  }
350 
351  case Qt::Key_A:
352  Options::setUseAntialias(!Options::useAntialias());
353  qDebug() << Q_FUNC_INFO << "Use Antialiasing: " << Options::useAntialias();
354  forceUpdate();
355  break;
356 
357  case Qt::Key_K:
358  {
359  if (m_fovCaptureMode)
360  slotCaptureFov();
361  break;
362  }
363 
364  case Qt::Key_PageUp:
365  {
366  KStars::Instance()->selectPreviousFov();
367  break;
368  }
369 
370  case Qt::Key_PageDown:
371  {
372  KStars::Instance()->selectNextFov();
373  break;
374  }
375 
376  default:
377  // We don't want to do anything in this case. Key is unknown
378  return;
379  }
380 
381  if (arrowKeyPressed)
382  {
383  stopTracking();
384  setDestination(*focus());
385  }
386 
387  forceUpdate(); //need a total update, or slewing with the arrow keys doesn't work.
388 }
389 
390 void SkyMap::stopTracking()
391 {
392  KStars *kstars = KStars::Instance();
393 
394  emit positionChanged(focus());
395  if (kstars && Options::isTracking())
396  kstars->slotTrack();
397 }
398 
399 bool SkyMap::event(QEvent *event)
400 {
401 #if !defined(KSTARS_LITE)
402  if (event->type() == QEvent::TouchBegin)
403  {
404  m_touchMode = true;
405  m_pinchScale = -1;
406  }
407 
408  if (event->type() == QEvent::Gesture && m_touchMode)
409  {
410  QGestureEvent* gestureEvent = static_cast<QGestureEvent*>(event);
411 
412  if (QPinchGesture *pinch = static_cast<QPinchGesture*>(gestureEvent->gesture(Qt::PinchGesture)))
413  {
414  QPinchGesture::ChangeFlags changeFlags = pinch->changeFlags();
415 
416  m_pinchMode = true;
417  if (changeFlags & QPinchGesture::ScaleFactorChanged)
418  {
419  if (m_pinchScale == -1)
420  {
421  m_pinchScale = pinch->totalScaleFactor();
422  return true;
423  }
424  if (pinch->totalScaleFactor() - m_pinchScale > 0.1)
425  {
426  m_pinchScale = pinch->totalScaleFactor();
427  zoomInOrMagStep(0);
428  return true;
429  }
430  if (pinch->totalScaleFactor() - m_pinchScale < -0.1)
431  {
432  m_pinchScale = pinch->totalScaleFactor();
433  zoomOutOrMagStep(0);
434  return true;
435  }
436  }
437  }
438  if (QTapAndHoldGesture *tapAndHold = static_cast<QTapAndHoldGesture*>(gestureEvent->gesture(Qt::TapAndHoldGesture)))
439  {
440  m_tapAndHoldMode = true;
441  if (tapAndHold->state() == Qt::GestureFinished)
442  {
443  if (clickedObject())
444  {
445  clickedObject()->showPopupMenu(pmenu, tapAndHold->position().toPoint());
446  }
447  else
448  {
449  pmenu->createEmptyMenu(clickedPoint());
450  pmenu->popup(tapAndHold->position().toPoint());
451  }
452  m_touchMode = false;
453  m_pinchMode = false;
454  m_tapAndHoldMode = false;
455  }
456  }
457  return true;
458  }
459 #endif
460  return QGraphicsView::event(event);
461 }
462 
464 {
465  switch (e->key())
466  {
467  case Qt::Key_Plus: //Zoom in
468  case Qt::Key_Equal:
469  case Qt::Key_Minus: //Zoom out
470  case Qt::Key_Underscore:
471 
472  case Qt::Key_Left: //no break; continue to Qt::Key_Down
473  case Qt::Key_Right: //no break; continue to Qt::Key_Down
474  case Qt::Key_Up: //no break; continue to Qt::Key_Down
475  case Qt::Key_Down:
476  slewing = false;
477 
478  if (Options::useAltAz())
479  setDestinationAltAz(focus()->alt(), focus()->az(), false);
480  else
481  setDestination(*focus());
482 
483  showFocusCoords();
484  forceUpdate(); // Need a full update to draw faint objects that are not drawn while slewing.
485  break;
486  }
487 }
488 
490 {
491 #if !defined(KSTARS_LITE)
492  // Skip touch points
493  if (m_pinchMode || m_tapAndHoldMode || (m_touchMode && e->globalX() == 0 && e->globalY() == 0))
494  return;
495 #endif
496 
497  if (Options::useHoverLabel())
498  {
499  //Start a single-shot timer to monitor whether we are currently hovering.
500  //The idea is that whenever a moveEvent occurs, the timer is reset. It
501  //will only timeout if there are no move events for HOVER_INTERVAL ms
502  m_HoverTimer.start(HOVER_INTERVAL);
504  }
505 
506  //Are we defining a ZoomRect?
507  if (ZoomRect.center().x() > 0 && ZoomRect.center().y() > 0)
508  {
509  //cancel operation if the user let go of CTRL
510  if (!(e->modifiers() & Qt::ControlModifier))
511  {
512  ZoomRect = QRect(); //invalidate ZoomRect
513  update();
514  }
515  else
516  {
517  //Resize the rectangle so that it passes through the cursor position
518  QPoint pcenter = ZoomRect.center();
519  int dx = abs(e->x() - pcenter.x());
520  int dy = abs(e->y() - pcenter.y());
521  if (dx == 0 || float(dy) / float(dx) > float(height()) / float(width()))
522  {
523  //Size rect by height
524  ZoomRect.setHeight(2 * dy);
525  ZoomRect.setWidth(2 * dy * width() / height());
526  }
527  else
528  {
529  //Size rect by height
530  ZoomRect.setWidth(2 * dx);
531  ZoomRect.setHeight(2 * dx * height() / width());
532  }
533  ZoomRect.moveCenter(pcenter); //reset center
534 
535  update();
536  return;
537  }
538  }
539 
540  if (projector()->unusablePoint(e->pos()))
541  return; // break if point is unusable
542 
543  //determine RA, Dec of mouse pointer
544  m_MousePoint = projector()->fromScreen(e->pos(), data->lst(), data->geo()->lat());
545 
546  double dyPix = 0.5 * height() - e->y();
547  if (midMouseButtonDown) //zoom according to y-offset
548  {
549  float yoff = dyPix - y0;
550  if (yoff > 10)
551  {
552  y0 = dyPix;
553  slotZoomIn();
554  }
555  if (yoff < -10)
556  {
557  y0 = dyPix;
558  slotZoomOut();
559  }
560  }
561 
562  if (mouseButtonDown)
563  {
564 #ifdef HAVE_INDI
565  if (Options::showMosaicPanel())
566  {
567  auto tiles = KStarsData::Instance()->skyComposite()->mosaicComponent()->tiles();
568 
569  if (tiles->operationMode() == MosaicTiles::MODE_PLANNING)
570  {
571  // Check if mouse point within Mosaic FOV bounds.
572  auto mosaicFOV = tiles->mosaicFOV();
573  auto upperRA = tiles->ra0().Degrees() + mosaicFOV.width() / 60;
574  auto lowerRA = tiles->ra0().Degrees() - mosaicFOV.width() / 60;
575  auto upperDE = tiles->dec0().Degrees() + mosaicFOV.height() / 60;
576  auto lowerDE = tiles->dec0().Degrees() - mosaicFOV.height() / 60;
577 
578  auto mouseRA = m_MousePoint.ra().Degrees();
579  auto mouseDE = m_MousePoint.dec().Degrees();
580 
581  // If mouse point is within, then behave like drag and drop
582  if (mouseRA > lowerRA && mouseRA < upperRA && mouseDE > lowerDE && mouseDE < upperDE)
583  {
584  if (!mouseDragCursor)
585  setMouseDragCursor();
586 
587  dms dRA = m_MousePoint.ra() - clickedPoint()->ra();
588  dms dDec = m_MousePoint.dec() - clickedPoint()->dec();
589 
590  // Emit difference between mouse point and clicked point.
591  emit mosaicCenterChanged(dRA, dDec);
592 
593  // Update mouse and clicked points.
594  m_MousePoint = projector()->fromScreen(e->pos(), data->lst(), data->geo()->lat());
595  setClickedPoint(&m_MousePoint);
596  update();
597  return;
598  }
599  }
600  }
601 #endif
602 
603  // set the mouseMoveCursor and set slewing=true, if they are not set yet
604  if (!mouseMoveCursor)
605  setMouseMoveCursor();
606  if (!slewing)
607  {
608  slewing = true;
609  stopTracking(); //toggle tracking off
610  }
611 
612  //Update focus such that the sky coords at mouse cursor remain approximately constant
613  if (Options::useAltAz())
614  {
615  m_MousePoint.EquatorialToHorizontal(data->lst(), data->geo()->lat());
616  clickedPoint()->EquatorialToHorizontal(data->lst(), data->geo()->lat());
617  dms dAz = m_MousePoint.az() - clickedPoint()->az();
618  dms dAlt = m_MousePoint.altRefracted() - clickedPoint()->altRefracted();
619  focus()->setAz(focus()->az().Degrees() - dAz.Degrees()); //move focus in opposite direction
620  focus()->setAz(focus()->az().reduce());
621  focus()->setAltRefracted(KSUtils::clamp(focus()->altRefracted().Degrees() - dAlt.Degrees(), -90.0, 90.0));
622  focus()->HorizontalToEquatorial(data->lst(), data->geo()->lat());
623  }
624  else
625  {
626  dms dRA = m_MousePoint.ra() - clickedPoint()->ra();
627  dms dDec = m_MousePoint.dec() - clickedPoint()->dec();
628  focus()->setRA(focus()->ra().Hours() - dRA.Hours()); //move focus in opposite direction
629  focus()->setRA(focus()->ra().reduce());
630  focus()->setDec(KSUtils::clamp(focus()->dec().Degrees() - dDec.Degrees(), -90.0, 90.0));
631  focus()->EquatorialToHorizontal(data->lst(), data->geo()->lat());
632  }
633  showFocusCoords();
634 
635  //redetermine RA, Dec of mouse pointer, using new focus
636  m_MousePoint = projector()->fromScreen(e->pos(), data->lst(), data->geo()->lat());
637  setClickedPoint(&m_MousePoint);
638  forceUpdate(); // must be new computed
639  }
640  else //mouse button not down
641  {
642  if (Options::useAltAz())
643  m_MousePoint.EquatorialToHorizontal(data->lst(), data->geo()->lat());
644  emit mousePointChanged(&m_MousePoint);
645  }
646 }
647 
649 {
650  if (e->angleDelta().y() > 0)
651  zoomInOrMagStep(e->modifiers());
652  else if (e->angleDelta().y() < 0)
653  zoomOutOrMagStep(e->modifiers());
654 }
655 
657 {
658 #if !defined(KSTARS_LITE)
659  if (m_touchMode)
660  {
661  m_touchMode = false;
662  m_pinchMode = false;
663  m_tapAndHoldMode = false;
664  }
665 #endif
666 
667  if (ZoomRect.isValid())
668  {
669  stopTracking();
670  SkyPoint newcenter = projector()->fromScreen(ZoomRect.center(), data->lst(), data->geo()->lat());
671  setFocus(&newcenter);
672  setDestination(newcenter);
673 
674  //Zoom in on center of Zoom Circle, by a factor equal to the ratio
675  //of the sky pixmap's width to the Zoom Circle's diameter
676  float factor = float(width()) / float(ZoomRect.width());
677  setZoomFactor(Options::zoomFactor() * factor);
678  }
679 
680  setMouseCursorShape(static_cast<Cursor>(Options::defaultCursor()));
681 
682  ZoomRect = QRect(); //invalidate ZoomRect
683 
684  if (m_previewLegend)
685  {
686  slotCancelLegendPreviewMode();
687  }
688 
689  //false if double-clicked, because it's unset there.
690  if (mouseButtonDown)
691  {
692  mouseButtonDown = false;
693  if (slewing)
694  {
695  slewing = false;
696  if (Options::useAltAz())
697  setDestinationAltAz(focus()->alt(), focus()->az(), false);
698  else
699  setDestination(*focus());
700  }
701  else if (Options::leftClickSelectsObject())
703  forceUpdate(); // is needed because after moving the sky not all stars are shown
704  }
705  // if middle button was pressed unset here
706  midMouseButtonDown = false;
707 }
708 
710 {
711  KStars *kstars = KStars::Instance();
712 
713  if ((e->modifiers() & Qt::ControlModifier) && (e->button() == Qt::LeftButton))
714  {
715  ZoomRect.moveCenter(e->pos());
716  setZoomMouseCursor();
717  update(); //refresh without redrawing skymap
718  return;
719  }
720 
721  // if button is down and cursor is not moved set the move cursor after 500 ms
722  //QTimer::singleShot(500, this, SLOT(setMouseMoveCursor()));
723 
724  // break if point is unusable
725  if (projector()->unusablePoint(e->pos()))
726  return;
727 
728  if (!midMouseButtonDown && e->button() == Qt::MidButton)
729  {
730  y0 = 0.5 * height() - e->y(); //record y pixel coordinate for middle-button zooming
731  midMouseButtonDown = true;
732  }
733 
734  if (!mouseButtonDown)
735  {
736  if (e->button() == Qt::LeftButton)
737  {
738  mouseButtonDown = true;
739  }
740 
741  //determine RA, Dec of mouse pointer
742  m_MousePoint = projector()->fromScreen(e->pos(), data->lst(), data->geo()->lat());
743  setClickedPoint(&m_MousePoint);
744 
745  //Find object nearest to clickedPoint()
746  double maxrad = 5000.0 / Options::zoomFactor();
747  SkyObject *obj = data->skyComposite()->objectNearest(clickedPoint(), maxrad);
748  setClickedObject(obj);
749  if (obj)
750  setClickedPoint(obj);
751 
752  switch (e->button())
753  {
754  case Qt::LeftButton:
755  {
756  QString name;
757  if (clickedObject())
758  {
759  name = clickedObject()->translatedLongName();
761  }
762  else
763  name = i18n("Empty sky");
764  //kstars->statusBar()->changeItem(name, 0 );
765  kstars->statusBar()->showMessage(name, 0);
766 
767  emit positionClicked(&m_MousePoint);
768  }
769 
770  break;
771  case Qt::RightButton:
772  if (rulerMode)
773  {
774  // Compute angular distance.
776  }
777  else
778  {
779  // Show popup menu
780  if (clickedObject())
781  {
783  }
784  else
785  {
786  pmenu->createEmptyMenu(clickedPoint());
787  pmenu->popup(QCursor::pos());
788  }
789  }
790  break;
791  default:
792  ;
793  }
794  }
795 }
796 
798 {
799  if (e->button() == Qt::LeftButton && !projector()->unusablePoint(e->pos()))
800  {
801  mouseButtonDown = false;
802  if (e->x() != width() / 2 || e->y() != height() / 2)
803  slotCenter();
804  }
805 }
806 
807 double SkyMap::zoomFactor(const int modifier)
808 {
809  double factor = (modifier & Qt::ControlModifier) ? DZOOM : (Options::zoomScrollFactor() + 1);
810  if (modifier & Qt::ShiftModifier)
811  factor = sqrt(factor);
812  return factor;
813 }
814 
815 void SkyMap::zoomInOrMagStep(const int modifier)
816 {
817  if (modifier & Qt::AltModifier)
818  incMagLimit(modifier);
819  else
820  setZoomFactor(Options::zoomFactor() * zoomFactor(modifier));
821 }
822 
823 void SkyMap::zoomOutOrMagStep(const int modifier)
824 {
825  if (modifier & Qt::AltModifier)
826  decMagLimit(modifier);
827  else
828  setZoomFactor(Options::zoomFactor() / zoomFactor(modifier));
829 }
830 
831 double SkyMap::magFactor(const int modifier)
832 {
833  double factor = (modifier & Qt::ControlModifier) ? 0.1 : 0.5;
834  if (modifier & Qt::ShiftModifier)
835  factor *= 2.0;
836  return factor;
837 }
838 
839 void SkyMap::incMagLimit(const int modifier)
840 {
841  double limit = 2.222 * log10(static_cast<double>(Options::starDensity())) + 0.35;
842  limit += magFactor(modifier);
843  if (limit > 5.75954)
844  limit = 5.75954;
845  Options::setStarDensity(pow(10, (limit - 0.35) / 2.222));
846  //printf("maglim set to %3.1f\n", limit);
847  forceUpdate();
848 }
849 
850 void SkyMap::decMagLimit(const int modifier)
851 {
852  double limit = 2.222 * log10(static_cast<double>(Options::starDensity())) + 0.35;
853  limit -= magFactor(modifier);
854  if (limit < 1.18778)
855  limit = 1.18778;
856  Options::setStarDensity(pow(10, (limit - 0.35) / 2.222));
857  //printf("maglim set to %3.1f\n", limit);
858  forceUpdate();
859 }
void objectClicked(SkyObject *)
Emitted when a position is clicked.
void mousePressEvent(QMouseEvent *e) override
Determine RA, Dec coordinates of clicked location.
QPoint pos() const const
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition: skypoint.h:194
GestureFinished
void setWidth(int width)
void setDestinationAltAz(const dms &alt, const dms &az, bool altIsRefracted)
sets the destination point of the sky map, using its alt/az coordinates.
Definition: skymap.cpp:980
void slotZoomOut()
Zoom out one step.
Definition: skymap.cpp:1166
QString translatedLongName() const
Definition: skyobject.h:169
void mosaicCenterChanged(dms dRA, dms dDE)
Emitter when mosaic center is dragged in the sky map.
SkyPoint * clickedPoint()
Retrieve the ClickedPoint position.
Definition: skymap.h:216
void createEmptyMenu(SkyPoint *nullObj)
Create a popup menu for empty sky.
Qt::MouseButton button() const const
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
void mouseMoveEvent(QMouseEvent *e) override
This function does several different things depending on the state of the program:
void setZoomFactor(double factor)
@ Set zoom factor.
Definition: skymap.cpp:1176
void update()
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition: skymap.cpp:996
void resizeEvent(QResizeEvent *) override
If the skymap will be resized, the sky must be new computed.
QPoint angleDelta() const const
CachingDms * lst()
Definition: kstarsdata.h:223
void showFocusCoords()
Update object name and coordinates in the Focus InfoBox.
Definition: skymap.cpp:292
SkyObject * clickedObject() const
Retrieve the object nearest to a mouse click event.
Definition: skymap.h:243
int width() const const
bool isObjectLabeled(SkyObject *o)
Definition: skymap.cpp:815
void slotAddObjectLabel()
Add ClickedObject to KStarsData::ObjLabelList, which stores pointers to SkyObjects which have User La...
Definition: skymap.cpp:856
int x() const const
int y() const const
virtual bool event(QEvent *event) override
LeftButton
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition: skypoint.cpp:77
void slotEndRulerMode()
Computes the angular distance, prints the result in the status bar and disables the angular distance ...
Definition: skymap.cpp:631
dms altRefracted() const
Definition: skypoint.cpp:1050
void showPopupMenu(KSPopupMenu *pmenu, const QPoint &pos)
Show Type-specific popup menu.
Definition: skyobject.cpp:56
void setMouseCursorShape(Cursor type)
Sets the shape of the default mouse cursor.
Definition: skymap.cpp:1264
static KStars * Instance()
Definition: kstars.h:125
void showMessage(const QString &message, int timeout)
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition: skymap.cpp:968
void keyPressEvent(QKeyEvent *e) override
Process keystrokes:
Qt::KeyboardModifiers modifiers() const const
void start(int msec)
QString i18n(const char *text, const TYPE &arg...)
const CachingDms & dec() const
Definition: skypoint.h:269
const CachingDms * lat() const
Definition: geolocation.h:70
void slotRemoveObjectLabel()
Remove ClickedObject from KStarsData::ObjLabelList, which stores pointers to SkyObjects which have Us...
Definition: skymap.cpp:830
SkyPoint * focus()
Retrieve the Focus point; the position on the sky at the center of the skymap.
Definition: skymap.h:122
void wheelEvent(QWheelEvent *e) override
Zoom in and out with the mouse wheel.
void setHeight(int height)
void positionChanged(SkyPoint *)
Emitted when pointing changed.
void setAltRefracted(dms alt_apparent)
Sets the apparent altitude, checking whether refraction corrections are enabled.
Definition: skypoint.cpp:1055
GeoLocation * geo()
Definition: kstarsdata.h:229
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
bool isValid() const const
void mouseDoubleClickEvent(QMouseEvent *e) override
Center SkyMap at double-clicked location
int x() const const
int y() const const
typedef ChangeFlags
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition: skymap.cpp:331
int globalX() const const
int globalY() const const
QPoint center() const const
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
void positionClicked(SkyPoint *)
Emitted when a position is clicked.
void slotRemovePlanetTrail()
Remove the PlanetTrail from ClickedObject.
Definition: skymap.cpp:862
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:92
void slotDetail()
Popup menu function: Show the Detailed Information window for ClickedObject.
Definition: skymap.cpp:882
Key_Left
QPoint pos()
void slotAddPlanetTrail()
Add a Planet Trail to ClickedObject.
Definition: skymap.cpp:872
void moveCenter(const QPoint &position)
PinchGesture
void slotCenter()
Center the display at the point ClickedPoint.
Definition: skymap.cpp:345
QStatusBar * statusBar() const const
Qt::KeyboardModifiers modifiers() const const
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:165
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
void resize(int w, int h)
void popup(const QPoint &p, QAction *atAction)
void slotTrack()
action slot: Toggle whether kstars is tracking current position
void setAz(dms az)
Sets Az, the Azimuth.
Definition: skypoint.h:230
const CachingDms & ra() const
Definition: skypoint.h:263
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Definition: skymap.h:261
void slotBeginAngularDistance()
Enables the angular distance measuring mode.
Definition: skymap.cpp:595
int key() const const
virtual SkyPoint fromScreen(const QPointF &p, dms *LST, const dms *lat, bool onlyAltAz=false) const
Determine RA, Dec coordinates of the pixel at (dx, dy), which are the screen pixel coordinate offsets...
Definition: projector.cpp:406
void slotCancelRulerMode()
Disables the angular distance measuring mode.
Definition: skymap.cpp:737
const double & Degrees() const
Definition: dms.h:141
bool hasTrail() const
Definition: trailobject.h:36
void setDec(dms d)
Sets Dec, the current Declination.
Definition: skypoint.h:169
void hideText()
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
Definition: skypoint.cpp:143
void setRA(dms &r)
Sets RA, the current Right Ascension.
Definition: skypoint.h:144
void mouseReleaseEvent(QMouseEvent *e) override
set mouseButtonDown==false, slewing==false
void forceUpdate(bool now=false)
Recalculates the positions of objects in the sky, and then repaints the sky map.
Definition: skymap.cpp:1186
void slotZoomIn()
Zoom in one step.
Definition: skymap.cpp:1161
const Projector * projector() const
Get the current projector.
Definition: skymap.h:299
void mousePointChanged(SkyPoint *)
Emitted when position under mouse changed.
void keyReleaseEvent(QKeyEvent *e) override
When keyRelease is triggered, just set the "slewing" flag to false, and update the display (to draw o...
ShiftModifier
bool isEmpty() const const
void setFocus()
Information about an object in the sky.
Definition: skyobject.h:41
QGesture * gesture(Qt::GestureType type) const const
double Hours() const
Definition: dms.h:168
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
const dms & az() const
Definition: skypoint.h:275
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:58 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.