Did you use Cartesian widgets as an example?

If so, some explanation:
I have added a special custom flag to speed-up incremental redrawing when 
additional object is added on top of Ca_Canvas - but previous drawings are still
valid. Ihis flag is used ONLY for Ca_Canvas - but not for axes, they need to be 
redrawn as a whole and axes must have box of OPAQUE type (not frames only)
Anyway, you need to be cautions with custom damage, normally you should perform 
redraw of the whole widget. IF you know that ONLY some part of the widget has
changed, you could do partial redraw and use a free damage flag as nan 
indicator (look to Fl;_Widget which are free). Note that new redraw must fully 
cover the
changed area and there is not left some residuals from last drawing - otherwise 
you need to do the whole redraw.

In that case you could implement drawing function like:

class My_Widget: public Fl_Box{

void draw(){
  if(damage()!= MY_DAMAGE){ // must redraw the whole thing,
     Fl_Box::draw(); // drawing box + background
     ... // drawing additional things
  }
  draw_my_widget_part() //must always cover area from last call to 
draw_my_widget_part()
}

};

R.



On 14/02/2011 22:58, Giau P wrote:
> I have the following code. Every time start_cb() is called with new a set of 
> data given. This new set of data is used to draw new graphs, ticks and labels 
> for an x-axis. I have damage() called in Minimum() and Maximum(), but it does 
> not clear the existing ticks and labels for the new ticks and labels 
> corresponding to the new data set. Please give me some advice on what should 
> be done. Thanks,
> 
> Giau
> 
> 
> enum Damage {CA_DAMAGE_ALL=1, CA_DAMAGE_ADD=2};
> 
> class Axis: public Fl_Box
> {
> public:
>    void Minimum(double minimum)
>    {
>        damage(CA_DAMAGE_ALL);
>        min = minimum;
>    }
>    void Maximum(double maximum)
>    {
>        damage(CA_DAMAGE_ALL);
>        max = maximum;
>    }
> };
> 
> class X_Axis: public Axis
> {
> protected:
>     void draw()
>     {   ...
>         draw x axis with ticks and label
>         ...
>     };
> }
> 
> class Graph : public Fl_Gl_Window
> {
>     X_Axis *x_axis;
>     float min, max;
> public:
>     void Calculate() {... set min and max ...}
>     float GetMin(){ return min; }
>     float GetMax(){ return max; }
>     Graph(....) { x_axis = new X_axis(...); }
> }
> 
> 
> void start_cb( Fl_Widget* o, void*)
> {
>     graph->Calculate();
>     graph->x_axis->Minimum(graph->GetMin());
>     graph->x_axis->Maximum(graph->GetMax());
>     graph->x_axis->redraw();
> }
> 
> in Main()
> {
>    graph = new Graph(245, 334, 134, 179, "");
> }
> 

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to