Ejemplo n.º 1
0
void PolyObject::drawPolyLine(float polyOriginX, float polyOriginY, float pixelsPerCell, float cellsPerMeter) {
    fl_begin_loop();

    for(unsigned i = 0; i < points.size(); i++) {
        float pointOffsetX = SiteObject::worldToScreen(points[i].x, pixelsPerCell, cellsPerMeter);
        float pointOffsetY = SiteObject::worldToScreen(points[i].y, pixelsPerCell, cellsPerMeter);

        float pointX = polyOriginX + pointOffsetX;
        float pointY = polyOriginY - pointOffsetY;

        fl_vertex(pointX, pointY);
    }

    if(nextPoint) {
        float pointOffsetX = SiteObject::worldToScreen(nextPoint->x, pixelsPerCell, cellsPerMeter);
        float pointOffsetY = SiteObject::worldToScreen(nextPoint->y, pixelsPerCell, cellsPerMeter);

        float pointX = polyOriginX + pointOffsetX;
        float pointY = polyOriginY - pointOffsetY;

        fl_vertex(pointX, pointY);
    }

    fl_end_loop();


}
Ejemplo n.º 2
0
static inline void ca_rect(double x, double y, double w, double h){
  fl_begin_loop();
  fl_vertex(x,y);
  fl_vertex(x+w,y);
  fl_vertex(x+w,y+h);
  fl_vertex(x,y+h);
  fl_end_loop();
};
Ejemplo n.º 3
0
void DesktopIcon::draw(void) { 
	// draw_box(FL_UP_BOX, FL_BLACK);

	if(image() && (damage() & FL_DAMAGE_ALL)) {
		Fl_Image* im = image();

		/* center image in the box */
		int ix = (w()/2) - (im->w()/2);
		int iy = (h()/2) - (im->h()/2);
		ix += x();
		iy += y();

		/* darker_img is always present if image() is present */
		if(is_focused())
			darker_img->draw(ix, iy);
		else
			im->draw(ix, iy);

		E_DEBUG(E_STRLOC ": DesktopIcon icon redraw\n");
	}

	if(gsettings->label_draw && (damage() & (FL_DAMAGE_ALL | EDAMAGE_CHILD_LABEL))) {
		int X = x() + w()-(w()/2)-(lwidth/2);
		int Y = y() + h() + LABEL_OFFSET;

		Fl_Color old = fl_color();

		if(!gsettings->label_transparent) {
			fl_color(gsettings->label_background);
			fl_rectf(X, Y, lwidth, lheight);
		}

		int old_font = fl_font();
		int old_font_sz = fl_size();

		/* draw with icon's font */
		fl_font(labelfont(), labelsize());

		/* pseudo-shadow */
		fl_color(FL_BLACK);
		fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0);

		fl_color(gsettings->label_foreground);
		fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0);

		/* restore old font */
		fl_font(old_font, old_font_sz);

		if(is_focused()) {
			/* draw focused box on our way so later this can be used to draw customised boxes */
			fl_color(gsettings->label_foreground);
			fl_line_style(FL_DOT);

			fl_push_matrix();
			fl_begin_loop();
				fl_vertex(X, Y);
				fl_vertex(X + lwidth, Y);
				fl_vertex(X + lwidth, Y + lheight);
				fl_vertex(X, Y + lheight);
				fl_vertex(X, Y);
			fl_end_loop();
			fl_pop_matrix();

			/* revert to default line style */
			fl_line_style(0);
		}

		/* revert to old color whatever that be */
		fl_color(old);
		E_DEBUG(E_STRLOC ": DesktopIcon label redraw\n");
	}
}
Ejemplo n.º 4
0
 FL_EXPORT_C(void,flc_end_loop)( ){
   fl_end_loop();
 }
