示例#1
0
void
Fl_Arc_Dial::draw ( void )
{
    int X = x();
    int Y = y();
    int W = w();
    int H = h();

    draw_box();
    draw_label();

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

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

    fl_line_style( FL_SOLID, W / 6 );

    X += W / 8;
    Y += H / 8;
    W -= W / 4;
    H -= H / 4;

    if ( box() == FL_NO_BOX )
    {
        /* draw backgrond arc */
        fl_color( fl_color_average( FL_BLACK, selection_color(), 0.80f ) );
        fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle2() );
    }

    fl_color( selection_color() );
//    fl_color( fl_color_average( FL_RED, selection_color(), ( value() - minimum() ) / ( maximum() - minimum() ) ) );


    if ( type() == FL_FILL_DIAL )
        fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle  );
    else
    {
        const int d = 6;

        /* account for edge conditions */
        angle = angle < angle1() + d ? angle1() + d : angle;
        angle = angle > angle2() - d ? angle2() - d : angle;

        fl_arc( X, Y, W, H, 270 - (angle - d), 270 - (angle + d) );
    }

    fl_line_style( FL_SOLID, 0 );

    fl_color( labelcolor() );

    char s[10];

    fl_font( FL_HELVETICA, 8 );

    snprintf( s, sizeof( s ), "%.1f", value() );
    fl_draw( s, X, Y, W, H, FL_ALIGN_BOTTOM );
}
示例#2
0
	virtual void draw() 
	{
		fl_color(FL_BLACK);

		// draw face
		short centerX, centerY;
		float radius;
		centerX = w()/2;
		centerY = h()/2;
		radius = MIN(w(), h())/4;
		fl_pie(centerX - radius, centerY-radius, radius*2, radius*2, 0, 360);

		// draw hands
		int hourX, hourY, minuteX, minuteY, secondX, secondY;
		hourX = centerX + 0.35 * radius * cos(RADIAN(hourHand));
		hourY = centerY + 0.35 * radius * sin(RADIAN(hourHand));
		minuteX = centerX + 0.65 * radius * cos(RADIAN(minuteHand));
		minuteY = centerY + 0.65 * radius * sin(RADIAN(minuteHand));
		secondX = centerX + 0.85 * radius * cos(RADIAN(secondHand));
		secondY = centerY + 0.85 * radius * sin(RADIAN(secondHand));
		fl_color(FL_GREEN);
		fl_line_style(FL_SOLID, 3);
		fl_line(centerX, centerY, hourX, hourY);
		fl_line(centerX, centerY, minuteX, minuteY);
		fl_color(FL_RED);
		fl_line_style(FL_SOLID, 1);
		fl_line(centerX, centerY, secondX, secondY);
	}
