AngleMeasure.cpp   AngleMeasure.cpp 
skipping to change at line 67 skipping to change at line 67
info.displayedName = "Angle Measure"; info.displayedName = "Angle Measure";
info.authors = "Matthew Gates"; info.authors = "Matthew Gates";
info.contact = "http://porpoisehead.net/"; info.contact = "http://porpoisehead.net/";
info.description = "Provides an angle measurement tool"; info.description = "Provides an angle measurement tool";
return info; return info;
} }
Q_EXPORT_PLUGIN2(AngleMeasure, AngleMeasureStelPluginInterface) Q_EXPORT_PLUGIN2(AngleMeasure, AngleMeasureStelPluginInterface)
AngleMeasure::AngleMeasure() AngleMeasure::AngleMeasure()
: flagShowAngleMeasure(false), lineVisible(false), dragging(false), : flagShowAngleMeasure(false), dragging(false),
angleText(""), flagUseDmsFormat(false), pxmapGlow(NULL), pxmapOnIc angleText(""), flagUseDmsFormat(false), toolbarButton(NULL)
on(NULL),
pxmapOffIcon(NULL), toolbarButton(NULL)
{ {
setObjectName("AngleMeasure"); setObjectName("AngleMeasure");
font.setPixelSize(16); font.setPixelSize(16);
messageTimer = new QTimer(this); messageTimer = new QTimer(this);
messageTimer->setInterval(7000); messageTimer->setInterval(7000);
messageTimer->setSingleShot(true); messageTimer->setSingleShot(true);
connect(messageTimer, SIGNAL(timeout()), this, SLOT(clearMessage())) ; connect(messageTimer, SIGNAL(timeout()), this, SLOT(clearMessage())) ;
skipping to change at line 128 skipping to change at line 127
// create action for enable/disable & hook up signals // create action for enable/disable & hook up signals
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); Q_ASSERT(gui);
gui->addGuiActions("actionShow_Angle_Measure", N_("Angle measure"), "Ctrl+A", "Plugin Key Bindings", true, false); gui->addGuiActions("actionShow_Angle_Measure", N_("Angle measure"), "Ctrl+A", "Plugin Key Bindings", true, false);
gui->getGuiActions("actionShow_Angle_Measure")->setChecked(flagShowA ngleMeasure); gui->getGuiActions("actionShow_Angle_Measure")->setChecked(flagShowA ngleMeasure);
connect(gui->getGuiActions("actionShow_Angle_Measure"), SIGNAL(toggl ed(bool)), this, SLOT(enableAngleMeasure(bool))); connect(gui->getGuiActions("actionShow_Angle_Measure"), SIGNAL(toggl ed(bool)), this, SLOT(enableAngleMeasure(bool)));
// Add a toolbar button // Add a toolbar button
try try
{ {
pxmapGlow = new QPixmap(":/graphicGui/gui/glow32x32.png"); toolbarButton = new StelButton(NULL, QPixmap(":/angleMeasure
pxmapOnIcon = new QPixmap(":/angleMeasure/bt_anglemeasure_on /bt_anglemeasure_on.png"), QPixmap(":/angleMeasure/bt_anglemeasure_off.png"
.png"); ), QPixmap(":/graphicGui/glow32x32.png"), gui->getGuiActions("actionShow_An
pxmapOffIcon = new QPixmap(":/angleMeasure/bt_anglemeasure_o gle_Measure"));
ff.png");
toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff
Icon, *pxmapGlow, gui->getGuiActions("actionShow_Angle_Measure"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup");
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "WARNING: unable create toolbar button for Ang leMeasure plugin: " << e.what(); qWarning() << "WARNING: unable create toolbar button for Ang leMeasure plugin: " << e.what();
} }
} }
void AngleMeasure::update(double deltaTime) void AngleMeasure::update(double deltaTime)
{ {
if (!messageFader && messageFader.getInterstate() <= 0.)
return;
messageFader.update((int)(deltaTime*1000)); messageFader.update((int)(deltaTime*1000));
lineVisible.update((int)(deltaTime*1000));
} }
//! Draw any parts on the screen which are for our module //! Draw any parts on the screen which are for our module
void AngleMeasure::draw(StelCore* core) void AngleMeasure::draw(StelCore* core)
{ {
if (lineVisible.getInterstate() < 0.000001f && messageFader.getInter
state() < 0.000001f)
return;
const StelProjectorP prj = core->getProjection(StelCore::FrameEquino xEqu); const StelProjectorP prj = core->getProjection(StelCore::FrameEquino xEqu);
StelPainter painter(prj); StelPainter painter(prj);
painter.setFont(font); painter.setFont(font);
if (lineVisible || flagShowAngleMeasure) if (lineVisible.getInterstate() > 0.000001f)
{ {
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_TEXTURE_2D);
}
if (lineVisible)
{
Vec3d xy; Vec3d xy;
if (prj->project(perp1EndPoint,xy)) if (prj->project(perp1EndPoint,xy))
{ {
glColor3fv(textColor); painter.setColor(textColor[0], textColor[1], textCol or[2], lineVisible.getInterstate());
painter.drawText(xy[0], xy[1], angleText, 0, 15, 15) ; painter.drawText(xy[0], xy[1], angleText, 0, 15, 15) ;
} }
glDisable(GL_TEXTURE_2D);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
// main line is a great circle // main line is a great circle
glColor3fv(lineColor); painter.setColor(lineColor[0], lineColor[1], lineColor[2], l ineVisible.getInterstate());
painter.drawGreatCircleArc(startPoint, endPoint, NULL); painter.drawGreatCircleArc(startPoint, endPoint, NULL);
// End lines // End lines
painter.drawGreatCircleArc(perp1StartPoint, perp1EndPoint, N ULL); painter.drawGreatCircleArc(perp1StartPoint, perp1EndPoint, N ULL);
painter.drawGreatCircleArc(perp2StartPoint, perp2EndPoint, N ULL); painter.drawGreatCircleArc(perp2StartPoint, perp2EndPoint, N ULL);
} }
if (messageFader.getInterstate() > 0.) if (messageFader.getInterstate() > 0.000001f)
{ {
glEnable(GL_BLEND); painter.setColor(textColor[0], textColor[1], textColor[2], m
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); essageFader.getInterstate());
glColor4f(textColor[0], textColor[1], textColor[2], messageF
ader.getInterstate());
painter.drawText(83, 120, "Angle Tool Enabled - left drag to measure, left click to clear"); painter.drawText(83, 120, "Angle Tool Enabled - left drag to measure, left click to clear");
painter.drawText(83, 95, "right click to change end point o nly"); painter.drawText(83, 95, "right click to change end point o nly");
} }
} }
void AngleMeasure::handleKeys(QKeyEvent* event) void AngleMeasure::handleKeys(QKeyEvent* event)
{ {
event->setAccepted(false); event->setAccepted(false);
} }
skipping to change at line 241 skipping to change at line 236
{ {
const StelProjectorP prj = StelApp::getInstance().getCore()- >getProjection(StelCore::FrameEquinoxEqu); const StelProjectorP prj = StelApp::getInstance().getCore()- >getProjection(StelCore::FrameEquinoxEqu);
prj->unProject(event->x(),event->y(),endPoint); prj->unProject(event->x(),event->y(),endPoint);
calculateEnds(); calculateEnds();
event->setAccepted(true); event->setAccepted(true);
return; return;
} }
event->setAccepted(false); event->setAccepted(false);
} }
bool AngleMeasure::handleMouseMoves(int x, int y, Qt::MouseButtons b) bool AngleMeasure::handleMouseMoves(int x, int y, Qt::MouseButtons)
{ {
if (dragging) if (dragging)
{ {
const StelProjectorP prj = StelApp::getInstance().getCore()- >getProjection(StelCore::FrameEquinoxEqu); const StelProjectorP prj = StelApp::getInstance().getCore()- >getProjection(StelCore::FrameEquinoxEqu);
prj->unProject(x,y,endPoint); prj->unProject(x,y,endPoint);
calculateEnds(); calculateEnds();
lineVisible = true; lineVisible = true;
return true; return true;
} }
else else
skipping to change at line 283 skipping to change at line 278
StelUtils::radToDms(startPoint.angle(endPoint), sign, d, m, s); StelUtils::radToDms(startPoint.angle(endPoint), sign, d, m, s);
if (flagUseDmsFormat) if (flagUseDmsFormat)
angleText = QString("%1d %2m %3s").arg(d).arg(m).arg (s, 0, 'f', 2); angleText = QString("%1d %2m %3s").arg(d).arg(m).arg (s, 0, 'f', 2);
else else
angleText = QString("%1%2 %3' %4\"").arg(d).arg(QCha r(0x00B0)).arg(m).arg(s, 0, 'f', 2); angleText = QString("%1%2 %3' %4\"").arg(d).arg(QCha r(0x00B0)).arg(m).arg(s, 0, 'f', 2);
} }
void AngleMeasure::enableAngleMeasure(bool b) void AngleMeasure::enableAngleMeasure(bool b)
{ {
flagShowAngleMeasure = b; flagShowAngleMeasure = b;
lineVisible = b;
messageFader = b; messageFader = b;
if (b) if (b)
{ {
qDebug() << "AngleMeasure::enableAngleMeasure starting timer "; qDebug() << "AngleMeasure::enableAngleMeasure starting timer ";
messageTimer->start(); messageTimer->start();
} }
} }
void AngleMeasure::clearMessage() void AngleMeasure::clearMessage()
{ {
 End of changes. 16 change blocks. 
28 lines changed or deleted 24 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/