1 /***************************************************************************
2 kstarsdcop.cpp - description
5 copyright : (C) 2002 by Thomas Kabelmann
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 //KStars DCOP functions
21 #include <qlistview.h>
22 #include <qradiobutton.h>
24 #include <kio/netaccess.h>
25 #include <kmessagebox.h>
27 #include <kshortcut.h>
28 #include <ktempfile.h>
30 #include <klistview.h>
31 #include <kpushbutton.h>
32 #include <klineedit.h>
33 #include <knuminput.h>
36 #include "kstarsdata.h"
38 #include "skyobject.h"
39 #include "infoboxes.h"
44 #include "indidriver.h"
46 #include "indielement.h"
47 #include "indidevice.h"
48 #include "indiproperty.h"
49 #include "devicemanager.h"
51 void KStars::setRaDec( double ra
, double dec
) {
52 map()->setDestination( new SkyPoint( ra
, dec
) );
55 void KStars::setAltAz( double alt
, double az
) {
56 map()->setDestinationAltAz(alt
,az
);
59 void KStars::lookTowards ( const QString direction
) {
60 QString dir
= direction
.lower();
61 if (dir
== "zenith" || dir
=="z") map()->invokeKey( KKey( "Z" ).keyCodeQt() );
62 else if (dir
== "north" || dir
=="n") map()->invokeKey( KKey( "N" ).keyCodeQt() );
63 else if (dir
== "east" || dir
=="e") map()->invokeKey( KKey( "E" ).keyCodeQt() );
64 else if (dir
== "south" || dir
=="s") map()->invokeKey( KKey( "S" ).keyCodeQt() );
65 else if (dir
== "west" || dir
=="w") map()->invokeKey( KKey( "W" ).keyCodeQt() );
66 else if (dir
== "northeast" || dir
=="ne") {
67 map()->stopTracking();
68 map()->clickedPoint()->setAlt( 15.0 ); map()->clickedPoint()->setAz( 45.0 );
69 map()->clickedPoint()->HorizontalToEquatorial( LST(), geo()->lat() );
71 } else if (dir
== "southeast" || dir
=="se") {
72 map()->stopTracking();
73 map()->clickedPoint()->setAlt( 15.0 ); map()->clickedPoint()->setAz( 135.0 );
74 map()->clickedPoint()->HorizontalToEquatorial( LST(), geo()->lat() );
76 } else if (dir
== "southwest" || dir
=="sw") {
77 map()->stopTracking();
78 map()->clickedPoint()->setAlt( 15.0 ); map()->clickedPoint()->setAz( 225.0 );
79 map()->clickedPoint()->HorizontalToEquatorial( LST(), geo()->lat() );
81 } else if (dir
== "northwest" || dir
=="nw") {
82 map()->stopTracking();
83 map()->clickedPoint()->setAlt( 15.0 ); map()->clickedPoint()->setAz( 315.0 );
84 map()->clickedPoint()->HorizontalToEquatorial( LST(), geo()->lat() );
87 SkyObject
*target
= data()->objectNamed( direction
);
88 if ( target
!= NULL
) {
89 map()->setClickedObject( target
);
90 map()->setClickedPoint( target
);
96 void KStars::zoom( double z
) {
97 if ( z
> MAXZOOM
) z
= MAXZOOM
;
98 if ( z
< MINZOOM
) z
= MINZOOM
;
99 Options::setZoomFactor( z
);
100 map()->forceUpdate();
103 void KStars::setLocalTime(int yr
, int mth
, int day
, int hr
, int min
, int sec
) {
104 data()->changeDateTime( KStarsDateTime( ExtDate(yr
, mth
, day
), QTime(hr
,min
,sec
) ) );
107 void KStars::waitFor( double t
) {
108 kapp
->dcopClient()->suspend();
109 QTimer::singleShot( int( 1000.*t
), this, SLOT( resumeDCOP() ) );
112 void KStars::waitForKey( const QString k
) {
113 data()->resumeKey
= KKey( k
);
114 if ( ! data()->resumeKey
.isNull() ) {
115 kapp
->dcopClient()->suspend();
117 kdDebug() << i18n( "Error [DCOP waitForKey()]: Invalid key requested." ) << endl
;
121 void KStars::setTracking( bool track
) {
122 if ( track
!= Options::isTracking() ) slotTrack();
125 void KStars::popupMessage( int /*x*/, int /*y*/, QString
/*message*/ ){
126 //Show a small popup window at (x,y) with a text message
129 void KStars::drawLine( int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/, int /*speed*/ ) {
130 //Draw a line on the skymap display
133 void KStars::setGeoLocation( QString city
, QString province
, QString country
) {
134 //Set the geographic location
135 bool cityFound( false );
137 for (GeoLocation
*loc
= data()->geoList
.first(); loc
; loc
= data()->geoList
.next()) {
138 if ( loc
->translatedName() == city
&&
139 ( province
.isEmpty() || loc
->translatedProvince() == province
) &&
140 loc
->translatedCountry() == country
) {
144 data()->setLocation( *loc
);
146 //notify on-screen GeoBox
147 infoBoxes()->geoChanged( loc
);
149 //configure time zone rule
150 KStarsDateTime ltime
= loc
->UTtoLT( data()->ut() );
151 loc
->tzrule()->reset_with_ltime( ltime
, loc
->TZ0(), data()->isTimeRunningForward() );
152 data()->setNextDSTChange( loc
->tzrule()->nextDSTChange() );
157 //make sure planets, etc. are updated immediately
158 data()->setFullTimeUpdate();
160 // If the sky is in Horizontal mode and not tracking, reset focus such that
161 // Alt/Az remain constant.
162 if ( ! Options::isTracking() && Options::useAltAz() ) {
163 map()->focus()->HorizontalToEquatorial( LST(), geo()->lat() );
166 // recalculate new times and objects
167 data()->setSnapNextFocus();
170 //no need to keep looking, we're done.
176 if ( province
.isEmpty() )
177 kdDebug() << i18n( "Error [DCOP setGeoLocation]: city " ) << city
<< ", "
178 << country
<< i18n( " not found in database." ) << endl
;
180 kdDebug() << i18n( "Error [DCOP setGeoLocation]: city " ) << city
<< ", "
181 << province
<< ", " << country
<< i18n( " not found in database." ) << endl
;
185 void KStars::changeViewOption( const QString op
, const QString val
) {
186 bool bOk(false), nOk(false), dOk(false);
190 if ( val
.lower() == "true" ) { bOk
= true; bVal
= true; }
191 if ( val
.lower() == "false" ) { bOk
= true; bVal
= false; }
192 if ( val
== "1" ) { bOk
= true; bVal
= true; }
193 if ( val
== "0" ) { bOk
= true; bVal
= false; }
196 int nVal
= val
.toInt( &nOk
);
199 double dVal
= val
.toDouble( &dOk
);
202 if ( op
== "ShowInfoBoxes" && bOk
) Options::setShowInfoBoxes( bVal
);
203 if ( op
== "ShowTimeBox" && bOk
) Options::setShowTimeBox( bVal
);
204 if ( op
== "ShowGeoBox" && bOk
) Options::setShowGeoBox( bVal
);
205 if ( op
== "ShowFocusBox" && bOk
) Options::setShowFocusBox( bVal
);
206 if ( op
== "ShadeTimeBox" && bOk
) Options::setShadeTimeBox( bVal
);
207 if ( op
== "ShadeGeoBox" && bOk
) Options::setShadeGeoBox( bVal
);
208 if ( op
== "ShadeFocusBox" && bOk
) Options::setShadeFocusBox( bVal
);
209 if ( op
== "ShowMainToolBar" && bOk
) Options::setShowMainToolBar( bVal
);
210 if ( op
== "ShowViewToolBar" && bOk
) Options::setShowViewToolBar( bVal
);
213 if ( op
== "FOVName" ) Options::setFOVName( val
);
214 if ( op
== "FOVSize" && dOk
) Options::setFOVSize( (float)dVal
);
215 if ( op
== "FOVShape" && nOk
) Options::setFOVShape( nVal
);
216 if ( op
== "FOVColor" ) Options::setFOVColor( val
);
217 if ( op
== "ShowStars" && bOk
) Options::setShowStars( bVal
);
218 if ( op
== "ShowMessier" && bOk
) Options::setShowMessier( bVal
);
219 if ( op
== "ShowMessierImages" && bOk
) Options::setShowMessierImages( bVal
);
220 if ( op
== "ShowNGC" && bOk
) Options::setShowNGC( bVal
);
221 if ( op
== "ShowIC" && bOk
) Options::setShowIC( bVal
);
222 if ( op
== "ShowCLines" && bOk
) Options::setShowCLines( bVal
);
223 if ( op
== "ShowCBounds" && bOk
) Options::setShowCBounds( bVal
);
224 if ( op
== "ShowCNames" && bOk
) Options::setShowCNames( bVal
);
225 if ( op
== "ShowMilkyWay" && bOk
) Options::setShowMilkyWay( bVal
);
226 if ( op
== "ShowGrid" && bOk
) Options::setShowGrid( bVal
);
227 if ( op
== "ShowEquator" && bOk
) Options::setShowEquator( bVal
);
228 if ( op
== "ShowEcliptic" && bOk
) Options::setShowEcliptic( bVal
);
229 if ( op
== "ShowHorizon" && bOk
) Options::setShowHorizon( bVal
);
230 if ( op
== "ShowGround" && bOk
) Options::setShowGround( bVal
);
231 if ( op
== "ShowSun" && bOk
) Options::setShowSun( bVal
);
232 if ( op
== "ShowMoon" && bOk
) Options::setShowMoon( bVal
);
233 if ( op
== "ShowMercury" && bOk
) Options::setShowMercury( bVal
);
234 if ( op
== "ShowVenus" && bOk
) Options::setShowVenus( bVal
);
235 if ( op
== "ShowMars" && bOk
) Options::setShowMars( bVal
);
236 if ( op
== "ShowJupiter" && bOk
) Options::setShowJupiter( bVal
);
237 if ( op
== "ShowSaturn" && bOk
) Options::setShowSaturn( bVal
);
238 if ( op
== "ShowUranus" && bOk
) Options::setShowUranus( bVal
);
239 if ( op
== "ShowNeptune" && bOk
) Options::setShowNeptune( bVal
);
240 if ( op
== "ShowPluto" && bOk
) Options::setShowPluto( bVal
);
241 if ( op
== "ShowAsteroids" && bOk
) Options::setShowAsteroids( bVal
);
242 if ( op
== "ShowComets" && bOk
) Options::setShowComets( bVal
);
243 if ( op
== "ShowPlanets" && bOk
) Options::setShowPlanets( bVal
);
244 if ( op
== "ShowDeepSky" && bOk
) Options::setShowDeepSky( bVal
);
245 if ( op
== "ShowStarNames" && bOk
) Options::setShowStarNames( bVal
);
246 if ( op
== "ShowStarMagnitudes" && bOk
) Options::setShowStarMagnitudes( bVal
);
247 if ( op
== "ShowAsteroidNames" && bOk
) Options::setShowAsteroidNames( bVal
);
248 if ( op
== "ShowCometNames" && bOk
) Options::setShowCometNames( bVal
);
249 if ( op
== "ShowPlanetNames" && bOk
) Options::setShowPlanetNames( bVal
);
250 if ( op
== "ShowPlanetImages" && bOk
) Options::setShowPlanetImages( bVal
);
251 if ( op
== "HideOnSlew" && bOk
) Options::setHideOnSlew( bVal
);
252 if ( op
== "HideStars" && bOk
) Options::setHideStars( bVal
);
253 if ( op
== "HidePlanets" && bOk
) Options::setHidePlanets( bVal
);
254 if ( op
== "HideMessier" && bOk
) Options::setHideMessier( bVal
);
255 if ( op
== "HideNGC" && bOk
) Options::setHideNGC( bVal
);
256 if ( op
== "HideIC" && bOk
) Options::setHideIC( bVal
);
257 if ( op
== "HideMilkyWay" && bOk
) Options::setHideMilkyWay( bVal
);
258 if ( op
== "HideCNames" && bOk
) Options::setHideCNames( bVal
);
259 if ( op
== "HideCLines" && bOk
) Options::setHideCLines( bVal
);
260 if ( op
== "HideCBounds" && bOk
) Options::setHideCBounds( bVal
);
261 if ( op
== "HideGrid" && bOk
) Options::setHideGrid( bVal
);
263 if ( op
== "UseAltAz" && bOk
) Options::setUseAltAz( bVal
);
264 if ( op
== "UseRefraction" && bOk
) Options::setUseRefraction( bVal
);
265 if ( op
== "UseAutoLabel" && bOk
) Options::setUseAutoLabel( bVal
);
266 if ( op
== "UseHoverLabel" && bOk
) Options::setUseHoverLabel( bVal
);
267 if ( op
== "UseAutoTrail" && bOk
) Options::setUseAutoTrail( bVal
);
268 if ( op
== "UseAnimatedSlewing" && bOk
) Options::setUseAnimatedSlewing( bVal
);
269 if ( op
== "FadePlanetTrails" && bOk
) Options::setFadePlanetTrails( bVal
);
270 if ( op
== "SlewTimeScale" && dOk
) Options::setSlewTimeScale( dVal
);
271 if ( op
== "ZoomFactor" && dOk
) Options::setZoomFactor( dVal
);
272 if ( op
== "MagLimitDrawStar" && dOk
) Options::setMagLimitDrawStar( dVal
);
273 if ( op
== "MagLimitDrawDeepSky" && dOk
) Options::setMagLimitDrawDeepSky( dVal
);
274 if ( op
== "MagLimitDrawStarZoomOut" && dOk
) Options::setMagLimitDrawStarZoomOut( dVal
);
275 if ( op
== "MagLimitDrawDeepSkyZoomOut" && dOk
) Options::setMagLimitDrawDeepSkyZoomOut( dVal
);
276 if ( op
== "MagLimitDrawStarInfo" && dOk
) Options::setMagLimitDrawStarInfo( dVal
);
277 if ( op
== "MagLimitHideStar" && dOk
) Options::setMagLimitHideStar( dVal
);
278 if ( op
== "MagLimitAsteroid" && dOk
) Options::setMagLimitAsteroid( dVal
);
279 if ( op
== "MagLimitAsteroidName" && dOk
) Options::setMagLimitAsteroidName( dVal
);
280 if ( op
== "MaxRadCometName" && dOk
) Options::setMaxRadCometName( dVal
);
282 //these three are a "radio group"
283 if ( op
== "UseLatinConstellationNames" && bOk
) {
284 Options::setUseLatinConstellNames( true );
285 Options::setUseLocalConstellNames( false );
286 Options::setUseAbbrevConstellNames( false );
288 if ( op
== "UseLocalConstellationNames" && bOk
) {
289 Options::setUseLatinConstellNames( false );
290 Options::setUseLocalConstellNames( true );
291 Options::setUseAbbrevConstellNames( false );
293 if ( op
== "UseAbbrevConstellationNames" && bOk
) {
294 Options::setUseLatinConstellNames( false );
295 Options::setUseLocalConstellNames( false );
296 Options::setUseAbbrevConstellNames( true );
299 map()->forceUpdate();
302 void KStars::setColor( const QString name
, const QString value
) {
303 ColorScheme
*cs
= data()->colorScheme();
304 if ( cs
->hasColorNamed( name
) ) {
305 cs
->setColor( name
, value
);
306 map()->forceUpdate();
310 void KStars::loadColorScheme( const QString _name
) {
311 QString
name( _name
);
312 QString filename
= name
.lower().stripWhiteSpace();
315 //Parse default names which don't follow the regular file-naming scheme
316 if ( name
== i18n("use default color scheme", "Default Colors") ) filename
= "default.colors";
317 if ( name
== i18n("use 'star chart' color scheme", "Star Chart") ) filename
= "chart.colors";
318 if ( name
== i18n("use 'night vision' color scheme", "Night Vision") ) filename
= "night.colors";
320 //Try the filename if it ends with ".colors"
321 if ( filename
.endsWith( ".colors" ) )
322 ok
= data()->colorScheme()->load( filename
);
324 //If that didn't work, try assuming that 'name' is the color scheme name
325 //convert it to a filename exactly as ColorScheme::save() does
327 if ( !filename
.isEmpty() ) {
328 for( unsigned int i
=0; i
<filename
.length(); ++i
)
329 if ( filename
.at(i
)==' ' ) filename
.replace( i
, 1, "-" );
331 filename
= filename
.append( ".colors" );
332 ok
= data()->colorScheme()->load( filename
);
335 if ( ! ok
) kdDebug() << i18n( "Unable to load color scheme named %1. Also tried %2." ).arg( name
).arg( filename
);
339 map()->setStarColorMode( data()->colorScheme()->starColorMode() );
340 map()->setStarColorIntensity( data()->colorScheme()->starColorIntensity() );
342 //set the application colors for the Night Vision scheme
343 if ( Options::darkAppColors() == false && filename
== "night.colors" ) {
344 Options::setDarkAppColors( true );
345 OriginalPalette
= QApplication::palette();
346 QApplication::setPalette( DarkPalette
, true );
349 if ( Options::darkAppColors() && filename
!= "night.colors" ) {
350 Options::setDarkAppColors( false );
351 QApplication::setPalette( OriginalPalette
, true );
354 map()->forceUpdate();
358 void KStars::exportImage( const QString url
, int w
, int h
) {
359 //If the filename string contains no "/" separators, assume the
360 //user wanted to place a file in their home directory.
362 if ( ! url
.contains( "/" ) ) fileURL
= QDir::homeDirPath() + "/" + url
;
367 tmpfile
.setAutoDelete(true);
369 QPixmap
skyimage( map()->width(), map()->height() );
370 QPixmap
outimage( w
, h
);
373 if ( fileURL
.isValid() ) {
374 if ( fileURL
.isLocalFile() ) {
375 fname
= fileURL
.path();
377 fname
= tmpfile
.name();
380 //Determine desired image format from filename extension
381 QString ext
= fname
.mid( fname
.findRev(".")+1 );
382 const char* format
= "PNG";
383 if ( ext
.lower() == "png" ) { format
= "PNG"; }
384 else if ( ext
.lower() == "jpg" || ext
.lower() == "jpeg" ) { format
= "JPG"; }
385 else if ( ext
.lower() == "gif" ) { format
= "GIF"; }
386 else if ( ext
.lower() == "pnm" ) { format
= "PNM"; }
387 else if ( ext
.lower() == "bmp" ) { format
= "BMP"; }
388 else { kdWarning() << i18n( "Could not parse image format of %1; assuming PNG." ).arg( fname
) << endl
; }
390 map()->exportSkyImage( &skyimage
);
391 kapp
->processEvents(10000);
393 //skyImage is the size of the sky map. The requested image size is w x h.
394 //If w x h is smaller than the skymap, then we simply crop the image.
395 //If w x h is larger than the skymap, pad the skymap image with a white border.
396 if ( w
== map()->width() && h
== map()->height() ) {
399 int dx(0), dy(0), sx(0), sy(0);
400 int sw(map()->width()), sh(map()->height());
401 if ( w
> map()->width() ) {
402 dx
= (w
- map()->width())/2;
404 sx
= (map()->width() - w
)/2;
407 if ( h
> map()->height() ) {
408 dy
= (h
- map()->height())/2;
410 sy
= (map()->height() - h
)/2;
414 bitBlt( &outimage
, dx
, dy
, &skyimage
, sx
, sy
, sw
, sh
);
417 if ( ! outimage
.save( fname
, format
) ) kdDebug() << i18n( "Error: Unable to save image: %1 " ).arg( fname
) << endl
;
418 else kdDebug() << i18n( "Image saved to file: %1" ).arg( fname
) << endl
;
420 if ( tmpfile
.name() == fname
) { //attempt to upload image to remote location
421 if ( ! KIO::NetAccess::upload( tmpfile
.name(), fileURL
, this ) ) {
422 QString message
= i18n( "Could not upload image to remote location: %1" ).arg( fileURL
.prettyURL() );
423 KMessageBox::sorry( 0, message
, i18n( "Could not upload file" ) );
429 void KStars::printImage( bool usePrintDialog
, bool useChartColors
) {
430 KPrinter
printer( true, QPrinter::HighResolution
);
431 printer
.setFullPage( false );
433 //Set up the printer (either with the Print Dialog,
434 //or using the default settings)
436 if ( usePrintDialog
)
437 ok
= printer
.setup( this, i18n("Print Sky") );
439 ok
= printer
.autoConfigure();
442 kapp
->setOverrideCursor( waitCursor
);
444 //Save current colorscheme and switch to Star Chart colors
447 if ( useChartColors
) {
448 cs
.copy( * data()->colorScheme() );
449 loadColorScheme( "chart.colors" );
452 map()->setMapGeometry();
453 map()->exportSkyImage( &printer
);
455 //Restore old color scheme if necessary
456 //(if printing was aborted, the colorscheme is still restored)
457 if ( useChartColors
) {
458 data()->colorScheme()->copy( cs
);
460 // restore colormode and colorintensity in skymap
461 map()->setStarColorMode( cs
.starColorMode() );
462 map()->setStarColorIntensity( cs
.starColorIntensity() );
463 map()->forceUpdate();
466 kapp
->restoreOverrideCursor();
470 void KStars::startINDI (QString deviceName
, bool useLocal
)
475 if (!indidriver
|| !indimenu
)
477 kdDebug() << "establishINDI() failed." << endl
;
481 QListViewItem
*driverItem
= NULL
;
482 driverItem
= indidriver
->localListView
->findItem(deviceName
, 0);
483 if (driverItem
== NULL
)
485 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
489 // If device is already running, we need to shut it down first
490 if (indidriver
->isDeviceRunning(deviceName
))
492 indidriver
->localListView
->setSelected(driverItem
, true);
493 indidriver
->processDeviceStatus(1);
496 // Set custome label for device
497 indimenu
->setCustomLabel(deviceName
);
499 indidriver
->localListView
->setSelected(driverItem
, true);
501 // Start it either locally or as series
503 indidriver
->localR
->setChecked(true);
505 indidriver
->serverR
->setChecked(true);
508 indidriver
->processDeviceStatus(0);
512 void KStars::shutdownINDI (QString deviceName
)
514 if (!indidriver
|| !indimenu
)
516 kdDebug() << "establishINDI() failed." << endl
;
520 QListViewItem
*driverItem
= NULL
;
521 driverItem
= indidriver
->localListView
->findItem(deviceName
, 0);
522 if (driverItem
== NULL
)
524 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
528 indidriver
->processDeviceStatus(1);
533 void KStars::switchINDI(QString deviceName
, bool turnOn
)
538 if (!indidriver
|| !indimenu
)
540 kdDebug() << "switchINDI: establishINDI() failed." << endl
;
544 dev
= indimenu
->findDevice(deviceName
);
546 dev
= indimenu
->findDeviceByLabel(deviceName
);
549 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
553 if (turnOn
&& dev
->isOn() || (!turnOn
&& !dev
->isOn()))
556 prop
= dev
->findProp("CONNECTION");
567 void KStars::setINDIPort(QString deviceName
, QString port
)
573 if (!indidriver
|| !indimenu
)
575 kdDebug() << "setINDIPort: establishINDI() failed." << endl
;
579 dev
= indimenu
->findDevice(deviceName
);
581 dev
= indimenu
->findDeviceByLabel(deviceName
);
584 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
588 prop
= dev
->findProp("DEVICE_PORT");
591 el
= prop
->findElement("PORT");
596 el
->write_w
->setText(port
);
603 void KStars::setINDITargetCoord(QString deviceName
, double RA
, double DEC
)
609 if (!indidriver
|| !indimenu
)
611 kdDebug() << "setINDITarget: establishINDI() failed." << endl
;
615 dev
= indimenu
->findDevice(deviceName
);
617 dev
= indimenu
->findDeviceByLabel(deviceName
);
620 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
624 prop
= dev
->findProp("EQUATORIAL_EOD_COORD");
627 el
= prop
->findElement("RA");
629 if (!el
->write_w
) return;
631 el
->write_w
->setText(QString("%1").arg(RA
));
633 el
= prop
->findElement("DEC");
635 if (!el
->write_w
) return;
637 el
->write_w
->setText(QString("%1").arg(DEC
));
644 void KStars::setINDITargetName(QString deviceName
, QString objectName
)
650 if (!indidriver
|| !indimenu
)
652 kdDebug() << "setINDITarget: establishINDI() failed." << endl
;
656 SkyObject
*target
= data()->objectNamed( objectName
);
659 dev
= indimenu
->findDevice(deviceName
);
661 dev
= indimenu
->findDeviceByLabel(deviceName
);
664 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
668 prop
= dev
->findProp("EQUATORIAL_EOD_COORD");
671 el
= prop
->findElement("RA");
673 if (!el
->write_w
) return;
675 el
->write_w
->setText(QString("%1").arg(target
->ra()->Hours()));
677 el
= prop
->findElement("DEC");
679 if (!el
->write_w
) return;
681 el
->write_w
->setText(QString("%1").arg(target
->dec()->Degrees()));
688 void KStars::setINDIAction(QString deviceName
, QString action
)
693 if (!indidriver
|| !indimenu
)
695 kdDebug() << "setINDIAction: establishINDI() failed." << endl
;
699 dev
= indimenu
->findDevice(deviceName
);
701 dev
= indimenu
->findDeviceByLabel(deviceName
);
704 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
708 el
= dev
->findElem(action
);
711 el
->pp
->activateSwitch(action
);
716 void KStars::waitForINDIAction(QString deviceName
, QString action
)
723 if (!indidriver
|| !indimenu
)
725 kdDebug() << "waitForINDIAction: establishINDI() failed." << endl
;
729 dev
= indimenu
->findDevice(deviceName
);
731 dev
= indimenu
->findDeviceByLabel(deviceName
);
734 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
738 prop
= dev
->findProp(action
);
742 el
= dev
->findElem(action
);
745 QObject::connect(el
->pp
, SIGNAL(okState()), this, SLOT(resumeDCOP(void )));
748 QObject::connect(prop
, SIGNAL(okState()), this, SLOT(resumeDCOP(void )));
750 kapp
->dcopClient()->suspend();
755 void KStars::setINDIFocusSpeed(QString deviceName
, QString action
)
757 if (!indidriver
|| !indimenu
)
759 kdDebug() << "setINDIFocusSpeed: establishINDI() failed." << endl
;
763 setINDIAction(deviceName
, action
);
768 void KStars::startINDIFocus(QString deviceName
, int focusDir
)
770 if (!indidriver
|| !indimenu
)
772 kdDebug() << "setINDIFocusSpeed: establishINDI() failed!" << endl
;
777 setINDIAction(deviceName
, "FOCUS_IN");
778 else if (focusDir
== 1)
779 setINDIAction(deviceName
, "FOCUS_OUT");
784 void KStars::setINDIGeoLocation(QString deviceName
, double longitude
, double latitude
)
791 if (!indidriver
|| !indimenu
)
793 kdDebug() << "setINDIGeoLocation: establishINDI() failed." << endl
;
797 dev
= indimenu
->findDevice(deviceName
);
799 dev
= indimenu
->findDeviceByLabel(deviceName
);
802 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
806 prop
= dev
->findProp("GEOGRAPHICAL_COORD");
809 el
= prop
->findElement("LONG");
811 if (!el
->write_w
) return;
813 el
->write_w
->setText(QString("%1").arg(longitude
));
815 el
= prop
->findElement("LAT");
817 if (!el
->write_w
) return;
819 el
->write_w
->setText(QString("%1").arg(latitude
));
826 void KStars::setINDIFocusTimeout(QString deviceName
, int timeout
)
832 if (!indidriver
|| !indimenu
)
834 kdDebug() << "startINDIFocus: establishINDI() failed." << endl
;
838 dev
= indimenu
->findDevice(deviceName
);
840 dev
= indimenu
->findDeviceByLabel(deviceName
);
843 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
847 prop
= dev
->findProp("FOCUS_TIMEOUT");
851 el
= prop
->findElement("TIMEOUT");
855 el
->write_w
->setText(QString("%1").arg(timeout
));
857 el
->spin_w
->setValue(timeout
);
864 void KStars::startINDIExposure(QString deviceName
, int timeout
)
870 if (!indidriver
|| !indimenu
)
872 kdDebug() << "startINDIExposure: establishINDI() failed." << endl
;
876 dev
= indimenu
->findDevice(deviceName
);
878 dev
= indimenu
->findDeviceByLabel(deviceName
);
881 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
885 prop
= dev
->findProp("EXPOSE_DURATION");
888 el
= prop
->findElement("EXPOSE_S");
892 el
->write_w
->setText(QString("%1").arg(timeout
));
894 el
->spin_w
->setValue(timeout
);
901 void KStars::setINDIFilterNum(QString deviceName
, int filter_num
)
907 if (!indidriver
|| !indimenu
)
909 kdDebug() << "setINDIFilterNum: establishINDI() failed." << endl
;
913 dev
= indimenu
->findDevice(deviceName
);
915 dev
= indimenu
->findDeviceByLabel(deviceName
);
918 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
922 prop
= dev
->findProp("FILTER_CONF");
925 el
= prop
->findElement("FILTER_NUM");
929 el
->write_w
->setText(QString("%1").arg(filter_num
));
931 el
->spin_w
->setValue(filter_num
);
937 void KStars::setINDIUTC(QString deviceName
, QString UTCDateTime
)
943 if (!indidriver
|| !indimenu
)
945 kdDebug() << "startINDIUTC: establishINDI() failed." << endl
;
949 dev
= indimenu
->findDevice(deviceName
);
951 dev
= indimenu
->findDeviceByLabel(deviceName
);
954 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
958 prop
= dev
->findProp("TIME");
961 el
= prop
->findElement("UTC");
963 if (!el
->write_w
) return;
965 el
->write_w
->setText(UTCDateTime
);
971 void KStars::setINDIScopeAction(QString deviceName
, QString action
)
973 setINDIAction(deviceName
, action
);
976 void KStars::setINDIFrameType(QString deviceName
, QString type
)
978 setINDIAction(deviceName
, type
);
981 void KStars::setINDICCDTemp(QString deviceName
, int temp
)
987 if (!indidriver
|| !indimenu
)
989 kdDebug() << "setINDICCDTemp: establishINDI() failed." << endl
;
993 dev
= indimenu
->findDevice(deviceName
);
995 dev
= indimenu
->findDeviceByLabel(deviceName
);
998 kdDebug() << "Device " << deviceName
<< " not found!" << endl
;
1002 prop
= dev
->findProp("CCD_TEMPERATURE");
1005 el
= prop
->findElement("TEMPERATURE");
1009 el
->write_w
->setText(QString("%1").arg(temp
));
1010 else if (el
->spin_w
)
1011 el
->spin_w
->setValue(temp
);