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

As far as I know I have addressed all pending issues concerning the

angular distance measurement tool.

- Instead of hardcoding the color Kstars now uses the colorscheme for plotting
  the ruler. This is defined in files .colors under the name AngularRuler.

- The angular measurement tool now may be triggered:
   either pressing [
   or clicking on the right mouse button on a object in the sky and
    selecting the item "Angular distance to....   ["
  and it is finished by:
   pressing ]
   or clicking on the right mouse button on an object in the sky and
   selecting the item "Compute angular distance .... ]"

- The angular distance can be measured on the empty sky when using the keys
  [ and ]. In that case the status bar only will show the result of the
  measurement. If one uses the popup menu one should select a valid sky
  object.

- Now the angular distance measurement mode can be cancelled by pressing Esc

- The ruler is correctly plotted in equatorial and horiontal coordinates mode.

CCMAIL: kstars-devel@kde.org

svn path=/trunk/kdeedu/kstars/; revision=287977
parent 9bd7d8a8
......@@ -100,6 +100,9 @@ ColorScheme::ColorScheme() : FileName() {
KeyName.append( "PlanetTrailColor" );
Name.append( i18n( "Planet Trails" ) );
Default.append( "#963" );
KeyName.append( "AngularRuler" );
Name.append( i18n( "Angular Distance Ruler" ) );
Default.append( "#FFF" );
//Default values for integer variables:
StarColorMode = 0;
......
......@@ -21,3 +21,4 @@
#006600 :TargetColor
#000000 :UserLabelColor
#BB9900 :PlanetTrailColor
#000000 :AngularRuler
......@@ -21,3 +21,4 @@
#88BB88 :TargetColor
#FFFFFF :UserLabelColor
#996633 :PlanetTrailColor
#FFFFFF :AngularRuler
......@@ -21,3 +21,4 @@
#DD0000 :TargetColor
#AAAAAA :UserLabelColor
#993311 :PlanetTrailColor
#456 :AngularRuler
......@@ -21,3 +21,4 @@
#DD0000 :TargetColor
#AA0000 :UserLabelColor
#992200 :PlanetTrailColor
#770000 :AngularRuler
......@@ -255,9 +255,9 @@ void KSPopupMenu::initPopupMenu( SkyObject *obj, QString s1, QString s2, QString
//Insert item for measuring distances
if ( showAngularDistance && obj ) {
if (! (ksw->map()->isAngleMode()) ) {
insertItem( i18n( "Angular distance to... Ctrl+[" ), ksw->map(), SLOT( slotBeginAngularDistance() ) );
insertItem( i18n( "Angular distance to... [" ), ksw->map(), SLOT( slotBeginAngularDistance() ) );
} else {
insertItem( i18n( "Compute angular distance Ctrl+]" ), ksw->map(), SLOT( slotEndAngularDistance() ) );
insertItem( i18n( "Compute angular distance ]" ), ksw->map(), SLOT( slotEndAngularDistance() ) );
}
}
......
......@@ -15,6 +15,7 @@
* *
***************************************************************************/
#include <iostream.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <kstatusbar.h>
......@@ -633,27 +634,36 @@ void SkyMap::slotInfo( int id ) {
}
void SkyMap::slotBeginAngularDistance(void) {
if ( clickedObject() ) {
angularDistanceMode = true;
setPreviousClickedPoint( clickedPoint() );
}
angularDistanceMode = true;
setPreviousClickedPoint( mousePoint() );
// cout << previousClickedPoint()->ra()->hour() << ":" <<
// previousClickedPoint()->ra()->minute() << ":" <<
// previousClickedPoint()->ra()->second() << endl ;
}
void SkyMap::slotEndAngularDistance(void) {
dms angularDistance;
if ( clickedObject() ) {
if(angularDistanceMode) {
angularDistance = clickedObject()->angularDistanceTo( previousClickedPoint() );
ksw->statusBar()->changeItem( i18n(clickedObject()->longname().utf8()) +
if(angularDistanceMode) {
if ( SkyObject *so = objectNearest( mousePoint() ) ) {
angularDistance = so->angularDistanceTo( previousClickedPoint() );
ksw->statusBar()->changeItem( i18n(so->longname().utf8()) +
" " +
i18n("Angular distance: " ) +
angularDistance.toDMSString(), 0 );
angularDistanceMode=false;
} else {
angularDistance = mousePoint()->angularDistanceTo( previousClickedPoint() );
ksw->statusBar()->changeItem( i18n("Angular distance: " ) +
angularDistance.toDMSString(), 0 );
}
angularDistanceMode=false;
}
}
void SkyMap::slotCancelAngularDistance(void) {
angularDistanceMode=false;
}
void SkyMap::slotImage( int id ) {
QStringList::Iterator it = clickedObject()->ImageList.at(id-100);
QString sURL = (*it);
......
......@@ -371,9 +371,24 @@ public slots:
/**Checks whether the timestep exceeds a threshold value. If so, sets
*ClockSlewing=true and sets the SimClock to ManualMode. */
void slotClockSlewing();
/** Enables the angular distance measuring mode. It saves the first
* position of the ruler in a SkyPoint. It makes difference between
* having clicked on the skymap and not having done so */
void slotBeginAngularDistance(void);
/** Computes the angular distance, prints the result in the status
* bar and disables the angular distance measuring mode
* If the user has clicked on the map the status bar shows the
* name of the clicked object plus the angular distance. If
* the user did not clicked on the map, just pressed ], only
* the angular distance is printed */
void slotEndAngularDistance(void);
/** Disables the angular distance measuring mode. Nothing is printed
* in the status bar */
void slotCancelAngularDistance(void);
signals:
void destinationChanged();
void linkAdded();
......
......@@ -50,8 +50,7 @@ void SkyMap::drawOverlays( QPixmap *pm ) {
}
void SkyMap::drawAngleRuler( QPainter &p ) {
//draw the manual zoom-box, if it exists
p.setPen( QPen( "white", 1, DotLine ) );
p.setPen( QPen( data->options->colorScheme()->colorNamed( "AngularRuler" ), 1, DotLine ) );
p.drawLine( beginRulerPoint, endRulerPoint );
}
......
......@@ -228,6 +228,12 @@ void SkyMap::keyPressEvent( QKeyEvent *e ) {
break;
case Key_Escape: // Cancel angular distance measurement
if (isAngleMode() ) {
slotCancelAngularDistance();
}
break;
//DUMP_HORIZON
/*
case Key_X: //Spit out coords of horizon polygon
......@@ -361,13 +367,17 @@ void SkyMap::keyReleaseEvent( QKeyEvent *e ) {
}
void SkyMap::mouseMoveEvent( QMouseEvent *e ) {
// Are we in angularDistanceMode: Then draw a line
// 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);
// We put this instruction here so that the first point of the
// ruler is recomputed when moving the mouse. The initial
// point of the ruler may change if the time step is high.
if ( data->options->useAltAz ) PreviousClickedPoint.EquatorialToHorizontal( data->LST, data->options->Location()->lat() );
beginRulerPoint = getXY( previousClickedPoint(), data->options->useAltAz, data->options->useRefraction);
endRulerPoint = QPoint(e->x(), e->y());
update();
return;
......
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