Skip navigation.
Home
The QNX Community Portal

View topic - PtTrend or PtMTrend

PtTrend or PtMTrend

Isn't the name clear?

PtTrend or PtMTrend

Postby meg » Tue Oct 03, 2006 12:19 pm

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!
meg
Active Member
 
Posts: 10
Joined: Mon May 29, 2006 6:53 am

RE: PtTrend or PtMTrend

Postby jinma » Tue Oct 03, 2006 9:30 pm

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.
jinma
Senior Member
 
Posts: 428
Joined: Thu Oct 28, 2004 10:13 pm

Postby meg » Wed Oct 04, 2006 12:44 pm

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;
}
meg
Active Member
 
Posts: 10
Joined: Mon May 29, 2006 6:53 am

Re: PtTrend or PtMTrend

Postby david » Fri Jul 06, 2012 9:26 pm

did you solve your problem?
david
New Member
 
Posts: 9
Joined: Fri Sep 19, 2003 7:32 pm

Re: PtTrend or PtMTrend

Postby Thunderblade » Fri Jul 20, 2012 9:30 am

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.
Thunderblade
Senior Member
 
Posts: 487
Joined: Thu Apr 07, 2005 11:52 am

Re: PtTrend or PtMTrend

Postby david » Thu Aug 23, 2012 2:01 pm

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;
david
New Member
 
Posts: 9
Joined: Fri Sep 19, 2003 7:32 pm


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 0 guests