FLTK logo

Re: [fltk.general] How to do realtime data display in FLTK

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: How to do realtime data display in FLTK Team Prii Jul 15, 2013  
 
Thank you for the comment. I agree the "theory mode" is better. In fact I tried to make the vector a static member of Fl_Gauge but again it did not work - size() returned zero in timer callback. In the end I took Ian's suggestion: made a huge static array inside Fl_Gauge class, and a static int to count the number elements.

For the vector, I tried
1. extern variable
2. typedef first, then extern
3. class member of Gauges window (which contains all the Fl_Gauge objects)
4. static member of Fl_Gauge
Only 3. worked, as if the vector doesn't like to be a global variable. However I tried a small test program that uses a few lines of code to test a vector of int type as extern variable. That worked fine. I surrender.


On Sun, Jul 14, 2013 at 8:51 AM, Albrecht Schlosser <albrechts.fltk@gmail.com> wrote:
On 12.07.2013 22:04, Team Prii wrote:

For now I moved the vector inside the "Gauges" window (as a class
member) and that seems to work. The only complaint is that now Fl_Gauge
has to know about the "Gauges" window to access the vector, forcing
another header file to be added in Fl_Gauge.cxx. Maybe I should try to
make the vector a static member of the Fl_Gauge class instead.

<theory mode on>

In theory you would try to avoid any references to an array or vector (that resides) outside the class within the Fl_Gauges class itself. The class should deal only with its own properties. Then you would access the array/vector only outside the Fl_Gauges class, for instance like this:

  Fl_Gauge g1 = new Fl_Gauge(...);
  gauges[n_gauges++] = g1;
  ...

where gauges[] is the array and n_gauges the element counter (replace array with vector, if you like).

<theory mode off>

Of course you can add anything to your class in your application, if you decide that this is what you need, but for code reusability of the Fl_Gauges class the "theory mode" approach would be "better".

Albrecht


--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/-bIjXnLQCL4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.