changeset 134:bd28161e5ac2

Major code cleanup
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Wed, 22 Jan 2014 12:29:28 +0100
parents 7540703b8473
children 77539f2597b1
files Allan.c Allan.h FXAnalyse.c FXAnalyse.h FXAnalyse.uir Plot.c Plot.h
diffstat 7 files changed, 167 insertions(+), 277 deletions(-) [+]
line wrap: on
line diff
--- a/Allan.c	Wed Jan 22 12:10:17 2014 +0100
+++ b/Allan.c	Wed Jan 22 12:29:28 2014 +0100
@@ -10,7 +10,7 @@
 
 // ******************* Member functions : constructor and destructor *************************
 
-int Allan_InitPanel(Allan_Data * Instance, char * title, double Normalizer, void (*OnCloseFunc)(int)) {
+int Allan_InitPanel(Allan_Data * Instance, const char * title, double Normalizer, int parent, int control) {
 	
 	int i ;
 	
@@ -18,7 +18,9 @@
 	return -1;
 	SetPanelAttribute(Instance->AllanPanel, ATTR_TITLE, title) ; 
 	SetPanelAttribute (Instance->AllanPanel, ATTR_CALLBACK_DATA, (void *)Instance); // the panel callback therefore knows which data structure it is associated to
-	Instance->OnClosePanel = OnCloseFunc ;
+	Instance->active = TRUE;
+	Instance->parent = parent;
+	Instance->control = control;
 	for (i=0 ; i<ALLAN_MAXPOINTSNUMBER ; i++) {
 		Instance->AllanVar[i] = 0 ;
 		Instance->LastMean[i] = 0 ; 
@@ -35,7 +37,8 @@
 
 
 int Allan_ClosePanel(Allan_Data * Instance) {
-	Instance->OnClosePanel(Instance->AllanPanel) ;
+	Instance->active = FALSE;
+	SetCtrlVal(Instance->parent, Instance->control, FALSE);
 	DiscardPanel (Instance->AllanPanel); 
 	return 0;
 	}
--- a/Allan.h	Wed Jan 22 12:10:17 2014 +0100
+++ b/Allan.h	Wed Jan 22 12:29:28 2014 +0100
@@ -7,7 +7,6 @@
 
 typedef struct {
 	PanelHandle AllanPanel ;					// le handle sur le graphe
-	void (*OnClosePanel)(int);					// pointer on a function to execute when the panel is closed (argument is the panel Handle)	
 	double AllanVar[ALLAN_MAXPOINTSNUMBER] ;	// the values of variances for each tau = 2^n.tau_0 (with n from 0 to ALLAN_MAXPOINTSNUMBER)
 	double FirstMean[ALLAN_MAXPOINTSNUMBER] ;   // the means of the first block of 2^n data for which averaging was completed
 	double LastMean[ALLAN_MAXPOINTSNUMBER] ;    // the means of the last block of 2^n data for which averaging was completed
@@ -15,12 +14,15 @@
 	double CurrentAverage[ALLAN_MAXPOINTSNUMBER] ;  // the sum of the last p data points retrieved (with p<2^2n). used for averaging as soon as p=2^n
 	int NbCurrentAverage[ALLAN_MAXPOINTSNUMBER] ;	// number of data point being summed in CurrentAverage (from 0 up to 2^n)
 	double Drift, Mean ; // the drift rate of the data (in Hz/s), and the mean value (in Hz) : only usefull for dedrifting...
-	} Allan_Data ;
+	int active;
+	int parent;
+	int control;
+} Allan_Data ;
 
 
 // The functions of crypto class Allan
 
-int Allan_InitPanel(Allan_Data * Instance, char * title, double Normalizer, void (*OnCloseFunc)(int)) ;
+int Allan_InitPanel(Allan_Data * Instance, const char * title, double Normalizer, int parent, int control) ;
 int Allan_ClosePanel(Allan_Data * Instance) ;
 int Allan_AddFrequency(Allan_Data * Instance, double Freq) ;
 
--- a/FXAnalyse.c	Wed Jan 22 12:10:17 2014 +0100
+++ b/FXAnalyse.c	Wed Jan 22 12:29:28 2014 +0100
@@ -51,8 +51,114 @@
 double Math1, Math2, Math3, Math4, Math5;
 double N1, N2, N3, N4;
 
-Plot_Data PlotCh1, PlotCh2, PlotCh3, PlotCh4, PlotMath1, PlotMath2, PlotMath3, PlotMath4, PlotMath5 ;  
-Allan_Data AllanCh1, AllanCh2, AllanCh3, AllanCh4, AllanMath1, AllanMath2, AllanMath3, AllanMath4, AllanMath5 ; 
+
+// panels
+static int MainPanel;
+static int CalcNPanel;
+static int EstimateN3Panel;
+static int LoggingPanel;
+
+
+struct adev {
+	Allan_Data allan;
+	double *data;
+	const char *title;
+	double normalization;
+	int control;
+};
+
+
+#define ADEV_INIT(__channel, __normalization)	\
+	{											\
+		.data = & ## __channel,					\
+		.title = #__channel,					\
+		.normalization = __normalization,		\
+		.control = PANEL_ADEV_ ## __channel		\
+	}
+
+
+int adev_toggle(struct adev *adev)
+{
+	if (adev->allan.active)
+		Allan_ClosePanel(&(adev->allan));
+	else
+		Allan_InitPanel(&(adev->allan), adev->title,
+			adev->normalization, MainPanel, adev->control);
+	return adev->allan.active;
+}
+
+
+void adev_update(struct adev *adev)
+{
+	if (adev->allan.active)
+		Allan_AddFrequency(&(adev->allan), *(adev->data));
+}
+
+
+struct adev adevs[] = {
+	ADEV_INIT(Ch1, 1.84e12),
+	ADEV_INIT(Ch2, 10.0e3),
+	ADEV_INIT(Ch3, 429.228e12),
+	ADEV_INIT(Ch4, 275.0e3),
+	ADEV_INIT(Math1, 250.0e6),
+	ADEV_INIT(Math2, 194.395e12),
+	ADEV_INIT(Math3, 282.143e12),
+	ADEV_INIT(Math4, 429.228e12),
+	ADEV_INIT(Math5, 1.0),
+	{ NULL }
+};
+
+
+struct plot {
+	Plot_Data plot;
+	double *data;
+	const char *title;
+	double min;
+	double max;
+	int control;
+};
+
+
+#define PLOT_INIT(__channel, __min, __max) 		\
+	{											\
+		.data = & ## __channel, 				\
+		.title = #__channel,					\
+		.min = __min,							\
+		.max = __max,							\
+		.control = PANEL_PLOT_ ## __channel		\
+	}
+
+
+int plot_toggle(struct plot *plot)
+{
+	if (plot->plot.active)
+		Plot_ClosePanel(&(plot->plot));
+	else
+		Plot_InitPanel(&(plot->plot), plot->title,
+			plot->min, plot->max, MainPanel, plot->control);
+	return plot->plot.active;
+}
+
+
+void plot_update(struct plot *plot)
+{
+	if (plot->plot.active)
+		Plot_AddFrequency(&(plot->plot), *(plot->data));
+}
+
+struct plot plots[] = {
+	PLOT_INIT(Ch1, 54.999e6, 55.001e6),
+	PLOT_INIT(Ch2, 0.0, 0.0),
+	PLOT_INIT(Ch3, 0.0, 0.0),
+	PLOT_INIT(Ch4, 0.0, 0.0),
+	PLOT_INIT(Math1, 0.0, 0.0),
+	PLOT_INIT(Math2, 0.0, 0.0),
+	PLOT_INIT(Math3, 0.0, 0.0),
+	PLOT_INIT(Math4, 0.0, 0.0),
+	PLOT_INIT(Math5, 0.0, 0.0),
+	{ NULL }
+};
+
 
 // 1xAD9956 DDS box
 DDSParameter DDS1xAD9956;
@@ -179,18 +285,12 @@
 };
 
 
-// panels
-static int MainPanel;
-static int CalcNPanel;
-static int EstimateN3Panel;
-static int LoggingPanel;
-
-
 char * thousands(char *buffer, int size, char *fmt, double val)
 {
 	// compute how many separators we need
 	#pragma DisableFunctionRuntimeChecking log10
-	int nsep = log10(fabs(val)) / 3;
+	int nsep = log10(fabs(val));
+	nsep = (nsep > 0 ? nsep / 3 : 0);
 	// format value
 	int len = snprintf(buffer, size, fmt, val);
 	char *src = buffer + len;
@@ -431,31 +531,6 @@
 }
 
 
-void OnCloseViewPanel(int panel){
-	
-	if (panel==PlotCh1.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ1PLOT, FALSE) ; } ; 
-	if (panel==PlotCh2.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ2PLOT, FALSE) ; } ; 
-	if (panel==PlotCh3.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ3PLOT, FALSE) ; } ; 
-	if (panel==PlotCh4.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ4PLOT, FALSE) ; } ;
-	if (panel==PlotMath1.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH1PLOT, FALSE) ; } ; 
-	if (panel==PlotMath2.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH2PLOT, FALSE) ; } ;
-	if (panel==PlotMath3.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH3PLOT, FALSE) ; } ; 
-	if (panel==PlotMath4.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH4PLOT, FALSE) ; } ;
-	if (panel==PlotMath5.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH5PLOT, FALSE) ; } ;
-	
-	if (panel==AllanCh1.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ1ALLAN, FALSE) ; } ; 
-	if (panel==AllanCh2.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ2ALLAN, FALSE) ; } ; 
-	if (panel==AllanCh3.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ3ALLAN, FALSE) ; } ; 
-	if (panel==AllanCh4.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ4ALLAN, FALSE) ; } ; 
-	if (panel==AllanMath1.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH1ALLAN, FALSE) ; } ; 
-	if (panel==AllanMath2.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH2ALLAN, FALSE) ; } ; 
-	if (panel==AllanMath3.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH3ALLAN, FALSE) ; } ; 
-	if (panel==AllanMath4.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH4ALLAN, FALSE) ; } ; 
-	if (panel==AllanMath5.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH5ALLAN, FALSE) ; } ;  
-	
-	return ;
-}
-
 int CVICALLBACK QuitCallback (int panel, int control, int event,
 		void *callbackData, int eventData1, int eventData2)
 {
@@ -635,7 +710,6 @@
 {
 	struct event event;
 	int read;
-	int BoxChecked = FALSE;
 	
 	switch (ev) {
 		case EVENT_TSQ_ITEMS_IN_QUEUE:
@@ -677,88 +751,13 @@
 				SetCtrlVal(MainPanel,PANEL_MATH4, thousands(buffer, sizeof(buffer), "%.3f", Math4));
 				SetCtrlVal(MainPanel,PANEL_MATH5, thousands(buffer, sizeof(buffer), "%.3f", Math5));
 				
-				// plot
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotCh1, Ch1);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanCh1, Ch1);
-				}
+				// update timeseries plots
+				for (struct plot *plot = plots; plot->data; plot++)
+					plot_update(plot);
 
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ2PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotCh2, Ch2);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ2ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanCh2, Ch2);
-				}
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ3PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotCh3, Ch3);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ3ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanCh3, Ch3);
-				}
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ4PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotCh4, Ch4);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ4ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanCh4, Ch4);
-				}
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH1PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotMath1, Math1);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH1ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanMath1, Math1);
-				}
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotMath2, Math2);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanMath2, Math2);
-				}
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotMath3, Math3);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanMath3, Math3);
-				}
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH4PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotMath4, Math4);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH4ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanMath4, Math4);
-				}
-				
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5PLOT, &BoxChecked);
-				if (BoxChecked) {
-					Plot_AddFrequency(&PlotMath5, Math5);
-				}
-				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5ALLAN, &BoxChecked);
-				if (BoxChecked) {
-					Allan_AddFrequency(&AllanMath5, Math5);
-				}
+				// update allan deviation plots
+				for (struct adev *adev = adevs; adev->data; adev++)
+					adev_update(adev);
 				
 				// Calcul de N
 				
