GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Oct-2009, 04:18
Indra Indra is offline
New Member
 
Join Date: Oct 2009
Posts: 5
Indra is on a distinguished road

Difficult drawing task


Hello,

I'm new to Fltk and my C++ knowledge is rather basic. So I've problems finding out if the following task can be solved with Fltk by just reading the documentation and examples code. (I use 1.1.9 with Dev-C++.)

What we are trying to do is writing a program for data display in our lab. The data sets are arrays of 1 Mio points and more.

We would like to draw them at an acceptable speed (I'm aware that I don't have 1 Mio pixels, so there must be some sort of averaging involved, is there an automatic picture/buffer scaling function?). Overlayed should be several horizontal lines that the user can change without the data being redrawn every time. I'd also be able to zoom and scroll.

(I managed to draw some lines in a drawing box derived from Sean Ho's ScribbleBox. But I suppose that method would be too slow for the actual application.
Offline drawing is a little beyond me, I managed to create a buffer, put the content in an FL_RGB_Buffer, but when I try to display it as a Fl_Box->value, all is see is black.)

Is what I describe above in princible possible with Fltk or are we wasting our time here that we should better use with another toolkit?

Thanks in advance,
Indra
  #2  
Old 07-Oct-2009, 12:09
Indra Indra is offline
New Member
 
Join Date: Oct 2009
Posts: 5
Indra is on a distinguished road

Re: Difficult drawing task


Okay, I found this, which seems to be what I want:
Code:
http://phy19.phy.tcd.ie/fltk/cartesian/cartesian/
(sorry for the wrong tags, but [url] cuts off the adress somehow)

But now I have another problem. Because I want to have several graphs in Tabs, I made a subclass of Fl_Group to hold the a canvas and the axes, see below. The code compiles and I can display the empty graph in Fl_Tabs. The problem is, that I can only draw things inside the constructor, not when I call the normal drawing function. However, the drawing function perfectly rescales the axes according to the data I loaded, it just doesn't plot them. What am I doing wrong here?

Header:
CPP / C++ / C Code:
class TS_Canvas:public Fl_Group{ 
   public:	   
        Ca_Canvas* plot_area;
        Ca_X_Axis* x_axis;
        Ca_Y_Axis* y_axis;
        Fl_Scrollbar* x_pos;
        
        void plot(std::vector<double> data);
			   
	TS_Canvas(int x,int y,int w,int h,const char* label);
	//~TS_Canvas();	     
	};

Constructor:
CPP / C++ / C Code:
TS_Canvas::TS_Canvas(int x,int y,int w,int h,const char* label)
:Fl_Group(x,y,w,h,label){
        plot_area = new Ca_Canvas(x+55,y+25,w-60,h-100,label);
        /* deleted formatting */
        x_axis = new Ca_X_Axis(155, 545, 540, 30, "Time [Sampling Points]");
        /* deleted formatting */
        y_axis = new Ca_Y_Axis(125, 75, 50, 600, "I [ADC units]");
        /* deleted formatting */	              
	   
       /* test drawing, works*/
       y_axis->current();
       new Ca_Point(500,1800,FL_GREEN,CA_ROUND,10);
      }

Drawing function:
CPP / C++ / C Code:
void TS_Canvas::plot(std::vector<double> data){
     int i;
    	 y_axis->current();

         /* color change, works */
	 plot_area->color(17);

         /* test drawing, doesn't work */
	 Ca_Point* point = new Ca_Point(600,1800,FL_RED,CA_ROUND,10);
	 
         /* rescaling, works */
         y_axis->minimum(data[1]);
         y_axis->maximum(data[1]);
         x_axis->minimum(0);
         x_axis->maximum(data.size());
	 

	/* drawing loop, it rescales perfectly but doesn't draw anything*/
       for(i=0;i<data.size();i++){
        new Ca_Point(i,1800,FL_BLACK,CA_ROUND,1);
        y_axis->rescale(CA_WHEN_MAX,data[i]);            
        y_axis->rescale(CA_WHEN_MIN,data[i]);
        } 
}
  #3  
Old 14-Oct-2009, 08:25
Indra Indra is offline
New Member
 
Join Date: Oct 2009
Posts: 5
Indra is on a distinguished road

Re: Difficult drawing task


I'll just keep talking to myself, in case someone with a similar problem
comes across this site and finds my ramblings useful.

I've overcome my sub-classing problem above by simply not doing it.
Instead I just made three idential groups with each a Ca_Canvas, two
axes and some other stuff. Not very elegant, but it works.

So, the Cartesian library indeed can plot several hundred thousand
of data points at once. It even looks pretty. But I can easily go and brew
myself a cup of tea while I wait for it to happen. Apperently, Fltk
is not meant for extensive data drawing, just for gui drawing.

I set my hopes now on OpenGl. I read some more tutorials and switched
my canvas to a subclass of Fl_Gl_Window. The problem I'm stuck now
with is that I can only plot as many points as there are pixels in the
window. How can I squeeze more in? Cartesian did this automatically somehow.

I suspect it has to do something with
CPP / C++ / C Code:
int Fl_Gl_Window::mode(MULTISAMPLING)
, but how?
  #4  
Old 13-Nov-2009, 08:54
bluekid bluekid is offline
Junior Member
 
Join Date: Apr 2006
Posts: 42
bluekid will become famous soon enough

Re: Difficult drawing task


i don't understand any thing
simply what is problem ?
look these links may help you

http://www.kiwacan.co.nz/fltk/Fl_PlotXY.html
http://eetorres.googlepages.com/contour
  #5  
Old 13-Nov-2009, 17:45
Indra Indra is offline
New Member
 
Join Date: Oct 2009
Posts: 5
Indra is on a distinguished road

Re: Difficult drawing task


The problem was, that I was looking for a built-in function to magically scale my data into pixel coordinates to fit on the screen. Once I turned on my brain, I realized that this required about two lines of code for a simple linear transformation .

But thanks for looking up the links for me anyway. :-)
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing order Z_guy FLTK Forum 6 09-Sep-2007 13:57
Drawing an image over the CSliderCtrl Reva MS Visual C++ / MFC Forum 0 16-Aug-2007 02:22
Task Manager not COMING up insaneSNIPE Computer Software Forum - Windows 0 08-Oct-2006 23:45
How to save a drawing to the file amgturk MS Visual C++ / MFC Forum 2 25-Jul-2005 01:29
Undo Drawing Nelly MS Visual C++ / MFC Forum 3 10-May-2004 22:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:45.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.