Beispiel #1
0
void Ca_Line::draw(){
  fl_color(color);
  fl_line_style(line_style,line_width);
  fl_begin_line();
  int i;
  if(data_2){
    for(i=0;i<n;i++)
      fl_vertex(x_axis_->position(data[i]),y_axis_->position(data_2[i]));
    fl_end_line();
    fl_line_style(0,0);
    for(i=0;i<n;i++){
      x=data[i];
      y=data_2[i];
      Ca_Point::draw();
    }
  }else{
    for(i=0;i<n;i++)
      fl_vertex(x_axis_->position(data[2*i]),y_axis_->position(data[2*i+1]));
    fl_end_line();
    for(i=0;i<n;i++){
      x=data[2*i];
      y=data[2*i+1];
      Ca_Point::draw();
    }
  }
  fl_line_style(0,0);

};
Beispiel #2
0
void Ca_PolyLine::draw(){
  Ca_Point::draw();
  if(next) return;
  Ca_PolyLine * temp;
  int c=color;
  int style=line_style;
  int size=line_width;
  fl_color(c);
  fl_line_style(style,size);
  fl_begin_line();
  fl_vertex(x_axis_->position(x),y_axis_->position(y));
  temp=(Ca_PolyLine *)previous;
  while(temp){
    fl_vertex(temp->x_axis_->position(temp->x),temp->y_axis_->position(temp->y));
    if((temp->line_style != style)||(temp->color!=c)||(temp->line_width!=size)){
      fl_end_line();
      c=temp->color;
      style=temp->line_style;
      size=temp->line_width;
      fl_color(c);
      fl_line_style(style,size);
      fl_begin_line();
      fl_vertex(temp->x_axis_->position(x),temp->y_axis_->position(y));
    }
    temp=(Ca_PolyLine *)(temp->previous);
  }
  fl_end_line();
  fl_line_style(0,0);
};
Beispiel #3
0
void
SpectrumView::draw ( void ) 
{
    //Clear Widget
    Fl_Box::draw();

    int W = w() - padding_right;
    int H = h() - padding_bottom;

    if ( !_bands ) {
        analyze_data( W );
    }

    //Draw grid
    fl_color(fl_color_add_alpha(fl_rgb_color( 100,100,100), 50 ));

    draw_semilog();

    fl_push_clip( x(),y(),W,H);

            
    fl_color(fl_color_add_alpha( selection_color(), 20 ));
   
    fl_push_matrix();
    fl_translate( x(), y() + 2 );
    fl_scale( W,H- 2 );

    fl_begin_polygon();
    
    fl_vertex(0.0,1.0);

    draw_curve();

    fl_vertex(1.0,1.0);
                  
    fl_end_polygon();

    fl_color(fl_color_add_alpha( selection_color(), 100 ));
    fl_begin_line();
    fl_line_style(FL_SOLID,2);
    
    /* fl_vertex(0.0,1.0); */

    draw_curve();

    /* fl_vertex(1.0,1.0); */

    fl_end_line();
    
    fl_pop_matrix();

    fl_line_style(FL_SOLID,0);

    fl_pop_clip();
}
Beispiel #4
0
void Ca_LinePoint::draw(){
  Ca_Point::draw();
  if(previous){
    fl_color(color);
    fl_line_style(0,line_width);
    fl_begin_line();
    fl_vertex(previous->x_axis_->position(previous->x),previous->y_axis_->position(previous->y));
    fl_vertex(x_axis_->position(x),y_axis_->position(y));
    fl_end_line();
    fl_line_style(0,0);
  }

};
Beispiel #5
0
/*
class win: public Fl_Window
{
	int handle(int event)
	{
		switch(event)
		{
		case FL_PUSH:
		case FL_DRAG:
			int x=Fl::event_x()-BX;
			int y=BY-Fl::event_y();
			printf("pos : %d %d\n", x, y);
			if(y>=0)
				arms->movetoPt(x,y);
		}
		return 1;
	}
public:
	win(int x, int y, int w, int h, const char* text) : Fl_Window(x, y, w, h, text){}

};
*/
void Drawing::draw()
{
	fl_color(FL_WHITE);
	//draw_line(XX+0,0,0,150);
	for (int i=0; i<pairs.size();i++){
		fl_pie(pairs[i].x, pairs[i].y, 10, 10, 0, 360);
	}


	
	draw_line(arms->lines[1]->x1, arms->lines[1]->y1, arms->lines[1]->x2, arms->lines[1]->y2);
	fl_color(FL_WHITE);
	//draw_line(XX+0,150,0,100);
	draw_line(arms->lines[2]->x1, arms->lines[2]->y1, arms->lines[2]->x2, arms->lines[2]->y2);
	fl_color(FL_WHITE);
	//draw_line(XX+0,250,0,75);
	draw_line(arms->lines[3]->x1, arms->lines[3]->y1, arms->lines[3]->x2, arms->lines[3]->y2);


	fl_color(255, 255, 255);
	//int x1 = (int)arms->lines[0]->x1, BY-arms->lines[0]->y1;
	//int y1 = y()-5;
	fl_pie(BX+arms->lines[1]->x1-5, BY-arms->lines[1]->y1-5, 10, 10, 0, 360);

	//int x1 = x()-5;
	//int y1 = y()-5;
	fl_pie(BX+arms->lines[2]->x1-5, BY-arms->lines[2]->y1-5, 10, 10, 0, 360);

	//int x1 = x()-5;
	//int y1 = y()-5;
	fl_pie(BX+arms->lines[3]->x1-5, BY-arms->lines[3]->y1-5, 10, 10, 0, 360);
	//fl_arc(point(0).x,point(0).y,r+r,r+r,0,360);
	//fl_arc(100, 100, 200, 200, 0, 360);
	//fl_pie(0,0,200,200,0,360);

	fl_pie(BX+arms->lines[3]->x2-5, BY-arms->lines[3]->y2-5, 10, 10, 0, 360);

	
	fl_end_line();
}
Beispiel #6
0
void AnimationSet::DrawCover(int nPosX, int nPosY)
{
    auto nOldColor = fl_color();

    fl_color(FL_YELLOW);

    fl_begin_polygon();
    fl_arc(nPosX * 1.0, nPosY * 1.0, m_R * 1.0, 0.0, 360.0);
    fl_end_polygon();

    fl_color(FL_BLUE);

    fl_begin_line();
    fl_arc(nPosX * 1.0, nPosY * 1.0, m_R * 1.0, 0.0, 360.0);
    fl_end_line();

    // we put a cross to indicate the location
    fl_line(nPosX, nPosY - m_R, nPosX, nPosY + m_R);
    fl_line(nPosX - m_R, nPosY, nPosX + m_R, nPosY);

    fl_color(nOldColor);
}
Beispiel #7
0
void custom_graphics(ValueType vt, float val,int W,int H)
{
    int x0,y0,i;
    int _w, _h;
    float x,y,p;
    custom_graph_dimensions(vt, _w, _h);
    x0 = W / 2 - (_w / 2);
    y0 = H;

    switch(vt)
    {
    case VC_FilterVelocitySense:
    {
        p = powf(8.0f,(64.0f-(int)val)/64.0f);

        /* Grid */
        grid(x0,y0,_w,_h, 4);
        /*Function curve*/
        fl_color(FL_BLUE);
        if ((int)val == 127)
        {   // in this case velF will always return 1.0
            y = y0 - _h;
            fl_line(x0, y, x0 + _w, y);
        }
        else
        {
            fl_begin_line();
            for(i = 0; i < _w; i++)
            {
                x = (float)i / (float)_w;
                y = powf(x,p) * _h;
                fl_vertex((float)x0 + i, (float)y0 - y);
            }
            fl_end_line();
        }
        break;
    }
    case VC_FormFilterClearness:
    {
        p = powf(10.0f, (val - 32.0f) / 48.0f); //clearness param
        grid(x0,y0,_w,_h,10);
        fl_color(FL_BLUE);
        fl_begin_line();
        x = 0;
        float frac = 1.0f / (float)_w;
        for(i = 0; i < _w; i++)
        {
            y = (atanf((x * 2.0f - 1.0f) * p) / atanf(p) + 1.0f) * 0.5f * _h;
            fl_vertex((float)x0 + i, (float)y0 - y);
            x += frac;
        }
        fl_end_line();
        break;
    }
    case VC_SubBandwidthScale:
    {
        /* The scale centers around the factor 1 vertically
           and is logarithmic in both dimensions. */

        int margin = 28;
        _h -= margin;
        _w -= margin * 2;
        x0 += margin * 1.25;
        y0 -= margin * 0.75;

        float cy = y0 - _h / 2;

        int j = 1;
        const float lg1020 = log10(20); /* Lower bound = 20hz*/
        const float rx = _w / (log10(20000) - lg1020); /* log. width ratio */
        const float ry = (_h / 2) / log10(100000);

        string hzMarkers[] = {"20", "100", "1k", "10k"};
        string xMarkers[] = {"x10","x100","x1k","x10k","10%","1%","0.1%","0.01%"};

        /* Scale lines */

        fl_font(fl_font(),8);
        fl_line_style(0);
        for(i = 0; i < 4; i++) /* 10x / 10%, 100x / 1% ... */
        {
            y = ry * (i + 1);
            fl_color(169,169,169);
            fl_line(x0, cy - y, x0 + _w, cy - y);
            fl_line(x0, cy + y, x0 + _w, cy + y);
            fl_color(0,0,0);
            fl_draw(xMarkers[i].c_str(), x0 - 28, (cy - y - 4), 24, 12,
                    Fl_Align(FL_ALIGN_RIGHT));
            fl_draw(xMarkers[i + 4].c_str(), x0 - 28, (cy + y - 4), 24, 12,
                    Fl_Align(FL_ALIGN_RIGHT));
        }

        /* Hz lines */

        fl_color(196,196,196); /* Lighter inner lines*/

        for(i = 10;i != 0; i *= 10)
        {
            for(j = 2; j < 10; j++)
            {
                x = x0 + rx * (log10(i * j) - lg1020) + 1;
                fl_line(x, y0, x, y0 - _h);
                if(i * j >= 20000)
                {
                    i = 0;
                    break;
                }
            }
        }

        fl_font(fl_font(),10);
        for(i = 0; i < 4; i++) /* 20, 100, 1k, 10k */
        {
            x = x0 + (i == 0 ?  0 : ((float)i + 1 - lg1020) * rx);
            fl_color(127,127,127); /* Darker boundary lines */
            fl_line(x, y0, x, y0 - _h);
            fl_color(FL_BLACK);
            fl_draw(hzMarkers[i].c_str(), x - 20, y0 + 4, 40, 12,
                    Fl_Align(FL_ALIGN_CENTER));
        }
        /* Unit marker at the lower right of the graph */
        fl_draw("Hz", x0 + _w, y0 + 4, 20, 12, Fl_Align(FL_ALIGN_LEFT));

        /* Vertical center line */
        fl_color(64,64,64);
        fl_line(x0 - margin, cy, x0 + _w, cy);

        /* Function curve */
        fl_color(FL_BLUE);
        if((int)val == 0)
        {
            fl_line(x0, cy, x0 + _w, cy);
        }
        else
        {
            const float p = ((int)val / 64.0f) * 3.0;

            /* Cairo not necessary, but makes it easier to read the graph */
            cairo_t *cr;
            cairo_surface_t* Xsurface = cairo_xlib_surface_create
                (fl_display, fl_window, fl_visual->visual,
                 Fl_Window::current()->w(), Fl_Window::current()->h());
            cr = cairo_create (Xsurface);

            cairo_set_source_rgb(cr, 1, 0, 0);
            cairo_set_line_width(cr, 1.5);
            cairo_move_to(cr, x0, cy - ry * log10(powf(50, p)));
            cairo_line_to(cr, x0 + _w, cy - ry * log10(powf(0.05, p)));
            cairo_stroke(cr);

            cairo_surface_destroy(Xsurface);  cairo_destroy(cr);
        }
        break;
    }
    default:
        break;
    }
}
Beispiel #8
0
void PDFwin::draw()
{
	Fl_Double_Window::draw();


	int ww=w()-2;
	int hh=h()-2;

	if(!mModel) return;

	if(mState=="load")
	{
		fl_draw("loading page (please wait)", 0,0,w(), h(), FL_ALIGN_CENTER);
		return;
	}

	CImage* bmp=mModel->getPage(ww, hh, mCurrPage);
	std::list<SelectionRectangle> ::iterator i;
	for(i=mRects.begin(); i!=mRects.end(); ++i)
		(*i).updateScreenCoord(*this);
	
	int x=toWindowCoord(0,0).x;
	int y=toWindowCoord(0,0).y;
	//fl_draw_image(bmp->getDataPtr(), x, y, bmp->getWidth() , bmp->getHeight(), 3, bmp->getRowSize());
	
	fl_draw_CImage(*bmp, TRect(0, 0, bmp->GetWidth(), bmp->GetHeight()), x, y);

	// draw rects
	int c=0;

	for(i=mRects.begin(); i!=mRects.end(); ++i)
	{
		SelectionRectangle& mRect=*i;
		if(mRect.isValid())
		{
			c++;
			Fl_Boxtype type=FL_SHADOW_FRAME;
			if(i!=mSelectedRect)
				type=FL_BORDER_FRAME;

			fl_draw_box( type, mRect.left, mRect.top, mRect.Width(), mRect.Height(), FL_BLACK);

			TString temp;
			temp.format("Crop %d", c);
			fl_draw(temp, mRect.left, mRect.top, mRect.Width(), mRect.Height(), FL_ALIGN_TOP);

			if(i==mSelectedRect)
			{
				for(int j=0; j<2; j++)
				{
					int x=mRect.left;
					int y=mRect.top;
					if(j==1)
					{
						x=mRect.right;
						y=mRect.bottom;
					}
					fl_color(FL_WHITE);
					fl_begin_polygon();
					fl_arc(x, y, 3, 0,360);
					fl_end_polygon();
					fl_color(FL_BLACK);
					fl_begin_line();
					fl_arc(x-3, y-3, 7, 7, 0,360);
					fl_end_line();
				}
			}

		}
	}

	/*TString temp;
	temp.format("selected %d", mSelectedRect);
	fl_draw(temp, 0,0,w(), h(), FL_ALIGN_CENTER);
	*/

	
FlLayout* layout=mLayout->findLayout("Automatic segmentation");
double cropT=layout->findSlider("Crop T")->value()/100.0;
double cropB=layout->findSlider("Crop B")->value()/100.0;
double cropL=layout->findSlider("Crop L")->value()/100.0;
double cropR=layout->findSlider("Crop R")->value()/100.0;

int wCropL=toWindowCoord(cropL,cropT).x;
int wCropT=toWindowCoord(cropL,cropT).y;
int wCropR=toWindowCoord(cropR,cropB).x;
int wCropB=toWindowCoord(cropR,cropB).y;

fl_draw_box( FL_BORDER_FRAME, 0, 0, ww, wCropT, FL_BLACK);
fl_draw_box( FL_BORDER_FRAME, 0, hh-wCropB, ww, wCropB, FL_BLACK);
fl_draw_box( FL_BORDER_FRAME, 0, 0, wCropL, hh, FL_BLACK);
fl_draw_box( FL_BORDER_FRAME, ww-wCropR, 0, wCropR, hh, FL_BLACK);
}
Beispiel #9
0
 FL_EXPORT_C(void,flc_end_line)( ){
   fl_end_line();
 }
