Deselect of objects not working

Asked by Ian Hargraves

I have a large script that I am preparing for a public observing meeting.

I do several tours of the night sky and in one of these I select and highlight each visible constellation by using StelMovementMgr,autoZoomin() and StelMovementMgr.autoZoomOut() functions as follows:

StelMovementMgr.autoZoomIn(5);
core.wait(1);
StelMovementMgr.zoomTo(ZoomInLvl,moveDuration=5);
core.wait(5);
StelMovementMgr.autoZoomOut(5);
core.wait(1);
StelMovementMgr.zoomTo(ZoomOutLvl,moveDuration=5);
core.wait(7);

I use the zoomTo function to prevent the autoZoomIn going too far.

After this I use the following sequence to allow me to turn the constellation art etc off before highlighting another constellation.

// turn off constellation
ConstellationMgr.setFlagIsolateSelected(false);
ConstellationMgr.setFlagArt(false);
ConstellationMgr.setFlagLines(true);
// appear to need this to force the deselection of all the other previously selected objects
core.selectObjectByName("Pluto", true);

However after using theAutoZoomIn() functon I cannot deselect the object and so the view tracks round with the night sky which is not what I want to do.

How do I deselect all objects so that the view no longer tracks the movement of the sky due to Earth's rotation?

Thanks
Ian

Question information

Language:
English Edit question
Status:
Solved
For:
Stellarium Edit question
Assignee:
No assignee Edit question
Solved by:
Ian Hargraves
Solved:
Last query:
Last reply:
Revision history for this message
Alexander Wolf (alexwolf) said :
#1
Revision history for this message
Khalid AlAjaji (kajaji) said :
#2

There are two options:

1.
core.clear("starchart"); // will keep the sky view constant, similar to using ctrl+M to swich between equatorial and azimuthal mount (the telescope button in the lower bar)

2.
To deselect all objects, switch to another sky culture then back to western. For example:
core.setSkyCulture("inuit")

.
.
core.setSkyCulture("western")

Revision history for this message
Ian Hargraves (ihargraves) said :
#3

Hi Khalid,
I have been playing around with the various fixes suggested by you and Alex and none of them seem to fix the problem.

I was under the impression that either the core.selectObjectByName("") should work or at least by using your suggested switch of sky cultures that this a should clear the problem.

Is there a way that I can send you a 500 line script to look at? It is well structured using function calls and I will give you a guide to what is going wrong with it.

Thanks
Ian

Revision history for this message
Ian Hargraves (ihargraves) said :
#4

Hi Khalid,
Sorry, I used the wrong response button, so here it is again.

I have been playing around with the various fixes suggested by you and Alex and none of them seem to fix the problem.

I was under the impression that either the core.selectObjectByName("") should work or at least by using your suggested switch of sky cultures that this a should clear the problem.

Is there a way that I can send you a 500 line script to look at? It is well structured using function calls and I will give you a guide to what is going wrong with it.

Thanks
Ian

Revision history for this message
Ian Hargraves (ihargraves) said :
#5

Hi,
Here is a minimised script that reproduces the problem.

The main part of the program is at the foot of the listing;
1) It initialises Stellarium and theobservers location and telescope to altaz;

2) Then it calls the function SpinProcession(SGLSunsetTime,SGLObserveTime) which sets the view and then sets the time rate to 1000 to watch the stars process across the sky using Khalid's WaitUntil function;

3) Then it calls DispConstellation twice once with Orion and then with Cetus. Each time the function is called it isolates the constellation, displays the isolated constellation art and then deselects the constellation and deletes the constellation art.

4) Then SpinProcession is called a second time.

There are two POSSIBLE bugs highlighted here:

Bug 1) The ConstellationMgr.setFlagArt(false) does not remove the flag art unless I do a core-selectObjectByName using Pluto or HP44504 or something similar;

Bug 2) When I first run the script in a newly launched instance of Stellarium the first call to SpinProcession results in the expected behaviour with the stars processing and the mount stationary due south. Then following one or two calls to DispConstellation the next call to SpinProcession results in the mount tracking the sky.

If the two calls to DispConstellation are commented out then the two calls to SpinProcession work OK but only if Stellarium is relaunched.

