1 /***************************************************************************
4 begin : Fri 05 Sept 2003
5 copyright : (C) 2003 by Jason Harris
6 email : kstars@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
22 #include <kstandarddirs.h>
26 //------------FOV-----------------//
27 FOV::FOV( QString n
, float sz
, int sh
, QString col
) : Name( n
), Color( col
), Size( sz
), Shape( sh
)
30 FOV::FOV() : Name( i18n( "No FOV" ) ), Color( "#FFFFFF" ), Size( 0.0 ), Shape( 0 )
33 FOV::FOV( QString sname
) {
35 f
.setName( locate( "appdata", "fov.dat" ) );
40 if ( f
.exists() && f
.open( IO_ReadOnly
) ) {
41 QTextStream
stream( &f
);
42 while ( !stream
.eof() ) {
43 QStringList fields
= QStringList::split( ":", stream
.readLine() );
46 if ( fields
.count() == 4 ) {
47 if ( fields
[0] == sname
) {
48 sz
= (float)(fields
[1].toDouble( &ok
));
50 sh
= fields
[2].toInt( &ok
);
67 //If we get here, then the symbol could not be assigned
68 Name
= i18n( "No FOV" );
74 void FOV::draw( QPainter
&p
, float pixelsize
) {
75 p
.setPen( QColor( color() ) );
76 p
.setBrush( Qt::NoBrush
);
77 int w
= p
.viewport().width();
78 int h
= p
.viewport().height();
82 int s
= int( pixelsize
);
83 p
.drawRect( (w
- s
)/2, (h
- s
)/2, s
, s
);
87 int s
= int( pixelsize
);
88 p
.drawEllipse( (w
- s
)/2, (h
- s
)/2, s
, s
);
91 case 2: { //Crosshairs
92 int s1
= int( pixelsize
);
93 int s2
= 2*int( pixelsize
);
94 int s3
= 3*int( pixelsize
);
96 int x0
= w
/2; int y0
= h
/2;
97 int x1
= x0
- s1
/2; int y1
= y0
- s1
/2;
98 int x2
= x0
- s2
/2; int y2
= y0
- s2
/2;
99 int x3
= x0
- s3
/2; int y3
= y0
- s3
/2;
102 p
.drawLine( x1
, y0
, x3
, y0
);
103 p
.drawLine( x0
+s3
/2, y0
, x0
+s1
/2, y0
);
104 p
.drawLine( x0
, y1
, x0
, y3
);
105 p
.drawLine( x0
, y0
+s1
/2, x0
, y0
+s3
/2 );
107 //Draw circles at 0.5 & 1 degrees
108 p
.drawEllipse( x1
, y1
, s1
, s1
);
109 p
.drawEllipse( x2
, y2
, s2
, s2
);
114 int s1
= int( pixelsize
);
115 int s2
= 2*int( pixelsize
);
116 int s3
= 3*int( pixelsize
);
118 int x0
= w
/2; int y0
= h
/2;
119 int x1
= x0
- s1
/2; int y1
= y0
- s1
/2;
120 int x2
= x0
- s2
/2; int y2
= y0
- s2
/2;
121 int x3
= x0
- s3
/2; int y3
= y0
- s3
/2;
123 p
.drawEllipse( x1
, y1
, s1
, s1
);
124 p
.drawEllipse( x2
, y2
, s2
, s2
);
125 p
.drawEllipse( x3
, y3
, s3
, s3
);
129 case 4: { // Solid Circle
130 int s
= int( pixelsize
);
131 p
.setBrush( QBrush ( QColor( color() ), Qt::Dense4Pattern
) );
132 p
.drawEllipse( (w
- s
)/2, (h
- s
)/2, s
, s
);
133 p
.setBrush(Qt::NoBrush
);