Debian Codegraph @

Docs/README.xmlpanel.html

raw symbols SCIP
1 <HTML><HEAD><TITLE>Users Guide to FlightGear panel configuration</TITLE></HEAD>
2 <BODY>
3 <H1>Users Guide to FlightGear panel configuration</H1>
4
5 <CITE>
6 Version 0.7.7.2, July 24 2001
7 Author: John Check
8 </CITE>
9
10 <ol>
11 <li><A HREF="#history">Some History</A></li>
12 <li><A HREF="#property_manager">About The Property Manager</A></li>
13 <li><A HREF="#xml">XML and The Property Manager</A></li>
14 <li><A HREF="#load_panel">Loading Panels</A></li>
15 <li><A HREF="#window_geometry">Regarding Window Geometry</A></li>
16 <li><A HREF="#panel_architecture">Panel Architecture</A></li>
17 <li><A HREF="#example_panel">Example Top Level Panel Config</A></li>
18 <li><A HREF="#indexed_properties">Indexed Properties</A></li>
19 <li><A HREF="#inclusion">Inclusion</A></li>
20 <li><A HREF="#instrument_architecture">Instrument Architecture</A></li>
21 <li><A HREF="#textures">Textures</A></li>
22 <li><A HREF="#instrument_layers">Instrument Layers</A></li>
23 <li><A HREF="#transformations">Transformations</a></li>
24 <li><A HREF="#conditions">Conditions</A></li>
25 <li><A HREF="#needle_placement">About Transformations and Needle Placement</A></li>
26 <li><A HREF="#interpolation">Interpolation Tables</A></li>
27 <li><A HREF="#actions">Actions</A></li>
28 <li><A HREF="#more_texture">More About Textures</A></li>
29 <li><A HREF="#generating_textures">Generating Textures</A></li>
30 <li><A HREF="#contribute">Contributing Panels</A></li>
31 <li><A HREF="#units">Units</A></li>
32 </ol>
33
34 <P>
35 This document describes the configuration of
36 FlightGear flight simulator's aircraft panel display via XML.
37 The information was culled from the [email protected]
38 mailing list and my experiences making alternate panels.
39 Corrections and additions are encouraged.
40 </P>
41
42
43
44 <HR WIDTH="20%">
45 <H2><A NAME="history">Some History:</A></H2>
46 <HR WIDTH="20%">
47 <p>
48 Older versions of FGFS had a hard coded display of instruments.
49 This was a less than ideal state of affairs due to FGFS ability
50 to use different aircraft models. Being primarily developed on
51 UNIX type systems, a modular approach is taken towards the
52 simulation. To date, most alternatives to the default
53 Cessna 172 aircraft are the product of research institutions
54 interested in the flight characteristics and not cosmetics.
55 The result of this was that one could fly the X-15 or a Boeing 747
56 but be limited to C172 instrumentation.
57 </P>
58 <P>
59 A rewrite of the panel display code was done around v0.7.5 by
60 developer David Megginson allowing for configuration of the panel
61 via XML to address this limitation. Some major changes and additions
62 were made during the course of version 0.7.7 necessitating a rewrite
63 and expansion of this document.
64 </P>
65
66
67 <HR WIDTH="20%">
68 <H2><A NAME="property_manager">About The Property Manager:</A></H2>
69 <HR WIDTH="20%">
70 <p>
71 While intimate knowledge of the property manager is unnecessary to create
72 aircraft panels, some familiarity with the concept is required.
73 FlightGear provides a hierarchical representation of all aspects of
74 the state of the running simulation that is known as the property tree.
75 Some properties, such as velocities, are read only. Others such as the frequencies to which the navcom radios are tuned or the position of control surfaces
76 can be set by various means.
77 </P>
78 <P>
79 FlightGear can optionally provide an interface to these properties for external
80 applications such as Atlas, the moving map program, or even lowly telnet via
81 a network socket. Data can even be routed to a serial port and connected to
82 say, a GPS receiver.
83 Aside from its usefulness in a flight training context, being able to manipulate
84 the property tree on a running copy of FG allows for switching components on the fly,
85 a positive boon for panel authors.
86 To see the property tree start FG with the following command line:
87 </P>
88
89 <PRE>
90 fgfs --props=socket,bi,5,localhost,5500,tcp
91 </PRE>
92 <br>
93
94 <P>
95 Then use telnet to connect to localhost on port 5500. You can browse the
96 tree as you would a filesystem.
97 </P>
98
99 <HR WIDTH="20%">
100 <H2><A NAME="xml">XML And The Property Manager:</A></H2>
101 <HR WIDTH="20%">
102 <p>
103 Panel instruments interface with the property tree to get/set values as
104 appropriate. Properties for which FG doesn't yet provide a value can be
105 created by simply making them up. Values can be adjusted using the telnet
106 interface allowing for creation and testing of instruments while code to
107 drive them is being developed.
108 </P>
109 <P>
110 If fact, the XML configuration system allows a user to combine
111 components such as flight data model, aircraft exterior model,
112 heads up display, and of course control panel. Furthermore,
113 such a preconfigured aircraft.xml can be included into a scenario
114 with specific flight conditions. These can be manually specified or
115 a FG session can be saved and/or edited and reloaded later. Options specified
116 in these files can be overridden on the command line. For example:
117 </P>
118
119 <PRE>
120 --prop:/sim/panel/path=Aircraft/c172/Panels/c172-panel.xml
121 </PRE>
122 <br>
123
124 <P>
125 passed as an option, would override a panel specified elsewhere.
126 Property tree options all have the same format, specify the node
127 and supply it a value.
128 </P>
129 <p>
130 The order of precedence for options is thus:
131 </p>
132
133 <pre>
134 Source Location Format
135 ------ -------- ------
136 command line
137 .fgfsrc ~/ command line options
138 system.fgfsrc $FG_ROOT "" ""
139 preferences.xml $FG_ROOT XML property list
140 </pre>
141 <br>
142
143
144
145 <HR WIDTH="20%">
146 <H2><A NAME="load_panel">Loading Panels on the fly:</A></H2>
147 <HR WIDTH="20%">
148 <p>
149 When editing a panel configuration, pressing Shift +F3 will reload the
150 panel. If your changes don't seem to be taking effect, check the console output.
151 It will report the success or failure of the panel reload*. Editing textures requires
152 restarting FGFS so the new textures can be loaded. Panels can be switched on the fly
153 by setting the /sim/panel/path property value and reloading.
154 </P>
155
156
157
158 <HR WIDTH="20%">
159 <H2><A NAME="window_geometry">Regarding Window Geometry:</A></H2>
160 <HR WIDTH="20%">
161 <p>
162 For the sake of simplicity the FGFS window is always considered to be 1024x768
163 so all x/y values for instrument placement should relative to these dimensions.
164 Since FG uses OpenGL 0,0 represents the lower left hand corner of the
165 screen. Panels may have a virtual size larger than 1024x768. Vertical scrolling is accomplished
166 with Shift+F5/F6. Horizontal scrolling is via Shift+F7/F8. An offset should be supplied
167 to set the default visible area. It is possible to place items to overlap the 3D viewport.
168 </p>
169
170 <HR WIDTH="20%">
171 <H2><A NAME="panel_architecture">Panel Architecture:</A></H2>
172 <HR WIDTH="20%">
173 <p>
174 All of the panel configuration files are XML-encoded* property lists.
175 The root element of each file is always named &lt;PropertyList&gt;. Tags are
176 almost always found in pairs, with the closing tag having a slash prefixing
177 the tag name, i.e &lt;/PropertyList&gt;. The exception is the tag representing an aliased
178 property. In this case a slash is prepended to the closing angle bracket.
179 (see section Aliasing)
180 Properties must have units specified where appropriate. See section "Units"
181 at the end of this doc.
182 </P>
183 <P>
184 The top level panel configuration file is composed of a &lt;name&gt;, a &lt;background&gt;
185 texture and zero or more &lt;instruments&gt;.
186 </P>
187 <p>
188 [ Paths are relative to $FG_ROOT ( the installed location of FGFS data files ). ]<br>
189 [ Absolute paths may be used. Comments are bracketed with &lt;!-- --&gt;. ]
190 </p>
191 <HR WIDTH="20%">
192 <H2><A NAME="example_panel">Example Top Level Panel Config:</A></H2>
193 <HR WIDTH="20%">
194 <p>
195 <PRE>
196 &lt;PropertyList&gt;
197 &lt;name&gt;Example Panel&lt;/name&gt;
198 &lt;background&gt;Aircraft/c172/Panels/Textures/panel-bg.rgb&lt;/background&gt;
199 &lt;w&gt;1024&lt;/w&gt; &lt;!-- virtual width --&gt;
200 &lt;h&gt;768&lt;/h&gt; &lt;!-- virtual height --&gt;
201 &lt;y-offset&gt;-305&lt;/y-offset&gt; &lt;!-- hides the bottom part --&gt;
202 &lt;view-height&gt;172&lt;/view-height&gt; &lt;!-- amount of overlap between 2D panel and 3D viewport --&gt;
203
204 &lt;instruments&gt;
205
206 &lt;instrument include="../Instruments/clock.xml"&gt;
207 &lt;name&gt;Chronometer&lt;/name&gt; &lt;!-- currently optional but strongly recommended --&gt;
208 &lt;x&gt;150&lt;/x&gt; &lt;!-- required horizontal placement --&gt;
209 &lt;y&gt;645&lt;/y&gt; &lt;!-- required vertical placement --&gt;
210 &lt;w&gt;72&lt;/w&gt; &lt;!-- optional width specification --&gt;
211 &lt;h&gt;72&lt;/h&gt; &lt;!-- optional height specification --&gt;
212 &lt;/instrument&gt;
213
214 &lt;/instruments&gt;
215
216 &lt;/PropertyList&gt;
217 </PRE>
218 <BR>
219
220
221 <HR WIDTH="20%">
222 <H2><A NAME="indexed_properties">Indexed Properties:</A></H2>
223 <HR WIDTH="20%">
224 <p>
225 The property manager assigns incremental indices to repeated
226 properties with the same parent node, so that
227 </P>
228 <PRE>
229 &lt;PropertyList&gt;
230 &lt;x&gt;1&lt;/x&gt;
231 &lt;x&gt;2&lt;/x&gt;
232 &lt;x&gt;3&lt;/x&gt;
233 &lt;/PropertyList&gt;
234 </PRE><BR>
235 <p>
236 shows up as
237 </P>
238 <PRE>
239 /x[0] = 1
240 /x[1] = 2
241 /x[2] = 3
242 </PRE><BR>
243 <p>
244 In fact, the panel I/O code insists that every instrument have the XML element
245 name "instrument", every layer have the name "layer", every text chunk have the
246 name
247
248 "chunk", every action have the name "action", and every transformation
249 have the name "transformation" -- this makes the XML more regular (so
250 that it can be created in a DTD-driven tool) and also allows us to
251 include other kinds of information (such as doc strings) in the lists
252 without causing confusion.
253 </P>
254
255 <HR WIDTH="20%">
256 <H2><A NAME="inclusion">Inclusion:</A></H2>
257 <HR WIDTH="20%">
258 <p>
259 Inclusion means that a node can include another property list as if it
260 were a part of the current file.
261 To clarify how inclusion works, consider the following examples:
262 </P>
263 <p>
264 If bar.xml contains
265 </P>
266 <PRE>
267 &lt;PropertyList&gt;
268 &lt;a&gt;1&lt;/a&gt;
269 &lt;b&gt;
270 &lt;c&gt;2&lt;/c&gt;
271 &lt;/b&gt;
272 &lt;/PropertyList&gt;
273 </PRE><BR>
274 <p>
275 then the declaration
276 </P>
277 <PRE>
278 &lt;foo include="../bar.xml"&gt;
279 &lt;/foo&gt;
280 </PRE><br>
281 <p>
282 is exactly equivalent to
283 </P>
284 <PRE>
285 &lt;foo&gt;
286 &lt;a&gt;1&lt;/a&gt;
287 &lt;b&gt;
288 &lt;c&gt;2&lt;/c&gt;
289 &lt;/b&gt;
290 &lt;/foo&gt;
291 </PRE>
292 <br>
293 <p>
294 However, it is also possible to selectively override properties in the
295 included file. For example, if the declaration were
296 </p>
297
298 <PRE>
299 &lt;foo include="../bar.xml"&gt;
300 &lt;a&gt;3&lt;/a&gt;
301 &lt;/foo&gt;
302 </PRE>
303 <BR>
304 <p>
305 then the property manager would see
306 </P>
307 <PRE>
308 &lt;foo&gt;
309 &lt;a&gt;3&lt;/a&gt;
310 &lt;b&gt;
311 &lt;c&gt;2&lt;/c&gt;
312 &lt;/b&gt;
313 &lt;/foo&gt;
314 </PRE>
315 <br>
316 <p>
317 with the original 'a' property's value replaced with 3.
318 </P>
319 <p>
320 Inclusion allows property files to be broken up and reused
321 arbitrarily -- for example, there might be separate texture cropping
322 property lists for commonly-used textures or layers, to avoid
323 repeating the information in each instrument file.
324 </P>
325
326
327 <HR WIDTH="20%">
328 <H2><A NAME="aliasing">Aliasing:</A></H2>
329 <HR WIDTH="20%">
330 <p>
331 Properties can alias other properties, similar to a symbolic link
332 in Unix. When the target property changes value, the new value will
333 show up in the aliased property as well. For example,
334 </p>
335 <PRE>
336 &lt;PropertyList&gt;
337 &lt;foo&gt;3&lt;/foo&gt;
338 &lt;bar alias="/foo"/&gt;
339 &lt;/PropertyList&gt;
340 </PRE>
341 <br>
342 <p>
343 will look the same to the application as
344 </p>
345 <PRE>
346 &lt;PropertyList&gt;
347 &lt;foo&gt;3&lt;/foo&gt;
348 &lt;bar&gt;3&lt;/bar&gt;
349 &lt;/PropertyList&gt;
350 </PRE>
351 <br>
352 <p>
353 except that when foo changes value, bar will change too.
354 </p>
355 <p>
356 *IMPORTANT*
357 -----------
358 The combination of inclusions and aliases is very powerful, because it
359 allows for parameterized property files. However, you must keep in
360 mind that when an instrument is included by reference, its root is
361 *not* the root of the property tree, therefore aliases must be relative.
362 The relative location of the alias' root in the property hierarchy depends
363 on whether the alias is used in a layer, a switch or an action.
364 In lieu of snappy mnemonic, please use the following table.
365 </p>
366 <pre>
367 when alias
368 is used in go up
369 --------- -----
370 layer 5 ( ../../../../../params/foo )
371 switch 3 ( ../../../params/foo )
372 action 3 ( ../../../params/foo )
373 </pre>
374 <br>
375
376 <p>
377 As an example of inclusion and aliasing, consider the XML file
378 for the NAVCOM radio, which includes a parameter subtree at the start,
379 like this:
380 </p>
381
382 <PRE>
383 &lt;PropertyList&gt;
384 &lt;params&gt;
385 &lt;comm-freq-prop&gt;/radios/comm1/frequencies/selected-mhz&lt;/comm-freq-prop&gt;
386 &lt;nav-freq-prop&gt;/radios/nav1/frequencies/selected-mhz&lt;/nav-freq-prop&gt;
387 &lt;/params&gt;
388
389 ...
390
391 &lt;chunk&gt;
392 &lt;type&gt;number-value&lt;/type&gt;
393 &lt;property alias="../../../../../params/nav-freq-prop"/&gt;
394 &lt;/chunk&gt;
395
396 ...
397 &lt;/PropertyList&gt;
398 </PRE>
399 <br>
400 <P>
401 The same instrument file is used for navcomm1 and navcomm2 simply by
402 overriding the parameters at inclusion in the top level panel property list.
403 </P>
404
405 <pre>
406 &lt;instrument include="../Instruments/navcomm.xml"&gt;
407 &lt;name&gt;NAVCOM 1 radio&lt;/name&gt;
408 &lt;params&gt;
409 &lt;comm-freq-prop&gt;/radios/comm1/frequencies/selected-mhz&lt;/comm-freq-prop&gt;
410 &lt;nav-freq-prop&gt;/radios/nav1/frequencies/selected-mhz&lt;/nav-freq-prop&gt;
411 &lt;/params&gt;
412 .....
413 &lt;/instrument&gt;
414
415 &lt;instrument include="../Instruments/navcomm.xml"&gt;
416 &lt;name&gt;NAVCOM 2 radio&lt;/name&gt;
417 &lt;params&gt;
418 &lt;comm-freq-prop&gt;/radios/comm2/frequencies/selected-mhz&lt;/comm-freq-prop&gt;
419 &lt;nav-freq-prop&gt;/radios/nav2/frequencies/selected-mhz&lt;/nav-freq-prop&gt;
420 &lt;/params&gt;
421 .....
422 &lt;/instrument&gt;
423 </PRE>
424 <br>
425
426 <HR WIDTH="20%">
427 <H2><A NAME="instrument_architecture">Instrument Architecture:</A></H2>
428 <HR WIDTH="20%">
429
430 <p>
431 Instruments are defined in separate configuration files. An instrument
432 consists of a base width and height, one or more stacked layers,
433 and zero or more actions. Base dimensions are specified as follows:
434 </p>
435 <pre>
436 &lt;PropertyList&gt; &lt;!-- remember, all xml files start like this --&gt;
437 &lt;name&gt;Airspeed Indicator&lt;/name&gt; &lt;!-- names are good --&gt;
438 &lt;w-base&gt;128&lt;/w-base&gt; &lt;!-- required width spec--&gt;
439 &lt;h-base&gt;128&lt;/h-base&gt; &lt;!-- required height spec--&gt;
440 &lt;layers&gt; &lt;!-- begins layers section --&gt;
441 </pre>
442 <br>
443
444 <p>
445 Height and width can be overriden in the top level panel.xml by
446 specifying &lt;w&gt; and &lt;h&gt;. Transformations are caculated against the base size
447 regardless of the display size. This ensures that instruments remain calibrated.
448 </p>
449
450 <HR WIDTH="20%">
451 <H2><A NAME="textures">Textures:</A></H2>
452 <HR WIDTH="20%">
453 <p>
454 FG uses red/green/blue/alpha .rgba files for textures. Dimensions for
455 texture files should be power of 2 with a maximum 8:1 aspect ratio.
456 The lowest common denominator for maximum texture size is 256 pixels.
457 This is due to the limitations of certain video accelerators, most notably
458 those with 3Dfx chipset such as the Voodoo2.
459
460 </p>
461
462 <HR WIDTH="20%">
463 <H2><A NAME="instrument_layers">Instrument Layers**:</A></H2>
464 <HR WIDTH="20%">
465 <p>
466 The simplest layer is a &lt;texture&gt;. These can be combined in &lt;switch&gt; layers
467 </p>
468 <p>
469 &lt;texture&gt;
470 A texture layer looks like this:
471 </p>
472 <pre>
473 &lt;layer&gt; &lt;!-- creates a layer --&gt;
474 &lt;name&gt;face&lt;/name&gt;
475 &lt;texture&gt; &lt;!-- defines it as a texture layer --&gt;
476 &lt;path&gt;Aircraft/c172/Instruments/Textures/faces-2.rgb&lt;/path&gt;
477 &lt;x1&gt;0&lt;/x1&gt; &lt;!-- lower boundary for texture cropping--&gt;
478 &lt;y1&gt;0.51&lt;/y1&gt; &lt;!-- left boundary for texture cropping--&gt;
479 &lt;x2&gt;0.49&lt;/x2&gt; &lt;!-- upper boundary for texture cropping--&gt;
480 &lt;y2&gt;1.0&lt;/y2&gt; &lt;!-- right boundary for texture cropping--&gt;
481 &lt;/texture&gt; &lt;!-- closing texure tag --&gt;
482 &lt;/layer&gt; &lt;!-- closing layer tag --&gt;
483 </pre>
484 <br>
485 <p>
486 The texture cropping specification is represented as a decimal. There is a table
487 at the end of this document for converting from pixel coordinates to percentages.
488 </p>
489 <p>
490 This particular layer, being a gauge face has no transformations applied to it.
491 Layers with that aren't static *must* include &lt;w&gt; and &lt;h&gt; parameters to be visible.
492 </p>
493 <p>
494 &lt;type&gt; May be either text or switch..
495 </p>
496 <p>
497 &lt;type&gt;switch&lt;/type&gt;
498 A switch layer is composed of two or more nested layers and will display
499 one of the nested layers based on a boolean property. For a simple example
500 of a switch see $FG_ROOT/Aircraft/c172/Instruments/brake.xml.
501 </p>
502 <pre>
503 &lt;layer&gt;
504 &lt;name&gt;Brake light&lt;/name&gt;
505 &lt;type&gt;switch&lt;/type&gt; &lt;!-- define layer as a switch --&gt;
506 &lt;property&gt;/controls/gear/brake-left&lt;/property&gt; &lt;!-- tie it to a property --&gt;
507 &lt;layer1&gt; &lt;!-- layer for true state --&gt;
508 &lt;name&gt;on&lt;/name&gt; &lt;!-- label to make life easy --&gt;
509 &lt;texture&gt; &lt;!-- layer1 of switch is a texture layer --&gt;
510 &lt;path&gt;Aircraft/c172/Instruments/Textures/brake.rgb&lt;/path&gt;
511 &lt;x1&gt;0.25&lt;/x1&gt;
512 &lt;y1&gt;0.0&lt;/y1&gt;
513 &lt;x2&gt;0.5&lt;/x2&gt;
514 &lt;y2&gt;0.095&lt;/y2&gt;
515 &lt;/texture&gt;
516 &lt;w&gt;64&lt;/w&gt; &lt;!-- required width - layer isn't static --&gt;
517 &lt;h&gt;24&lt;/h&gt; &lt;!-- required height - layer isn't static --&gt;
518 &lt;/layer1&gt; &lt;!-- close layer1 of switch --&gt;
519 &lt;layer2&gt; &lt;!-- layer for false state --&gt;
520 &lt;name&gt;off&lt;/name&gt;
521 &lt;texture&gt;
522 &lt;path&gt;Aircraft/c172/Instruments/Textures/brake.rgb&lt;/path&gt;
523 &lt;x1&gt;0.0&lt;/x1&gt;
524 &lt;y1&gt;0.0&lt;/y1&gt;
525 &lt;x2&gt;0.25&lt;/x2&gt;
526 &lt;y2&gt;0.095&lt;/y2&gt;
527 &lt;/texture&gt;
528 &lt;w&gt;64&lt;/w&gt;
529 &lt;h&gt;24&lt;/h&gt;
530 &lt;/layer2&gt;
531 &lt;/layer&gt;
532 </pre>
533 <br>
534 <p>
535 Switches can have more than 2 states. This requires nesting one switch inside another.
536 One could make, for example, a 3 color LED by nesting switch layers.
537 </p>
538
539 <p>
540 &lt;type&gt;text&lt;/type&gt;
541 A text layer may be static, as in a label, generated from a property or a combination of both.
542 This example is a switch that contains both static and dynamic text:
543 </p>
544
545 <pre>
546 &lt;layer1&gt; &lt;!-- switch layer --&gt;
547 &lt;name&gt;display&lt;/name&gt;
548 &lt;type&gt;text&lt;/type&gt; &lt;!-- type == text --&gt;
549 &lt;point-size&gt;12&lt;/point-size&gt; &lt;!-- font size --&gt;
550 &lt;color&gt; &lt;!-- specify rgb values to color text --&gt;
551 &lt;red&gt;1.0&lt;/red&gt;
552 &lt;green&gt;0.5&lt;/green&gt;
553 &lt;blue&gt;0.0&lt;/blue&gt;
554 &lt;/color&gt; &lt;!-- close color section --&gt;
555 &lt;chunks&gt; &lt;!-- sections of text are referred to as chunks --&gt;
556 &lt;chunk&gt; &lt;!-- first chunk of text --&gt;
557 &lt;type&gt;number-value&lt;/type&gt; &lt;!-- value defines it as dynamic --&gt;
558 &lt;property&gt;/radios/nav1/dme/distance-nm&lt;/property&gt; &lt;!-- ties it to a property --&gt;
559 &lt;scale&gt;0.00053995680&lt;/scale&gt; &lt;!-- convert between statute and nautical miles? --&gt;
560 &lt;format&gt;%5.1f&lt;/format&gt; &lt;!-- define format --&gt;
561 &lt;/chunk&gt;
562 &lt;/chunks&gt;
563 &lt;/layer1&gt;
564 &lt;layer2&gt; &lt;!-- switch layer --&gt;
565 &lt;name&gt;display&lt;/name&gt;
566 &lt;type&gt;text&lt;/type&gt; &lt;!-- type == text --&gt;
567 &lt;point-size&gt;10&lt;/point-size&gt; &lt;!-- font size --&gt;
568 &lt;color&gt; &lt;!-- specify rgb values to color text --&gt;
569 &lt;red&gt;1.0&lt;/red&gt;
570 &lt;green&gt;0.5&lt;/green&gt;
571 &lt;blue&gt;0.0&lt;/blue&gt;
572 &lt;/color&gt; &lt;!-- close color section --&gt;
573 &lt;chunks&gt; &lt;!-- sections of text are referred to as chunks --&gt;
574 &lt;chunk&gt; &lt;!-- first chunk of text --&gt;
575 &lt;type&gt;literal&lt;/type&gt; &lt;!-- static text --&gt;
576 &lt;text&gt;---.--&lt;/text&gt; &lt;!-- fixed value --&gt;
577 &lt;/chunk&gt;
578 &lt;/chunks&gt;
579 &lt;/layer2&gt;
580 </pre>
581 <br>
582 Note that the value to be displayed can be modified using &lt;scale&gt; for multiplication,
583 &lt;offset&gt; for addition, and &lt;truncate&gt;true&lt;/truncate&gt; for truncation. The order of
584 operation is always scale-offset-truncation, which may require you to adapt your formula. For instance, the
585 normal conversion from Fahrenheit to Celsius would be C = (F-32)*0.555555556. Because of the order
586 of operation above you must use the formula C = (F*0.55555556)-17.77777777.
587 <br>
588
589 <HR WIDTH="20%">
590 <H2><A NAME="conditions">Conditions:</A></H2>
591 <HR WIDTH="20%">
592
593 <p>
594 A condition may appear in a binding (for keyboard, joystick, or panel
595 action) or in most parts of a panel configuration file (specifically,
596 for an instrument, layer, transformation, text chunk, or action). If
597 a condition is present, it must succeed for the component to be used
598 (i.e. if the condition fails, the binding will not be fired, the layer
599 will not be drawn, etc.). Conditions are compiled to an efficient
600 internal form and load time.
601 </p>
602 <p>
603 For example, to ensure that a layer is drawn only if the /foo/bar
604 property has the value "active", you would do the following:
605 </p>
606 <pre>
607 &lt;layer&gt;
608 &lt;name&gt;FooBar Layer&lt;/name&gt;
609 &lt;condition&gt;
610 &lt;equals&gt;
611 &lt;property&gt;/foo/bar&lt;/property&gt;
612 &lt;value&gt;active&lt;/value&gt;
613 &lt;/equals&gt;
614 &lt;/condition&gt;
615 ...
616 &lt;/layer&gt;
617 </pre>
618 <p>
619 To draw a different layer when the /foo/bar property does not have the
620 value "active", you could follow with this:
621 </p>
622 <pre>
623 &lt;layer&gt;
624 &lt;name&gt;FooBar Layer&lt;/name&gt;
625 &lt;condition&gt;
626 &lt;not-equals&gt;
627 &lt;property&gt;/foo/bar&lt;/property&gt;
628 &lt;value&gt;active&lt;/value&gt;
629 &lt;/not-equals&gt;
630 &lt;/condition&gt;
631 ...
632 &lt;/layer&gt;
633 </pre>
634 <p>
635 While conditions were originally created for panel designers, they
636 have proven to be very useful for binding input devices (such
637 as the keyboard or joystick), since they effectively allow any key,
638 axis, button, or panel action to act as a modifier for any other key,
639 axis, button, or panel action, and in fact, allow mind-numbingly
640 complicated combinations for people who like them (i.e. Emacs users).
641 </p>
642 <pre>
643 &lt;!-- make 'u' a modifier key --&gt;
644 &lt;!-- could also use property-toggle to make it a toggle modifier --&gt;
645 &lt;key n="117"&gt;
646 &lt;name&gt;u&lt;/name&gt;
647 &lt;desc&gt;Special 'u' modifier&lt;/desc&gt;
648
649 &lt;binding&gt;
650 &lt;command&gt;property-assign&lt;/command&gt;
651 &lt;property&gt;/modifiers/u&lt;/property&gt;
652 &lt;value&gt;1&lt;/value&gt;
653 &lt;/binding&gt;
654
655 &lt;mod-up&gt;
656 &lt;binding&gt;
657 &lt;command&gt;property-assign&lt;/command&gt;
658 &lt;property&gt;/modifiers/u&lt;/property&gt;
659 &lt;value&gt;0&lt;/value&gt;
660 &lt;/binding&gt;
661 &lt;/mod-up&gt;
662
663 &lt;/key&gt;
664
665 &lt;!-- take different actions based on the u modifier --&gt;
666 &lt;key n="118"&gt;
667 &lt;name&gt;v&lt;/name&gt;
668
669 &lt;binding&gt;
670 &lt;condition&gt;
671 &lt;property&gt;/modifiers/u&lt;/property&gt;
672 &lt;/condition&gt;
673 &lt;command&gt;property-toggle&lt;/command&gt;
674 &lt;property&gt;/foo/bar&lt;/property&gt;
675 &lt;/binding&gt;
676
677 &lt;binding&gt;
678 &lt;condition&gt;
679 &lt;not&gt;
680 &lt;property&gt;/modifiers/u&lt;/property&gt;
681 &lt;/not&gt;
682 &lt;/condition&gt;
683 &lt;command&gt;property-toggle&lt;/command&gt;
684 &lt;property&gt;/bar/foo&lt;/property&gt;
685 &lt;/binding&gt;
686
687 &lt;/key&gt;
688 </pre>
689 <p>
690 The &lt;condition&gt; element acts as an implicit 'and' group for everything
691 contained in it. Here are the elements that can appear inside:
692 </p>
693 <pre>
694 &lt;property&gt;[name]&lt;/property&gt;
695
696 - true if the named property returns a true boolean value (i.e. a
697 non-0 numeric value)
698
699 &lt;and&gt;[condition...]&lt;/and&gt;
700
701 - true if all of the conditions contained in it are true
702
703 &lt;or&gt;[condition...]&lt;/or&gt;
704
705 - true if any of the conditions contained in it is true
706
707 &lt;not&gt;[condition]&lt;/not&gt;
708
709 - true if the condition contained in it is false
710
711 &lt;less-than&gt;...&lt;/less-than&gt;
712 &lt;less-than-equals&gt;...&lt;/less-than-equals&gt;
713 &lt;equals&gt;...&lt;/equals&gt;
714 &lt;not-equals&gt;...&lt;/not-equals&gt;
715 &lt;greater-than&gt;...&lt;/greater-than&gt;
716 &lt;greater-than-equals&gt;...&lt;/greater-than-equals&gt;
717 </pre>
718 <p>
719 - all of these take two child elements; the first, "property", is
720 the property to test; the second argument may be "property" or
721 "value". If it is also "property" (i.e. property[1]), the named
722 property's value will be used; otherwise, the literal value
723 provided will be used
724 - be warned that any string comparison other than equals/not-equals
725 is guaranteed to be flaky
726 </p>
727
728 <HR WIDTH="20%">
729 <H2><A NAME="transformations">Transformations:</A></H2>
730 <HR WIDTH="20%">
731 <p>
732 A transformation is a rotation, an x-shift, or a y-shift. Transformations
733 can be static or they can be based on properties. Static rotations are
734 useful for flipping textures horizontally or vertically. Transformations
735 based on properties are useful for driving instrument needles. I.E. rotate the
736 number of degrees equal to the airspeed. X and y shifts are relative to the
737 center of the instrument. Each specified transformation type takes an &lt;offset&gt;.</p><p>
738 Offsets are relative to the center of the instrument. A shift without an offset
739 has no effect. For example, let's say we have a texture that is a circle. If we
740 use this texture in two layers, one defined as having a size of 128x128 and
741 the second layer is defined as 64x64 and neither is supplied a shift and offset
742 the net result appears as 2 concentric circles.
743 </p>
744
745 <HR WIDTH="20%">
746 <H2><A NAME="needle_placement">About Transformations and Needle Placement:</A></H2>
747 <HR WIDTH="20%">
748
749 <p>
750 When describing placement of instrument needles, a transformation offset must
751 be applied to shift the needles fulcrum or else the needle will rotate around it's
752 middle. The offset will be of &lt;type&gt; x-shift or y-shift depending on the orientation of
753 the needle section in the cropped texture.
754 </p>
755
756 <p>
757 This example comes from the altimeter.xml
758 </p>
759
760 <pre>
761 &lt;layer&gt;
762 &lt;name&gt;long needle (hundreds)&lt;/name&gt; &lt;!-- the altimeter has more than one needle --&gt;
763 &lt;texture&gt;
764 &lt;path&gt;Aircraft/c172/Instruments/Textures/misc-1.rgb&lt;/path&gt;
765 &lt;x1&gt;0.8&lt;/x1&gt;
766 &lt;y1&gt;0.78125&lt;/y1&gt;
767 &lt;x2&gt;0.8375&lt;/x2&gt;
768 &lt;y2&gt;1.0&lt;/y2&gt;
769 &lt;/texture&gt;
770 &lt;w&gt;8&lt;/w&gt;
771 &lt;h&gt;56&lt;/h&gt;
772 &lt;transformations&gt; &lt;!-- begin defining transformations --&gt;
773 &lt;transformation&gt; &lt;!-- start definition of transformation that drives the needle --&gt;
774 &lt;type&gt;rotation&lt;/type&gt;
775 &lt;property&gt;/steam/altitude-ft&lt;/property&gt; &lt;!-- bind it to a property --&gt;
776 &lt;max&gt;100000.0&lt;/max&gt; &lt;!-- upper limit of instrument --&gt;
777 &lt;scale&gt;0.36&lt;/scale&gt; &lt;!-- once around == 1000 ft --&gt;
778 &lt;/transformation&gt; &lt;!-- close this transformation --&gt;
779 &lt;transformation&gt; &lt;!-- this one shifts the fulcrum of the needle --&gt;
780 &lt;type&gt;y-shift&lt;/type&gt; &lt;!-- y-shift relative to needle --&gt;
781 &lt;offset&gt;24.0&lt;/offset&gt; &lt;!-- amount of shift --&gt;
782 &lt;/transformation&gt;
783 &lt;/transformations&gt;
784 &lt;/layer&gt;
785 </pre>
786 <br>
787
788 <p>
789 This needles has its origin in the center of the instrument. If the needles fulcrum was
790 towards the edge of the instrument, the transformations to place the pivot point must
791 precede those which drive the needle,
792 </p>
793
794 <HR WIDTH="20%">
795 <H2><A NAME="interpolation">Interpolation Tables:</A></H2>
796 <HR WIDTH="20%">
797
798 <p>
799 Non linear transformations are now possible via the use of interpolation tables.
800 </p>
801
802 <pre>
803 &lt;transformation&gt;
804 ...
805 &lt;interpolation&gt;
806 &lt;entry&gt;
807 &lt;ind&gt;0.0&lt;/ind&gt; &lt;!-- raw value --&gt;
808 &lt;dep&gt;0.0&lt;/dep&gt; &lt;!-- displayed value --&gt;
809 &lt;/entry&gt;
810 &lt;entry&gt;
811 &lt;ind&gt;10.0&lt;/ind&gt;
812 &lt;dep&gt;100.0&lt;/dep&gt;
813 &lt;/entry&gt;
814 &lt;entry&gt;
815 &lt;ind&gt;20.0&lt;/ind&gt;
816 &lt;dep&gt;-5.0&lt;/dep&gt;
817 &lt;/entry&gt;
818 &lt;entry&gt;
819 &lt;ind&gt;30.0&lt;/ind&gt;
820 &lt;dep&gt;1000.0&lt;/dep&gt;
821 &lt;/entry&gt;
822 &lt;/interpolation&gt;
823 &lt;/transformation&gt;
824 </pre>
825 <br>
826
827 <p>
828 Of course, interpolation tables are useful for non-linear stuff, as in
829 the above example, but I kind-of like the idea of using them for
830 pretty much everything, including non-trivial linear movement -- many
831 instrument markings aren't evenly spaced, and the interpolation tables
832 are much nicer than the older min/max/scale/offset stuff and should
833 allow for a more realistic panel without adding a full equation parser
834 to the property manager.
835 </p>
836 <p>
837 If you want to try this out, look at the airspeed.xml file in the base
838 package, and uncomment the interpolation table in it for a
839 very funky, non-linear and totally unreliable airspeed indicator.
840 </p>
841
842 <HR WIDTH="20%">
843 <H2><A NAME="actions">Actions:</A></H2>
844 <HR WIDTH="20%">
845
846 <p>
847 An action is a hotspot on an instrument where something will happen
848 when the user clicks the left or center mouse button. Actions are
849 always tied to properties: they can toggle a boolean property, adjust
850 the value of a numeric property, or swap the values of two properties.
851 The x/y placement for actions specifies the origin of the lower left corner.
852 In the following example the first action sets up a hotspot 32 pixels wide
853 and 16 pixels high. It lower left corner is placed 96 pixels (relative to the
854 defined base size of the instrument) to the right of the center of the
855 instrument. It is also 32 pixels below the centerline of the instrument.
856 The actual knob texture over which the action is superimposed is 32x32.
857 Omitted here is a second action, bound to the same property, with a positive
858 increment value. This second action is placed to cover the other half of the
859 knob. The result is that clicking on the left half of the knob texture decreases
860 the value and clicking the right half increases the value. Also omitted here
861 is a second pair of actions with the same coordinates but a larger increment
862 value. This second pair is bound to a different mouse button. The net result
863 is that we have both fine and coarse adjustments in the same hotspot, each
864 bound to a different mouse button.
865 </p>
866
867 <p>
868 These examples come from the radio stack:
869 </p>
870
871 <pre>
872 &lt;actions&gt; &lt;!-- open the actions section --&gt;
873 &lt;action&gt; &lt;!- first action --&gt;
874 &lt;name&gt;small nav frequency decrease&lt;/name&gt;
875 &lt;type&gt;adjust&lt;/type&gt;
876 &lt;button&gt;0&lt;/button&gt; &lt;!-- bind it to a mouse button --&gt;
877 &lt;x&gt;96&lt;/x&gt; &lt;!-- placement relative to instrument center --&gt;
878 &lt;y&gt;-32&lt;/y&gt;
879 &lt;w&gt;16&lt;/w&gt; &lt;!-- size of hotspot --&gt;
880 &lt;h&gt;32&lt;/h&gt;
881 &lt;property&gt;/radios/nav1/frequencies/standby-mhz&lt;/property&gt; &lt;!-- bind to a property --&gt;
882 &lt;increment&gt;-0.05&lt;/increment&gt; &lt;!-- amount of adjustment per mouse click --&gt;
883 &lt;min&gt;108.0&lt;/min&gt; &lt;!-- lower range --&gt;
884 &lt;max&gt;117.95&lt;/max&gt; &lt;!-- upper range --&gt;
885 &lt;wrap&gt;1&lt;/wrap&gt; &lt;!-- boolean value -- value wraps around when it hits bounds --&gt;
886 &lt;/action&gt;
887 &lt;action&gt;
888 &lt;name&gt;swap nav frequencies&lt;/name&gt;
889 &lt;type&gt;swap&lt;/type&gt; &lt;!-- define type of action --&gt;
890 &lt;button&gt;0&lt;/button&gt;
891 &lt;x&gt;48&lt;/x&gt;
892 &lt;y&gt;-32&lt;/y&gt;
893 &lt;w&gt;32&lt;/w&gt;
894 &lt;h&gt;32&lt;/h&gt;
895 &lt;property1&gt;/radios/nav1/frequencies/selected-mhz&lt;/property1&gt; &lt;!-- properties to toggle between --&gt;
896 &lt;property2&gt;/radios/nav1/frequencies/standby-mhz&lt;/property2&gt;
897 &lt;/action&gt;
898 &lt;action&gt;
899 &lt;name&gt;ident volume on/off&lt;/name&gt;
900 &lt;type&gt;adjust&lt;/type&gt;
901 &lt;button&gt;1&lt;/button&gt;
902 &lt;x&gt;40&lt;/x&gt;
903 &lt;y&gt;-24&lt;/y&gt;
904 &lt;w&gt;16&lt;/w&gt;
905 &lt;h&gt;16&lt;/h&gt;
906 &lt;property&gt;/radios/nav1/ident&lt;/property&gt; &lt;!-- this property is for Morse code identification of nav beacons --&gt;
907 &lt;increment&gt;1.0&lt;/increment&gt; &lt;!-- the increment equals the max value so this toggles on/off --&gt;
908 &lt;min&gt;0&lt;/min&gt;
909 &lt;max&gt;1&lt;/max&gt;
910 &lt;wrap&gt;1&lt;/wrap&gt; &lt;!-- a shortcut to avoid having separate actions for on/off --&gt;
911 &lt;/action&gt;
912 &lt;/actions&gt;
913 </pre>
914 <br>
915
916 <HR WIDTH="20%">
917 <H2><A NAME="more_texture">More About Textures:</A></H2>
918 <HR WIDTH="20%">
919
920 <p>
921 As previously stated, the usual size instrument texture files in FGFS are 256x256
922 pixels, red/green/blue/alpha format. However the mechanism for specifying
923 texture cropping coordinates is decimal in nature. When calling a section
924 of a texture file the 0,0 lower left convention is used.
925 There is a pair of x/y coordinates defining which section of the texture
926 to use.
927 </p>
928 <p>
929 The following table can be used to calculate texture cropping specifications.
930 </p>
931 <pre>
932 # of divisions | width in pixels | decimal specification
933 per axis
934 1 = 256 pixels 1
935 2 = 128 pixels, 0.5
936 4 = 64 pixels, 0.25
937 8 = 32 pixels, 0.125
938 16 = 16 pixels, 0.0625
939 32 = 8 pixels, 0.03125
940 64 = 4 pixels, 0.015625
941 128 = 2 pixels, 0.0078125
942 256 = 1 pixel, 0.00390625
943 </pre>
944 <br>
945
946 <p>
947 The displayed size of a texture in pixels is set in the instrument
948 configuration file. The size of the cropped area in pixels is not
949 directly related to the final display size.
950 </p>
951 <p>
952 What that table represents is:
953 </p>
954 <p>
955 1 / (256 / # of pixels)
956 </p>
957 <p>
958 Take as an example, a section 64 pixels wide on the texture file.
959 256/64 = 4
960 1/4 = 0.25
961 </p>
962 <p>
963 Or lets consider 1 pixel wide
964 256/1 = 256
965 1/256 = 0.00390625
966 </p>
967 <p>
968 If the section starts at the extreme left of the texture, the
969 starting number is 0.0 and the end is 0.25
970 If the section *doesn't* start at the edge you need to take the starting
971 pixel and calculate an offset. Lets say you start 2 pixels from the
972 edge and you are cropping a section 64 pixels wide...
973 </p>
974
975 <pre>
976 256/2 = 128
977 1/128 = 0.0078125 &lt;- this is the value for a 2 pixel wide offset
978
979
980 0.0078125 &lt;- start at
981 0.25 &lt;- add value for 64 px wide
982 0.2571825 &lt;- end at
983 </pre>
984 <br>
985
986 <HR WIDTH="20%">
987 <H2><A NAME="generating_textures">Generating Textures:</A></H2>
988 <HR WIDTH="20%">
989
990 <p>
991 A common procedure for generating gauge faces is to use a
992 vector graphics package such as xfig, exporting the result as a
993 postscript file. 3D modeling tools may also be used and I prefer them
994 for pretty items such as levers, switches, bezels and so forth.
995 Ideally, the size of the item in the final render
996 should be of proportions that fit into the recommended pixel widths.
997 The resulting files can be imported into a graphics manipulation
998 package such as GIMP, et al for final processing.
999 </P>
1000
1001 <HR WIDTH="20%">
1002 <H2><A NAME="contribute">Contributing Panels And Instruments</A></H2>
1003 <HR WIDTH="20%">
1004
1005 <p>
1006 There are two main considerations when contributing panels and instruments.
1007 Firstly, original artwork is a major plus since you as the creator can dictate the terms
1008 of distribution. All Artwork must have a license compatible with the GPL.
1009 Artwork of unverifiable origin is not acceptable.
1010 Secondly, texture sizes must meet the lowest common denominator of 256e2 pixels.
1011 Artwork from third parties may be acceptable if it meets these criteria.
1012 </p>
1013
1014 <HR WIDTH="20%">
1015 <H2><A NAME="units">UNITS:</A></H2>
1016 <HR WIDTH="20%">
1017 <p>
1018 Here is a list of property names including appropriate units:
1019 </p>
1020
1021 <PRE>
1022 /autopilot/locks/nav1 =&gt; /autopilot/locks/nav[0]
1023 /autopilot/settings/altitude += "-ft"
1024 /autopilot/settings/climb-rate += "-fpm"
1025 /autopilot/settings/heading-bug += "-deg"
1026 /consumables/fuel/tank1/level =&gt; /consumables/fuel/tank[0]/level-gal_us
1027 /consumables/fuel/tank2/level =&gt; /consumables/fuel/tank[1]/level-gal_us
1028 /engines/engine0/cht =&gt; /engines/engine[0]/cht-degf
1029 /engines/engine0/egt =&gt; /engines/engine[0]/egt-degf
1030 /engines/engine0/fuel-flow =&gt; /engines/engine[0]/fuel-flow-gph
1031 /engines/engine0/mp =&gt; /engines/engine[0]/mp-osi
1032 /engines/engine0/rpm =&gt; /engines/engine[0]/rpm
1033 /environment/clouds/altitude += "-ft"
1034 /environment/magnetic-dip += "-deg"
1035 /environment/magnetic-variation += "-deg"
1036 /environment/visibility += "-m"
1037 /environment/wind-down += "-fps"
1038 /environment/wind-east += "-fps"
1039 /environment/wind-north += "-fps"
1040 /orientation/heading += "-deg"
1041 /orientation/heading-magnetic += "-deg"
1042 /orientation/pitch += "-deg"
1043 /orientation/roll += "-deg"
1044 /position/altitude += "-ft"
1045 /position/altitude-agl += "-ft"
1046 /position/latitude += "-deg"
1047 /position/longitude += "-deg"
1048 /radios/adf/frequencies/selected += "-khz"
1049 /radios/adf/frequencies/standby += "-khz"
1050 /radios/adf/rotation += "-deg"
1051 /radios/nav1/* =&gt; /radios/nav[0]/*
1052 /radios/nav2/* =&gt; /radios/nav[1]/*
1053 /radios/nav[*]/dme/distance += "-nm"
1054 /radios/nav[*]/frequencies/selected += "-mhz"
1055 /radios/nav[*]/frequencies/standby += "-mhz"
1056 /radios/nav[*]/radials/actual += "-deg"
1057 /radios/nav[*]/radials/selected += "-deg"
1058 /sim/model/h-rotation =&gt; /sim/model/heading-offset-deg
1059 /sim/model/p-rotation =&gt; /sim/model/roll-offset-deg
1060 /sim/model/r-rotation =&gt; /sim/model/pitch-offset-deg
1061 /sim/model/x-offset += "-m"
1062 /sim/model/y-offset += "-m"
1063 /sim/model/z-offset += "-m"
1064 /sim/view/goal-offset += "-deg"
1065 /sim/view/offset += "-deg"
1066 /steam/adf += "-deg"
1067 /steam/airspeed += "-kt"
1068 /steam/altitude += "-ft"
1069 /steam/gyro-compass += "-deg"
1070 /steam/gyro-compass-error += "-deg"
1071 /steam/mag-compass += "-deg"
1072 /steam/vertical-speed += "-fpm"
1073 /velocities/airspeed += "-kt"
1074 /velocities/side-slip += "-rad"
1075 /velocities/speed-down += "-fps"
1076 /velocities/speed-east += "-fps"
1077 /velocities/speed-north += "-fps"
1078 /velocities/uBody += "-fps"
1079 /velocities/vBody += "-fps"
1080 /velocities/wBody += "-fps"
1081 /velocities/vertical-speed += "-fps"
1082 </pre>
1083 <br>
1084 <p>
1085 * If there are *any* XML parsing errors, the panel will fail to load,
1086 so it's worth downloading a parser like Expat (http://www.jclark.com/xml/)
1087 for checking your XML. FlightGear will print the location of errors, but
1088 the messages are a little cryptic right now.
1089 </P>
1090 <p>
1091 ** NOTE: There is one built-in layer -- for the mag compass ribbon --
1092 and all other layers are defined in the XML files. In the future,
1093 there may also be built-in layers for special things like a
1094 weather-radar display or a GPS (though the GPS could be handled with
1095 text properties).
1096 </p>
1097 </BODY>
1098 </HTML>