Skip navigation.
Home
The QNX Community Portal

View topic - PtTrend or PtMTrend

Page 1 of 1

PtTrend or PtMTrend

PostPosted: Tue Oct 03, 2006 12:19 pm
by meg
Hello
Do you have anybody fully and correctly working Trend widget code(in PhAB or without PhAB) ? Could you publish it here or send me it on email? I have still a problem how to use this widget.
Thanks a lot!

RE: PtTrend or PtMTrend

PostPosted: Tue Oct 03, 2006 9:30 pm
by jinma
what are you trying to do exactly? if you are having trouble seeing the trend then the reason is probably because you need to put PtFlush(); and PtBkgdHandlerProcess(); in the callback which updates these widgets.

PostPosted: Wed Oct 04, 2006 12:44 pm
by meg
I re-made some source code with PtTrend widget to PtMTrend (I found it on the web). With PtTrend widget it works perfectly. I have a problem with adding data to PtMTrend widget. When I use PtMTrendChangeData program falls down with memory fault. Why? What is wrong?

Code: Select all
#include <Pt.h>
#include <math.h>

#define START_X         .0
#define WIDTH         628
#define SAMPLES         628
#define TRENDS         2
#define HEIGHT         200
#define STEP            (2. / HEIGHT)

PtWidget_t *trend;

int main ()
{
   int i;
   double x, y;
   PtWidget_t *window;
   PtArg_t args[10];
   PhDim_t dim;
   int trend_data [SAMPLES * TRENDS];
   PtMTrendAttr_t trend_info;
   
   if (PtInit(NULL) == -1)
      return -1;

   dim.w = WIDTH;
   dim.h = HEIGHT;
   PtSetArg(&args[0], Pt_ARG_DIM, &dim, 0);

   if ((window = PtCreateWidget(PtWindow, NULL, 1, &args[0])) == NULL)
      return -1;
 
   i=1;   
   PtSetArg(&args[i++], Pt_ARG_MTREND_FLAGS, Pt_MTREND_GRID_NONE , Pt_MTREND_GRID_MASK );
   PtSetArg(&args[i++],Pt_ARG_MTREND_FLAGS , Pt_MTREND_HORZ_L2R , Pt_MTREND_DIRECTION_MASK );
   PtSetArg(&args[i++],Pt_ARG_MTREND_FLAGS , Pt_MTREND_BLIT , 0 );
   PtSetArg(&args[i++],Pt_ARG_MTREND_FLAGS , Pt_MTREND_ALWAYS_SCROLL , 0 );
   PtSetArg(&args[i++],Pt_ARG_MTREND_N_SAMPLES , SAMPLES , 0 );

   PtSetArg(&args[i++],Pt_ARG_MTREND_N_GRAPHS , TRENDS , 0 );
   
   trend_info.state= Pt_MTREND_STATE_SHOWN;
   trend_info.color = Pg_GREEN;
   trend_info.line_thickness = 2;
   trend_info.min = -(HEIGHT / 2);
   trend_info.max = (HEIGHT / 2);
   trend_info.join_type = Pg_MITER_JOIN;
   PtSetArg(&args[i++], Pt_ARG_MTREND_GRAPH_ATTR, &trend_info , 1);

   
   if ((trend = PtCreateWidget(PtMTrend, window, i, args)) == NULL)
      return -1;

   for (i = 0, x = START_X; i < SAMPLES; i++, x += STEP)
   {
      y = sin(x)/ STEP;
      trend_data[i] = y;
   }
   
   for (i = 0, x = START_X; i < SAMPLES; i++, x += STEP)
   {
      y = sin(4 * x) / STEP / 4;
      trend_data[SAMPLES + i] = y;
   }
   
   PtRealizeWidget(window);
   PtMTrendChangeData(trend,0, trend_data, 0, SAMPLES);
   PtMainLoop();
   
   return 0;
}

Re: PtTrend or PtMTrend

PostPosted: Fri Jul 06, 2012 9:26 pm
by david
did you solve your problem?

Re: PtTrend or PtMTrend

PostPosted: Fri Jul 20, 2012 9:30 am
by Thunderblade
Notice that QNX is going to deprecate Photon as per the 6.5 SP1 Release Notes. Photon today is still supported but it's not further developed and will probably disappear from the next "big" QNX release. So if you are starting a new project today I'd recommend you look at Qt. Qt officially supports QNX.

Re: PtTrend or PtMTrend

PostPosted: Thu Aug 23, 2012 2:01 pm
by david
My problem was silimar, It has been solved just by adding this line before PtSetArg(&args[i++], Pt_ARG_MTREND_GRAPH_ATTR, &trend_info , 1):

trend_info.draw_f=NULL;