void Fl_ImageViewer::draw()
{
    fl_push_clip( x(), y(), w(), h() );
    Fl_Scroll::draw();

    if ( isdrawruler == true )
    {
        fl_color( FL_BLUE );
        fl_line_style( 0, 3, NULL );

        fl_line( coordclicked_x, coordclicked_y, coordmoving_x, coordmoving_y );
    }
    else
    if ( isdrawclickpointer == true )
    {
        fl_color( colorclicked );
        fl_line_style( 0, 1, NULL );

        fl_line( coordclicked_x , y() , coordclicked_x, coordclicked_y - 1 );
        fl_line( coordclicked_x, coordclicked_y + 1 , coordclicked_x, y() + h() );
        fl_line( x(), coordclicked_y, coordclicked_x - 1, coordclicked_y );
        fl_line( coordclicked_x + 1, coordclicked_y, x() + w(), coordclicked_y );
    }

    fl_pop_clip();
}
示例#4
0
文件: SpectrumView.C 项目: 0mk/non
void 
SpectrumView::draw_semilog ( void )
{
    int W = w() - padding_right;
    int H = h() - padding_bottom;
    char label[50];

    fl_line_style(FL_SOLID,0);
    fl_font( FL_HELVETICA_ITALIC, 7 );

    //Db grid is easy, it is just a linear spacing
    for(int i=0; i<16; ++i) {
        int level = y()+H*i/16.0;
        fl_line(x(), level, x()+W, level);

        float value = (1-i/16.0)*(_dbmax-_dbmin) + _dbmin;
        sprintf(label, "%.1f", value);
        fl_draw(label, x() + 4, level + 3, w() - 8, 7, FL_ALIGN_LEFT );
    }

    //The frequency grid is defined with points at
    //10,11,12,...,18,19,20,30,40,50,60,70,80,90,100,200,400,...
    //Thus we find each scale that we cover and draw the nine lines unique to
    //that scale
    float lb = 1.0f / logf( 10 );
    const int min_base = logf(_fmin)*lb;
    const int max_base = logf(_fmax)*lb;
    const float b = logf(_fmin)*lb;
    const float a = logf(_fmax)*lb-b;
    for(int i=min_base; i<=max_base; ++i) {
        for(int j=1; j<10; ++j) {
            const float freq = pow(10.0, i)*j;
            const float xloc = (logf(freq)*lb-b)/a;
            if(xloc<1.0 && xloc > -0.001)
            {
                fl_line(xloc*W+x(), y(), xloc*W+x(), y()+H);
            
                if ( j == 1 || j == 2 || j == 5 )
                {
                    sprintf(label, "%0.f%s", freq < 1000.0 ? freq : freq / 1000.0, freq < 1000.0 ? "" : "k" );
                    int sx = x() + xloc*W + 1;
                    if ( sx < x() * W - 20 )
                        fl_draw(label, sx, y()+h());
                }
            }
        }
    }

    /* draw 0dB line */
    {
        fl_line_style(FL_DASH,0);
        float i = ((_dbmax-_dbmin)+_dbmin) / (_dbmax-_dbmin);
        
        int level = y()+H*i;
                
        fl_color(fl_color_add_alpha(fl_rgb_color(240,240,240), 60 ));
        fl_line(x(), level, x()+W, level);
        fl_line_style(FL_SOLID,0);
    }
}
示例#5
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);
};
示例#6
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);

};
示例#7
0
void ResonanceGraph::draw() {
  int ox=x(),oy=y(),lx=w(),ly=h(),i,ix,iy,oiy;
REALTYPE freqx;

fl_color(FL_BLACK);
fl_rectf(ox,oy,lx,ly);


//draw the lines
fl_color(FL_GRAY);

fl_line_style(FL_SOLID);
fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);

freqx=respar->getfreqpos(1000.0);
if ((freqx>0.0)&&(freqx<1.0))
   fl_line(ox+(int) (freqx*lx),oy,
    ox+(int) (freqx*lx),oy+ly);

for (i=1;i<10;i++){
   if(i==1){
     draw_freq_line(i*100.0,0);
     draw_freq_line(i*1000.0,0);
   }else 
    if (i==5){
      draw_freq_line(i*100.0,2);
      draw_freq_line(i*1000.0,2);
    }else{
      draw_freq_line(i*100.0,1);
      draw_freq_line(i*1000.0,1);
    };
};

draw_freq_line(10000.0,0);
draw_freq_line(20000.0,1);

fl_line_style(FL_DOT);
int GY=10;if (ly<GY*3) GY=-1;
for (i=1;i<GY;i++){
   int tmp=(int)(ly/(REALTYPE)GY*i);
   fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
};



