Usage of QwtPlot

In Qt Designer input a QWT Plot. Be sure to set "nCurves" and "nMarker" to the maximum value you want to use. The code needed to define the basic QWT Plot will be generated. The rest must be programmed see "defineQwtPlot()". The Range of values in the axis will be determined automatically. In order to output a curve see showData().

example of qwt plot

Please copy and paste from the following example.

//<snip>

typedef struct // (todo: define your data structure here)
{
  double xa[100];
  double ya[100];
}
DATA;

//<snip>

static int defineQwtPlot(PARAM *p)
{
  // outline
  qpwEnableOutline(p,qwtPlot1,1);
  qpwSetOutlinePen(p,qwtPlot1,GREEN);

  // legend
  qpwSetAutoLegend(p,qwtPlot1,1);
  qpwEnableLegend(p,qwtPlot1,1);
  qpwSetLegendPos(p,qwtPlot1,0);
  qpwSetLegendFrameStyle(p,qwtPlot1,Box|Sunken);

  // axes
  qpwSetAxisTitle(p,qwtPlot1,xBottom, "Normalized Frequency");
  qpwSetAxisTitle(p,qwtPlot1,yLeft, "Amplitude");

  // curves
  qpwInsertCurve(p,qwtPlot1,0,"Sinus");
  qpwSetCurvePen(p,qwtPlot1,0,YELLOW,3,DashDotLine);
  qpwSetCurveYAxis(p,qwtPlot1,0,yLeft);

  return 0;
}

static int defineMask(PARAM *p)
{
  if(p == NULL) return 1;
  generated_defineMask(p);
  defineQwtPlot(p);
  // (todo: add your code here)
  return 0;
}

//<snip>

static int showData(PARAM *p, DATA *d)
{
  if(p == NULL) return 1;
  if(d == NULL) return 1;
  generatedShowData(p,d);
  // (todo: add your code here)
  qpwSetCurveData(p,qwtPlot1,0,100,d->xa,d->ya);
  //qpwSetCurveSymbol(p,qwtPlot1,0,MarkerDiamond,RED,BLUE,10,10);
  qpwReplot(p,qwtPlot1);
  //qpwRemoveCurve(p,wtPlot1,0);

  return 0;
}

//<snip>

int show_mask1(PARAM *p)
{
  DATA d;
  char event[MAX_EVENT_LENGTH];
  char text[MAX_EVENT_LENGTH];
  char str1[MAX_EVENT_LENGTH];
  int  i,w,h,val,x,y,button;
  float xval, yval;

  defineMask(p);
  memset(&d,0,sizeof(DATA));
  for(int i=0; i<100; i++) // here we set a sinus curve
  {
    d.xa[i] = (((double) i) * 2.0 * 3.141592654) / 100.0;
    d.ya[i] = sin(d.xa[i]);
  }

//<snip>