The problem is that I want to be able to loop the full script indefinitely all night for an unattended sky show.

Sorry its so long but I could not shorten it any more without generating loads of parsing errors etc.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Debugging sky stracking problem

//===============================================================================
// Name: waituntil alternative to core.waitfor function which does not work any more
// License: Public Domain
// Author: Khalid AlAjaji with accuracy mods by Ian Hargraves
// Description: example
//===============================================================================
function WaitUntil(jd)
{
var minFPS=0.0;

tr = core.getTimeRate(); //get time rate

if (tr!=0)
{ //only wait if tr <>0
//core.debug("tr not equal to 0");
minFPS = core.getMinFps();

//core.debug(minFPS);
//speed up the core to minimise timing inaccuracies
core.setMinFps(1000);

var dfTimeNow = 0;

if (tr > 0)
   {
   do
      {
      dfTimeNow = core.getJDay();
      }
   while( dfTimeNow < jd); // let time go by
   }
else
   {
   do
      {
      dfTimeNow = core.getJDay();
      }
   while( dfTimeNow > jd); // let time go by
   }

//restore original core speed to save processor power
core.setMinFps(minFPS);
} //only run the function if tr <>0
} // end of WaitUntil()
//===============================================================================

//===============================================================================
// Name: Display constellation function
// License: copyright Ian Hargraves 2012
// Author: Ian Hargraves
// Description: Displays named constellation art and zooms to it then turns it off afterwards
//
// ConstNamestr = name of constellation to display, ConstDescstr = additional description string
// ZoomLvl = numeric level to zoom in to for each constellation
// ZoomOutLvl = numeric level to zoom back out to
//===============================================================================

function DispConstellation(ConstNamestr,ConstDescstr,ZoomInLvl,ZoomOutLvl)
{
Strid = LabelMgr.labelScreen("The constellation of " + ConstNamestr + " " + ConstDescstr, ScrnWide*0.025,ScrnHigh*0.95, false, 26);

LabelMgr.setLabelShow(Strid, true);

core.selectObjectByName(ConstNamestr, false);

ConstellationMgr.setFlagIsolateSelected(true);
ConstellationMgr.setFlagLines(true);
ConstellationMgr.setFlagArt(true);

StelMovementMgr.autoZoomIn(5);
core.wait(1);

StelMovementMgr.zoomTo(ZoomInLvl,moveDuration=5);
core.wait(5);
StelMovementMgr.autoZoomOut(5);
core.wait(1);
StelMovementMgr.zoomTo(ZoomOutLvl,moveDuration=5);
core.wait(7);

LabelMgr.setLabelShow(Strid, false);

// turn off constellation
ConstellationMgr.setFlagIsolateSelected(false);
ConstellationMgr.setFlagArt(false);
ConstellationMgr.setFlagLines(true);

// need to select Pluto to force the deselection of all the other previously selected objects
core.selectObjectByName("HP44504"); // this is just a star which is NOT part of a constellation line

//core.selectObjectByName("Pluto", false);
core.selectObjectByName("");

}//end DispConstellation()
//===============================================================================

//===============================================================================
// INITIALISATION SEQUENCE (Location, mount and zoom setup)
//===============================================================================
function InitObserver(InitTime)
{
core.setJDay(InitTime);//Set display to reasonable time of night
core.wait(1);
// set up SGL event location
core.debug("setLocation");
core.setObserverLocation(1.1,51.25,0,duration=1);

// make sure mount is in alt-az mode
core.setMountMode("azimuthal");

// dont track the objects
StelMovementMgr.setFlagTracking(false);
core.selectObjectByName("", false);

}//end InitObserver()

