00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00029 #include "../Include/FlyLegacy.h"
00030 #include "../Include/Fui.h"
00031 #include "../Include/Globals.h"
00032
00033
00034 void FrameRateNotify (Tag id,
00035 Tag component,
00036 EFuiEvents event,
00037 EFuiEvents subevent)
00038 {
00039 CFuiManager *fui = globals->fuimgr;
00040 switch (event) {
00041 case EVENT_OPENWINDOW:
00042 {
00043
00044
00045 float maxSamples = (float)(globals->drawRate->GetMaxSamples());
00046 fui->SetGraphGridRange (id, 'graf', 0, 0, maxSamples, 100.0f);
00047 fui->SetGraphGridSpacing (id, 'graf', maxSamples, 20.0f);
00048
00049
00050 fui->AddGraphTrace (id, 'graf', 'draw', FUI_GRAPH_TRACE_LINE);
00051 fui->SetGraphTraceColour (id, 'graf', 'draw', MakeRGB (255, 0, 0));
00052 fui->SetGraphTraceRange (id, 'graf', 'draw', 0, 0, maxSamples, 100.0f);
00053
00054
00055 fui->SetLabelColour (id, 'rate', MakeRGB (255, 255, 255));
00056 }
00057 break;
00058
00059 case EVENT_UPDATE:
00060 {
00061
00062 static int rate = 0;
00063 rate++; if (rate > 100) rate = 0;
00064 char r[8];
00065 sprintf (r, "%d", r);
00066 fui->SetComponentText (id, 'rate', r);
00067
00068
00069 float total = 0;
00070 fui->ClearGraphTracePoints(id, 'graf', 'draw');
00071 int nSamples = globals->drawRate->GetActualSamples ();
00072 for (int i=0; i<nSamples; i++) {
00073 float x = (float)i;
00074 float y = globals->drawRate->GetSample (i);
00075 fui->AddGraphTracePoint (id, 'graf', 'draw', x, y);
00076 total += y;
00077 }
00078
00079
00080 float avg = total / (float)nSamples;
00081 char s[8];
00082 sprintf (s, "%3d", (int)(floorf(avg)));
00083 fui->SetComponentText (id, 'rate', s);
00084
00087
00091 }
00092 break;
00093 }
00094
00096 }
00097