@@ -1478,67 +1477,13 @@
 int CVICALLBACK CB_OnFreqPlot (int panel, int control, int event,
 		void *callbackData, int eventData1, int eventData2)
 {
-	int BoxChecked ;
-	Plot_Data * pPlot = NULL;
-	char PlotTitle[] = "Ch? Frequency Plot" ;
-	double PlotMin = 10e6 ;
-	double PlotMax = 65e6 ;
-	
-	switch (event) {
+	switch (event)
+	{
 		case EVENT_COMMIT:
-		
-			GetCtrlVal(MainPanel, control, &BoxChecked);
-			switch (control) {
-				case PANEL_CHECKBOX_FREQ1PLOT :
-					pPlot = &PlotCh1 ;
-					Fmt(PlotTitle, "Ch1 Frequency Plot") ;
-					PlotMin = 54.999e6 ; PlotMax = 55.001e6 ;
-					break ;
-				case PANEL_CHECKBOX_FREQ2PLOT :
-					pPlot = &PlotCh2 ;
-					Fmt(PlotTitle, "Ch2 Frequency Plot") ;
-					PlotMin = 8.0e3 ; PlotMax = 12.0e3 ;
-					break ;
-				case PANEL_CHECKBOX_FREQ3PLOT :
-					pPlot = &PlotCh3 ;
-					Fmt(PlotTitle, "Ch3 Frequency Plot") ;
-					PlotMin = 8.0e3 ; PlotMax = 12.0e3 ;
-					break ;
-				case PANEL_CHECKBOX_FREQ4PLOT :
-					pPlot = &PlotCh4 ;
-					Fmt(PlotTitle, "Ch4 Frequency Plot") ;
-					break ;
-				case PANEL_CHECKBOX_MATH1PLOT :
-					pPlot = &PlotMath1 ;
-					Fmt(PlotTitle, "Math1 Plot") ;
-					PlotMin = 765.0e6 ; PlotMax = 775.0e6 ;
-					break ;
-				case PANEL_CHECKBOX_MATH2PLOT :
-					pPlot = &PlotMath2 ;
-					Fmt(PlotTitle, "Math2 Plot") ;
-					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
-					break ;	
-				case PANEL_CHECKBOX_MATH3PLOT :
-					pPlot = &PlotMath3 ;
-					Fmt(PlotTitle, "Math3 Plot") ;
-					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
-					break ;	
-				case PANEL_CHECKBOX_MATH4PLOT :
-					pPlot = &PlotMath4 ;
-					Fmt(PlotTitle, "Math4 Plot") ;
-					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
-					break ;	
-				case PANEL_CHECKBOX_MATH5PLOT :
-					pPlot = &PlotMath5 ;
-					Fmt(PlotTitle, "Math5 Plot") ;
-					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
-					break ;
+			for (struct plot *plot = plots; plot->data; plot++) {
+				if (plot->control == control)
+					plot_toggle(plot);
 			}
-			
-			if (BoxChecked)
-				Plot_InitPanel(pPlot, PlotTitle, PlotMin, PlotMax, &OnCloseViewPanel);
-			else
-				Plot_ClosePanel(pPlot);
 			break;
 	}
 	return 0;
@@ -1548,77 +1493,15 @@
 int CVICALLBACK CB_OnAllanPlot (int panel, int control, int event,
 		void *callbackData, int eventData1, int eventData2)
 {
-	int BoxChecked ;
-	Allan_Data * pAllan = NULL;
-	char AllanTitle[] = "Ch? Allan Deviation  " ;
-	double Normalizer = 300e12 ;
-	
 	switch (event)
-		{
+	{
 		case EVENT_COMMIT:
-			
-			GetCtrlVal(MainPanel, control, &BoxChecked);
-			switch (control) {
-				case PANEL_CHECKBOX_FREQ1ALLAN :
-					pAllan = &AllanCh1 ;
-					Fmt(AllanTitle, "Ch1 Allan Deviation") ;
-					Normalizer = 1.84e12 ;
-					break ;
-				case PANEL_CHECKBOX_FREQ2ALLAN :
-					pAllan = &AllanCh2 ;
-					Fmt(AllanTitle, "Ch2 Allan Deviation") ;
-					Normalizer = 10.e3 ; 
-					break ;
-				case PANEL_CHECKBOX_FREQ3ALLAN :
-					pAllan = &AllanCh3 ;
-					Fmt(AllanTitle, "Ch3 Allan Deviation") ;
-					Normalizer = 429.228e12 ; 
-					break ;
-				case PANEL_CHECKBOX_FREQ4ALLAN :
-					pAllan = &AllanCh4 ;
-					Fmt(AllanTitle, "Ch4 Allan Deviation") ;
-					Normalizer = 275.0e3 ; 
-					break ;
-				case PANEL_CHECKBOX_MATH1ALLAN :
-					pAllan = &AllanMath1 ;
-					Fmt(AllanTitle, "Math1 Allan Deviation") ;
-					Normalizer = 250.0e6 ;
-					break ;
-				case PANEL_CHECKBOX_MATH2ALLAN :
-					pAllan = &AllanMath2 ;
-					Fmt(AllanTitle, "Math2 Allan Deviation") ;
-					Normalizer = 194.395e12 ;
-					break ;
-				case PANEL_CHECKBOX_MATH3ALLAN :
-					pAllan = &AllanMath3 ;
-					Fmt(AllanTitle, "Math3 Allan Deviation") ;
-					Normalizer = 282.143e12 ;
-					break ;
-				case PANEL_CHECKBOX_MATH4ALLAN :
-					pAllan = &AllanMath4 ;
-					Fmt(AllanTitle, "Math4 Allan Deviation") ;
-					Normalizer = 429.228e12 ;
-					break ;
-				case PANEL_CHECKBOX_MATH5ALLAN :
-					pAllan = &AllanMath5 ;
-					Fmt(AllanTitle, "Math5 Allan Deviation") ;
-					Normalizer = 429.228e12 ;
-					break ;
-			}			
-			
-			if (BoxChecked) {
-				Allan_InitPanel(pAllan, AllanTitle, Normalizer, &OnCloseViewPanel) ;	
-				}
-			else {
-				Allan_ClosePanel(pAllan) ;
-				} ;
+			for (struct adev *adev = adevs; adev->data; adev++) {
+				if (adev->control == control)
+					adev_toggle(adev);
+			}
 			break;
-			
-		case EVENT_RIGHT_CLICK:
-
-			break;
-			
-		}
+	}
 	return 0;
 }
 
--- a/FXAnalyse.h	Wed Jan 22 12:10:17 2014 +0100
+++ b/FXAnalyse.h	Wed Jan 22 12:29:28 2014 +0100
@@ -43,17 +43,17 @@
 #define  PANEL_CH3                        6       /* control type: numeric, callback function: (none) */
 #define  PANEL_CH2                        7       /* control type: numeric, callback function: (none) */
 #define  PANEL_CH1                        8       /* control type: numeric, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH1ALLAN        9       /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_CHECKBOX_FREQ4ALLAN        10      /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_CHECKBOX_FREQ3ALLAN        11      /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_CHECKBOX_FREQ4PLOT         12      /* control type: radioButton, callback function: CB_OnFreqPlot */
-#define  PANEL_CHECKBOX_FREQ2ALLAN        13      /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_CHECKBOX_FREQ3PLOT         14      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_ADEV_Math1                 9       /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_ADEV_Ch4                   10      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_ADEV_Ch3                   11      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_PLOT_Ch4                   12      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_ADEV_Ch2                   13      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_PLOT_Ch3                   14      /* control type: radioButton, callback function: CB_OnFreqPlot */
 #define  PANEL_CHECKBOX_CORRFREQU         15      /* control type: radioButton, callback function: CB_OnCROX */
-#define  PANEL_CHECKBOX_FREQ1ALLAN        16      /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_CHECKBOX_FREQ2PLOT         17      /* control type: radioButton, callback function: CB_OnFreqPlot */
-#define  PANEL_CHECKBOX_MATH1PLOT         18      /* control type: radioButton, callback function: CB_OnFreqPlot */
-#define  PANEL_CHECKBOX_FREQ1PLOT         19      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_ADEV_Ch1                   16      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_PLOT_Ch2                   17      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_PLOT_Math1                 18      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_PLOT_Ch1                   19      /* control type: radioButton, callback function: CB_OnFreqPlot */
 #define  PANEL_DDS2                       20      /* control type: numeric, callback function: CB_ChangeDDSOut */
 #define  PANEL_TEXTMSG                    21      /* control type: textMsg, callback function: (none) */
 #define  PANEL_TEXTMSG_2                  22      /* control type: textMsg, callback function: (none) */
@@ -72,22 +72,22 @@
 #define  PANEL_DDS2STEP                   35      /* control type: ring, callback function: CB_ChangeDDSStep */
 #define  PANEL_CENTERFREQUENCY            36      /* control type: numeric, callback function: (none) */
 #define  PANEL_SLOPE_APPLIED              37      /* control type: numeric, callback function: CB_SetSlope */
-#define  PANEL_CHECKBOX_MATH5PLOT         38      /* control type: radioButton, callback function: CB_OnFreqPlot */
-#define  PANEL_CHECKBOX_MATH4PLOT         39      /* control type: radioButton, callback function: CB_OnFreqPlot */
-#define  PANEL_CHECKBOX_MATH4ALLAN        40      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_PLOT_Math5                 38      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_PLOT_Math4                 39      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_ADEV_Math4                 40      /* control type: radioButton, callback function: CB_OnAllanPlot */
 #define  PANEL_DDS1STEP                   41      /* control type: ring, callback function: CB_ChangeDDSStep */
 #define  PANEL_TEXTMSG_15                 42      /* control type: textMsg, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH5ALLAN        43      /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_CHECKBOX_MATH3PLOT         44      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_ADEV_Math5                 43      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_PLOT_Math3                 44      /* control type: radioButton, callback function: CB_OnFreqPlot */
 #define  PANEL_CHECKBOX_MATH5SAVE         45      /* control type: radioButton, callback function: (none) */
 #define  PANEL_SR_LOGGER                  46      /* control type: radioButton, callback function: (none) */
 #define  PANEL_CHECKBOX_MATH4SAVE         47      /* control type: radioButton, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH3ALLAN        48      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_ADEV_Math3                 48      /* control type: radioButton, callback function: CB_OnAllanPlot */
 #define  PANEL_MATHSTRING4                49      /* control type: string, callback function: CB_ChangeMath */
-#define  PANEL_CHECKBOX_MATH2PLOT         50      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_PLOT_Math2                 50      /* control type: radioButton, callback function: CB_OnFreqPlot */
 #define  PANEL_CHECKBOX_MATH3SAVE         51      /* control type: radioButton, callback function: (none) */
 #define  PANEL_CHECKBOX_MATH2SAVE         52      /* control type: radioButton, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH2ALLAN        53      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_ADEV_Math2                 53      /* control type: radioButton, callback function: CB_OnAllanPlot */
 #define  PANEL_MATHSTRING3                54      /* control type: string, callback function: CB_ChangeMath */
 #define  PANEL_MATHSTRING1                55      /* control type: string, callback function: CB_ChangeMath */
 #define  PANEL_MATHSTRING2                56      /* control type: string, callback function: CB_ChangeMath */
Binary file FXAnalyse.uir has changed
--- a/Plot.c	Wed Jan 22 12:10:17 2014 +0100
+++ b/Plot.c	Wed Jan 22 12:29:28 2014 +0100
@@ -8,17 +8,17 @@
 #include "FXPlot.h"   // Auto generated panel definitions and protypes
 #include "Plot.h"	  // My own .h file, containing prototypes and definitions for the class Plot...
 
-
-
 // ******************* Member functions : constructor and destructor **********************
 
-int Plot_InitPanel(Plot_Data * Instance, char * title, double PlotMin, double PlotMax, void (*OnCloseFunc)(int) ) {
+int Plot_InitPanel(Plot_Data * Instance, const char * title, double PlotMin, double PlotMax, int parent, int control) {
 	
 	if ((Instance->PlotPanel = LoadPanel (0, "FXPlot.uir", PLOTPANEL)) < 0)
 	return -1;
 	SetPanelAttribute(Instance->PlotPanel, ATTR_TITLE, title) ;  
 	SetPanelAttribute (Instance->PlotPanel, ATTR_CALLBACK_DATA, (void *)Instance); // the panel callback therefore knows which data structure it is associated to 
-	Instance->OnClosePanel = OnCloseFunc ;
+	Instance->active = TRUE;
+	Instance->parent = parent;
+	Instance->control = control;
 	Instance->IndexPoint = 0 ;
 	Instance->Mean = 0 ;
 	Instance->Slope = 0;
@@ -34,8 +34,9 @@
 
 
 int Plot_ClosePanel(Plot_Data * Instance) {
-	free(Instance->Frequencies) ;
-	Instance->OnClosePanel(Instance->PlotPanel) ;
+	Instance->active = FALSE;
+	free(Instance->Frequencies);
+	SetCtrlVal(Instance->parent, Instance->control, FALSE);
 	DiscardPanel (Instance->PlotPanel); 
 	return 0;
 	}
--- a/Plot.h	Wed Jan 22 12:10:17 2014 +0100
+++ b/Plot.h	Wed Jan 22 12:29:28 2014 +0100
@@ -4,14 +4,15 @@
 
 typedef struct {
 	PanelHandle PlotPanel ;					// le handle sur le graphe
-	void (*OnClosePanel)(int);				// pointer on a function to execute when the panel is closed (argument is the panel Handle)						 
 	int IndexPoint ;						// le nombre de points à plotter
 	double * Frequencies ; 					// les valeurs à plotter (alloué dynamiquement par le constructeur...)
 	double Mean, Slope, ADev ;				// les valeurs de moyenne, pente et deviation d'Allan calculés au fur et à mesure
+	int active;
+	int parent;
+	int control;
 	} Plot_Data ;
 
-
-int Plot_InitPanel(Plot_Data * Instance, char * title, double PlotMin, double PlotMax, void (*OnCloseFunc)()) ;
+int Plot_InitPanel(Plot_Data * Instance, const char * title, double PlotMin, double PlotMax, int parent, int control);
 int Plot_ClosePanel(Plot_Data * Instance) ;
 
 int Plot_AddFrequency(Plot_Data * Instance, double Freq) ;