Пример #1
0
void drawEtch() {
	int i;

	if (color_ind) {
		attrset(COLOR_PAIR(ETCH_COLOR_FRAME));
	}

	mvaddstr(0, 0, "  ___________________________________________________________________________  ");
	mvaddstr(1, 0, " /  _______________________________________________________________________  \\ ");
	mvaddstr(2, 0, "/  /                                                                       \\  \\");
	for (i = 3; i <= 18; i++) {
		mvaddstr(i, 0, "|  |                                                                       |  |");
	}
	mvaddstr(19, 0, "|  \\_______________________________________________________________________/  |");
	for (i = 20; i <= 21; i++) {
		mvaddstr(i, 0, "|                                                                             |");
	}

	mvaddstr(22, 0, "\\                                                                             /");
	mvaddstr(23, 0, " \\___________________________________________________________________________/ ");

	drawKnob(20, 4);
	drawKnob(20, 71);

	refresh();
}
Пример #2
0
/*!
  Repaint the knob
  \param event Paint event
*/
void QwtKnob::paintEvent( QPaintEvent *event )
{
    const QRectF knobRect = this->knobRect();

    QPainter painter( this );
    painter.setClipRegion( event->region() );

    QStyleOption opt;
    opt.init(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);

    painter.setRenderHint( QPainter::Antialiasing, true );

    if ( !knobRect.contains( event->region().boundingRect() ) )
    {
        scaleDraw()->setRadius( 0.5 * knobRect.width() + d_data->scaleDist );
        scaleDraw()->moveCenter( knobRect.center() );

        scaleDraw()->draw( &painter, palette() );
    }

    drawKnob( &painter, knobRect );

    drawMarker( &painter, knobRect,
        qwtNormalizeDegrees( scaleMap().transform( value() ) ) );

    painter.setRenderHint( QPainter::Antialiasing, false );

    if ( hasFocus() )
        drawFocusIndicator( &painter );
}
Пример #3
0
void Knob::paintEvent(QPaintEvent*)
      {
/*      QPainter p(this);
      const QRect &r = e->rect();

      if ((r == kRect) && d_newVal ) {        // event from valueChange()
        if (d_newVal > 1)               // lost paintEvents()?
          drawKnob(&p, kRect);
            else {
                  drawMarker(&p, d_oldAngle, d_curFaceColor);
                  drawMarker(&p, d_angle, d_markerColor);
                  }
            }
      else {
            p.eraseRect(rect());
            if (hasScale)
                  d_scale.draw(&p);
            drawKnob(&p, kRect);
            }
      d_newVal = 0;
*/
      
      QPainter p(this);
      p.setRenderHint(QPainter::Antialiasing, true);
      if(hasScale)
        d_scale.draw(&p, palette());
      drawKnob(&p, kRect);
      //drawMarker(&p, d_oldAngle, d_curFaceColor);
      //drawMarker(&p, d_angle, d_markerColor);
 
      d_newVal = 0;
      }
