Canvas ND framework: Difference between revisions

Jump to navigation Jump to search
Some little updates/edits
(Some little updates/edits)
Line 1: Line 1:
{{Template:Non-stable|version=3.2|progress=60}}
[[File:Canvasready.png|right]]
[[File:Canvasready.png|right]]
{{infobox subsystem
{{infobox subsystem
Line 9: Line 7:
|description  = [[Canvas]]/[[Nasal]] driven NDs
|description  = [[Canvas]]/[[Nasal]] driven NDs
|status      = Under active development as of 12/2013
|status      = Under active development as of 12/2013
|maintainers  = Gijs (B747), Hyde(B777), Soitanen(B737NG), (Hooray, Philosopher & D-LEON via [[MapStructure]])
|maintainers  = Gijs (B747), Hyde (B777), Soitanen (B737NG), (Hooray, Philosopher & D-LEON via [[MapStructure]])
|developers  = [[User:Gijs]] (since 11/2013)
|developers  = [[User:Gijs]] (since 11/2013)
}}
}}
Line 20: Line 18:
Extending the framework should normally require very little in terms of coding - typically, people can simply take an existing feature/symbol, copy & paste the code section and customize it according to their needs (e.g. different SVG element id, different animations, different properties) - symbols can be easily changed by providing a separate SVG file, or by creating a new one via Inkscape.
Extending the framework should normally require very little in terms of coding - typically, people can simply take an existing feature/symbol, copy & paste the code section and customize it according to their needs (e.g. different SVG element id, different animations, different properties) - symbols can be easily changed by providing a separate SVG file, or by creating a new one via Inkscape.


It can be found on [[Git]] in fgdata/master (2.99). The main source is located in <tt>{{Git link|gitorious|fg/fgdata|master|Nasal/canvas/map/navdisplay.mfd|pre=$FG_ROOT/}}</tt> aircraft-specifics can be found in {{Git link|gitorious|fg/fgdata|master|Nasal/canvas/map/navdisplay.styles|pre=$FG_ROOT/}}.
The main source is located at {{fgdata file|Nasal/canvas/map/navdisplay.mfd}}. Aircraft-specifics can be found in {{fgdata file|Nasal/canvas/map/navdisplay.styles}}.
 


[[File:777-200-ND-Controls.png|thumb|Screen shot showing the control panel of the 777-200ER for controlling the Canvas-based [[NavDisplay]]]]
[[File:777-200-ND-Controls.png|thumb|Screen shot showing the control panel of the 777-200ER for controlling the Canvas-based [[NavDisplay]]]]


== Adding the navigation display to your aircraft ==
== Adding the navigation display to your aircraft ==
Line 31: Line 27:
Note that the latest ND code is currently only available in Git and not in the latest stable release.  
Note that the latest ND code is currently only available in Git and not in the latest stable release.  
# Add a surface object to your 3D model and apply a place holder texture to it. You can refer to the 747-400 and 777 for examples.
# Add a surface object to your 3D model and apply a place holder texture to it. You can refer to the 747-400 and 777 for examples.
# Copy the ND.nas file of the Boeing 777 into your own aircraft directory (<tt>{{Git link|gitorious|fg/fgdata|master|Aircraft/777/Models/Instruments/ND/ND.nas|pre=[[$FG_ROOT]]/}}</tt>).  
# Copy the ND.nas file of the Boeing 777 into your own aircraft directory ([{{fgaddon url|777|Models/Instruments/ND/ND.nas}} $FG_ROOT/Aircraft/777/Models/Instruments/ND/ND.nas]).  
# Add the file to the <nasal> block in your aircraft's [[Aircraft-set.xml|-set.xml]] file.
# Add the file to the <nasal> block in your aircraft's [[Aircraft-set.xml|-set.xml]] file.
# In order to customize the ND for your specific aircraft, change a few options in your ND.nas file:
# In order to customize the ND for your specific aircraft, change a few options in your ND.nas file:
## the node behind <code>addPlacement</code> is the name of the object in your 3D model. For multiple independent NDs, each ND should have its own object (and thus placement node). The 777 for example has a "ndScreenL" and a "ndScreenR".
## the node behind <code>addPlacement</code> is the name of the object in your 3D model. For multiple independent NDs, each ND should have its own object (and thus placement node). The 777 for example has a "ndScreenL" and a "ndScreenR".
## Rename the properties in the "myCockpit_switches" hash at the top of the ND.nas file to match your own properties (range selector, mode selector etc.), see {{Git link|gitorious|fg/fgdata|master|Aircraft/747-400/Models/Cockpit/Instruments/ND/ND.nas|3|22|pre=[[$FG_ROOT]]/}} You're advised to use the defaults (and change other systems of your aircraft accordingly). For an overview of switches, see [[#Cockpit switches]].
## Rename the properties in the "myCockpit_switches" hash at the top of the ND.nas file to match your own properties (range selector, mode selector etc.), see [{{fgaddon url|747-400|Models/Cockpit/Instruments/ND/ND.nas}} $FG_ROOT/Aircraft/747-400/Models/Cockpit/Instruments/ND/ND.nas]. You're advised to use the defaults (and change other systems of your aircraft accordingly). For an overview of switches, see [[#Cockpit switches]].
# Add knobs/buttons to the 3D model of your cockpit to control the various options of the ND. See <tt>{{Git link|gitorious|fg/fgdata|master|Aircraft/777/Models/Instruments/EFIS/efis-ctl1.xml|pre=[[$FG_ROOT]]/}}</tt> for an example.
# Add knobs/buttons to the 3D model of your cockpit to control the various options of the ND. See [{{fgaddon url|777|Models/Instruments/EFIS/efis-ctl1.xml}} $FG_ROOT/Aircraft/777/Models/Instruments/EFIS/efis-ctl1.xml] for an example.
# Add a binding to your screen(s) to open the ND in a popup dialog. See <tt>{{Git link|gitorious|fg/fgdata|master|Aircraft/777/Models/Instruments/ND/ND_L.xml|pre=[[$FG_ROOT]]/}}</tt> for an example.
# Add a binding to your screen(s) to open the ND in a popup dialog. See [{{fgaddon url|777|Models/Instruments/ND/ND_L.xml}} $FG_ROOT/Aircraft/777/Models/Instruments/ND/ND_L.xml] for an example.


That's the only thing you need to do right now. future changes will be in navdisplay.mfd and will be automatically available to you once they're committed/merged, no changes needed in your ND.nas at all, except for additional switches/buttons that may be created, and which would obviously need to be mapped to your cockpit hot spots.
That's the only thing you need to do right now. future changes will be in navdisplay.mfd and will be automatically available to you once they're committed/merged, no changes needed in your ND.nas at all, except for additional switches/buttons that may be created, and which would obviously need to be mapped to your cockpit hot spots.
Line 168: Line 164:


== Gallery ==
== Gallery ==
<gallery mode=packed widths=230px heights=230px>
<gallery mode="packed" widths="230px" heights="230px">
Navigation display MAP mode.png|MAP mode
Navigation display MAP mode.png|MAP mode
Navigation display centered MAP mode.png|Centered MAP mode
Navigation display centered MAP mode.png|Centered MAP mode
Line 282: Line 278:


<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <!--######################## Airports ############################-->
<!--######################## Airports ############################-->
  <animation>
<animation>
    <type>pick</type>
  <type>pick</type>
    <object-name>bt-h1</object-name>
  <object-name>bt-h1</object-name>
    <visible>true</visible>
  <visible>true</visible>
    <action>
  <action>
        <button>0</button>
    <button>0</button>
        <binding>
    <binding>
        <command>property-toggle</command>
      <command>property-toggle</command>
        <property>/instrumentation/efis/inputs/arpt</property>
      <property>/instrumentation/efis/inputs/arpt</property>
        </binding>
    </binding>
    </action>
  </action>
  </animation>
</animation>
</syntaxhighlight>
</syntaxhighlight>


Or here again for the range selection:
Or here again for the range selection:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <animation>
<animation>
    <type>pick</type>
  <type>pick</type>
    <object-name>trim1</object-name>
  <object-name>trim1</object-name>
    <action>
  <action>
      <button>4</button>
    <button>4</button>
      <!--  scroll up -->
    <!--  scroll up -->
      <repeatable>false</repeatable>   
    <repeatable>false</repeatable>   
      <binding>
    <binding>
                <command>property-cycle</command>
      <command>property-cycle</command>
                <property>/instrumentation/efis/inputs/range-nm</property>
      <property>/instrumentation/efis/inputs/range-nm</property>
                <value>10</value>
      <value>10</value>
                <value>20</value>
      <value>20</value>
                <value>40</value>
      <value>40</value>
                <value>80</value>
      <value>80</value>
                <value>160</value>
      <value>160</value>
                <value>320</value>
      <value>320</value>
      </binding>   
    </binding>   
    </action>
  </action>
  </animation>
</animation>


  <animation>
<animation>
    <type>pick</type>
  <type>pick</type>
    <object-name>trim1</object-name>
  <object-name>trim1</object-name>
    <action>
  <action>
      <button>3</button>
    <button>3</button>
      <!--  scroll up -->
    <!--  scroll up -->
      <repeatable>false</repeatable>
    <repeatable>false</repeatable>
 
    <binding>
      <binding>
      <command>property-cycle</command>
                <command>property-cycle</command>
      <property>/instrumentation/efis/inputs/range-nm</property>
                <property>/instrumentation/efis/inputs/range-nm</property>
      <value>320</value>
                <value>320</value>
      <value>160</value>
                <value>160</value>
      <value>80</value>
                <value>80</value>
      <value>40</value>
                <value>40</value>
      <value>20</value>
                <value>20</value>
      <value>10</value>               
                <value>10</value>               
    </binding>   
      </binding>   
  </action>
    </action>
</animation>
  </animation>
</syntaxhighlight>
</syntaxhighlight>


Line 344: Line 339:


<syntaxhighlight lang="xml">  
<syntaxhighlight lang="xml">  
  <animation>
<animation>
  <type>pick</type>
  <type>pick</type>
  <object-name>blackbkd</object-name>
  <object-name>blackbkd</object-name>
  <action>
  <action>
      <button>0</button>
    <button>0</button>
      <repeatable>false</repeatable>
    <repeatable>false</repeatable>
      <binding>
    <binding>
        <command>nasal</command>
      <command>nasal</command>
        <script>mirage2000.showNd();</script>
      <script>mirage2000.showNd();</script>
      </binding>
    </binding>
  </action>
  </action>
  </animation>
</animation>
</syntaxhighlight>
</syntaxhighlight>


Line 391: Line 386:
* $FG_ROOT/Nasal/canvas/map/ND/nd.airbus-3_4
* $FG_ROOT/Nasal/canvas/map/ND/nd.airbus-3_4
* $FG_ROOT/Nasal/canvas/map/ND/nd.airbus-4_0
* $FG_ROOT/Nasal/canvas/map/ND/nd.airbus-4_0


{{FGCquote
{{FGCquote
Line 406: Line 400:
=== Getting rid of Aircraft Dependencies ===
=== Getting rid of Aircraft Dependencies ===
*  the constructor/newMFD() methods still contain a few hard-coded assumptions due to the origins of the code, but those can be also moved into some kind of construct() field in the hash, or you can simply use the method I suggested, i.e. hiding unneeded symbols. But you're right, that the most proper solution would be identifying non-generic code that contains hard-coded assumptions and moving that into some kind of construct() field that is simply invoked by the new/newMFD() methods. Doing that would not be difficult, it would be just copy & paste - i.e. copy from the navdisplay.mfd file into the style file, by adding a corresponding hash field entry there - and calling it instead. Takes under 3 minutes[http://forum.flightgear.org/viewtopic.php?f=71&t=21509&p=214897#p214835]
*  the constructor/newMFD() methods still contain a few hard-coded assumptions due to the origins of the code, but those can be also moved into some kind of construct() field in the hash, or you can simply use the method I suggested, i.e. hiding unneeded symbols. But you're right, that the most proper solution would be identifying non-generic code that contains hard-coded assumptions and moving that into some kind of construct() field that is simply invoked by the new/newMFD() methods. Doing that would not be difficult, it would be just copy & paste - i.e. copy from the navdisplay.mfd file into the style file, by adding a corresponding hash field entry there - and calling it instead. Takes under 3 minutes[http://forum.flightgear.org/viewtopic.php?f=71&t=21509&p=214897#p214835]
=== Encapsulating Properties ===
=== Encapsulating Properties ===
{{FGCquote
{{FGCquote
Line 445: Line 440:
   }}
   }}
}}
}}
=== Post 3.2 ===
=== Post 3.2 ===
Gijs has already begun to clean up the update() method, and navdisplay.mfd is now back down to under 800 lines of code. Hooray will need to revisit adding support for '''switches''' (i.e. a helper class) and corresponding display modes.  
Gijs has already begun to clean up the update() method, and navdisplay.mfd is now back down to under 800 lines of code. Hooray will need to revisit adding support for '''switches''' (i.e. a helper class) and corresponding display modes.  

Navigation menu