//===============================================================================
// SGL Spin Procession of the stars (Initilase due south at sunset)
//===============================================================================
function SpinProcession(ProcessStartTime,ProcessEndTime)
{
StelMovementMgr.setFlagTracking(false);
LandscapeMgr.setFlagAtmosphere(true);
core.setJDay(ProcessStartTime); // Set display to reasonable time of night
core.wait(1);

// point 40 degrees alt due south to start with on first night
core.debug("Move to 40, 180")
core.moveToAltAzi(40,180,duration=3);
core.debug("move to 40,180");
core.wait(5);
StelMovementMgr.zoomTo(95,moveDuration=5);
core.wait(2);

core.setTimeRate(1000);
WaitUntil(ProcessEndTime);
core.setTimeRate(0);
core.setJDay(ProcessEndTime); // corrects any overshoot

LabelMgr.setLabelShow(SpinProcessionTitleid, false);
core.wait(1);
LandscapeMgr.setFlagAtmosphere(false);

}//end SpinProcession()

//========================================================================================

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Main Program sequence
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

//set SGLSunsetTime
core.setDate("2013-01-08T16:00:00","utc");
SGLSunsetTime = core.getJDay();

core.setDate("2013-01-08T20:00:00","utc");
SGLObserveTime = core.getJDay();

//set SGLSunriseTime
core.setDate("2013-01-09T08:00:00","utc");
SGLSunriseTime = core.getJDay();

id = LabelMgr.deleteAllLabels();
ScrnHigh=core.getScreenHeight();
ScrnWide=core.getScreenWidth();

InitObserver(SGLObserveTime);
GuideTitleid=LabelMgr.labelScreen("Debugging Sky Tracking", ScrnWide*0.2,ScrnHigh*0.05, false, 40);
SpinProcessionTitleid = LabelMgr.labelScreen("Procession of the stars from dusk to dawn tonight.", ScrnWide*0.2,ScrnHigh*0.05, false, 40);

ConstellationMgr.setFlagLines(true);
// Initialise display start time to sunset
core.setJDay(SGLObserveTime);

LabelMgr.setLabelShow(GuideTitleid, true);
core.wait(3);
LabelMgr.setLabelShow(GuideTitleid,false);

SpinProcession(SGLSunsetTime,SGLObserveTime); //change to SGLSunriseTime when debugged

// Debuggng call to dispconstellation
DispConstellation("Orion","the hunter containing M42 the Great Orion Nebula",45,95);
DispConstellation("Cetus","the whale, tonight without the variable star 'Mira the wonderful'",60,95);

core.setSkyCulture("inuit");
core.setSkyCulture("western");
core.clear("starchart");
core.clear("natural");
ConstellationMgr.setFlagLines(true);

SpinProcession(SGLSunsetTime,SGLObserveTime); //change to SGLSunriseTime when debugged

core.setMinFps(10);

Revision history for this message
Khalid AlAjaji (kajaji) said :
#6

Hi Ian,
The script works for me if I remove all StelMovementMgr.setFlagTracking(false); and add one in the DispConstellation function after the autozoomin call.

My modification are marked with ***

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Debugging sky stracking problem

//===============================================================================
// Name: waituntil alternative to core.waitfor function which does not work any more
// License: Public Domain
// Author: Khalid AlAjaji with accuracy mods by Ian Hargraves
// Description: example
//===============================================================================
function WaitUntil(jd)
{
var minFPS=0.0;

tr = core.getTimeRate(); //get time rate

if (tr!=0)
{ //only wait if tr <>0
//core.debug("tr not equal to 0");
minFPS = core.getMinFps();

//core.debug(minFPS);
//speed up the core to minimise timing inaccuracies
core.setMinFps(1000);

var dfTimeNow = 0;

if (tr > 0)
   {
   do
      {
      dfTimeNow = core.getJDay();
      }
   while( dfTimeNow < jd); // let time go by
   }
else
   {
   do
      {
      dfTimeNow = core.getJDay();
      }
   while( dfTimeNow > jd); // let time go by
   }

//restore original core speed to save processor power
core.setMinFps(minFPS);
} //only run the function if tr <>0
} // end of WaitUntil()
//===============================================================================

//===============================================================================
// Name: Display constellation function
// License: copyright Ian Hargraves 2012
// Author: Ian Hargraves
// Description: Displays named constellation art and zooms to it then turns it off afterwards
//
// ConstNamestr = name of constellation to display, ConstDescstr = additional description string
// ZoomLvl = numeric level to zoom in to for each constellation
// ZoomOutLvl = numeric level to zoom back out to
//===============================================================================

