> It is difficult to tell what is wrong without seeing the source code. Sample
> code would be a good start.
>
> You need to change the number of data points, and re-load your data when your
> 'X' scale changes. I can't tell if PtTrend supports it, but PtMTrend supports
> this for sure.
> PtMTrend also supports min/max for the 'Y'.
>
> I am not sure what you mean by 'zoom' callback. Please advise.
Thank you for your response.
This is the code of callback which is activated by button "START". This callback is named start.c.
int
start( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
int i;
int b, *c, d, e, max, min;
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
PtGetResource(ABW_numericinteger, Pt_ARG_NUMERIC_VALUE, &c, 0);//getting the number of samples from user
printf("numeric value is %d\n", *c);
d= *c;
printf("d=%d\n", d);//printing the number of samples
int x[d], max, min;
srand(time(0));
printf("figures:\n");
for(i=0; i<d; i++){
x[i]= -50 + rand() % 100;//this is the table with data which will be displayed on graph
printf("%d | ", x[i]);
}
max=x[0];
min=x[0];
for(i=1;i<d;i++){
if(max-x[i]>=0){
max=max;
}else{
max=x[i];
}
}//searching for biggest datum
printf("\n\nbiggest datum %d", max);
if(max>0){
PtSetResource(ABW_trend, Pt_ARG_TREND_MAX, 1.1*max, 0);//setting max value of trend
}else{
PtSetResource(ABW_trend, Pt_ARG_TREND_MAX, 0.9*max, 0);//setting max value of trend
}
for(i=1;i<d;i++){
if(min-x[i]<=0){
min=min;
}else{
min=x[i];
}
}//serching for smallest datum
printf("\n\nsmallest datum %d", min);
if(min>0){
PtSetResource(ABW_trend, Pt_ARG_TREND_MIN,0.9*min, 0);//setting min value of trend
}else{
PtSetResource(ABW_trend, Pt_ARG_TREND_MIN, 1.1*min, 0);//setting min value of trend
e=700/d;//PtTrend widget is 700pixels of width
printf("\ne=%d\n", e);//increment
PtSetResource(ABW_trend, Pt_ARG_TREND_INC, e, 0);//setting increment
PtSetResource(ABW_trend, Pt_ARG_TREND_DATA, x, d); // displaying graph
return( Pt_CONTINUE);
}
This is the code of callback which is activated by "ZOOM IN" button. The callback is called zoom.c and zooms Y axis.
int
zoom( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
int *a,*b,*c, d,e,a1,b1;
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
PtGetResource(ABW_trend, Pt_ARG_TREND_MAX, &b, 0);//getting the max value of trend
PtGetResource(ABW_trend, Pt_ARG_TREND_MIN, &a, 0);/getting the min value of trend
printf("\na=%d\nb=%d\n",*a,*b);
a1= *a;
b1= *b;
printf("\na=%d\nb=%d\n",a1,b1);//printing min and max(it goes wrong, it prints wrong values, so the rest of the code is
not working)
e=(b1-a1)/5;//counting the width of areas beetween lines of grid(I set 4 lines so 5 areas)
printf("e=%d\n",e);
// if i want to zoom the area at the bottom i set the parameters like below
PtSetResource(ABW_trend, Pt_ARG_TREND_MAX, a1+e, 0);//setting max value of trend
PtSetResource(ABW_trend, Pt_ARG_TREND_MIN, a1, 0);//setting min value of trend
return( Pt_CONTINUE );
}
About zooming in Xaxis i do not know how to send table x from callback start.c to callback zoom.c(i called it in earlier
post 'zoom callback').
I will try with mtrend. I hope I can make it. I will tell you if it work.
Thank you very much.
Catherine