//draw the data
fl_color(FL_RED);
fl_line_style(FL_SOLID);
oiy=(int)(respar->Prespoints[0]/128.0*ly);
for (i=1;i<N_RES_POINTS;i++){
   ix=(int)(i*1.0/N_RES_POINTS*lx);
   iy=(int)(respar->Prespoints[i]/128.0*ly);
   fl_line(ox+ix-1,oy+ly-oiy,ox+ix,oy+ly-iy);
   oiy=iy;
};
}
示例#8
0
void Shape::draw() const
{
    Fl_Color oldc = fl_color();
    // there is no good portable way of retrieving the current style
    fl_color(lcolor.as_int());            // set color
    fl_line_style(ls.style(),ls.width()); // set style
    draw_lines();
    fl_color(oldc);      // reset color (to previous)
    fl_line_style(0);    // reset line style to default
}
示例#9
0
文件: SpectrumView.C 项目: 0mk/non
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();
}
示例#10
0
void tutsim::
draw_robot(jspace::Vector const & jpos, int width,
	   unsigned char red, unsigned char green, unsigned char blue,
	   double x0, double y0, double scale)
{
  write_state_to_tree(&jpos, 0, *scratch_tree);
  fl_color(red, green, blue);
  fl_line_style(FL_SOLID, width, 0);
  raw_draw_tree(*scratch_tree, x0, y0, scale);
  fl_line_style(0);		// back to default
}
示例#11
0
void tutsim::
draw_delta_jpos(jspace::Vector const & jpos, int width,
		unsigned char red, unsigned char green, unsigned char blue,
		double x0, double y0, double scale)
{
  if (0 > id1) {
    id1 = find_node(*sim_tree, "link1")->getID();
    id2 = find_node(*sim_tree, "link2")->getID();
    id3 = find_node(*sim_tree, "link3")->getID();
    id4 = find_node(*sim_tree, "link4")->getID();
  }
  
  jspace::Vector scratchpos(sim_tree->info.size());
  read_state_from_tree(*sim_tree, &scratchpos, 0, 0);
  
  fl_color(red, green, blue);
  fl_line_style(FL_SOLID, width, 0);
  
  scratchpos[id4] = jpos[id4];
  write_state_to_tree(&scratchpos, 0, *scratch_tree);
  deFrame locframe;
  locframe.translation()[2] = -1.0;
  deFrame globframe;
  globframe.multiply(*(scratch_tree->info[id4].node->frameGlobal()), locframe);
  fl_line(x0 + (scratch_tree->info[id4].node->frameGlobal()->translation()[1] * scale),
	  y0 - (scratch_tree->info[id4].node->frameGlobal()->translation()[2] * scale),
	  x0 + (globframe.translation()[1] * scale),
	  y0 - (globframe.translation()[2] * scale));
  
  scratchpos[id3] = jpos[id3];
  write_state_to_tree(&scratchpos, 0, *scratch_tree);
  fl_line(x0 + (scratch_tree->info[id3].node->frameGlobal()->translation()[1] * scale),
	  y0 - (scratch_tree->info[id3].node->frameGlobal()->translation()[2] * scale),
	  x0 + (scratch_tree->info[id4].node->frameGlobal()->translation()[1] * scale),
	  y0 - (scratch_tree->info[id4].node->frameGlobal()->translation()[2] * scale));
  
  scratchpos[id2] = jpos[id2];
  write_state_to_tree(&scratchpos, 0, *scratch_tree);
  fl_line(x0 + (scratch_tree->info[id2].node->frameGlobal()->translation()[1] * scale),
	  y0 - (scratch_tree->info[id2].node->frameGlobal()->translation()[2] * scale),
	  x0 + (scratch_tree->info[id3].node->frameGlobal()->translation()[1] * scale),
	  y0 - (scratch_tree->info[id3].node->frameGlobal()->translation()[2] * scale));
  
  scratchpos[id1] = jpos[id1];
  write_state_to_tree(&scratchpos, 0, *scratch_tree);
  fl_line(x0 + (scratch_tree->info[id1].node->frameGlobal()->translation()[1] * scale),
	  y0 - (scratch_tree->info[id1].node->frameGlobal()->translation()[2] * scale),
	  x0 + (scratch_tree->info[id2].node->frameGlobal()->translation()[1] * scale),
	  y0 - (scratch_tree->info[id2].node->frameGlobal()->translation()[2] * scale));

  fl_line_style(0);		// back to default
}
示例#12
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);
  }

};
示例#13
0
void FormantFilterGraph::draw_freq_line(REALTYPE freq,int type) {
  REALTYPE freqx=pars->getfreqpos(freq);
switch(type){
  case 0:fl_line_style(FL_SOLID);break;
  case 1:fl_line_style(FL_DOT);break;
  case 2:fl_line_style(FL_DASH);break;
}; 


if ((freqx>0.0)&&(freqx<1.0))
   fl_line(x()+(int) (freqx*w()),y(),
   x()+(int) (freqx*w()),y()+h());
}
示例#14
0
文件: sparkline.cpp 项目: qartis/dori
void Fl_Sparkline::drawCursor(void)
{
    int x = Fl::event_x() - Fl_Widget::x();
    int index;
    float value;

    hideCursor();

    x -= padding;

    index = num_values * x / width;
    index = snap(index);

    x = index * width / num_values;

    value = map(values[index], values[min_index], values[max_index],
        height, 0);

    fl_color(FL_BLUE);
    fl_rectf(Fl_Widget::x() + padding + x - 1, y() + value + padding - 1, 3, 3);


    fl_color(FL_RED);
    fl_line_style(FL_SOLID, 1);
    fl_line(Fl_Widget::x() + padding + x, y() + padding,
            Fl_Widget::x() + padding + x, y() + h() - padding);

    prev_x = x;
}
示例#15
0
void gActionWidget::baseDraw(bool clear) {

	/* clear the screen */

	if (clear)
		fl_rectf(x(), y(), w(), h(), COLOR_BG_MAIN);

	/* draw the container */

	fl_color(COLOR_BD_0);
	fl_rect(x(), y(), w(), h());

	/* grid drawing, if > 1 */

	if (pParent->gridTool->getValue() > 1) {

		fl_color(fl_rgb_color(54, 54, 54));
		fl_line_style(FL_DASH, 0, NULL);

		for (int i=0; i<(int) pParent->gridTool->points.size; i++) {
			int px = pParent->gridTool->points.at(i)+x()-1;
			fl_line(px, y()+1, px, y()+h()-2);
		}
		fl_line_style(0);
	}

	/* bars and beats drawing */

	fl_color(COLOR_BD_0);
	for (int i=0; i<(int) pParent->gridTool->beats.size; i++) {
		int px = pParent->gridTool->beats.at(i)+x()-1;
		fl_line(px, y()+1, px, y()+h()-2);
	}

	fl_color(COLOR_BG_2);
	for (int i=0; i<(int) pParent->gridTool->bars.size; i++) {
		int px = pParent->gridTool->bars.at(i)+x()-1;
		fl_line(px, y()+1, px, y()+h()-2);
	}

	/* cover unused area. Avoid drawing cover if width == 0 (i.e. beats
	 * are 32) */

	int coverWidth = pParent->totalWidth-pParent->coverX;
	if (coverWidth != 0)
		fl_rectf(pParent->coverX+x(), y()+1, coverWidth, h()-2, COLOR_BG_1);
}
示例#16
0
void gActionWidget::baseDraw(bool clear) {

	

	if (clear)
		fl_rectf(x(), y(), w(), h(), COLOR_BG_MAIN);

	

	fl_color(COLOR_BD_0);
	fl_rect(x(), y(), w(), h());

	

	if (pParent->gridTool->getValue() > 1) {

		fl_color(fl_rgb_color(54, 54, 54));
		fl_line_style(FL_DASH, 0, NULL);

		for (int i=0; i<(int) pParent->gridTool->points.size(); i++) {
			int px = pParent->gridTool->points.at(i)+x()-1;
			fl_line(px, y()+1, px, y()+h()-2);
		}
		fl_line_style(0);
	}

	

	fl_color(COLOR_BD_0);
	for (int i=0; i<(int) pParent->gridTool->beats.size(); i++) {
		int px = pParent->gridTool->beats.at(i)+x()-1;
		fl_line(px, y()+1, px, y()+h()-2);
	}

	fl_color(COLOR_BG_2);
	for (int i=0; i<(int) pParent->gridTool->bars.size(); i++) {
		int px = pParent->gridTool->bars.at(i)+x()-1;
		fl_line(px, y()+1, px, y()+h()-2);
	}

	

	int coverWidth = pParent->totalWidth-pParent->coverX;
	if (coverWidth != 0)
		fl_rectf(pParent->coverX+x(), y()+1, coverWidth, h()-2, COLOR_BG_1);
}
示例#17
0
void CCanvas::draw_odom()
{
    // Draw particles
    fl_color(FL_BLUE);
    for (int i = 0; i < m_cfg->ODOM_SAMPLES; i ++)
        fl_point((int) m_particles[i].x(), (int) m_particles[i].y());

    // Choose one particle to draw as a robot
    // Draw with dash style line
    const int choose = m_cfg->CHOSEN_SAMPLE;

    fl_color(FL_RED);
    fl_line_style(FL_DASH);
    CPoint2D p0(m_particles[choose].x(), m_particles[choose].y());
    CPoint2D p1(p0.translate(m_cfg->ROBOT_RADIUS, m_particles[choose].th()));
    fl_line(m_particles[choose].x(), m_particles[choose].y(), p1.x(), p1.y());
    fl_circle(m_particles[choose].x(), m_particles[choose].y(), m_cfg->ROBOT_RADIUS);
    fl_line_style(FL_SOLID);
}
示例#18
0
void PolyObject::drawScreen(bool drawCenterPoint, float cellsPerMeter, float pixelsPerCell, float worldPanX, float worldPanY) {
    float screenOffsetX = SiteObject::worldToScreen(worldOffsetX, pixelsPerCell, cellsPerMeter);
    float screenOffsetY = SiteObject::worldToScreen(worldOffsetY, pixelsPerCell, cellsPerMeter);


    float siteCenterScreenX = SiteObject::worldToScreen(siteCenterX - worldPanX, pixelsPerCell, cellsPerMeter);
    float siteCenterScreenY = SiteObject::worldToScreen(siteCenterY - worldPanY, pixelsPerCell, cellsPerMeter);

    float polyOriginX = siteCenterScreenX + screenOffsetX;
    float polyOriginY = siteCenterScreenY - screenOffsetY;

    // if the object is selected, draw the outline first
    if(selected) {
        int outline = 4;
        fl_line_style(FL_SOLID, 5 + outline);
        fl_color(255, 0, 0);
        drawPolyLine(polyOriginX, polyOriginY, pixelsPerCell, cellsPerMeter);
    }

    fl_line_style(FL_SOLID, 5);
    fl_color(r, g, b);

    drawPolyLine(polyOriginX, polyOriginY, pixelsPerCell, cellsPerMeter);

    if(drawCenterPoint) {
        fl_color(255, 0, 0);

        if(recalculateCenterPoint) {
            calculateCenterPoint();
            recalculateCenterPoint = false;
        }

        float centerPointScreenOffsetX = SiteObject::worldToScreen(centerPointWorldOffsetX, pixelsPerCell, cellsPerMeter);
        float centerPointScreenOffsetY = SiteObject::worldToScreen(centerPointWorldOffsetY, pixelsPerCell, cellsPerMeter);

        fl_circle(siteCenterScreenX + centerPointScreenOffsetX, siteCenterScreenY - centerPointScreenOffsetY, 1);
    }
}
示例#19
0
void DiagramWindow::DrawKey3()
{
    int yPosn = 55;

    fl_color(225, 225, 225);
    fl_rectf(m_menus[0]->x(), yPosn, m_menus[0]->w(), 3);
    fl_rectf(m_menus[1]->x(), yPosn, m_menus[1]->w(), 3);
    fl_rectf(m_menus[2]->x(), yPosn, m_menus[2]->w(), 3);
    yPosn += 10;

    fl_color(FL_RED);
    fl_rectf(m_menus[0]->x(), yPosn, m_menus[0]->w(), 3);
    fl_line_style(FL_DOT);
    fl_xyline(m_menus[1]->x(), yPosn, m_menus[1]->x() + m_menus[1]->w());
    fl_xyline(m_menus[2]->x(), yPosn, m_menus[2]->x() + m_menus[2]->w());
    yPosn += 10;

    fl_color(FL_GREEN);
    fl_rectf(m_menus[1]->x(), yPosn, m_menus[1]->w(), 3);
    fl_line_style(FL_DOT);
    fl_xyline(m_menus[0]->x(), yPosn, m_menus[0]->x() + m_menus[0]->w());
    fl_xyline(m_menus[2]->x(), yPosn, m_menus[2]->x() + m_menus[2]->w());
    yPosn += 10;

    fl_color(FL_BLUE);
    fl_rectf(m_menus[2]->x(), yPosn, m_menus[2]->w(), 3);
    fl_line_style(FL_DOT);
    fl_xyline(m_menus[0]->x(), yPosn, m_menus[0]->x() + m_menus[0]->w());
    fl_xyline(m_menus[1]->x(), yPosn, m_menus[1]->x() + m_menus[1]->w());
    yPosn += 10;

    fl_color(FL_YELLOW);
    fl_rectf(m_menus[0]->x(), yPosn, m_menus[0]->w(), 3);
    fl_rectf(m_menus[1]->x(), yPosn, m_menus[1]->w(), 3);
    fl_line_style(FL_DOT);
    fl_xyline(m_menus[2]->x(), yPosn, m_menus[2]->x() + m_menus[2]->w());
    yPosn += 10;

    fl_color(FL_MAGENTA);
    fl_rectf(m_menus[0]->x(), yPosn, m_menus[0]->w(), 3);
    fl_rectf(m_menus[2]->x(), yPosn, m_menus[2]->w(), 3);
    fl_line_style(FL_DOT);
    fl_xyline(m_menus[1]->x(), yPosn, m_menus[1]->x() + m_menus[1]->w());
    yPosn += 10;

    fl_color(FL_CYAN);
    fl_rectf(m_menus[1]->x(), yPosn, m_menus[1]->w(), 3);
    fl_rectf(m_menus[2]->x(), yPosn, m_menus[2]->w(), 3);
    fl_line_style(FL_DOT);
    fl_xyline(m_menus[0]->x(), yPosn, m_menus[0]->x() + m_menus[0]->w());
}
示例#20
0
void DiagramWindow::RedrawBuffer(RNAStructure** structures, const int numStructures, const int resolution)
{
    fl_color(FL_BLACK);
    fl_rectf(0, 0, resolution, resolution);

    int priorFont = fl_font();
    int priorFontSize = fl_size();
    fl_font(priorFont, 10);

    fl_line_style(0);

    if (numStructures == 1)
	Draw1(structures, resolution);
    else if (numStructures == 2)
	Draw2(structures, resolution);
    else if (numStructures == 3)
	Draw3(structures, resolution);

    fl_font(priorFont, priorFontSize);
}
示例#21
0
文件: sparkline.cpp 项目: qartis/dori
void Fl_Sparkline::hideCursor(void)
{
    if (prev_x < 0)
        return;

    fl_color(color());

    fl_line_style(FL_SOLID, 3);
    fl_line(Fl_Widget::x() + padding + prev_x, y(),
        Fl_Widget::x() + padding + prev_x, y() + h());

    fl_color(FL_BLACK);

    drawPoint(prev_x);
    drawPoint(prev_x + 1);
    drawPoint(prev_x + 2);

    drawPeaks();

    prev_x = -1;
}
示例#22
0
文件: Fl_DrawC.cpp 项目: deech/fltkhs
 FL_EXPORT_C(void,flc_line_style_with_width)(int style,int width){
   fl_line_style(style,width,0);
 }
