Marker labels added to Celestia 1.5

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Marker labels added to Celestia 1.5

Post #1by Vincent » 03.01.2008, 13:05

Celestia 1.5 now includes support for marker labels. This feature is already available for users who compile from CVS. Others should wait for the next (pre) release.

Adding label to markers allows users to display text information below the marker symbol:
Image

This is particularly useful when information about objects, such as name, Hubble type, ..., need to be displayed whatever the distance to the observer or the magnitude. Also, invisible objects now can be labelled using a marker.

- In Celx scripting, marker labels are added as the fifth argument of the object:mark method:

Code: Select all

venus = celestia:find("Sol/Venus")
venus:mark("red", "circle", 10, 0.7, "Planet type: Telluric")
or

Code: Select all

mw = celestia:find("Milky Way")
mw:mark("red", "circle", 10, 0.7, mw:getinfo().hubbleType)


Here's a complete example for celx scripting:

Code: Select all

-- Title: Mark and label nearby galaxies with their Hubble Type

mw = celestia:find("Milky Way")

function label_galaxy_types()
   for dso in celestia:dsos() do
      if dso:getinfo().type == "galaxy" then
         dsoPos = dso:getposition()
         mwPos = mw:getposition()
         if dsoPos:distanceto(mwPos) < 1e20 then
            hubbleType = dso:getinfo().hubbleType
            text = dso:name()..": "..hubbleType
            if string.find(hubbleType, "E") then
               dso:mark( "red", "disk", 7, 0.7, text )
            elseif string.find(hubbleType, "Irr") then
               dso:mark( "yellow", "disk", 7, 0.7, text )
            elseif string.find(hubbleType, "SB") then
               dso:mark( "green", "disk", 7, 0.7, text )
            elseif string.find(hubbleType, "S") then
               dso:mark( "blue", "disk", 7, 0.7, text )
            end
         end
      end
   end
end

celestia:unmarkall()
celestia:setrenderflags { markers = true }
label_galaxy_types()

celestia:select(mw)
celestia:getobserver():gotodistance(mw, 1e20, 10)
wait(10)


- In Cel scripting, marker labels are added using the label "xxx" field:

Code: Select all

mark { object "Sol/Mars" size 55 color [ 0 0 1 ] symbol "disk" alpha 0.7 label "Planet type: Telluric"}
Last edited by Vincent on 03.01.2008, 22:05, edited 1 time in total.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #2by ElChristou » 03.01.2008, 13:43

How long the string can be? If too long there is some auto breaks?
Image

ajtribick
Developer
Posts: 1855
Joined: 11.08.2003
With us: 21 years 3 months

Post #3by ajtribick » 03.01.2008, 13:57

Looks like I'll have to regenerate my CHARM2 marker script when the next release comes out.

Is it possible to include manual line breaks in the label?

Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #4by Vincent » 03.01.2008, 13:58

ElChristou wrote:How long the string can be? If too long there is some auto breaks?
chaos syndrome wrote:Is it possible to include manual line breaks in the label?

The string can be as long as your screen width allows... :wink:
I initially added no text layout support for marker labels, so as to keep things simple. That means that neither manual ("\n"), nor auto line breaks can be used. Of course, this can be added later, along with a new argument to specify the font to use...
Last edited by Vincent on 03.01.2008, 15:35, edited 1 time in total.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #5by ElChristou » 03.01.2008, 14:21

Vincent wrote:Of course, this can be added later, along with a new argument to specify the font to use...


I think the manual break would be welcome; now text should stay normalized to keep the coherence of Celestia display...
Image

Topic author
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Post #6by Vincent » 03.01.2008, 22:14

The field for cel scripting has been changed from 'name' to 'label':

Code: Select all

mark { object "Sol/Mars" size 55 color [ 0 0 1 ] symbol "disk" alpha 0.7 label "Planet type: Telluric"}


ElChristou wrote:I think the manual break would be welcome

Handling line breaks might be trickier than I first thought...
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #7by ElChristou » 03.01.2008, 22:19

ElChristou wrote:I think the manual break would be welcome
Handling line breaks might be trickier than I first thought...[/quote]

It's was my fear! :x
Image


Return to “Scripting”