Sign in to follow this  
Guest SRS-103

Gauge parameters

Recommended Posts

Hi,We can use an extra parameter in panel.cfg to pass user data to the gauge. This can be read from the gauge callback function. However I do not know how to reach this data from the element callbacks and especially from the mosue callbacks.Let's have an example. I would like to develop an DME indicator. It should show distance from VOR1 or VOR2. I put two instance of the gauge on the panel with 1 and 2 (meaning VOR1 and VOR2) as the last parameter. Let's suppose that besides displaying distance there is a switch on the gauge where I can change between km and miles unit. I would like to be able to change the unit independently on the two gauges.Gaborgabor[at]hrasko.com

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Here is a sample from my sound gauge:case PANEL_SERVICE_PRE_UPDATE: if ( params_read == 0 ) { if ( strlen(pgauge->parameters) > 0 ) { params_read = 1; strcpy (ini_name, (char*)(pgauge->parameters)); } else if (strlen(pgauge->parameters) == 0) { params_read = 1; strcpy (ini_name, "./Gauges/dsd_xml_sound.ini" ); } if ( params_read == 1 ) {// some other code})I believe this information is actually available in PANEL_SERVICE_PRE_INSTALL, so you should be OK in PRE_UPDATE. However, because it is provided in the form of a pointer to a C string, you are always best to check pgauge->parameters against NULL before trying to read it (OK, I didn't do that here...)If you are looking for numeric input, you will have to parse it, using the atoi or atof functions.Doug Dawson

Share this post


Link to post
Share on other sites

Gabor,In the element callbacks you can use:FLOAT64 FSAPI my_element_callback(PELEMENT_ICON pelement){ char *param =(char *)pelement->gauge_header->parameters; ...}It's different for the mouse functions. I guess, your intention is to use one gauge twice and that you want to distinguish them by the fifth parameter like this:gauge00=mygauge,0,0,10,10,1gauge01=mygauge,10,0,10,10,2That doesn't work if you have clickspots in the gauge since both gauges are in fact the same (only difference is the fifth parameter) and there is no way to get access to the current gauge_header structure from within a mouse functions (only parameters for this one are a PPIXPOINT and a MOUSE_FLAGS variable). You just don't know if the user clicked on gauge00 or gauge01.The only solution is to create two different gauges (use copy & paste and search & replace for that).

Share this post


Link to post
Share on other sites

Since FS2002 the gauge header IS available via the mouse function. The PPIXPOINT argument is not only a pointer to pixpoint, but also to some other data (arg1->mouse is the related mouse rectangle, good for scaling;arg1->user_data is a pointer to the gauges header). Any updated ...gauges.h from Dai's tutorial includes the macros:#define GAUGEHDR_FOR_MOUSE_CALLBACK(PIXPOINT) ((PIXPOINT) ? ((PGAUGEHDR)(((PMOUSECALLBACK)(PIXPOINT))->user_data)) : NULL)#define PMOUSERECT_FOR_MOUSE_CALLBACK(PIXPOINT) ((PIXPOINT) ? ((PMOUSERECT)(((PMOUSECALLBACK)(PIXPOINT))->mouse)) : NULL)soGAUGEHDR *header = NULL;...header=GAUGEHDR_FOR_MOUSE_CALLBACK(arg1);...if(header)//do something with header->parametersworks in a mouse callback.Arne Bartels

Share this post


Link to post
Share on other sites

Ui! Schon wieder was gelernt. Das kommt davon, wenn man eine Struktur f

Share this post


Link to post
Share on other sites

Thanks Arne, this was the answer for my question. I also found Dai's examples and header file.Gabor

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this