示例#23
0
void FormantFilterGraph::draw() {
  int maxdB=30;
int ox=x(),oy=y(),lx=w(),ly=h(),i,oiy;
REALTYPE freqx;

fl_color(FL_BLACK);
fl_rectf(ox,oy,lx,ly);


//draw the lines
fl_color(FL_GRAY);

fl_line_style(FL_SOLID);
//fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);

freqx=pars->getfreqpos(1000.0);
if ((freqx>0.0)&&(freqx<1.0))
   fl_line(ox+(int) (freqx*lx),oy,
    ox+(int) (freqx*lx),oy+ly);

for (i=1;i<10;i++){
   if(i==1){
     draw_freq_line(i*100.0,0);
     draw_freq_line(i*1000.0,0);
   }else 
    if (i==5){
      draw_freq_line(i*100.0,2);
      draw_freq_line(i*1000.0,2);
    }else{
      draw_freq_line(i*100.0,1);
      draw_freq_line(i*1000.0,1);
    };
};

draw_freq_line(10000.0,0);
draw_freq_line(20000.0,1);

fl_line_style(FL_DOT);
int GY=10;if (ly<GY*3) GY=-1;
for (i=1;i<GY;i++){
   int tmp=(int)(ly/(REALTYPE)GY*i);
   fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
};

fl_color(FL_YELLOW);
fl_font(FL_HELVETICA,10);
if (*nformant<pars->Pnumformants){
   draw_freq_line(pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq),2);

//show some information (like current formant frequency,amplitude)
   char tmpstr[20];

   snprintf(tmpstr,20,"%.2f kHz",pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq)*0.001);
   fl_draw(tmpstr,ox+1,oy+1,40,12,FL_ALIGN_LEFT,NULL,0);

   snprintf(tmpstr,20,"%d dB",(int)( rap2dB(1e-9 + pars->getformantamp(pars->Pvowels[*nvowel].formants[*nformant].amp)) + pars->getgain() ));
   fl_draw(tmpstr,ox+1,oy+15,40,12,FL_ALIGN_LEFT,NULL,0);

};