Beispiel #10
0
// Draw the block window...
void BlockWindow::draw() {
	int		j, k, xx, yy;
	Block		*b;
	Column	*c;

	// Draw the blocks...
	fl_color(FL_BLACK);
	fl_rectf(0, 0, w(), h());

	// Draw the blocks...
	for (j = num_columns_, c = columns_; j > 0; j --, c ++)
		for (k = c->num_blocks, b = c->blocks; k > 0; k --, b ++) {
			xx = w() - c->x;
			yy = h() - BLOCK_SIZE - b->y;

			if (b->color >= BLOCK_BLAST) {
				b->color ++;
				blast_pixmap.draw(xx, yy);
			} else if (b->color < 0) {
				if (b->bomb) bomb_pixmaps[-b->color - 1]->draw(xx, yy);
				else normal_pixmaps[-b->color - 1]->draw(xx, yy);
			} else {
				if (b->bomb) bomb_pixmaps[b->color - 1]->draw(xx, yy);
				else normal_pixmaps[b->color - 1]->draw(xx, yy);
			}
		}

	if (interval_ < 0.0 || paused_) {
		fl_color(FL_BLACK);
		screen_tile.draw(0, 0, w(), h(), 0, 0);
	}

	// Redraw the widgets...
	play_button_->redraw();
	help_button_->redraw();
	draw_children();

	// Draw any paused/game over/new game message...
	if ((paused_ || interval_ < 0.0) && play_button_->w() == 80) {
		const char *s;

		if (help_) {
			s = "Click on adjacent blocks of the same color. Clear all blocks "
				"before they reach the left side.";

			fl_font(FL_HELVETICA_BOLD, 24);
			fl_color(FL_BLACK);
			fl_draw(s, 171, 3, w() - 250, h() - 6,
					(Fl_Align)(FL_ALIGN_WRAP | FL_ALIGN_LEFT));

			fl_color(FL_YELLOW);
			fl_draw(s, 168, 0, w() - 250, h(),
					(Fl_Align)(FL_ALIGN_WRAP | FL_ALIGN_LEFT));
		} else {
			if (interval_ < 0.0) {
#ifdef DEBUG
				// Show sample waveform...
				short *sample_ptr;

				for (i = 0; i < 2; i ++)
				{
					fl_color(FL_RED + i);
					fl_begin_line();
					for (j = 0, sample_ptr = sound_->sample_data + i;
							j < sound_->sample_size;
							j ++, sample_ptr += 2)
						fl_vertex(j * w() / sound_->sample_size,
								*sample_ptr * h() / 4 / 65534 + h() / 2);
					fl_end_line();
				}
#endif // DEBUG

				if (num_columns_ && (time(NULL) & 7) < 4) s = "Game Over";
				else s = "Block Attack!\nby Michael R Sweet";
			} else s = "Paused";

			fl_font(FL_HELVETICA_BOLD, 32);
			fl_color(FL_BLACK);
			fl_draw(s, 6, 6, w() - 6, h() - 6, FL_ALIGN_CENTER);

			fl_color(FL_YELLOW);
			fl_draw(s, 0, 0, w(), h(), FL_ALIGN_CENTER);
		}
	}

	// Draw the scores and level...
	char s[255];

	sprintf(s, " Score: %d", score_);
	fl_color(FL_WHITE);
	fl_font(FL_HELVETICA, 14);
	fl_draw(s, 40, 0, w() - 40, 20, FL_ALIGN_LEFT);

	sprintf(s, "High Score: %d ", high_score_);
	fl_draw(s, 0, 0, w(), 20, FL_ALIGN_RIGHT);

	if (level_ > 1 || title_y_ <= 0)
	{
		sprintf(s, "Level: %d ", level_);
		fl_draw(s, 0, 0, w(), 20, FL_ALIGN_CENTER);
	}

	if (title_y_ > 0 && interval_ > 0.0)
	{
		int sz = 14 + title_y_ * 86 / h();

		fl_font(FL_HELVETICA_BOLD, sz);
		fl_color(FL_YELLOW);
		fl_draw(title_, 0, title_y_, w(), sz, FL_ALIGN_CENTER);
	}
}
Beispiel #11
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();
  }
};
void Fl_Canvas::DrawWires()
{
        fl_line_style( FL_SOLID, 2 );

	for(vector<CanvasWire>::iterator i=m_WireVec.begin();
		i!=m_WireVec.end(); i++)
	{
		Fl_DeviceGUI* SourceDevice = FindDevice(i->OutputID);
		Fl_DeviceGUI* DestDevice   = FindDevice(i->InputID);

		if (!SourceDevice || !DestDevice)
		{
			SpiralInfo::Alert("Cant find source or dest device while drawing wires");
			return;
		}

         Fl_Color col = (Fl_Color) WIRE_COL0;
         switch (SourceDevice->GetPortType(i->OutputPort+SourceDevice->GetInfo()->NumInputs)) {
             case 0:     col = (Fl_Color) WIRE_COL0; break;
             case 1:     col = (Fl_Color) WIRE_COL1; break;
             case 2:     col = (Fl_Color) WIRE_COL2; break;
             case 3:     col = (Fl_Color) WIRE_COL3; break;
             case 4:     col = (Fl_Color) WIRE_COL4; break;
             default:    col = (Fl_Color) WIRE_COL0;
         }
         fl_color(col);

#ifdef NTK_MAJOR_VERSION
         fl_color( fl_color_add_alpha( fl_color(), 127 ) );
#endif

                double ep1_x, ep1_y, ep2_x, ep2_y,
                    ep1_mix_x,
                    ep1_new_x,
                    ep1_mid_x,
                    ep2_mid_x,
                    ep2_new_x,
                    ep1_mid_y,
                    ep2_mid_y;
                
                ep1_x = SourceDevice->GetPortX(i->OutputPort+SourceDevice->GetInfo()->NumInputs);
                
                ep1_y = SourceDevice->GetPortY(i->OutputPort+SourceDevice->GetInfo()->NumInputs);
                ep1_mid_y = ep1_y + 7.5;
                
                
                ep2_x = DestDevice->GetPortX(i->InputPort);
                ep2_y = DestDevice->GetPortY(i->InputPort);
                ep2_mid_y = 7.5 + ep2_y;
                
                ep1_mid_x = fabs(ep1_x-ep2_x)/2;
                ep1_new_x = ep1_x+ep1_mid_x;
                
                ep2_mid_x = fabs(ep1_x-ep2_x)/2;
                ep2_new_x = ep2_x-ep2_mid_x;
                
                fl_begin_line();
                
                fl_curve( ep1_x, ep1_y, ep1_new_x, ep1_mid_y, ep2_new_x, ep2_mid_y, ep2_x, ep2_y );
                
                fl_end_line();

		/* fl_line(SourceDevice->GetPortX(i->OutputPort+SourceDevice->GetInfo()->NumInputs), */
		/* 		SourceDevice->GetPortY(i->OutputPort+SourceDevice->GetInfo()->NumInputs), */
		/* 		DestDevice->GetPortX(i->InputPort), */
		/* 		DestDevice->GetPortY(i->InputPort)); */
	}

	DrawIncompleteWire();
        
        fl_line_style( FL_SOLID, 0 );
}
Beispiel #13
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();
}