Exemplo n.º 1
0
static inline void ca_rectf(double x, double y, double w, double h){
  fl_begin_polygon();
  fl_vertex(x,y);
  fl_vertex(x+w,y);
  fl_vertex(x+w,y+h);
  fl_vertex(x,y+h);
  fl_end_polygon();
};
Exemplo n.º 2
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();
}
Exemplo n.º 3
0
void SoftBox::draw_lines() const
{

	if (fill_color().visibility()) {
		fl_color(fill_color().as_int());

		fl_begin_polygon();

			fl_vertex(point(0).x - (w/2) + r, point(0).y - (h/2));
			fl_vertex(point(0).x + (w/2) - r, point(0).y - (h/2));
			
			fl_vertex(point(0).x + (w/2), point(0).y - (h/2) + r);
			fl_vertex(point(0).x + (w/2), point(0).y + (h/2) - r);
			
			fl_vertex(point(0).x + (w/2) - r, point(0).y + (h/2));
			fl_vertex(point(0).x - (w/2) + r, point(0).y + (h/2));
			
			fl_vertex(point(0).x - (w/2),     point(0).y + (h/2) - r);
			fl_vertex(point(0).x - (w/2),     point(0).y - (h/2) + r);
					
		fl_end_polygon();

		fl_pie(point(0).x - (w/2),         point(0).y - (h/2),         r+r-1,r+r-1,90,180);
		fl_pie(point(0).x + (w/2) - r - r, point(0).y - (h/2),         r+r-1,r+r-1,0,90);
		fl_pie(point(0).x - (w/2),         point(0).y + (h/2) - r - r, r+r-1,r+r-1,180,270);
		fl_pie(point(0).x + (w/2) - r - r, point(0).y + (h/2) - r - r, r+r-1,r+r-1,270,360);

		fl_color(color().as_int());

	}

	if (color().visibility()){

		fl_color(color().as_int());

		// Draw Lines
		fl_line(point(0).x - (w/2) + r, point(0).y - (h/2),     point(0).x + (w/2) - r, point(0).y - (h/2));
		fl_line(point(0).x - (w/2),     point(0).y - (h/2) + r, point(0).x - (w/2),     point(0).y + (h/2) - r);
		fl_line(point(0).x - (w/2) + r, point(0).y + (h/2),     point(0).x + (w/2) - r, point(0).y + (h/2));
		fl_line(point(0).x + (w/2),     point(0).y - (h/2) + r, point(0).x + (w/2),     point(0).y + (h/2) - r);
		
		// Draw Arcs
		fl_arc(point(0).x - (w/2),         point(0).y - (h/2),         r+r,r+r,90,180);
		fl_arc(point(0).x + (w/2) - r - r, point(0).y - (h/2),         r+r,r+r,0,90);
		fl_arc(point(0).x - (w/2),         point(0).y + (h/2) - r - r, r+r,r+r,180,270);
		fl_arc(point(0).x + (w/2) - r - r, point(0).y + (h/2) - r - r, r+r,r+r,270,360);

	}

}
Exemplo n.º 4
0
void Regular_hexagon::draw_lines() const
{

	if (fill_color().visibility()) {
		fl_color(fill_color().as_int());

		fl_begin_polygon();

			fl_vertex(point(0).x - w, 		point(0).y);
			fl_vertex(point(0).x - (w/2), 	point(0).y - y_off);
			
			fl_vertex(point(0).x + (w/2), 	point(0).y - y_off);
			fl_vertex(point(0).x + w, 		point(0).y);
			
			fl_vertex(point(0).x + (w/2), 	point(0).y + y_off);
			fl_vertex(point(0).x - (w/2), 	point(0).y + y_off);
			fl_vertex(point(0).x - w, 		point(0).y);

		fl_end_polygon();

		fl_color(color().as_int());

	}

	if (color().visibility()){

		fl_color(color().as_int());

		// Draw Lines
		fl_line(point(0).x - w, 		point(0).y,     		point(0).x - (w/2), 	point(0).y - y_off);
		fl_line(point(0).x - (w/2), 	point(0).y - y_off,     point(0).x + (w/2), 	point(0).y - y_off);
		fl_line(point(0).x + (w/2), 	point(0).y - y_off,		point(0).x + w, 		point(0).y);

		fl_line(point(0).x + w, 		point(0).y,     		point(0).x + (w/2), 	point(0).y + y_off);
		fl_line(point(0).x + (w/2), 	point(0).y + y_off,     point(0).x - (w/2), 	point(0).y + y_off);
		fl_line(point(0).x - (w/2), 	point(0).y + y_off,		point(0).x - w, 		point(0).y);

	}
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
void Regular_polygon::draw_lines() const
{

	if (fill_color().visibility()) {
		fl_color(fill_color().as_int());

		fl_begin_polygon();

		for (int i = 1; i < s + 1; i++){
			fl_vertex((int)std::round(point(0).x + w * (cos(2.0*PI*(double)i/(double)s + ar))),
				(int)std::round(point(0).y + w * (sin(2.0*PI*(double)i/(double)s + ar))));

		}

		fl_vertex((int)std::round(point(0).x + w * (cos(2.0*PI*1/(double)s + ar))),
			(int)std::round(point(0).y + w * (sin(2.0*PI*1/(double)s + ar))));

		fl_end_polygon();

		fl_color(color().as_int());

	}

	if (color().visibility()){

		fl_color(color().as_int());

		for (int i = 1; i < s + 1; i++){
			fl_line((int)std::round(point(0).x + w * (cos(2.0*PI*(double)i/(double)s + ar))),
				(int)std::round(point(0).y + w * (sin(2.0*PI*(double)i/(double)s + ar))),
				(int)std::round(point(0).x + w * (cos(2.0*PI*(double)(i+1)/(double)s + ar))),
				(int)std::round(point(0).y + w * (sin(2.0*PI*(double)(i+1)/(double)s + ar))));


		}

	}
}
Exemplo n.º 7
0
void
Fl_DialX::draw ( void )
{
    int X,Y,S;

    {
    int ox, oy, ww, hh, side;
    ox = x();
    oy = y();
    ww = w();
    hh = h();
    
    if (ww > hh)
    {
        side = hh;
        ox = ox + (ww - side) / 2;
    }
    else
    {
        side = ww;
        oy = oy + (hh - side) / 2;
    }
    side = w() > h() ? hh : ww;

    X = ox;
    Y = oy;
    S = side;
    }

    draw_box();
    draw_label();

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

    fl_draw_box( box(), X, Y, S, S, color() );
    
    /* shrink a bit */
    int OX = x();
    int OY = y();
    X += S / 8;
    Y += S / 8;
    int OS = S;
    S -= S / 4;
    
    fl_line_style( FL_SOLID, S / 12 );
        
    /* background arc */
    fl_color( fl_darker( color() ) );
    fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle2() );
        
    /* foreground arc */
    fl_color( selection_color() );
    fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle  );


    fl_line_style( FL_SOLID, 0 );
 
    if ( active_r() )
    {
        int W = OS;
        int H = OS;

        fl_push_matrix();
        fl_translate(OX+W/2, OY+H/2);
        fl_scale(W, H);
        fl_rotate(310+angle);
        fl_color( fl_color_add_alpha( FL_WHITE, 127 ));
        fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.12); fl_end_polygon();
        fl_color( FL_WHITE );
        fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.06); fl_end_polygon();
            
        fl_pop_matrix();
    }
    
    fl_color( fl_contrast( labelcolor(), color() ) );
 
    if ( Fl::belowmouse() == this )
    {
        char s[10];
    
        fl_font( FL_HELVETICA, 10 );
    
        snprintf( s, sizeof( s ), "%.1f", value() );

        fl_color( FL_FOREGROUND_COLOR );
        fl_draw( s, X, Y, S, S, FL_ALIGN_CENTER );
    }
}
Exemplo n.º 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);
}
Exemplo n.º 9
0
 FL_EXPORT_C(void,flc_begin_polygon)( ){
   fl_begin_polygon();
 }