function DispConstellation(ConstNamestr,ConstDescstr,ZoomInLvl,ZoomOutLvl)
{
Strid = LabelMgr.labelScreen("The constellation of " + ConstNamestr + " " + ConstDescstr, ScrnWide*0.025,ScrnHigh*0.95, false, 26);

LabelMgr.setLabelShow(Strid, true);

core.selectObjectByName(ConstNamestr, false);

ConstellationMgr.setFlagIsolateSelected(true);
ConstellationMgr.setFlagLines(true);
ConstellationMgr.setFlagArt(true);

StelMovementMgr.autoZoomIn(5);
core.wait(1);
StelMovementMgr.setFlagTracking(false); //*** add

StelMovementMgr.zoomTo(ZoomInLvl,moveDuration=5);
core.wait(5);
StelMovementMgr.autoZoomOut(5);
core.wait(1);
StelMovementMgr.zoomTo(ZoomOutLvl,moveDuration=5);
core.wait(7);

LabelMgr.setLabelShow(Strid, false);

// turn off constellation
ConstellationMgr.setFlagIsolateSelected(false);
ConstellationMgr.setFlagArt(false);
ConstellationMgr.setFlagLines(true);

// need to select Pluto to force the deselection of all the other previously selected objects
core.selectObjectByName("HP44504"); // this is just a star which is NOT part of a constellation line

//core.selectObjectByName("Pluto", false);
core.selectObjectByName("");

}//end DispConstellation()
//===============================================================================

//===============================================================================
// INITIALISATION SEQUENCE (Location, mount and zoom setup)
//===============================================================================
function InitObserver(InitTime)
{
core.setJDay(InitTime);//Set display to reasonable time of night
core.wait(1);
// set up SGL event location
core.debug("setLocation");
core.setObserverLocation(1.1,51.25,0,duration=1);

// make sure mount is in alt-az mode
core.setMountMode("azimuthal");

// dont track the objects
//StelMovementMgr.setFlagTracking(false); *** remove
core.selectObjectByName("", false);

}//end InitObserver()

//===============================================================================
// SGL Spin Procession of the stars (Initilase due south at sunset)
//===============================================================================
function SpinProcession(ProcessStartTime,ProcessEndTime)
{
//StelMovementMgr.setFlagTracking(false); *** remove
LandscapeMgr.setFlagAtmosphere(true);
core.setJDay(ProcessStartTime); // Set display to reasonable time of night
core.wait(1);

// point 40 degrees alt due south to start with on first night
core.debug("Move to 40, 180")
core.moveToAltAzi(40,180,duration=3);
core.debug("move to 40,180");
core.wait(5);
StelMovementMgr.zoomTo(95,moveDuration=5);
core.wait(2);

core.setTimeRate(1000);
WaitUntil(ProcessEndTime);
core.setTimeRate(0);
core.setJDay(ProcessEndTime); // corrects any overshoot

LabelMgr.setLabelShow(SpinProcessionTitleid, false);
core.wait(1);
LandscapeMgr.setFlagAtmosphere(false);

}//end SpinProcession()

//========================================================================================

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Main Program sequence
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

//set SGLSunsetTime
core.setDate("2013-01-08T16:00:00","utc");
SGLSunsetTime = core.getJDay();
// *** alternatively you can use the following instead of the previous 2 lines
//SGLSunsetTime = core.jdFromDateString("2013-01-08T16:00:00","utc");

core.setDate("2013-01-08T20:00:00","utc");
SGLObserveTime = core.getJDay();

//set SGLSunriseTime
core.setDate("2013-01-09T08:00:00","utc");
SGLSunriseTime = core.getJDay();

id = LabelMgr.deleteAllLabels();
ScrnHigh=core.getScreenHeight();
ScrnWide=core.getScreenWidth();

InitObserver(SGLObserveTime);
GuideTitleid=LabelMgr.labelScreen("Debugging Sky Tracking", ScrnWide*0.2,ScrnHigh*0.05, false, 40);
SpinProcessionTitleid = LabelMgr.labelScreen("Procession of the stars from dusk to dawn tonight.", ScrnWide*0.2,ScrnHigh*0.05, false, 40);

