AngleMeasure.cpp   AngleMeasure.cpp 
skipping to change at line 20 skipping to change at line 20
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelVertexArray.hpp"
#include "AngleMeasure.hpp" #include "AngleMeasure.hpp"
#include "renderer/StelCircleArcRenderer.hpp"
#include "renderer/StelRenderer.hpp"
#include <QtOpenGL>
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QAction> #include <QAction>
#include <QPixmap> #include <QPixmap>
#include <QtNetwork> #include <QtNetwork>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMouseEvent> #include <QMouseEvent>
#include <cmath> #include <cmath>
skipping to change at line 68 skipping to change at line 67
info.authors = "Matthew Gates"; info.authors = "Matthew Gates";
info.contact = "http://porpoisehead.net/"; info.contact = "http://porpoisehead.net/";
info.description = N_("Provides an angle measurement tool"); info.description = N_("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), dragging(false), : flagShowAngleMeasure(false), dragging(false),
angleText(""), flagUseDmsFormat(false), toolbarButton(NULL) angleText(""), flagUseDmsFormat(false), 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 122 skipping to change at line 121
perp1StartPoint.set(0.,0.,0.); perp1StartPoint.set(0.,0.,0.);
perp1EndPoint.set(0.,0.,0.); perp1EndPoint.set(0.,0.,0.);
perp2StartPoint.set(0.,0.,0.); perp2StartPoint.set(0.,0.,0.);
perp2EndPoint.set(0.,0.,0.); perp2EndPoint.set(0.,0.,0.);
StelApp& app = StelApp::getInstance(); StelApp& app = StelApp::getInstance();
// Create action for enable/disable & hook up signals // Create action for enable/disable & hook up signals
StelGui* gui = dynamic_cast<StelGui*>(app.getGui()); StelGui* gui = dynamic_cast<StelGui*>(app.getGui());
Q_ASSERT(gui); Q_ASSERT(gui);
QAction* action = gui->addGuiActions("actionShow_Angle_Measure", QAction* action = gui->getGuiAction("actionShow_Angle_Measure");
N_("Angle measure"),
"Ctrl+A",
N_("Plugin Key Bindings"),
true, false);
action->setChecked(flagShowAngleMeasure); action->setChecked(flagShowAngleMeasure);
connect(action, SIGNAL(toggled(bool)), this, SLOT(enableAngleMeasure (bool))); connect(action, SIGNAL(toggled(bool)), this, SLOT(enableAngleMeasure (bool)));
// Initialize the message strings and make sure they are translated when // Initialize the message strings and make sure they are translated when
// the language changes. // the language changes.
updateMessageText(); updateMessageText();
connect(&app, SIGNAL(languageChanged()), this, SLOT(updateMessageTex t())); connect(&app, SIGNAL(languageChanged()), this, SLOT(updateMessageTex t()));
// Add a toolbar button // Add a toolbar button
try try
{ {
toolbarButton = new StelButton(NULL, QPixmap(":/angleMeasure toolbarButton = new StelButton(NULL, QPixmap(":/angleMeasure
/bt_anglemeasure_on.png"), QPixmap(":/angleMeasure/bt_anglemeasure_off.png" /bt_anglemeasure_on.png"), QPixmap(":/angleMeasure/bt_anglemeasure_off.png"
), QPixmap(":/graphicGui/glow32x32.png"), gui->getGuiActions("actionShow_An ),
gle_Measure"));
QPixmap(":/gra
phicGui/glow32x32.png"), gui->getGuiAction("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)
{ {
messageFader.update((int)(deltaTime*1000)); messageFader.update((int)(deltaTime*1000));
lineVisible.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, StelRenderer* renderer)
{ {
if (lineVisible.getInterstate() < 0.000001f && messageFader.getInter state() < 0.000001f) if (lineVisible.getInterstate() < 0.000001f && messageFader.getInter state() < 0.000001f)
return; return;
const StelProjectorP prj = core->getProjection(StelCore::FrameEquino xEqu); const StelProjectorP prj = core->getProjection(StelCore::FrameEquino xEqu);
StelPainter painter(prj);
painter.setFont(font); renderer->setFont(font);
Vec3f tColor, lColor;
if (StelApp::getInstance().getVisionModeNight()) const bool night = StelApp::getInstance().getVisionModeNight();
{ const Vec3f tColor = night ? StelUtils::getNightColor(textColor) : l
tColor = StelUtils::getNightColor(textColor); ineColor;
lColor = StelUtils::getNightColor(lineColor); const Vec3f lColor = night ? StelUtils::getNightColor(lineColor) : l
} ineColor;
else
{
tColor = textColor;
lColor = lineColor;
}
if (lineVisible.getInterstate() > 0.000001f) if (lineVisible.getInterstate() > 0.000001f)
{ {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); renderer->setBlendMode(BlendMode_Alpha);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
Vec3d xy; Vec3d xy;
if (prj->project(perp1EndPoint,xy)) if (prj->project(perp1EndPoint,xy))
{ {
painter.setColor(tColor[0], tColor[1], tColor[2], li renderer->setGlobalColor(tColor[0], tColor[1], tColo
neVisible.getInterstate()); r[2],
painter.drawText(xy[0], xy[1], angleText, 0, 15, 15) lineVisible.getInterstate()
; );
renderer->drawText(TextParams(xy[0], xy[1], angleTex
t).shift(15, 15));
} }
glDisable(GL_TEXTURE_2D); renderer->setGlobalColor(lColor[0], lColor[1], lColor[2],
glEnable(GL_LINE_SMOOTH); lineVisible.getInterstate());
glEnable(GL_BLEND);
// main line is a great circle // main line is a great circle
painter.setColor(lColor[0], lColor[1], lColor[2], lineVisibl StelCircleArcRenderer circleArcRenderer(renderer, prj);
e.getInterstate()); circleArcRenderer.drawGreatCircleArc(startPoint, endPoint);
painter.drawGreatCircleArc(startPoint, endPoint, NULL);
// End lines // End lines
painter.drawGreatCircleArc(perp1StartPoint, perp1EndPoint, N circleArcRenderer.drawGreatCircleArc(perp1StartPoint, perp1E
ULL); ndPoint);
painter.drawGreatCircleArc(perp2StartPoint, perp2EndPoint, N circleArcRenderer.drawGreatCircleArc(perp2StartPoint, perp2E
ULL); ndPoint);
} }
if (messageFader.getInterstate() > 0.000001f) if (messageFader.getInterstate() > 0.000001f)
{ {
painter.setColor(tColor[0], tColor[1], tColor[2], messageFad renderer->setGlobalColor(tColor[0], tColor[1], tColor[2],
er.getInterstate()); messageFader.getInterstate());
int x = 83; int x = 83;
int y = 120; int y = 120;
int ls = painter.getFontMetrics().lineSpacing(); const int ls = QFontMetrics(font).lineSpacing();
painter.drawText(x, y, messageEnabled); renderer->drawText(TextParams(x, y, messageEnabled));
y -= ls; y -= ls;
painter.drawText(x, y, messageLeftButton); renderer->drawText(TextParams(x, y, messageLeftButton));
y -= ls; y -= ls;
painter.drawText(x, y, messageRightButton); renderer->drawText(TextParams(x, y, messageRightButton));
} }
} }
void AngleMeasure::handleKeys(QKeyEvent* event) void AngleMeasure::handleKeys(QKeyEvent* event)
{ {
event->setAccepted(false); event->setAccepted(false);
} }
void AngleMeasure::handleMouseClicks(class QMouseEvent* event) void AngleMeasure::handleMouseClicks(class QMouseEvent* event)
{ {
if (!flagShowAngleMeasure) if (!flagShowAngleMeasure)
{ {
event->setAccepted(false); event->setAccepted(false);
return; return;
} }
skipping to change at line 280 skipping to change at line 268
calculateEnds(); calculateEnds();
lineVisible = true; lineVisible = true;
return true; return true;
} }
else else
return false; return false;
} }
void AngleMeasure::calculateEnds(void) void AngleMeasure::calculateEnds(void)
{ {
Vec3d v0 = endPoint - startPoint; Vec3d v0 = endPoint - startPoint;
Vec3d v1 = Vec3d(0,0,0) - startPoint; Vec3d v1 = Vec3d(0,0,0) - startPoint;
Vec3d p = v0 ^ v1; Vec3d p = v0 ^ v1;
p *= 0.08; // end width p *= 0.08; // end width
perp1StartPoint.set(startPoint[0]-p[0],startPoint[1]-p[1],st perp1StartPoint.set(startPoint[0]-p[0],startPoint[1]-p[1],startPoint
artPoint[2]-p[2]); [2]-p[2]);
perp1EndPoint.set(startPoint[0]+p[0],startPoint[1]+p[1],star perp1EndPoint.set(startPoint[0]+p[0],startPoint[1]+p[1],startPoint[2
tPoint[2]+p[2]); ]+p[2]);
v1 = Vec3d(0,0,0) - endPoint; v1 = Vec3d(0,0,0) - endPoint;
p = v0 ^ v1; p = v0 ^ v1;
p *= 0.08; // end width p *= 0.08; // end width
perp2StartPoint.set(endPoint[0]-p[0],endPoint[1]-p[1],endPoi perp2StartPoint.set(endPoint[0]-p[0],endPoint[1]-p[1],endPoint[2]-p[
nt[2]-p[2]); 2]);
perp2EndPoint.set(endPoint[0]+p[0],endPoint[1]+p[1],endPoint perp2EndPoint.set(endPoint[0]+p[0],endPoint[1]+p[1],endPoint[2]+p[2]
[2]+p[2]); );
unsigned int d, m; unsigned int d, m;
double s; double s;
bool sign; bool sign;
StelUtils::radToDms(startPoint.angle(endPoint), sign, d, m, StelUtils::radToDms(startPoint.angle(endPoint), sign, d, m, s);
s); if (flagUseDmsFormat)
if (flagUseDmsFormat) angleText = QString("%1d %2m %3s").arg(d).arg(m).arg(s, 0, '
angleText = QString("%1d %2m %3s").arg(d).arg(m).arg f', 2);
(s, 0, 'f', 2); else
else angleText = QString("%1%2 %3' %4\"").arg(d).arg(QChar(0x00B0
angleText = QString("%1%2 %3' %4\"").arg(d).arg(QCha )).arg(m).arg(s, 0, 'f', 2);
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; lineVisible = b;
messageFader = b; messageFader = b;
if (b) if (b)
{ {
//qDebug() << "AngleMeasure::enableAngleMeasure starting tim er"; //qDebug() << "AngleMeasure::enableAngleMeasure starting tim er";
 End of changes. 20 change blocks. 
79 lines changed or deleted 68 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/