#include "azimutscale.h"
#include <qpainter.h>
#include <qbitmap.h>
AzimutScale
::AzimutScale( QWidget *parent,
const char *name
) : mapParent
(parent
),
QWidget( parent, name
) {
resize(parent->width()*0.9, parent->height()*0.9);
}
{
bm.fill( color0 ); //transparent
paint.begin( &bm, this, false );
drawScale( &paint );
paint.end();
setMask( bm );
}
void AzimutScale
::drawScale( QPainter *paint
) {
/*QColor mainTagsColor (127,0,127);
QColor tagsColor( 127,127,191);*/
QColor mainTagsColor
(color1
);
paint->setWindow( -500,-500, 1000,1000 );
QRect v
= paint
->viewport
();
int d = QMIN( v.width(), v.height() );
paint->setViewport( v.left() + (v.width()-d)/2,
v.top() + (v.height()-d)/2, d, d );
//Draw cross at center of scale
paint
->setPen
(QPen(mainTagsColor,
1));
paint->drawLine( 0, -50, 0, 50 );
paint->drawLine( -50, 0, 50,0 );
//Draw main scale
for ( int i=0; i<12; i++ ) {
//draw label
paint->setPen(mainTagsColor);
paint->setFont(fontLabel);
int pixWidth = fm.width(label);
paint->drawText(0-pixWidth/2, -480, label);
//draw tag
paint
->setPen
(QPen(mainTagsColor,
1));
paint->drawLine( 0, -300, 0, -470 );
paint->rotate( 30 );
}
//Draw minus scale
paint->setPen(tagsColor);
for ( int j=0; j<60; j++ ) {
if ((j%5) !=0 )
paint->drawLine( 0, -450, 0, -470 );
paint->rotate( 6 );
}
}
#include "azimutscale.h"
#include <qpainter.h>
#include <qbitmap.h>
AzimutScale::AzimutScale( QWidget *parent, const char *name)
: mapParent(parent), QWidget( parent, name )
{
resize(parent->width()*0.9, parent->height()*0.9);
}
void AzimutScale::paintEvent( QPaintEvent * )
{
QBitmap bm( size() );
bm.fill( color0 ); //transparent
QPainter paint;
paint.begin( &bm, this, false );
drawScale( &paint );
paint.end();
setMask( bm );
}
void AzimutScale::drawScale( QPainter *paint )
{
/*QColor mainTagsColor (127,0,127);
QColor tagsColor( 127,127,191);*/
QColor mainTagsColor (color1);
QColor tagsColor( color1);
paint->setWindow( -500,-500, 1000,1000 );
QRect v = paint->viewport();
int d = QMIN( v.width(), v.height() );
paint->setViewport( v.left() + (v.width()-d)/2,
v.top() + (v.height()-d)/2, d, d );
//Draw cross at center of scale
paint->setPen(QPen(mainTagsColor,1));
paint->drawLine( 0, -50, 0, 50 );
paint->drawLine( -50, 0, 50,0 );
//Draw main scale
QFont fontLabel ("times", 15, QFont::Bold);
QFontMetrics fm (fontLabel);
for ( int i=0; i<12; i++ ) {
//draw label
paint->setPen(mainTagsColor);
paint->setFont(fontLabel);
QString label = QString::number(i*30);
int pixWidth = fm.width(label);
paint->drawText(0-pixWidth/2, -480, label);
//draw tag
paint->setPen(QPen(mainTagsColor,1));
paint->drawLine( 0, -300, 0, -470 );
paint->rotate( 30 );
}
//Draw minus scale
paint->setPen(tagsColor);
for ( int j=0; j<60; j++ ) {
if ((j%5) !=0 )
paint->drawLine( 0, -450, 0, -470 );
paint->rotate( 6 );
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks