TheTom wrote:It works the same, both with and without the patch. Only the names have been different. Every autopilot component has an input and one or more output properties. Normally it should be enough to just plot the output property of each component which should be inspected. If there is no output property defined in the ap.xml the according component won't be of much use, as its output would not be able to be used by anything.
You can not modify anything at runtime. Just edit the ap.xml and reload it: http://wiki.flightgear.org/Howto:Design ... Pre-design
<filter>
<name>AP:Pitch sample and hold</name>
<debug>false</debug>
<enable>
<condition>
<not>
<property>/autopilot/locks/roc-lock</property>
</not>
</condition>
</enable>
<type>gain</type>
<gain>1.0</gain>
<input>/orientation/pitch-deg</input>
<output>/autopilot/internal/target-pitch-deg</output>
</filter>
<?xml version="1.0"?>
<!--
Set the multythreading to of when it is still off, in the
$FG_ROOT/preferences.xml
for better performance.
add to $FGHOME/Translations/en/menu.xml
direct under
<equipment>Equipment</equipment>
<fgplot>Fgplot</fgplot>
add to $FGHOME/gui/menubar.xml
direct under
<name>equipment</name>
<item>
<name>fgplot</name>
<binding>
<command>dialog-show</command>
<dialog-name>fgplot</dialog-name>
</binding>
<item>
Now you can choose from menubar in equipment fgplot.
-->
<PropertyList>
<name>fgplot</name>
<modal>false</modal>
<!--layout>hbox</layout-->
<resizable>false</resizable>
<x>0</x> <!-- x runs to right -->
<y>0</y> <!-- y runs to up -->
<width>825</width>
<height>311</height> <!-- 301 + 5*2 -->
<color>
<red>0.2</red>
<green>0.2</green>
<blue>0.2</blue>
<alpha>0.5</alpha> <!-- a little bit of transparency -->
</color>
<group>
<!-- space for the butons and labels and the canvas -->
<layout>hbox</layout>
<!--halign>fill</halign-->
<default-padding>5</default-padding>
<!--empty><stretch>true</stretch></empty-->
<color>
<red>0.2</red>
<green>0.2</green>
<blue>0.2</blue>
</color>
<text>
<label>fgplot</label>
<x>0</x>
<y>285</y>
<width>5</width>
<height>15</height>
</text>
<!-- Buttons for start-stop-quit -->
<button>
<legend>></legend>
<!--equal>true</equal-->
<x>60</x>
<y>285</y>
<width>15</width>
<height>15</height>
<binding>
<command>nasal</command>
<script><![CDATA[
var a = getprop("/gui/fgplot/running") or 0;
if(a == 0){
setprop("/gui/fgplot/running",1);
dotPlot();
};]]>
</script>
</binding>
</button>
<button>
<legend>-</legend>
<!--equal>true</equal-->
<x>80</x>
<y>285</y>
<width>15</width>
<height>15</height>
<binding>
<command>nasal</command>
<script>setprop("/gui/fgplot/running",0);</script>
</binding>
</button>
<button>
<legend>X</legend>
<!--equal>true</equal-->
<x>100</x>
<y>285</y>
<width>15</width>
<height>15</height>
<key>Esc</key>
<binding>
<command>nasal</command>
<script>setprop("/gui/fgplot/running",0);</script>
</binding>
<binding>
<command>dialog-close</command>
</binding>
</button>
<!-- option to set transparency of the plot-area -->
<checkbox>
<label>transparent</label>
<!--pref-width>100</pref-width-->
<x>10</x>
<y>265</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/transparency</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>
SetTransparency();
</script>
</binding>
</checkbox>
<!-- options choose which of the 6 lines are visible -->
<checkbox>
<label></label>
<color>
<red>1.0</red>
<green>0.0</green>
<blue>0.0</blue>
</color>
<x>10</x>
<y>245</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[0]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(0);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[0]</property>
<live>true</live>
<x>20</x>
<y>240</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.0</red>
<green>1.0</green>
<blue>0.0</blue>
</color>
<x>10</x>
<y>225</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[1]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(1);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[1]</property>
<live>true</live>
<x>20</x>
<y>220</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.0</red>
<green>0.0</green>
<blue>1.0</blue>
</color>
<x>10</x>
<y>205</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[2]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(2);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[2]</property>
<live>true</live>
<x>20</x>
<y>200</y>
</text>
<checkbox>
<label></label>
<color>
<red>1.0</red>
<green>0.5</green>
<blue>0.5</blue>
</color>
<x>10</x>
<y>185</y>
<width>10</width>
<height>10</height>
<property>/gui/fgplot/line[3]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(3);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[3]</property>
<live>true</live>
<x>20</x>
<y>180</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.0</red>
<green>0.5</green>
<blue>0.5</blue>
</color>
<x>10</x>
<y>165</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[4]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(4);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[4]</property>
<live>true</live>
<x>20</x>
<y>160</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.5</red>
<green>0.5</green>
<blue>1.0</blue>
</color>
<x>10</x>
<y>145</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[5]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(5);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[5]</property>
<live>true</live>
<x>20</x>
<y>140</y>
</text>
<!-- selector for property to plot -->
<button>
<legend>Properties</legend>
<x>10</x>
<y>10</y>
<width>105</width>
<height>20</height>
<binding>
<command>dialog-show</command>
<dialog-name>property-selector</dialog-name>
</binding>
<binding>
<command>nasal</command>
<!-- signal user-set properties -->
<script>setprop("/gui/fgplot/userdefined",1);</script>
</binding>
</button>
<!-- now only settable vis the property tree , but still left in source -->
<!-- version setting for test -->
<!--
<text>
<label>Version</label>
<x>10</x>
<y>70</y>
<width>10</width>
<height>10</height>
</text>
<button>
<legend>0</legend>
<x>10</x>
<y>40</y>
<width>20</width>
<height>20</height>
<binding>
<command>nasal</command>
<script>
setprop("/gui/fgplot/version",0);
print("using version 0");
</script>
</binding>
</button>
<button>
<legend>1</legend>
<x>40</x>
<y>40</y>
<width>20</width>
<height>20</height>
<binding>
<command>nasal</command>
<script>
setprop("/gui/fgplot/version",1);
print("using version 1");
</script>
</binding>
</button>
<button>
<legend>2</legend>
<x>70</x>
<y>40</y>
<width>20</width>
<height>20</height>
<binding>
<command>nasal</command>
<script>
setprop("/gui/fgplot/version",2);
print("using version 2");
</script>
</binding>
</button>
-->
<!-- this is where we draw on -->
<canvas>
<name>fgplot</name>
<x>130</x> <!-- save space for buttons on the left -->
<y>5</y>
<layout>hbox</layout>
<!--valign>fill</valign-->
<!--halign>fill</halign-->
<!--stretch>true</stretch-->
<width>685</width> <!-- width is 685, but will contain 800 positions ??? -->
<height>301</height> <!-- how is that posible -->
<!-- all the nasal coding below -->
<nasal>
<load> <!-- when the fgplot is loaded ?? == pressed equipment-fgplot -->
<![CDATA[
# general values to have something at startup.
var setProps = func () {
var a = getprop("/gui/fgplot/running") or 0;
if(a == 0) {
setprop("/gui/fgplot/name[0]","fdm-head.rror-deg");
setprop("/gui/fgplot/name[1]","heading-.rror-deg");
setprop("/gui/fgplot/name[2]","true-hea.rror-deg");
setprop("/gui/fgplot/name[3]","nav1-course-error");
setprop("/gui/fgplot/name[4]","nav1-hea.rror-deg");
setprop("/gui/fgplot/name[5]","nav1-tra.rror-deg");
setprop("/gui/fgplot/prop[0]","/autopilot/internal/fdm-heading-bug-error-deg");
setprop("/gui/fgplot/prop[1]","/autopilot/internal/heading-bug-error-deg");
setprop("/gui/fgplot/prop[2]","/autopilot/internal/true-heading-error-deg");
setprop("/gui/fgplot/prop[3]","/autopilot/internal/nav1-course-error");
setprop("/gui/fgplot/prop[4]","/autopilot/internal/nav1-heading-error-deg");
setprop("/gui/fgplot/prop[5]","/autopilot/internal/nav1-track-error-deg");
for( var j = 0 ; 6 > j ; j += 1)
setprop("/gui/fgplot/factor["~j~"]",-1);
for( var j = 0 ; 6 > j ; j += 1)
setprop("/gui/fgplot/top["~j~"]",360);
for( var j = 0 ; 6 > j ; j += 1)
setprop("/gui/fgplot/line["~j~"]",1);
setprop("/gui/fgplot/running",0);
setprop("/gui/fgplot/version",1);
setprop("/gui/fgplot/plot",0);
setprop("/gui/fgplot/transparency",0.0);
# gui.popupTip("Properties set",3);
};
};
setProps();
# gui.popupTip("Properties set in LOAD",3);
var SetTransparency = func () {
if(getprop("/gui/fgplot/transparency")==1){
my_canvas.setColorBackground(0,0,0,1); # Transparancy == last 0
setprop("/gui/fgplot/transparency",0);
} else {
my_canvas.setColorBackground(0,0,0,0); # Transparancy == last 0
setprop("/gui/fgplot/transparency",1);
};
};
var SetLine = func (a) {
# A property with a variable part must be a 2-step job.
if(getprop("/gui/fgplot/line["~a~"]")==0){
setprop("/gui/fgplot/line["~a~"]",1);
} else {
setprop("/gui/fgplot/line["~a~"]",0);
};
};
# canvas-specific code here
var my_canvas = canvas.get( cmdarg() ); # Handle to the parent canvas
my_canvas.setColorBackground(0,0,0,1); # Transparancy when last digit == 0
var root = my_canvas.createGroup();
var graph = root.createChild("group");
# center of the graph.
var x_axis = graph.createChild("path", "x-axis")
.moveTo(0, 151) # start of centerline horizontaly
.lineTo(800, 151) # end of centerline hor. but ends too soon
.setColor(0.8,0.8,0.8)
.setStrokeLineWidth(1);
#currently the center of the graph.
var y1 = 151;
var y = [ 151, 151 ];
var Max = 800;
var y0 = 0; # position of degrees in circle (only in testphase)
var x0 = 0; # position on x-ax
var i = 0;
var pnts = {};
for(var i = 0; i< 6 ; i+=1 ){
pnts[i]={};
};
var plot = {};
for(var i = 0; i< 6 ; i+=1 ){
plot[i]={};
for( var j = 0 ; j< 8 ; j+=1){
plot[i][j] = graph.createChild("path", "data");
};
};
for(i=0;i<8;i+=1){
plot[0][i].setColor(1,0,0);
plot[1][i].setColor(0,1,0);
plot[2][i].setColor(0,0,1);
plot[3][i].setColor(1,0.5,0.5);
plot[4][i].setColor(0,0.5,0.5);
plot[5][i].setColor(0.5,0.5,1);
};
var y0=0;
x0=0;
var dotPlot = func () {
var MyTimeout = func () {
if(getprop("/gui/fgplot/running") == 1){
# Generated inside flightgear Should be a loop ?
pnts[0][x0] = 151+getprop(getprop("/gui/fgplot/prop[0]"))*getprop("/gui/fgplot/factor[0]");
pnts[1][x0] = 151+getprop(getprop("/gui/fgplot/prop[1]"))*getprop("/gui/fgplot/factor[1]");
pnts[2][x0] = 151+getprop(getprop("/gui/fgplot/prop[2]"))*getprop("/gui/fgplot/factor[2]");
pnts[3][x0] = 151+getprop(getprop("/gui/fgplot/prop[3]"))*getprop("/gui/fgplot/factor[3]");
pnts[4][x0] = 151+getprop(getprop("/gui/fgplot/prop[4]"))*getprop("/gui/fgplot/factor[4]");
pnts[5][x0] = 151+getprop(getprop("/gui/fgplot/prop[5]"))*getprop("/gui/fgplot/factor[5]");
### Version now only to be set via the property tree. version 2 is default/fastest
### although it looks a bit ugly.
###
### version 1
if(getprop("/gui/fgplot/version") == 0){
for (var y = 0 ; y<8 ; y+=1){ # 8 pieces of lines
for(i=0;i<6;i+=1){ # 6 lines
if(x0 == 0){
plot[i][y].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][y].lineTo(x0, pnts[i][x0]);
};
};
};
### version 2
} else if(getprop("/gui/fgplot/version") == 1){
if(x0<100){
if(x0 == 0){
plot[0][0].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][0].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][0].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][0].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][0].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][0].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][0].lineTo(x0, pnts[0][x0]);
} else {
plot[0][0].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][0].lineTo(x0, pnts[1][x0]);
} else {
plot[1][0].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][0].lineTo(x0, pnts[2][x0]);
} else {
plot[2][0].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][0].lineTo(x0, pnts[3][x0]);
} else {
plot[3][0].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][0].lineTo(x0, pnts[4][x0]);
} else {
plot[4][0].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][0].lineTo(x0, pnts[5][x0]);
} else {
plot[5][0].moveTo(x0, pnts[5][x0]);
};
} else if(x0<200){
if(x0 == 100){
plot[0][1].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][1].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][1].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][1].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][1].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][1].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][1].lineTo(x0, pnts[0][x0]);
} else {
plot[0][1].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][1].lineTo(x0, pnts[1][x0]);
} else {
plot[1][1].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][1].lineTo(x0, pnts[2][x0]);
} else {
plot[2][1].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][1].lineTo(x0, pnts[3][x0]);
} else {
plot[3][1].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][1].lineTo(x0, pnts[4][x0]);
} else {
plot[4][1].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][1].lineTo(x0, pnts[5][x0]);
} else {
plot[5][1].moveTo(x0, pnts[5][x0]);
};
} else if(x0<300){
if(x0 == 200){
plot[0][2].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][2].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][2].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][2].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][2].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][2].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][2].lineTo(x0, pnts[0][x0]);
} else {
plot[0][2].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][2].lineTo(x0, pnts[1][x0]);
} else {
plot[1][2].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][2].lineTo(x0, pnts[2][x0]);
} else {
plot[2][2].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][2].lineTo(x0, pnts[3][x0]);
} else {
plot[3][2].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][2].lineTo(x0, pnts[4][x0]);
} else {
plot[4][2].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][2].lineTo(x0, pnts[5][x0]);
} else {
plot[5][2].moveTo(x0, pnts[5][x0]);
};
} else if(x0<400){
if(x0 == 300){
plot[0][3].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][3].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][3].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][3].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][3].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][3].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][3].lineTo(x0, pnts[0][x0]);
} else {
plot[0][3].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][3].lineTo(x0, pnts[1][x0]);
} else {
plot[1][3].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][3].lineTo(x0, pnts[2][x0]);
} else {
plot[2][3].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][3].lineTo(x0, pnts[3][x0]);
} else {
plot[3][3].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][3].lineTo(x0, pnts[4][x0]);
} else {
plot[4][3].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][3].lineTo(x0, pnts[5][x0]);
} else {
plot[5][3].moveTo(x0, pnts[5][x0]);
};
} else if(x0<500){
if(x0 == 400){
plot[0][4].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][4].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][4].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][4].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][4].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][4].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][4].lineTo(x0, pnts[0][x0]);
} else {
plot[0][4].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][4].lineTo(x0, pnts[1][x0]);
} else {
plot[1][4].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][4].lineTo(x0, pnts[2][x0]);
} else {
plot[2][4].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][4].lineTo(x0, pnts[3][x0]);
} else {
plot[3][4].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][4].lineTo(x0, pnts[4][x0]);
} else {
plot[4][4].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][4].lineTo(x0, pnts[5][x0]);
} else {
plot[5][4].moveTo(x0, pnts[5][x0]);
};
} else if(x0<600){
if(x0 == 500){
plot[0][5].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][5].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][5].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][5].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][5].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][5].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][5].lineTo(x0, pnts[0][x0]);
} else {
plot[0][5].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][5].lineTo(x0, pnts[1][x0]);
} else {
plot[1][5].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][5].lineTo(x0, pnts[2][x0]);
} else {
plot[2][5].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][5].lineTo(x0, pnts[3][x0]);
} else {
plot[3][5].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][5].lineTo(x0, pnts[4][x0]);
} else {
plot[4][5].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][5].lineTo(x0, pnts[5][x0]);
} else {
plot[5][5].moveTo(x0, pnts[5][x0]);
};
} else if(x0<700){
if(x0 == 600){
plot[0][6].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][6].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][6].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][6].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][6].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][6].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][6].lineTo(x0, pnts[0][x0]);
} else {
plot[0][6].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][6].lineTo(x0, pnts[1][x0]);
} else {
plot[1][6].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][6].lineTo(x0, pnts[2][x0]);
} else {
plot[2][6].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][6].lineTo(x0, pnts[3][x0]);
} else {
plot[3][6].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][6].lineTo(x0, pnts[4][x0]);
} else {
plot[4][6].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][6].lineTo(x0, pnts[5][x0]);
} else {
plot[5][6].moveTo(x0, pnts[5][x0]);
};
} else if(x0<800){
if(x0 == 700){
plot[0][7].reset().moveTo(x0-1,pnts[0][x0]);
plot[1][7].reset().moveTo(x0-1,pnts[1][x0]);
plot[2][7].reset().moveTo(x0-1,pnts[2][x0]);
plot[3][7].reset().moveTo(x0-1,pnts[3][x0]);
plot[4][7].reset().moveTo(x0-1,pnts[4][x0]);
plot[5][7].reset().moveTo(x0-1,pnts[5][x0]);
};
if(getprop("/gui/fgplot/line[0]") == 1){
plot[0][7].lineTo(x0, pnts[0][x0]);
} else {
plot[0][7].moveTo(x0, pnts[0][x0]);
};
if(getprop("/gui/fgplot/line[1]") == 1){
plot[1][7].lineTo(x0, pnts[1][x0]);
} else {
plot[1][7].moveTo(x0, pnts[1][x0]);
};
if(getprop("/gui/fgplot/line[2]") == 1){
plot[2][7].lineTo(x0, pnts[2][x0]);
} else {
plot[2][7].moveTo(x0, pnts[2][x0]);
};
if(getprop("/gui/fgplot/line[3]") == 1){
plot[3][7].lineTo(x0, pnts[3][x0]);
} else {
plot[3][7].moveTo(x0, pnts[3][x0]);
};
if(getprop("/gui/fgplot/line[4]") == 1){
plot[4][7].lineTo(x0, pnts[4][x0]);
} else {
plot[4][7].moveTo(x0, pnts[4][x0]);
};
if(getprop("/gui/fgplot/line[5]") == 1){
plot[5][7].lineTo(x0, pnts[5][x0]);
} else {
plot[5][7].moveTo(x0, pnts[5][x0]);
};
};
### version 3
} else if(getprop("/gui/fgplot/version") == 2){
if(x0<100){
# print("x0 under 100");
for(i=0;i<6;i+=1){
if(x0 == 0){
plot[i][0].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][0].lineTo(x0, pnts[i][x0]);
} else {
plot[i][0].moveTo(x0,pnts[i][x0]);
};
};
} else if(x0<200){
# print("x0 under 200");
for(i=0;i<6;i+=1){
if(x0 == 100){
plot[i][1].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][1].lineTo(x0, pnts[i][x0]);
} else {
plot[i][1].moveTo(x0,pnts[i][x0]);
};
};
} else if(x0<300){
# print("x0 under 300");
for(i=0;i<6;i+=1){
if(x0 == 200){
plot[i][2].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][2].lineTo(x0, pnts[i][x0]);
} else {
plot[i][2].moveTo(x0,pnts[i][x0]);
};
};
} else if(x0<400){
# print("x0 under 400");
for(i=0;i<6;i+=1){
if(x0 == 300){
plot[i][3].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][3].lineTo(x0, pnts[i][x0]);
} else {
plot[i][3].moveTo(x0,pnts[i][x0]);
};
};
} else if(x0<500){
# print("x0 under 500");
for(i=0;i<6;i+=1){
if(x0 == 400){
plot[i][4].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][4].lineTo(x0, pnts[i][x0]);
} else {
plot[i][4].moveTo(x0,pnts[i][x0]);
};
};
} else if(x0<600){
# print("x0 under 600");
for(i=0;i<6;i+=1){
if(x0 == 500){
plot[i][5].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][5].lineTo(x0, pnts[i][x0]);
} else {
plot[i][5].moveTo(x0,pnts[i][x0]);
};
};
} else if(x0<700){
# print("x0 under 700");
for(i=0;i<6;i+=1){
if(x0 == 600){
plot[i][6].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][6].lineTo(x0, pnts[i][x0]);
} else {
plot[i][6].moveTo(x0,pnts[i][x0]);
};
};
} else if(x0<800){
# print("x0 under 800");
for(i=0;i<6;i+=1){
if(x0 == 700){
plot[i][7].reset().moveTo(x0-1,pnts[i][x0]);
};
if(getprop("/gui/fgplot/line["~i~"]") == 1){
plot[i][7].lineTo(x0, pnts[i][x0]);
} else {
plot[i][7].moveTo(x0,pnts[i][x0]);
};
};
};
};
# print(x0);
x0 += 1;
if(x0>=Max)x0=0;
} else {
#print("plotting stopping");
return ;
};
settimer(MyTimeout,0.05);
}; # End function MyTimeout
MyTimeout();
}; # End function dotplot
]]>
</load>
</nasal>
</canvas>
</group>
</PropertyList>
<?xml version="1.0"?>
<PropertyList>
<name>property-selector</name>
<layout>vbox</layout>
<resizable>true</resizable>
<default-padding>3</default-padding>
<color>
<red>0.2</red>
<green>0.2</green>
<blue>0.2</blue>
<alpha>0.7</alpha> <!-- a little bit of transparency -->
</color>
<group>
<layout>hbox</layout>
<default-padding>1</default-padding>
<button>
<legend><</legend>
<pref-width>14</pref-width>
<pref-height>14</pref-height>
<border>2</border>
<!-- looks better in anthrax style -->
<color>
<red>0.34</red>
<green>0.33</green>
<blue>0.35</blue>
</color>
<!-- -->
<binding>
<command>nasal</command>
<script>Pre_set()</script>
</binding>
</button>
<empty><whatever/></empty>
<text>
<label>/</label>
<property>/sim/gui/dialogs/property-selector/title</property>
<live>true</live>
</text>
<empty><stretch>true</stretch></empty>
<button>
<legend>-</legend>
<key>Esc</key>
<pref-width>14</pref-width>
<pref-height>14</pref-height>
<border>2</border>
<binding>
<command>dialog-close</command>
</binding>
</button>
</group>
<hrule/>
<property-list>
<name>property-list</name>
<color>
<red>0.3</red>
<green>0.3</green>
<blue>0.3</blue>
</color>
<pref-height>250</pref-height>
<pref-width>410</pref-width>
<halign>fill</halign>
<valign>fill</valign>
<stretch>true</stretch>
<property>/sim/gui/dialogs/property-selector/list</property>
<binding>
<command>dialog-apply</command>
<object-name>property-list</object-name>
</binding>
<binding>
<command>nasal</command>
<script>select()</script>
</binding>
</property-list>
<hrule/>
<group>
<layout>table</layout>
<default-padding>1</default-padding>
<!--pref-width>350</pref-width-->
<radio>
<row>0</row>
<col>0</col>
<color>
<red>1.0</red>
<green>0.0</green>
<blue>0.0</blue>
</color>
<label>0</label>
<halign>left</halign>
<width>10</width>
<live>true</live>
<property>/sim/gui/dialogs/property-selector/sel[0]</property>
<binding>
<command>property-assign</command>
<property>/sim/gui/dialogs/property-selector/sel[0]</property>
<value>1</value>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(0);</script>
</binding>
</radio>
<radio>
<row>1</row>
<col>0</col>
<color>
<red>0.0</red>
<green>1.0</green>
<blue>0.0</blue>
</color>
<label>1</label>
<halign>left</halign>
<width>10</width>
<live>true</live>
<property>/sim/gui/dialogs/property-selector/sel[1]</property>
<binding>
<command>property-assign</command>
<property>/sim/gui/dialogs/property-selector/sel[1]</property>
<value>1</value>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(1);</script>
</binding>
</radio>
<radio>
<row>2</row>
<col>0</col>
<color>
<red>0.0</red>
<green>0.0</green>
<blue>1.0</blue>
</color>
<label>2</label>
<halign>left</halign>
<width>10</width>
<live>true</live>
<property>/sim/gui/dialogs/property-selector/sel[2]</property>
<binding>
<command>property-assign</command>
<property>/sim/gui/dialogs/property-selector/sel[2]</property>
<value>1</value>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(2);</script>
</binding>
</radio>
<radio>
<row>3</row>
<col>0</col>
<color>
<red>1.0</red>
<green>0.5</green>
<blue>0.5</blue>
</color>
<label>3</label>
<halign>left</halign>
<width>10</width>
<live>true</live>
<property>/sim/gui/dialogs/property-selector/sel[3]</property>
<binding>
<command>property-assign</command>
<property>/sim/gui/dialogs/property-selector/sel[3]</property>
<value>1</value>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(3);</script>
</binding>
</radio>
<radio>
<row>4</row>
<col>0</col>
<color>
<red>0.0</red>
<green>0.5</green>
<blue>0.5</blue>
</color>
<label>4</label>
<halign>left</halign>
<width>10</width>
<live>true</live>
<property>/sim/gui/dialogs/property-selector/sel[4]</property>
<binding>
<command>property-assign</command>
<property>/sim/gui/dialogs/property-selector/sel[4]</property>
<value>1</value>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(4);</script>
</binding>
</radio>
<radio>
<row>5</row>
<col>0</col>
<color>
<red>0.5</red>
<green>0.5</green>
<blue>1.0</blue>
</color>
<label>5</label>
<halign>left</halign>
<width>10</width>
<live>true</live>
<property>/sim/gui/dialogs/property-selector/sel[5]</property>
<binding>
<command>property-assign</command>
<property>/sim/gui/dialogs/property-selector/sel[5]</property>
<value>1</value>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(5);</script>
</binding>
</radio>
<text>
<label>--</label>
<row>0</row>
<col>1</col>
<col>2</col>
<col>3</col>
<col>4</col>
<col>5</col>
<col>6</col>
<live>true</live>
<halign>left</halign>
<property>/sim/gui/dialogs/property-selector/label[0]</property>
<width>170</width>
</text>
<text>
<label>--</label>
<row>1</row>
<col>1</col>
<col>2</col>
<col>3</col>
<col>4</col>
<col>5</col>
<col>6</col>
<live>true</live>
<halign>left</halign>
<property>/sim/gui/dialogs/property-selector/label[1]</property>
<pref-width>170</pref-width>
</text>
<text>
<label>--</label>
<row>2</row>
<col>1</col>
<col>2</col>
<col>3</col>
<col>4</col>
<col>5</col>
<col>6</col>
<live>true</live>
<halign>left</halign>
<property>/sim/gui/dialogs/property-selector/label[2]</property>
<pref-width>170</pref-width>
</text>
<text>
<label>--</label>
<row>3</row>
<col>1</col>
<col>2</col>
<col>3</col>
<col>4</col>
<col>5</col>
<col>6</col>
<live>true</live>
<halign>left</halign>
<property>/sim/gui/dialogs/property-selector/label[3]</property>
<pref-width>170</pref-width>
</text>
<text>
<label>--</label>
<row>4</row>
<col>1</col>
<col>2</col>
<col>3</col>
<col>4</col>
<col>5</col>
<col>6</col>
<live>true</live>
<halign>left</halign>
<property>/sim/gui/dialogs/property-selector/label[4]</property>
<pref-width>170</pref-width>
</text>
<text>
<label>--</label>
<row>5</row>
<col>1</col>
<col>2</col>
<col>3</col>
<col>4</col>
<col>5</col>
<col>6</col>
<live>true</live>
<halign>left</halign>
<property>/sim/gui/dialogs/property-selector/label[5]</property>
<pref-width>170</pref-width>
</text>
<input>
<row>0</row>
<col>7</col>
<height>10</height>
<name>f0</name>
<live>true</live>
<halign>right</halign>
<property>/sim/gui/dialogs/property-selector/input[0]</property>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(0);</script>
</binding>
<width>50</width>
<editable>true</editable>
</input>
<input>
<row>1</row>
<col>7</col>
<height>10</height>
<name>f1</name>
<live>true</live>
<halign>right</halign>
<property>/sim/gui/dialogs/property-selector/input[1]</property>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(1);</script>
</binding>
<width>50</width>
<editable>true</editable>
</input>
<input>
<row>2</row>
<col>7</col>
<height>10</height>
<name>f2</name>
<live>true</live>
<halign>right</halign>
<property>/sim/gui/dialogs/property-selector/input[2]</property>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(2);</script>
</binding>
<width>50</width>
<editable>true</editable>
</input>
<input>
<row>3</row>
<col>7</col>
<height>10</height>
<name>f3</name>
<live>true</live>
<halign>right</halign>
<property>/sim/gui/dialogs/property-selector/input[3]</property>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(3);</script>
</binding>
<width>50</width>
<editable>true</editable>
</input>
<input>
<row>4</row>
<col>7</col>
<height>10</height>
<name>f4</name>
<live>true</live>
<halign>right</halign>
<property>/sim/gui/dialogs/property-selector/input[4]</property>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(4);</script>
</binding>
<width>50</width>
<editable>true</editable>
</input>
<input>
<row>5</row>
<col>7</col>
<height>10</height>
<name>f5</name>
<live>true</live>
<halign>right</halign>
<property>/sim/gui/dialogs/property-selector/input[5]</property>
<binding>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>Set_Select(5);</script>
</binding>
<width>50</width>
<editable>true</editable>
</input>
</group>
<hrule/>
<group>
<layout>hbox</layout>
<default-padding>1</default-padding>
<button>
<legend>Set</legend>
<pref-width>100</pref-width>
<default>true</default>
<binding>
<command>nasal</command>
<script>set()</script>
</binding>
</button>
</group>
<nasal>
<open>
var self = cmdarg();
var dlgname = self.getNode("name").getValue();
var dlg = props.globals.getNode("/sim/gui/dialogs/" ~ dlgname, 1);
var title = dlg.getNode("title", 1);
var Line_Selected=0;
var mname = {};
var label = {};
var input = {};
var sel = {};
for( var i = 0 ; 6 > i ; i += 1){
label[i] = dlg.getNode("label["~i~"]", 1);
input[i] = dlg.getNode("input["~i~"]", 1);
sel[i] = dlg.getNode("sel["~i~"]", 1);
if(sel[i] == 1)Line_Selected=i;
};
var list = dlg.getNode("list", 1);
var node = nil; # selected node entry (props.Node)
var dir = nil; # current directory (string)
var update_interval = 5;
var root_title = "Internal Properties";
var no_selection = "[none]";
var update = func(w) {
self.setValues({ "dialog-name": dlgname, "object-name": w });
fgcommand("dialog-update", self);
}
var squeeze = func(s, n) {
if (n >= size(s) or 7 > n )
return s;
var l = substr(s, 0, (n - 2) / 2);
var r = substr(s, size(s) + size(l) + 3 - n);
return l ~ "." ~ r;
}
var basename = func(a) {
print ( split("/", a) );
}
var select = func {
var lst = list.getValue();
node = props.globals.getNode(lst);
if (node == nil) node = props.globals;
setprop("/sim/gui/dialogs/property-selector/selected", node.getPath());
if (node.getAttribute("children")) {
dir = node.getPath();
title.setValue(node.getPath() == "" ? root_title : lst);
node = nil;
} else {
var name = node.getName();
mname = name;
var index = node.getIndex();
var type = node.getType();
if (index) name ~= "[" ~ index ~ "]";
var value = 0;
if((type == "INT") or (type == "DOUBLE") or (type == "BOOL")
or (type == "FLOAT")){
label[Line_Selected].setValue(squeeze(dir ~"/"~ name, 80));
input[Line_Selected].setValue(150);
};
};
};
var set = func {
var f=0;
setprop("/gui/fgplot/prop["~Line_Selected~"]",
label[Line_Selected].getValue() );
f=input[Line_Selected].getValue();
setprop("/gui/fgplot/top["~Line_Selected~"]",f);
setprop("/gui/fgplot/factor["~Line_Selected~"]",(-150/f));
var name = basename(label[Line_Selected].getValue());
setprop("/gui/fgplot/name["~Line_Selected~"]",squeeze(mname, 18));
}
var Pre_set = func {
var i = 0;
var f = 0;
for( i = 0 ; 6 > i ; i += 1 ){
setprop("/sim/gui/dialogs/property-selector/sel["~i~"]",0);
label[i].setValue(getprop("/gui/fgplot/prop["~i~"]"));
f=getprop("/gui/fgplot/top["~i~"]");
setprop("/gui/fgplot/factor["~i~"]",(-150/f));
input[i].setValue(f);
};
setprop("/sim/gui/dialogs/property-selector/sel[0]",1);
Line_Selected=0;
}
var auto_update = func {
list.setValue(dir);
update("property-list");
if (update_interval)
settimer(auto_update, update_interval, 1);
}
dir = dlg.getNode("last") != nil ? dlg.getNode("last").getValue() : "/";
var Set_Select = func(which) {
var i = 0;
for( i = 0 ; 6 > i ; i += 1 )
setprop("/sim/gui/dialogs/property-selector/sel["~i~"]",0);
setprop("/sim/gui/dialogs/property-selector/sel["~which~"]",1);
Line_Selected=which;
}
list.setValue(dir);
select();
Pre_set();
#auto_update(); # Don't know if this is needed, but can be handy.
</open>
<close>
update_interval = 0;
if (find("property-selector-", dlgname) >= 0)
dlg.getParent().removeChildren(dlgname);
else
dlg.getNode("last", 1).setValue(dir);
</close>
</nasal>
</PropertyList>
<load> <!-- when the fgplot is loaded ?? == pressed equipment-fgplot -->
<![CDATA[
# general values to have something at startup.
var setProps = func () {
var a = getprop("/gui/fgplot/running") or 0;
if(a == 0) {
setprop("/gui/fgplot/name[0]","fdm-head.rror-deg");
setprop("/gui/fgplot/name[1]","heading-.rror-deg");
setprop("/gui/fgplot/name[2]","true-hea.rror-deg");
setprop("/gui/fgplot/name[3]","nav1-course-error");
setprop("/gui/fgplot/name[4]","nav1-hea.rror-deg");
setprop("/gui/fgplot/name[5]","nav1-tra.rror-deg");
setprop("/gui/fgplot/prop[0]","/autopilot/internal/fdm-heading-bug-error-deg");
setprop("/gui/fgplot/prop[1]","/autopilot/internal/heading-bug-error-deg");
setprop("/gui/fgplot/prop[2]","/autopilot/internal/true-heading-error-deg");
setprop("/gui/fgplot/prop[3]","/autopilot/internal/nav1-course-error");
setprop("/gui/fgplot/prop[4]","/autopilot/internal/nav1-heading-error-deg");
setprop("/gui/fgplot/prop[5]","/autopilot/internal/nav1-track-error-deg");
for( var j = 0 ; 6 > j ; j += 1)
{
setprop("/gui/fgplot/factor["~j~"]",-1);
setprop("/gui/fgplot/top["~j~"]",360);
setprop("/gui/fgplot/line["~j~"]",1);
}
setprop("/gui/fgplot/running",0);
setprop("/gui/fgplot/version",1);
setprop("/gui/fgplot/plot",0);
setprop("/gui/fgplot/transparency",0.0);
# gui.popupTip("Properties set",3);
};
};
setProps();
var SetTransparency = func () {
if(getprop("/gui/fgplot/transparency")==1){
my_canvas.setColorBackground(0,0,0,1); # Transparancy == last 0
setprop("/gui/fgplot/transparency",0);
} else {
my_canvas.setColorBackground(0,0,0,0); # Transparancy == last 0
setprop("/gui/fgplot/transparency",1);
};
};
var SetLine = func(a)
{
setprop("/gui/fgplot/line["~a~"]", !getprop("/gui/fgplot/line["~a~"]"));
};
# canvas-specific code here
var my_canvas = canvas.get( cmdarg() ); # Handle to the parent canvas
my_canvas.set("mipmapping", 1)
.setColorBackground(0,0,0,1); # Transparancy when last digit == 0
var root = my_canvas.createGroup();
var graph = root.createChild("group");
# center of the graph.
var x_axis =
graph.createChild("path", "x-axis")
.moveTo(0, 151) # start of centerline horizontaly
.lineTo(800, 151) # end of centerline hor. but ends too soon
.setColor(0.8,0.8,0.8)
.setStrokeLineWidth(1);
var colors = [
"#ff0000",
"#00ff00",
"#0000ff",
"#ff8000",
"#008080",
"#8080ff"
];
var num_plots = size(colors);
var plots = setsize([], num_plots);
for(var i = 0; i< num_plots; i+=1)
plots[i] = graph.createChild("path", "data")
.set("stroke", colors[i])
.set("stroke-width", 2);
var max_x = 800;
var dx = 2;
var cur_x = 0;
var x_offset = max_x;
var doPlot = func()
{
var MyTimeout = func()
{
if( getprop("/gui/fgplot/running") != 1 )
return;
for(var i = 0; i < 6; i += 1)
{
if( getprop("/gui/fgplot/line[" ~ i ~ "]") != 1 )
continue;
var y = getprop(getprop("/gui/fgplot/prop[" ~ i ~ "]")) * getprop("/gui/fgplot/factor[" ~ i ~ "]");
if( cur_x == 0 )
plots[i].moveTo(cur_x, y);
else
plots[i].lineTo(cur_x, y);
plots[i].setTranslation(x_offset, 151);
if( plots[i].getNumSegments() > max_x / dx )
plots[i].pop_front();
}
x_offset -= dx;
cur_x += dx;
settimer(MyTimeout,0.1);
};
MyTimeout();
};
]]>
</load>
kuifje09 wrote in Fri Jun 28, 2013 11:11 pm:Did some work and testing but far from satisfied. Currently the framerate drops from ~15 to ~10.
<?xml version="1.0"?>
<!--
Set the multythreading to of when it is still off, in the
$FG_ROOT/preferences.xml
for better performance.
add to $FGHOME/Translations/en/menu.xml
direct under
<equipment>Equipment</equipment>
<fgplot>Fgplot</fgplot>
add to $FGHOME/gui/menubar.xml
direct under
<name>equipment</name>
<item>
<name>fgplot</name>
<binding>
<command>dialog-show</command>
<dialog-name>fgplot</dialog-name>
</binding>
<item>
Now you can choose from menubar in equipment fgplot.
-->
<PropertyList>
<name>fgplot</name>
<modal>false</modal>
<!--layout>hbox</layout-->
<resizable>false</resizable>
<x>0</x> <!-- x runs to right -->
<y>0</y> <!-- y runs to up -->
<width>940</width>
<height>311</height> <!-- 301 + 5*2 -->
<color>
<red>0.2</red>
<green>0.2</green>
<blue>0.2</blue>
<alpha>0.5</alpha> <!-- a little bit of transparency -->
</color>
<group>
<!-- space for the butons and labels and the canvas -->
<layout>hbox</layout>
<!--halign>fill</halign-->
<default-padding>5</default-padding>
<!--empty><stretch>true</stretch></empty-->
<color>
<red>0.2</red>
<green>0.2</green>
<blue>0.2</blue>
</color>
<text>
<label>fgplot</label>
<x>0</x>
<y>285</y>
<width>5</width>
<height>15</height>
</text>
<!-- Buttons for start-stop-quit -->
<button>
<legend>></legend>
<!--equal>true</equal-->
<x>60</x>
<y>285</y>
<width>15</width>
<height>15</height>
<binding>
<command>nasal</command>
<script><![CDATA[
var a = getprop("/gui/fgplot/running") or 0;
if(a == 0){
setprop("/gui/fgplot/running",1);
dotPlot();
};]]>
</script>
</binding>
</button>
<button>
<legend>-</legend>
<!--equal>true</equal-->
<x>80</x>
<y>285</y>
<width>15</width>
<height>15</height>
<binding>
<command>nasal</command>
<script>setprop("/gui/fgplot/running",0);</script>
</binding>
</button>
<button>
<legend>X</legend>
<!--equal>true</equal-->
<x>100</x>
<y>285</y>
<width>15</width>
<height>15</height>
<key>Esc</key>
<binding>
<command>nasal</command>
<script>setprop("/gui/fgplot/running",0);</script>
</binding>
<binding>
<command>dialog-close</command>
</binding>
</button>
<!-- option to set transparency of the plot-area -->
<checkbox>
<label>transparent</label>
<!--pref-width>100</pref-width-->
<x>10</x>
<y>265</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/transparency</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>
SetTransparency();
</script>
</binding>
</checkbox>
<!-- options choose which of the 6 lines are visible -->
<checkbox>
<label></label>
<color>
<red>1.0</red>
<green>0.0</green>
<blue>0.0</blue>
</color>
<x>10</x>
<y>245</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[0]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(0);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[0]</property>
<live>true</live>
<x>20</x>
<y>240</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.0</red>
<green>1.0</green>
<blue>0.0</blue>
</color>
<x>10</x>
<y>225</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[1]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(1);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[1]</property>
<live>true</live>
<x>20</x>
<y>220</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.0</red>
<green>0.0</green>
<blue>1.0</blue>
</color>
<x>10</x>
<y>205</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[2]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(2);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[2]</property>
<live>true</live>
<x>20</x>
<y>200</y>
</text>
<checkbox>
<label></label>
<color>
<red>1.0</red>
<green>0.5</green>
<blue>0.5</blue>
</color>
<x>10</x>
<y>185</y>
<width>10</width>
<height>10</height>
<property>/gui/fgplot/line[3]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(3);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[3]</property>
<live>true</live>
<x>20</x>
<y>180</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.0</red>
<green>0.5</green>
<blue>0.5</blue>
</color>
<x>10</x>
<y>165</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[4]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(4);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[4]</property>
<live>true</live>
<x>20</x>
<y>160</y>
</text>
<checkbox>
<label></label>
<color>
<red>0.5</red>
<green>0.5</green>
<blue>1.0</blue>
</color>
<x>10</x>
<y>145</y>
<width>12</width>
<height>12</height>
<property>/gui/fgplot/line[5]</property>
<live>true</live>
<binding>
<command>nasal</command>
<script>SetLine(5);</script>
</binding>
</checkbox>
<text>
<label>.</label>
<property>/gui/fgplot/name[5]</property>
<live>true</live>
<x>20</x>
<y>140</y>
</text>
<!-- selector for property to plot -->
<button>
<legend>Properties</legend>
<x>10</x>
<y>10</y>
<width>105</width>
<height>20</height>
<binding>
<command>dialog-show</command>
<dialog-name>property-selector</dialog-name>
</binding>
<binding>
<command>nasal</command>
<!-- signal user-set properties -->
<script>setprop("/gui/fgplot/userdefined",1);</script>
</binding>
</button>
<!-- this is where we draw on -->
<canvas>
<name>fgplot</name>
<x>130</x> <!-- save space for buttons on the left -->
<y>5</y>
<layout>hbox</layout>
<!--valign>fill</valign-->
<!--halign>fill</halign-->
<!--stretch>true</stretch-->
<width>800</width> <!-- will contain 800 positions -->
<height>301</height>
<!-- all the nasal coding below -->
<nasal>
<load> <!-- when the fgplot is loaded ?? == pressed equipment-fgplot -->
<![CDATA[
var dx = 1;
# general values to have something at startup.
var setProps = func () {
var a = getprop("/gui/fgplot/running") or 0;
if(a == 0) {
setprop("/gui/fgplot/name[0]","fdm-head.rror-deg");
setprop("/gui/fgplot/name[1]","heading-.rror-deg");
setprop("/gui/fgplot/name[2]","true-hea.rror-deg");
setprop("/gui/fgplot/name[3]","nav1-course-error");
setprop("/gui/fgplot/name[4]","nav1-hea.rror-deg");
setprop("/gui/fgplot/name[5]","nav1-tra.rror-deg");
setprop("/gui/fgplot/prop[0]","/autopilot/internal/fdm-heading-bug-error-deg");
setprop("/gui/fgplot/prop[1]","/autopilot/internal/heading-bug-error-deg");
setprop("/gui/fgplot/prop[2]","/autopilot/internal/true-heading-error-deg");
setprop("/gui/fgplot/prop[3]","/autopilot/internal/nav1-course-error");
setprop("/gui/fgplot/prop[4]","/autopilot/internal/nav1-heading-error-deg");
setprop("/gui/fgplot/prop[5]","/autopilot/internal/nav1-track-error-deg");
for( var j = 0 ; 6 > j ; j += 1){
setprop("/gui/fgplot/factor["~j~"]",-0.833334);
setprop("/gui/fgplot/top["~j~"]",180);
setprop("/gui/fgplot/line["~j~"]",1);
};
setprop("/gui/fgplot/running",0);
setprop("/gui/fgplot/version",1);
setprop("/gui/fgplot/plot",0);
setprop("/gui/fgplot/transparency",0.0);
# gui.popupTip("Properties set",3);
};
};
setProps();
var SetTransparency = func () {
if(getprop("/gui/fgplot/transparency")==1){
my_canvas.setColorBackground(0,0,0,1); # Transparancy == last 0
setprop("/gui/fgplot/transparency",0);
} else {
my_canvas.setColorBackground(0,0,0,0); # Transparancy == last 0
setprop("/gui/fgplot/transparency",1);
};
};
# Toggle line on/off
var SetLine = func(a)
{
setprop("/gui/fgplot/line["~a~"]", !getprop("/gui/fgplot/line["~a~"]"));
};
# canvas-specific code here
var my_canvas = canvas.get( cmdarg() ); # Handle to the parent canvas
my_canvas.set("mipmapping", 0)
.setColorBackground(0,0,0,1); # Transparancy when last digit == 0
var root = my_canvas.createGroup();
var graph = root.createChild("group");
# center of the graph.
var x_axis = graph.createChild("path", "x-axis")
.moveTo(0, 151) # start of centerline horizontaly
.lineTo(800, 151) # end of centerline horizontaly
.setColor(0.8,0.8,0.8)
.setStrokeLineWidth(1);
var colors = [
"#ff0000",
"#00ff00",
"#0000ff",
"#ff8000",
"#008080",
"#8080ff"
];
var num_plots = size(colors);
var plots = setsize([], num_plots);
for(var i = 0; i< num_plots; i+=1)
plots[i] = graph.createChild("path", "data")
.set("stroke", colors[i])
.set("stroke-width", 1); # was 2
# Now we need the path-number in the texture[?] too correct size of canvas
var Txtr = 0;
for(i=0;i<10;i+=1){
if(getprop("/canvas/by-index/texture["~i~"]/name") == "fgplot"){
Txtr = i;
# then we can correct the view sizes. for correct pixel-value
setprop("/canvas/by-index/texture["~Txtr~"]/view[0]",800);
setprop("/canvas/by-index/texture["~Txtr~"]/view[1]",301);
};
};
if(Txtr == 0){
gui.popupTip("Texture.path for fgplot not found !",3);
setprop("/gui/fgplot/running",0);
dialog-close;
};
var max_x = 800;
var cur_x = 0;
var x_offset = max_x;
var ToRemove = {};
var y = 0;
var dotPlot = func()
{
var MyTimeout = func()
{
if( getprop("/gui/fgplot/running") != 1 )
return;
for(var i = 0; i < 6; i += 1)
{
# we must keep scrolling so poke lines-off y = 0
if( getprop("/gui/fgplot/line[" ~ i ~ "]") != 1 )
y = 0;
else
y = getprop(getprop("/gui/fgplot/prop[" ~ i ~ "]")) * getprop("/gui/fgplot/factor[" ~ i ~ "]");
if( cur_x == 0 )
plots[i].moveTo(cur_x, y);
else
plots[i].lineTo(cur_x, y);
plots[i].setTranslation(x_offset, 151);
if( cur_x > max_x ){
# print(i~"--"~cur_x~"--"~x_offset);
ToRemove[0] = (cur_x-800)/dx;
ToRemove[1] = 2*ToRemove[0];
ToRemove[2] = 1+ToRemove[1];
var pathnum = i+1;
# print ("/canvas/by-index/texture["~Txtr~"]/group/group/path["~pathnum~"]/cmd["~ToRemove[0]~"]");
var Node = props.globals.getNode("/canvas/by-index/texture["~Txtr~"]/group/group/path["~pathnum~"]/cmd["~ToRemove[0]~"]").remove();
# print ("/canvas/by-index/texture["~Txtr~"]/group/group/path["~pathnum~"]/coord["~ToRemove[1]~"]");
var Node = props.globals.getNode("/canvas/by-index/texture["~Txtr~"]/group/group/path["~pathnum~"]/coord["~ToRemove[1]~"]").remove();
# print ("/canvas/by-index/texture["~Txtr~"]/group/group/path["~pathnum~"]/coord["~ToRemove[2]~"]");
var Node = props.globals.getNode("/canvas/by-index/texture["~Txtr~"]/group/group/path["~pathnum~"]/coord["~ToRemove[2]~"]").remove();
};
};
x_offset -= dx;
cur_x += dx;
settimer(MyTimeout,0.1);
};
MyTimeout();
};
]]>
</load>
</nasal>
</canvas>
</group>
</PropertyList>
Users browsing this forum: No registered users and 4 guests