ConstellationMgr.setFlagLines(true);
// Initialise display start time to sunset
core.setJDay(SGLObserveTime);

LabelMgr.setLabelShow(GuideTitleid, true);
core.wait(3);
LabelMgr.setLabelShow(GuideTitleid,false);

SpinProcession(SGLSunsetTime,SGLObserveTime); //change to SGLSunriseTime when debugged

// Debuggng call to dispconstellation
DispConstellation("Orion","the hunter containing M42 the Great Orion Nebula",45,95);
DispConstellation("Cetus","the whale, tonight without the variable star 'Mira the wonderful'",60,95);

//core.setSkyCulture("inuit"); *** remove
//core.setSkyCulture("western");*** remove
//core.clear("starchart");*** remove
//core.clear("natural");*** remove
ConstellationMgr.setFlagLines(true);

SpinProcession(SGLSunsetTime,SGLObserveTime); //change to SGLSunriseTime when debugged

core.setMinFps(10);

Revision history for this message
Ian Hargraves (ihargraves) said :
#7

Dear Khalid,
Thank-you so much for sorting out my scripting problem.

I have now made all of your suggested changes in my full script and it appears to be working well.

I note that I have obviously misunderstood the correct use of the StelMovementMgr.setFlagTracking(false); function call. Could you please explain when it should be used.

Also many thanks for pointing out the function core.jdFromDateString("2013-01-08T16:00:00","utc");. I have now replaced the more cumbersome scripting that I

Revision history for this message
Ian Hargraves (ihargraves) said :
#8

continued:
Also many thanks for pointing out the function core.jdFromDateString("2013-01-08T16:00:00","utc");. I have now replaced the more cumbersome scripting that I had used.

Did you have time to look at the problem that I was experiencing with turning off the constellation lines in DispConstellation. Don't worry too much about this as I am using a work round in my script.

I am very grateful for your help as it has now allowed me to get the full script working.

Regards
Ian

Revision history for this message
Khalid AlAjaji (kajaji) said :
#9

Hi Ian,

I don't think you misunderstood the correct use of the StelMovementMgr.setFlagTracking(false); function call. It looks like there is a bug somewhere in the combination of tracking and autozoomIn.

For turning off the constellation, I do not know any direct way to perform that other than what you did or alternatively switching sky cultures.

I have another implementation of the waituntil function which is simpler if you want to look at it:

// Name: WaitUntil
// License: Public Domain
// Author: Khalid AlAjaji
// Description: alternative to core.waitfor function which does not work after 0.10.4

function WaitUntil(datestring,spec)
{
//example format of datestring "2010:04:30T20:35:00", spec is ""utc" or "local"

tr = core.getTimeRate();
JD = core.jdFromDateString(datestring,spec);
if ( tr != 0 )
 {
 td = (JD-core.getJDay())*86400/tr; //td will be positive if both time differnece and time rate are negative or positive
 }
 core.debug("time rate is " + tr + " time difference is " + td);

if ((tr != 0) && (td > 0))
 {
 core.wait(td);
 }
} // end of WaitUntil()

// Sample usage

core.moveToAltAzi(25,0,2);
core.setTimeRate(50);
core.setDate("2010:04:30T20:30:00","local");
WaitUntil("2010:04:30T20:25:00","local");
core.setTimeRate(0);
// Now move view direction south and up
core.moveToAltAzi(25,180,2);

Revision history for this message
Khalid AlAjaji (kajaji) said :
#10

It looks like that I didn't get any credit for solving the question. The question status is "solved" and the solved by is "Ian Hargraves".

Revision history for this message
Ian Hargraves (ihargraves) said :
#11

Dear Khalid,
I don't know why you didn't get any credit for solving my problem for me.

You most certainly did and very rapidly as well.

I was just having a cup of coffee with a mutual friend of ours from the UK when the fix arrived.

Don't know why I would have been credited with the fix, sorry if it was anything that I did......

Regards
Ian

Revision history for this message
Khalid AlAjaji (kajaji) said :
#12

Don't worry. No problem. Enjoy the sky, coffee and friendship. They certainly make life more pleasant.