Ejemplo n.º 5
0
void Ca_Y_Axis::draw_grid(){
  if(!valid_)return;
  if(max_==min_)return;
  int tick_index=-1;
  double tick_value;
  int tick_order;
  double _interval=0;
  int l1,l2;

  int BD = 0;
  Fl_Widget * W_ = this;
  if(canvas_){
    BD = canvas_->border();
    W_ = canvas_;
  }else if(widget_){
    W_ = widget_;
  }
  l1=W_->x()+Fl::box_dx(W_->box());
  l2=W_->x()+W_->w()+Fl::box_dx(W_->box())-Fl::box_dw(W_->box());
  int tcl;
  if(!(tcl=tick_length_))
    tcl=label_font_size_;
  while(next_tick(tick_index, tick_value, tick_order,_interval)){
    double _pos=position(tick_value);
    if(scale_&CA_REV){
      if(_pos<min_pos_-BD) continue;
      if(_pos>max_pos_+BD) break;
    }else{
      if(_pos<max_pos_-BD) break;
      if(_pos>min_pos_+BD) continue;
    }
    int grt;
    if((grt=grid_visible_&CA_LABEL_GRID) && !(tick_index % label_step_)){
      fl_color(label_grid_color_);
      fl_line_style(label_grid_style_,label_grid_width_);
      if(grt==CA_LABEL_GRID){
        fl_begin_loop();
        fl_vertex(l1,_pos);
        fl_vertex(l2,_pos);
        fl_end_loop();

      }else{
        if(grt&CA_LEFT_LABEL_TICK){
          fl_begin_loop();
          fl_vertex(l1,_pos);
          fl_vertex(l1+tcl,_pos);
          fl_end_loop();
        }
        if(grt&CA_RIGHT_LABEL_TICK){
          fl_begin_loop();
          fl_vertex(l2-tcl,_pos);
          fl_vertex(l2,_pos);
          fl_end_loop();
        }
      }
    }else if((grt=grid_visible_&CA_MAJOR_GRID) && !(tick_index % major_step_)){
      fl_color(major_grid_color_);
      fl_line_style(major_grid_style_,major_grid_width_);
      if(grt==CA_MAJOR_GRID){
        fl_begin_loop();
        fl_vertex(l1,_pos);
        fl_vertex(l2,_pos);
        fl_end_loop();

      }else{
        if(grt&CA_LEFT_MAJOR_TICK){
          fl_begin_loop();
          fl_vertex(l1,_pos);
          fl_vertex(l1+tcl,_pos);
          fl_end_loop();
        }
        if(grt&CA_RIGHT_MAJOR_TICK){
          fl_begin_loop();
          fl_vertex(l2-tcl,_pos);
          fl_vertex(l2,_pos);
          fl_end_loop();
        }
      }
    }else if((grt=(grid_visible_&CA_MINOR_GRID))){
      fl_color(minor_grid_color_);
      fl_line_style(minor_grid_style_,minor_grid_width_);
      if(grt==CA_MINOR_GRID){
        fl_begin_loop();
        fl_vertex(l1,_pos);
        fl_vertex(l2,_pos);
        fl_end_loop();

      }else{
        if(grt&CA_LEFT_MINOR_TICK){
          fl_begin_loop();
          fl_vertex(l1,_pos);
          fl_vertex(l1+tcl/2,_pos);
          fl_end_loop();
        }
        if(grt&CA_RIGHT_MINOR_TICK){
          fl_begin_loop();
          fl_vertex(l2-tcl/2,_pos);
          fl_vertex(l2,_pos);
          fl_end_loop();
        }
      }
    }
  }

  fl_line_style(0,0);
  fl_color(FL_BLACK);
};
Ejemplo n.º 6
0
static inline void ca_loop(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){
  fl_begin_loop();
  fl_vertex(x1,y1); fl_vertex(x2,y2); fl_vertex(x3,y3); fl_vertex(x4,y4);
  fl_end_loop();
};
Ejemplo n.º 7
0
void Ca_Y_Axis::draw(){
  if(min_==max_) return;
  int BD = 0;
  Fl_Widget * W_ = this;
  if(canvas_){
    BD = canvas_->border();
    W_ = canvas_;
  }else if(widget_){
    W_ = widget_;
  }
  int tick_index=-1;
  double tick_value;
  int tick_order;//,tick_number;
  double _interval=0;
  const char * label_format=label_format_;
  //    if(damage()|FL_DAMAGE_ALL)
  //        draw_label();
  if (damage()&(FL_DAMAGE_ALL|CA_DAMAGE_ALL)){
    update();
    if (box()==FL_NO_BOX){
      fl_color(parent()->color());
      fl_rectf(x(),y(),w(),h());
    }else
      draw_box();
    if(!valid_) return;
    fl_font(label_font_face_,label_font_size_);
    int l1=0; int l2=0; int m1=0; int m2=0; int l=0; int _x=0; int _w,_h; //temporary coordinates for ticks
    double _pos,_y;
    //fl_clip(x()+Fl::box_dx(box()),y()+Fl::box_dy(box()),w()-Fl::box_dw(box()),h()-Fl::box_dh(box()));
    fl_color(axis_color_);
    int a=x()+Fl::box_dx(box())+border_;
    int b=a+w()-Fl::box_dw(box())-2*border_;
    switch(axis_align_ & CA_ALIGNMENT){
            case CA_RIGHT:
              l=l1=m1=a;
              if(axis_align_&CA_NO_TICS)
                m2=m1;
              else
                if (tick_length_)
                  m2=m1+tick_length_;
                else
                  m2=m1+label_font_size_;
              l2=(l1+m2)/2;
              break;
            case CA_LEFT:
              l=l2=m2=b-1;
              if(axis_align_&CA_NO_TICS)
                m1=m2;
              else
                if (tick_length_)
                  m1=m2-tick_length_;
                else
                  m1=m2-label_font_size_;
              l1=(m1+m2)/2;
              break;
            case CA_CENTER:
              m1=a;
              m2=b;
              l=(a+b)/2;
              l1=(a+l)/2;
              l2=(l+b)/2;
              break;
    }
    fl_line_style(FL_SOLID|FL_CAP_FLAT,tick_width_);
    //		double minp,maxp;
    double start_tick;
    double end_tick;
    bool tick_not_started = 1;


    while(next_tick(tick_index, tick_value, tick_order, _interval)){
      _pos=position(tick_value);
      if(scale_&CA_REV){
        if((_pos+1)<min_pos_-BD) continue;
        if((_pos-1)>max_pos_+BD) break;
      }else{
        if((_pos+1)<max_pos_-BD) break;
        if((_pos-1)>min_pos_+BD) continue;
      }
      if(!(axis_align_&CA_NO_TICS)){
        fl_begin_loop();
        if(tick_index % major_step_){
          fl_vertex(l1,_pos);
          fl_vertex(l2,_pos);
        }else{
          fl_vertex(m1,_pos);
          fl_vertex(m2,_pos);
        }
        fl_end_loop();
        if(tick_not_started){
          tick_not_started = 0;
          start_tick = _pos;
        }
        end_tick = _pos;
      }
      if(!((tick_index % label_step_)|(axis_align_&CA_NO_LABELS))){
        char label[MAX_LABEL_LENGTH];
        char _label_format[MAX_LABEL_FORMAT];
        if(!label_format){
          int _tick_order;
          if (tick_order>=0)
            _tick_order=0;
          else
            _tick_order=-tick_order - 1;
          sprintf(_label_format,"%s.%if","%",_tick_order);
        }
        else
          strcpy(_label_format,label_format);
        sprintf(label, _label_format,tick_value);
        fl_measure(label,_w,_h);
        _y=_pos+_h/3;
        switch (axis_align_ & CA_ALIGNMENT){
                    case CA_LEFT:
                      _x=m1-_h/3-_w;
                      break;
                    case CA_RIGHT:
                      _x=m2+_h/3;
                      break;
                    case CA_CENTER:
                      _x=(m1+m2)/2-_w/2;
                      Fl_Color _color=fl_color();
                      fl_color(color());
                      ca_rectf(_x-_h/6,_pos-_h/2,_w+_h/3,_h);
                      fl_color(_color);
                      break;
        }
        ca_text(label,_x,_y);
      }
    }
    if((axis_align_ & CA_LINE) && !tick_not_started){
      fl_begin_line();
      fl_vertex(l,start_tick);
      fl_vertex(l,end_tick);
      //fl_vertex(l,W_->y()+Fl::box_dy(W_->box()));
      //fl_vertex(l,W_->y()+W_->h()+Fl::box_dy(W_->box())-Fl::box_dh(W_->box()));

      fl_end_line();
    }
    fl_line_style(0);
    //fl_pop_clip();
  }
};
Ejemplo n.º 8
0
void Ca_Point::draw(){
  fl_color(color);
  double s,t;
  double _x=x_axis_->position(x);
  double _y=y_axis_->position(y);
  switch(style & CA_POINT_STYLE){
  case CA_NO_POINT:
    break;
  case CA_SIMPLE:
    ca_point(_x,_y);
    break;
  case CA_ROUND:
    ca_filled_circle(_x,_y,size);
    //ca_pie(_x-size,_y-size,2*size,2*size,0,360);
    if (style & CA_BORDER){
      fl_color(border_color);
      fl_line_style(0,border_width);
      fl_begin_loop();
      fl_circle(_x,_y,size);
      fl_end_loop();
      fl_line_style(0,0);
    }
    break;
  case CA_SQUARE:
    ca_rectf(_x-size,_y-size,2*size,2*size);
    if (style & CA_BORDER){
      fl_color(border_color);
      fl_line_style(0,border_width);
      ca_rect(_x-size,_y-size,2*size,2*size);
      fl_line_style(0,0);
    }
    break;
  case CA_UP_TRIANGLE:
    s=(int)(1.12*size+0.5);
    t=_y+size/3;
    ca_polygon(_x,t-2*size,_x-s,t,_x+s,t);
    if (style & CA_BORDER){
      fl_color(border_color);
      fl_line_style(0,border_width);
      ca_loop(_x,t-2*size,_x-s,t,_x+s,t);
      fl_line_style(0,0);
    }
    break;
  case CA_DOWN_TRIANGLE:
    s=(int)(1.12*size+0.5);
    t=_y-size/3;
    ca_polygon(_x,t+2*size,_x-s,t,_x+s,t);
    if (style & CA_BORDER){
      fl_color(border_color);
      fl_line_style(0,border_width);
      ca_loop(_x,t+2*size,_x-s,t,_x+s,t);
      fl_line_style(0,0);
    }
    break;
  case CA_DIAMOND:
    s=(int)(1.3*size+0.5);
    ca_polygon(_x,_y-s,_x-s,_y,_x,_y+s,_x+s,_y);
    if (style & CA_BORDER){
      fl_color(border_color);
      fl_line_style(0,border_width);
      ca_loop(_x,_y-s,_x-s,_y,_x,_y+s,_x+s,_y);
      fl_line_style(0,0);
    }
    break;
  }
};
Ejemplo n.º 9
0
Archivo: Panner.C Proyecto: 0mk/non
void
Panner::draw ( void )
{
    int tw, th, tx, ty;

    bbox( tx, ty, tw, th );

    fl_push_clip( x(),y(),w(),h() );

    draw_the_box( tx, ty, tw, th );

//    draw_box();
    draw_label();

    /* if ( _bypassed ) */
    /* { */
    /*     draw_box(); */
    /*     fl_color( 0 ); */
    /*     fl_font( FL_HELVETICA, 12 ); */
    /*     fl_draw( "(bypass)", x(), y(), w(), h(), FL_ALIGN_CENTER ); */
    /*     goto done; */
    /* } */
   
    /* tx += b; */
    /* ty += b; */
    /* tw -= b * 2; */
    /* th -= b * 2; */

    fl_line_style( FL_SOLID, 1 );

    fl_color( FL_WHITE );

    for ( unsigned int i = 0; i < _points.size(); i++ )
    {
        Point *p = &_points[i];

        if ( ! p->visible )
            continue;

        Fl_Color c = fl_color_add_alpha( p->color, 100 );

        fl_color(c);

        int px, py, pw, ph;
        point_bbox( p, &px, &py, &pw, &ph );
      
        {
            float po = 5;

            fl_push_clip( px - ( po * 12 ), 
                          py - ( po * 12 ),
                          pw + ( po * 24 ), ph + (po * 24 ));

            fl_pie( px + 5, py + 5, pw - 10, ph - 10, 0, 360 );


            fl_pie( px, py, pw, ph, 0, 360 );

            fl_pop_clip();

            if ( projection() == POLAR )
            {
           
                fl_color( fl_color_average( fl_rgb_color( 127,127,127 ), p->color, 0.50 ) );
                fl_begin_loop();
                fl_circle( tx + tw/2, ty + th/2, tw/2.0f * ( ( p->radius() / range() )));
                fl_end_loop();
            }

        }
    
        const char *s = p->label;

        fl_color( fl_color_add_alpha( fl_rgb_color( 220,255,255 ), 127 ) );
        fl_font( FL_HELVETICA_BOLD_ITALIC, 10 );
        fl_draw( s, px + 20, py + 1, 50, ph - 1, FL_ALIGN_LEFT );

        if ( tw > 100 )
        {
            char pat[50];
            snprintf( pat, sizeof(pat), "%.1f°:%.1f° %.1fm", p->azimuth(), p->elevation(), p->radius() );
            
//        fl_color( fl_color_add_alpha( fl_rgb_color( 220,255,255 ), 127 ) );
            fl_font( FL_COURIER, 9 );

            fl_draw( pat, px + 20, py + 15, 50, ph - 1, FL_ALIGN_LEFT | FL_ALIGN_WRAP );

            /* fl_font( FL_HELVETICA_ITALIC, 9 ); */
            /* snprintf(pat, sizeof(pat), "range: %.1f meters", range() ); */
            /* fl_draw( pat, tx, ty, tw, th, FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_INSIDE ); */
                
            /* if ( _projection == POLAR ) */
            /* { */
            /*     fl_draw( "Polar perspective; azimuth, elevation and radius input. Right click controls radius.", tx, ty, tw, th, FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ); */
            /* } */
            /* else */
            /* { */
            /*     fl_draw( "Polar orthographic; angle and distance input.", tx, ty, tw, th, FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ); */
            /* } */
        }

    }
    
    if ( tw > 200 )
        draw_children();

    fl_line_style( FL_SOLID, 0 );

    fl_pop_clip();
}
Ejemplo n.º 10
0
void Fl_Gauge::draw(void)
{
    int X = x();
    int Y = y();
    int W = w();
    int H = h();

    draw_box();

    X += Fl::box_dx(box());
    Y += Fl::box_dy(box());
    W -= Fl::box_dw(box());
    H -= Fl::box_dh(box());

    double frac = (value() - minimum()) / (maximum() - minimum());
    double angle = (angle2() - angle1()) * frac +  angle1();

    float cx = X + W/2.0f;
    float cy = Y + H/2.0f;

    float d = (float)((W < H)? W : H);

    double num_major_ticks = (maximum() - minimum()) / major_step_size;
    double num_minor_ticks = (maximum() - minimum()) / minor_step_size;

    double minor_angle = (angle2() - angle1()) / num_minor_ticks;
    double major_angle = (angle2() - angle1()) / num_major_ticks;
    int i;

    fl_color(FL_WHITE);
    fl_line_style(FL_SOLID, 1);

/* minor ticks */
    fl_push_matrix();
    fl_color(FL_WHITE);
    fl_translate(cx, cy);
    fl_scale(d, d);
    fl_rotate(-angle1());
    for (i = 0; i <= num_minor_ticks; i++) {
        fl_begin_line();
        fl_vertex(0, 0.40);
        fl_vertex(0, 0.45);
        fl_end_line();
        fl_rotate(-minor_angle);
    }
    fl_pop_matrix();

/* major ticks */
    fl_push_matrix();
    fl_color(FL_WHITE);
    fl_line_style(FL_SOLID, 3);
    fl_translate(cx, cy);
    fl_scale(d, d);
    fl_rotate(-angle1());
    for (i = 0; i <= num_major_ticks; i++) {
        fl_begin_line();
        fl_vertex(0, 0.40);
        fl_vertex(0, 0.47);
        fl_end_line();
        fl_rotate(-major_angle);
    }
    fl_pop_matrix();

/* tick labels */
    char buf[128];
    fl_color(FL_WHITE);
    for (i = 0; i <= num_major_ticks; i++) {
        snprintf(buf, sizeof(buf), "%.0lf", minimum() + i * major_step_size);
        double angle = 360.0 + -angle1() - 90 - i * major_angle;
        double rad = angle * M_PI/180.0;
        int width = 0;
        int height = 0;
        fl_measure(buf, width, height);
        if (width < 1) {
            width = 9;
        }
        if (height < 1) {
            height = 16;
        }
        double radius = d / 3;
        double x = cx + radius * cos(rad);
        double y = cy - radius * sin(rad);
        if (rad < M_PI/2.0 || rad > 3 * M_PI/2.0) {
            x = cx + (radius - width/2.0) * cos(rad);
        }
        x -= width/2.0;
        fl_draw(buf, x, y + height/2.0);
    }

    fl_push_matrix();
    fl_translate(cx, cy);
    fl_scale(d, d);

    fl_color(FL_WHITE);

    fl_rotate(-angle);

/* arrow */
    fl_begin_polygon();
    fl_vertex(-0.02, 0.03);
    fl_vertex(-0.02, 0.35);
    fl_vertex( 0.00, 0.37);
    fl_vertex( 0.02, 0.35);
    fl_vertex( 0.02, 0.03);
    fl_end_polygon();

/* border */
    fl_begin_loop();
    fl_circle(0.0, 0.0, 0.48);
    fl_end_loop();

    fl_pop_matrix();

    fl_color(FL_GRAY);
    fl_pie(cx - d * 0.05, cy - d * 0.05, d * 0.1, d * 0.1, 0, 360.0);
    fl_color(FL_BLACK);
    fl_pie(cx - d * 0.025, cy - d * 0.025, d * 0.05, d * 0.05, 0, 360.0);

    draw_label();
}