Commit fc87410b authored by Pablo de Vicente's avatar Pablo de Vicente
Browse files

Reworked the angular distance measurement mode. Now the angle measuring

mode is activated from the popupmenu or clicking on the skymap and
pressing CTRL+[. The angle mode is finished from the popupmenu or
clicking on the skymap and pressing CTRL+].

When the angle measuring mode is on, a line is drawn from the first
point to the second one. When the angle mode is finished the result is shown
in the status bar and the line disappears.

I have suppressed from skymapevent the event triggered from the left button
click. To draw the line I defined a function called drawRuler in skymapdraw as
Jason told me. That works nicely since it is very easy to implement it.

TODO:
 - There are some errors when plotting the line. I do not know why yet, but
   the start point is offset by a small quantity from the clicked point.
 - I do not like the labels I have written in the KSPopMenu class. I will try
   to fix that, or better, somebody speaking good english (Jason :-) ) writes
   some better labels
 - Investigate if the line can flash or if another color is nicer.
 - See if it is possible to avoid clicking first with the left button and then
   press CTRL+[. It would be easier to just do CTRL+[ and the position where
   the mouse is hovering on is read.

CCMAIL: kstars-devel@kde.org

svn path=/trunk/kdeedu/kstars/; revision=285577
parent e821548d
......@@ -254,7 +254,12 @@ void KSPopupMenu::initPopupMenu( SkyObject *obj, QString s1, QString s2, QString
//Insert item for measuring distances
if ( showAngularDistance && obj ) {
insertItem( i18n( "Angular distance to ...." ), ksw->map(), SLOT( slotAngularDistance() ) );
if (! (ksw->map()->isAngleMode()) ) {
insertItem( i18n( "Angular distance to .... CTRl+[" ), ksw->map(), SLOT( slotBeginAngularDistance() ) );
} else {
insertItem( i18n( "Compute angular distance CTRL+]" ), ksw->map(), SLOT( slotEndAngularDistance() ) );
}
}
......
......@@ -324,15 +324,28 @@ void SkyMap::slotInfo( int id ) {
kapp->invokeBrowser(sURL);
}
void SkyMap::slotAngularDistance(void) {
void SkyMap::slotBeginAngularDistance(void) {
if ( clickedObject() ) {
measuringAngularDistance = true;
angularDistanceMode = true;
setPreviousClickedPoint( clickedPoint() );
//previousClickedObject->setDec( clickedObject()->dec()->Degrees() );
}
}
void SkyMap::slotEndAngularDistance(void) {
dms angularDistance;
if ( clickedObject() ) {
if(angularDistanceMode) {
angularDistance = clickedObject()->angularDistanceTo( previousClickedPoint() );
ksw->statusBar()->changeItem( i18n(clickedObject()->longname().utf8()) +
" " +
i18n("Angular distance: " ) +
angularDistance.toDMSString(), 0 );
angularDistanceMode=false;
}
}
}
void SkyMap::slotImage( int id ) {
QStringList::Iterator it = clickedObject()->ImageList.at(id-100);
QString sURL = (*it);
......
......@@ -257,6 +257,9 @@ public:
bool isObjectLabeled( SkyObject *o );
//** @returns if the angular distance measuring mode is on */
bool isAngleMode() const {return angularDistanceMode;}
/**@short Convenience function for shutting off tracking mode. Just calls KStars::slotTrack().
*/
void stopTracking();
......@@ -339,7 +342,8 @@ public slots:
/**Checks whether the timestep exceeds a threshold value. If so, sets
*ClockSlewing=true and sets the SimClock to ManualMode. */
void slotClockSlewing();
void slotAngularDistance(void);
void slotBeginAngularDistance(void);
void slotEndAngularDistance(void);
signals:
void destinationChanged();
......@@ -453,6 +457,7 @@ private:
void drawTelescopeSymbols(QPainter &psky);
void drawZoomBox( QPainter &psky);
void SkyMap::drawAngleRuler( QPainter &psky );
/**@short Sets the shape of the default mouse cursor to a cross. */
void setDefaultMouseCursor();
......@@ -497,10 +502,11 @@ private:
QPointArray *pts; // needed in paintEvent() so it should not every event call reallocated (save time)
SkyPoint *sp; // see line above
QPoint beginRulerPoint, endRulerPoint; // used in angle mode
QRect ZoomRect; //The manual-focus circle.
//DEBUG
bool dumpHorizon;
bool measuringAngularDistance;
bool angularDistanceMode;
//END_DEBUG
};
......
......@@ -27,6 +27,7 @@
#include "indiproperty.h"
#include "indielement.h"
#include "indidevice.h"
#include <iostream>
#include <qpaintdevicemetrics.h>
#include <stdlib.h> // abs
......@@ -42,9 +43,17 @@ void SkyMap::drawOverlays( QPixmap *pm ) {
ksw->data()->fovSymbol.draw( p, (float)(data->options->FOVSize*zoomFactor()/57.3/60.0) );
drawTelescopeSymbols( p );
drawZoomBox( p );
if (isAngleMode())
drawAngleRuler( p );
}
}
void SkyMap::drawAngleRuler( QPainter &p ) {
//draw the manual zoom-box, if it exists
p.setPen( QPen( "white", 1, DotLine ) );
p.drawLine( beginRulerPoint, endRulerPoint );
}
void SkyMap::drawZoomBox( QPainter &p ) {
//draw the manual zoom-box, if it exists
if ( ZoomRect.isValid() ) {
......
......@@ -214,6 +214,20 @@ void SkyMap::keyPressEvent( QKeyEvent *e ) {
slotCenter();
break;
case Key_BracketLeft: // Begin measuring angular distance
if ( !isAngleMode() ) {
slotBeginAngularDistance();
}
break;
case Key_BracketRight: // End measuring angular distance
if ( isAngleMode() ) {
slotEndAngularDistance();
}
break;
//DUMP_HORIZON
/*
case Key_X: //Spit out coords of horizon polygon
......@@ -296,7 +310,6 @@ void SkyMap::keyPressEvent( QKeyEvent *e ) {
kdDebug() << "time taken for reading deep sky data old code (1 times): (msec): " << t4.elapsed() << endl;
*/
break;
}
......@@ -348,6 +361,19 @@ void SkyMap::keyReleaseEvent( QKeyEvent *e ) {
}
void SkyMap::mouseMoveEvent( QMouseEvent *e ) {
// Are we in angularDistanceMode: Then draw a line
if ( isAngleMode() ) {
// KStarsOptions* options = ksw->options();
// beginRulerPoint = getXY( previousClickedPoint(), options->useAltAz, false);
beginRulerPoint = getXY( previousClickedPoint(), false, true);
endRulerPoint = QPoint(e->x(), e->y());
update();
return;
}
//Are we dragging an infoBox?
if ( infoBoxes()->dragBox( e ) ) {
update();
......@@ -390,6 +416,7 @@ void SkyMap::mouseMoveEvent( QMouseEvent *e ) {
//determine RA, Dec of mouse pointer
setMousePoint( dXdYToRaDec( dx, dy, data->options->useAltAz, data->LST, data->geo()->lat() ) );
if ( midMouseButtonDown ) { //zoom according to y-offset
float yoff = dyPix - y0;
......@@ -815,15 +842,6 @@ void SkyMap::mousePressEvent( QMouseEvent *e ) {
//} else {
ksw->statusBar()->changeItem( i18n(clickedObject()->longname().utf8()), 0 );
//}
if(measuringAngularDistance) {
//deleteRuler();
angularDistance = clickedObject()->angularDistanceTo( previousClickedPoint() );
// ksw->statusBar()->changeItem( i18n(clickedObject()->longname().utf8()) + " " + i18n("Angular distance:" ), 0 );
ksw->statusBar()->changeItem( i18n(clickedObject()->longname().utf8()) + " " +
i18n("Angular distance: " ) +
angularDistance.toDMSString(), 0 );
measuringAngularDistance=false;
}
}
} else {
//Empty sky selected. If left-click, display "nothing" in the status bar.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment