CompassMarks.cpp   CompassMarks.cpp 
skipping to change at line 57 skipping to change at line 57
return new CompassMarks(); return new CompassMarks();
} }
StelPluginInfo CompassMarksStelPluginInterface::getPluginInfo() const StelPluginInfo CompassMarksStelPluginInterface::getPluginInfo() const
{ {
// Allow to load the resources when used as a static plugin // Allow to load the resources when used as a static plugin
Q_INIT_RESOURCE(CompassMarks); Q_INIT_RESOURCE(CompassMarks);
StelPluginInfo info; StelPluginInfo info;
info.id = "CompassMarks"; info.id = "CompassMarks";
info.displayedName = "Compass Marks"; info.displayedName = q_("Compass Marks");
info.authors = "Matthew Gates"; info.authors = "Matthew Gates";
info.contact = "http://porpoisehead.net/"; info.contact = "http://porpoisehead.net/";
info.description = "Displays compass bearing marks along the horizon "; info.description = q_("Displays compass bearing marks along the hori zon");
return info; return info;
} }
Q_EXPORT_PLUGIN2(CompassMarks, CompassMarksStelPluginInterface) Q_EXPORT_PLUGIN2(CompassMarks, CompassMarksStelPluginInterface)
CompassMarks::CompassMarks() CompassMarks::CompassMarks()
: markColor(1,1,1), pxmapGlow(NULL), pxmapOnIcon(NULL), pxmapOffIcon (NULL), toolbarButton(NULL) : markColor(1,1,1), pxmapGlow(NULL), pxmapOnIcon(NULL), pxmapOffIcon (NULL), toolbarButton(NULL)
{ {
setObjectName("CompassMarks"); setObjectName("CompassMarks");
skipping to change at line 120 skipping to change at line 120
void CompassMarks::init() void CompassMarks::init()
{ {
qDebug() << "CompassMarks plugin - press control-C to toggle compass marks"; qDebug() << "CompassMarks plugin - press control-C to toggle compass marks";
try try
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png"); pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png");
pxmapOnIcon = new QPixmap(":/compassMarks/bt_compass_on.png" ); pxmapOnIcon = new QPixmap(":/compassMarks/bt_compass_on.png" );
pxmapOffIcon = new QPixmap(":/compassMarks/bt_compass_off.pn g"); pxmapOffIcon = new QPixmap(":/compassMarks/bt_compass_off.pn g");
gui->addGuiActions("actionShow_Compass_Marks", N_("Compass m arks"), "Ctrl+C", "Plugin Key Bindings", true, false); gui->addGuiActions("actionShow_Compass_Marks", N_("Compass m arks"), "Ctrl+C", N_("Plugin Key Bindings"), true, false);
gui->getGuiActions("actionShow_Compass_Marks")->setChecked(m arkFader); gui->getGuiActions("actionShow_Compass_Marks")->setChecked(m arkFader);
toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff Icon, *pxmapGlow, gui->getGuiActions("actionShow_Compass_Marks")); toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff Icon, *pxmapGlow, gui->getGuiActions("actionShow_Compass_Marks"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup");
connect(gui->getGuiActions("actionShow_Compass_Marks"), SIGN AL(toggled(bool)), this, SLOT(setCompassMarks(bool))); connect(gui->getGuiActions("actionShow_Compass_Marks"), SIGN AL(toggled(bool)), this, SLOT(setCompassMarks(bool)));
connect(gui->getGuiActions("actionShow_Cardinal_Points"), SI GNAL(toggled(bool)), this, SLOT(cardinalPointsChanged(bool))); connect(gui->getGuiActions("actionShow_Cardinal_Points"), SI GNAL(toggled(bool)), this, SLOT(cardinalPointsChanged(bool)));
cardinalPointsState = false; cardinalPointsState = false;
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "WARNING: unable create toolbar button for Com passMarks plugin: " << e.what(); qWarning() << "WARNING: unable create toolbar button for Com passMarks plugin: " << e.what();
} }
} }
//! Draw any parts on the screen which are for our module //! Draw any parts on the screen which are for our module
void CompassMarks::draw(StelCore* core) void CompassMarks::draw(StelCore* core)
{ {
if (markFader.getInterstate() <= 0.0) { return; } if (markFader.getInterstate() <= 0.0) { return; }
Vec3f pos; Vec3d pos;
Vec3f xy;
Vec3f xy2;
StelProjectorP prj = core->getProjection(StelCore::FrameAltAz); StelProjectorP prj = core->getProjection(StelCore::FrameAltAz);
StelPainter painter(prj); StelPainter painter(prj);
painter.setFont(font); painter.setFont(font);
glColor4f(markColor[0],markColor[1],markColor[2], markFader.getInter state()); glColor4f(markColor[0],markColor[1],markColor[2], markFader.getInter state());
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
for(int i=0; i<360; i++) for(int i=0; i<360; i++)
{ {
float a = i*M_PI/180; float a = i*M_PI/180;
pos.set(sin(a),cos(a), 0.f);
float h = -0.002; float h = -0.002;
if (i % 15 == 0) if (i % 15 == 0)
{ {
h = -0.02; // the size of the mark every 15 degrees h = -0.02; // the size of the mark every 15 degrees
// draw a label every 15 degrees // draw a label every 15 degrees
pos.set(sin(a),cos(a), 0.f);
QString s = QString("%1").arg((i+90)%360); QString s = QString("%1").arg((i+90)%360);
float shiftx = painter.getFontMetrics().width(s) / 2 .; float shiftx = painter.getFontMetrics().width(s) / 2 .;
float shifty = painter.getFontMetrics().height() / 2 float shifty = painter.getFontMetrics().height() / 2
; .;
if (prj->project(pos,xy)) painter.drawText(xy[0], xy painter.drawText(pos, s, 0, -shiftx, shifty);
[1], s, 0, -shiftx, shifty);
} }
else if (i % 5 == 0) else if (i % 5 == 0)
{ {
h = -0.01; // the size of the marking every 5 degre es h = -0.01; // the size of the marking every 5 degre es
} }
painter.drawGreatCircleArc(Vec3d(sin(a), cos(a), 0), Vec3d(s glDisable(GL_TEXTURE_2D);
in(a), cos(a), h), NULL); painter.drawGreatCircleArc(pos, Vec3d(pos[0], pos[1], h), NU
LL);
} }
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
} }
void CompassMarks::update(double deltaTime) void CompassMarks::update(double deltaTime)
{ {
markFader.update((int)(deltaTime*1000)); markFader.update((int)(deltaTime*1000));
} }
void CompassMarks::setCompassMarks(bool b) void CompassMarks::setCompassMarks(bool b)
 End of changes. 9 change blocks. 
13 lines changed or deleted 12 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/