//draw the data

fl_color(FL_RED);
fl_line_style(FL_SOLID);

pars->formantfilterH(*nvowel,lx,graphpoints);

oiy=(int) ((graphpoints[0]/maxdB+1.0)*ly/2.0);
for (i=1;i<lx;i++){
   int iy=(int) ((graphpoints[i]/maxdB+1.0)*ly/2.0);
   if ((iy>=0)&&(oiy>=0)&&(iy<ly)&&(oiy<lx))
      fl_line(ox+i-1,oy+ly-oiy,ox+i,oy+ly-iy);
   oiy=iy;
};
}
示例#24
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;
    }
}
示例#25
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 );
    }
}
示例#26
0
void DiagramWindow::draw()
{
    Fl_Color priorColor = fl_color();
    int priorFont = fl_font();
    int priorFontSize = fl_size();

    fl_color(color());
    fl_rectf(0, 0, w(), h());
    fl_color(priorColor);

    Fl_Window::draw();

    // Get the structures. Be sure the reference structure is first.
    RNAStructure* sequences[3];
    StructureManager* structureManager = RNAStructViz::GetInstance()->GetStructureManager();
    for (int j = 0; j < 3; ++j)
    {
	if ((int)(m_menuItems[m_menus[j]->value()].user_data()) == -1)
	{
	    sequences[j] = 0;
	}
	else
	{
	    sequences[j] = structureManager->GetStructure((int)(m_menuItems[m_menus[j]->value()].user_data()));
	}
    }

    int numToDraw = 0;
    if (sequences[0])
    {
	if (sequences[1])
	{
	    if (sequences[2])
	    {
		numToDraw = 3;
		DrawKey3();
	    }
	    else
	    {
		numToDraw = 2;
		DrawKey2(0, 1);
	    }
	}
	else
	{
	    if (sequences[2])
	    {
		sequences[1] = sequences[2];
		DrawKey2(0, 2);
		numToDraw = 2;
	    }
	    else
	    {
		DrawKey1(0);
		numToDraw = 1;
	    }
	}
    }
    else
    {
	if (sequences[1])
	{
	    if (sequences[2])
	    {
		sequences[0] = sequences[1];
		sequences[1] = sequences[2];
		DrawKey2(1, 2);
		numToDraw = 2;
	    }
	    else
	    {
		sequences[0] = sequences[1];
		DrawKey1(1);
		numToDraw = 1;
	    }
	}
	else
	{
	    if (sequences[2])
	    {
		sequences[0] = sequences[2];
		DrawKey1(2);
		numToDraw = 1;
	    }
	    else
	    {
		numToDraw = 0;
	    }
	}
    }

    if (m_redrawStructures)
    {
	{
	    fl_begin_offscreen(m_offscreenImage[0]);
	    RedrawBuffer(sequences, numToDraw, 2048);
	    fl_read_image(m_imageData[0], 0, 0, 2048, 2048);
	    fl_end_offscreen();
	}

	{
	    fl_begin_offscreen(m_offscreenImage[1]);
	    RedrawBuffer(sequences, numToDraw, 1024);
	    fl_read_image(m_imageData[1], 0, 0, 1024, 1024);
	    fl_end_offscreen();
	}

	m_glWindow->UpdateTexture();
	m_redrawStructures = false;
    }

    m_glWindow->redraw();

    fl_color(priorColor);
    fl_font(priorFont, priorFontSize);
    fl_line_style(0);
}
示例#27
0
文件: Fl_DrawC.cpp 项目: deech/fltkhs
 FL_EXPORT_C(void,flc_line_style_with_width_dashes)(int style,int width,char* dashes){
   fl_line_style(style,width,dashes);
 }
示例#28
0
文件: Fl_DrawC.cpp 项目: deech/fltkhs
 FL_EXPORT_C(void,flc_line_style_with_dashes)(int style,char* dashes){
   fl_line_style(style,0,dashes);
 }
示例#29
0
文件: Fl_DrawC.cpp 项目: deech/fltkhs
 FL_EXPORT_C(void,flc_line_style)(int style){
   fl_line_style(style,0,0);
 }
示例#30
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");
	}
}