Exemplo n.º 10
0
static inline void ca_polygon(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){
  fl_begin_polygon();
  fl_vertex(x1,y1); fl_vertex(x2,y2); fl_vertex(x3,y3); fl_vertex(x4,y4);
  fl_end_polygon();
};
Exemplo n.º 11
0
static inline void ca_filled_circle(double x, double y, double r){
  fl_begin_polygon();
  //fl_arc(x,y,r,0,360);
  fl_circle(x,y,r);
  fl_end_polygon();
};
Exemplo n.º 12
0
void WidgetPDial::draw()
{
#ifdef NTK_GUI
    box( FL_NO_BOX );

    Fl_Dial::draw();
    
    return;
#else
    const int cx = x(), cy = y(), sx = w(), sy = h();
    const double a1 = angle1(), a2 = angle2();
    const double val = (value() - minimum()) / (maximum() - minimum());
    // even radius produces less artifacts if no antialiasing is avail
    const int rad = (sx > sy ? sy : sx) &~1;

    /* clears the button background */
    pdialcolor(160, 160, 160);
    fl_pie(cx - 2, cy - 2, rad + 4, rad + 4, 0, 360);

    /* dark outline */
    fl_color(60, 60, 60);
    fl_pie(cx - 1, cy - 1, rad + 2, rad + 2, 0, 360);

    /* Draws the button faceplate, min/max */
    pdialcolor(110, 110, 115);
    fl_pie(cx, cy, rad, rad, 270 - a2, 270 - a1);

    /* knob center */
    if (rad > 8) {
        pdialcolor(140, 140, 145);
        fl_pie(cx + 4, cy + 4, rad - 8, rad - 8, 0, 360);
    }

    /* value circle */
    double a = -(a2 - a1) * val - a1;
    fl_line_style(0, 2, 0);
    pdialcolor(0, 200, 0);
    fl_arc(cx + 1, cy + 1, rad - 2, rad - 2, a - 90, a1 - 180);
    fl_line_style(0);

    /* draw value line */
    int ll = rad/4;
    if (ll < 2) ll = 2;

    fl_push_matrix();

    fl_translate(cx + rad / 2, cy + rad / 2);
    fl_rotate(a - 90.0f);

    fl_translate(rad / 2, 0);

    fl_begin_polygon();
    pdialcolor(0, 0, 0);
    fl_vertex(-ll, 0);
    fl_vertex(0, 0);
    fl_end_polygon();

    fl_pop_matrix();

#endif
}
Exemplo n.º 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();
}