Пример #4
0
/*!
  Draw a needle looking like an arrow

  \param painter Painter
  \param palette Palette
  \param colorGroup Color group
  \param center center of the needle
  \param length Length of the needle
  \param width Width of the needle
  \param direction Current Direction
  \param hasKnob With/Without knob
*/
void QwtDialSimpleNeedle::drawArrowNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, int width,
    double direction, bool hasKnob )
{
    direction *= M_PI / 180.0;

    painter->save();

    if ( width <= 0 )
    {
        width = ( int )qMax( length * 0.06, 9.0 );
        if ( width % 2 == 0 )
            width++;
    }

    const int peak = 3;
    const QPoint p1( center.x() + 1, center.y() + 1 );
    const QPoint p2 = qwtPolar2Pos( p1, length - peak, direction );
    const QPoint p3 = qwtPolar2Pos( p1, length, direction );

    QPolygon pa( 5 );
    pa.setPoint( 0, qwtPolar2Pos( p1, width / 2, direction - M_PI_2 ) );
    pa.setPoint( 1, qwtPolar2Pos( p2, 1, direction - M_PI_2 ) );
    pa.setPoint( 2, p3 );
    pa.setPoint( 3, qwtPolar2Pos( p2, 1, direction + M_PI_2 ) );
    pa.setPoint( 4, qwtPolar2Pos( p1, width / 2, direction + M_PI_2 ) );

    painter->setPen( Qt::NoPen );
    painter->setBrush( palette.brush( colorGroup, QPalette::Mid ) );
    painter->drawPolygon( pa );

    QPolygon shadowPa( 3 );

    const int colorOffset = 10;

    int i;
    for ( i = 0; i < 3; i++ )
        shadowPa.setPoint( i, pa[i] );

    const QColor midColor = palette.color( colorGroup, QPalette::Mid );

    painter->setPen( midColor.dark( 100 + colorOffset ) );
    painter->drawPolyline( shadowPa );

    for ( i = 0; i < 3; i++ )
        shadowPa.setPoint( i, pa[i + 2] );

    painter->setPen( midColor.dark( 100 - colorOffset ) );
    painter->drawPolyline( shadowPa );

    if ( hasKnob )
    {
        drawKnob( painter, center, qRound( width * 1.3 ),
            palette.brush( colorGroup, QPalette::Base ),
            false );
    }

    painter->restore();
}
Пример #5
0
/*!
    Draw the needle

    \param painter Painter
    \param length Length of the needle
    \param colorGroup Color group, used for painting
*/
void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter, 
    double length, QPalette::ColorGroup colorGroup ) const
{
    if ( d_style == ThinStyle )
    {
        const double width = qMax( length / 6.0, 3.0 );

        const int colorOffset = 10;

        const QColor light = palette().color( colorGroup, QPalette::Light );
        const QColor dark = palette().color( colorGroup, QPalette::Dark );

        qwtDrawShadedPointer( painter,
            dark.light( 100 + colorOffset ),
            dark.dark( 100 + colorOffset ),
            length, width );
        
        painter->rotate( 180.0 );
    
        qwtDrawShadedPointer( painter,
            light.light( 100 + colorOffset ),
            light.dark( 100 + colorOffset ),
            length, width );
        
        const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base );
        drawKnob( painter, width, baseBrush, true );
    }
    else
    {
        qwtDrawTriangleNeedle( painter, palette(), colorGroup, length );
    }
}
Пример #6
0
/*!
  Draw a needle looking like a ray

  \param painter Painter
  \param palette Palette
  \param colorGroup Color group
  \param center center of the needle
  \param length Length of the needle
  \param width Width of the needle
  \param direction Current Direction
  \param hasKnob With/Without knob
*/
void QwtDialSimpleNeedle::drawRayNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, int width, double direction,
    bool hasKnob )
{
    if ( width <= 0 )
        width = 5;

    direction *= M_PI / 180.0;

    painter->save();

    const QPoint p1( center.x() + 1, center.y() + 2 );
    const QPoint p2 = qwtPolar2Pos( p1, length, direction );

    if ( width == 1 )
    {
        const QColor midColor =
            palette.color( colorGroup, QPalette::Mid );

        painter->setPen( QPen( midColor, 1 ) );
        painter->drawLine( p1, p2 );
    }
    else
    {
        QPolygon pa( 4 );
        pa.setPoint( 0, qwtPolar2Pos( p1, width / 2, direction + M_PI_2 ) );
        pa.setPoint( 1, qwtPolar2Pos( p2, width / 2, direction + M_PI_2 ) );
        pa.setPoint( 2, qwtPolar2Pos( p2, width / 2, direction - M_PI_2 ) );
        pa.setPoint( 3, qwtPolar2Pos( p1, width / 2, direction - M_PI_2 ) );

        painter->setPen( Qt::NoPen );
        painter->setBrush( palette.brush( colorGroup, QPalette::Mid ) );
        painter->drawPolygon( pa );
    }
    if ( hasKnob )
    {
        int knobWidth = qMax( qRound( width * 0.7 ), 5 );
        if ( knobWidth % 2 == 0 )
            knobWidth++;

        drawKnob( painter, center, knobWidth,
            palette.brush( colorGroup, QPalette::Base ),
            false );
    }

    painter->restore();
}
Пример #7
0
/*!
  Repaint the knob

  \param painter Painter
  \param rect Update rectangle
*/
void QwtKnob::draw(QPainter *painter, const QRect& rect)
{
    if ( !d_data->knobRect.contains( rect ) ) // event from valueChange()
    {
#if QT_VERSION < 0x040000
        scaleDraw()->draw( painter, colorGroup() );
#else
        scaleDraw()->draw( painter, palette() );
#endif
    }

    drawKnob( painter, d_data->knobRect );

    if ( hasFocus() )
        QwtPainter::drawFocusRect(painter, this);
}
Пример #8
0
void knob::paintEvent( QPaintEvent * _me )
{
	QPainter p( this );

	drawKnob( &p );
	if( !m_label.isEmpty() )
	{
		p.setFont( pointSizeF( p.font(), 6.5 ) );
/*		p.setPen( QColor( 64, 64, 64 ) );
		p.drawText( width() / 2 -
			p.fontMetrics().width( m_label ) / 2 + 1,
				height() - 1, m_label );*/
		p.setPen( QColor( 255, 255, 255 ) );
		p.drawText( width() / 2 -
				p.fontMetrics().width( m_label ) / 2,
				height() - 2, m_label );
	}
}
Пример #9
0
/*!
  Draw a needle looking like a ray
*/
void QwtDialSimpleNeedle::drawRayNeedle(
    QPainter *painter, const QColorGroup &cg,
    const QPoint &center, int length, int width, double direction, 
    bool hasKnob)
{
    if ( width <= 0 )
        width = 5;

    direction *= M_PI / 180.0;

    painter->save();

    const QPoint p1(center.x() + 1, center.y() + 2);
    const QPoint p2 = qwtPolar2Pos(p1, length, direction);

    if ( width == 1 )
    {
        painter->setPen(QPen(cg.mid(), 1));
        painter->drawLine(p1, p2);
    }
    else
    {
        QPointArray pa(4);
        pa.setPoint(0, qwtPolar2Pos(p1, width / 2, direction + M_PI_2));
        pa.setPoint(1, qwtPolar2Pos(p2, width / 2, direction + M_PI_2));
        pa.setPoint(2, qwtPolar2Pos(p2, width / 2, direction - M_PI_2));
        pa.setPoint(3, qwtPolar2Pos(p1, width / 2, direction - M_PI_2));

        painter->setPen(Qt::NoPen);
        painter->setBrush(cg.brush(QColorGroup::Mid));
        painter->drawPolygon(pa);
    }
    if ( hasKnob )
    {
        int knobWidth = QMAX(qRound(width * 0.7), 5);
        if ( knobWidth % 2 == 0 )
            knobWidth++;

        drawKnob(painter, center, knobWidth, 
            cg.brush(QColorGroup::Base), FALSE);
    }

    painter->restore();
}
Пример #10
0
/*!
  \brief Repaint the knob
*/
void QwtKnob::draw(QPainter *painter, const QRect& ur)
{
    if ( !d_kRect.contains( ur ) ) // event from valueChange()
        scaleDraw()->draw( painter );
    drawKnob( painter, d_kRect );

    if ( hasFocus() )
    {
        QRect r = rect();

#if QT_VERSION < 300
        style().drawFocusRect(painter, r, colorGroup());
#else
        style().drawPrimitive(QStyle::PE_FocusRect, painter,
            r, colorGroup());
#endif
    }

}
Пример #11
0
/*!
  Draw a compass needle 
*/
void QwtCompassMagnetNeedle::drawThinNeedle(
    QPainter *painter, const QColorGroup &cg,
    const QPoint &center, int length, double direction) 
{
    const int colorOffset = 10;
    const int width = QMAX(qRound(length / 6.0), 3);

    painter->save();

    const QPoint arrowCenter(center.x() + 1, center.y() + 1);

    drawPointer(painter, cg.brush(QColorGroup::Dark), colorOffset, 
        arrowCenter, length, width, direction);
    drawPointer(painter, cg.brush(QColorGroup::Light), -colorOffset, 
        arrowCenter, length, width, direction + 180.0);
    
    drawKnob(painter, arrowCenter, width, 
        cg.brush(QColorGroup::Base), TRUE);

    painter->restore();
}
Пример #12
0
/*!
  Repaint the knob
  \param event Paint event
*/
void QwtKnob::paintEvent( QPaintEvent *event )
{
    QPainter painter( this );
    painter.setClipRegion( event->region() );

    QStyleOption opt;
    opt.init(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);

    painter.setRenderHint( QPainter::Antialiasing, true );

    if ( !d_data->knobRect.contains( event->region().boundingRect() ) )
        scaleDraw()->draw( &painter, palette() );

    drawKnob( &painter, d_data->knobRect );
    drawMarker( &painter, d_data->knobRect, d_data->angle );

    painter.setRenderHint( QPainter::Antialiasing, false );

    if ( hasFocus() )
        QwtPainter::drawFocusRect( &painter, this );
}
Пример #13
0
/*!
 Draw the needle

 \param painter Painter
 \param length Length of the needle
 \param colorGroup Color group, used for painting
*/
void QwtDialSimpleNeedle::drawNeedle( QPainter *painter, 
    double length, QPalette::ColorGroup colorGroup ) const
{
    double knobWidth = 0.0;
    double width = d_width;

    if ( d_style == Arrow )
    {
        if ( width <= 0.0 )
            width = qMax(length * 0.06, 6.0);

        qwtDrawArrowNeedle( painter, 
            palette(), colorGroup, length, width );

        knobWidth = qMin( width * 2.0, 0.2 * length );
    }
    else
    {
        if ( width <= 0.0 )
            width = 5.0;
        
        QPen pen ( palette().brush( colorGroup, QPalette::Mid ), width );
        pen.setCapStyle( Qt::FlatCap );
    
        painter->setPen( pen );
        painter->drawLine( QPointF( 0.0, 0.0 ), QPointF( length, 0.0 ) );

        knobWidth = qMax( width * 3.0, 5.0 );
    }

    if ( d_hasKnob && knobWidth > 0.0 )
    {
        drawKnob( painter, knobWidth,
            palette().brush( colorGroup, QPalette::Base ), false );
    }
}
Пример #14
0
/*!
  Draw a compass needle

  \param painter Painter
  \param palette Palette
  \param colorGroup Color group
  \param center Center, where the needle starts
  \param length Length of the needle
  \param direction Direction
*/
void QwtCompassMagnetNeedle::drawThinNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, double direction )
{
    const QBrush darkBrush = palette.brush( colorGroup, QPalette::Dark );
    const QBrush lightBrush = palette.brush( colorGroup, QPalette::Light );
    const QBrush baseBrush = palette.brush( colorGroup, QPalette::Base );

    const int colorOffset = 10;
    const int width = qMax( qRound( length / 6.0 ), 3 );

    painter->save();

    const QPoint arrowCenter( center.x() + 1, center.y() + 1 );

    drawPointer( painter, darkBrush, colorOffset,
        arrowCenter, length, width, direction );
    drawPointer( painter, lightBrush, -colorOffset,
        arrowCenter, length, width, direction + 180.0 );

    drawKnob( painter, arrowCenter, width, baseBrush, true );

    painter->restore();
}