AngleMeasure.cpp   AngleMeasure.cpp 
skipping to change at line 37 skipping to change at line 37
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelVertexArray.hpp" #include "StelVertexArray.hpp"
#include "AngleMeasure.hpp" #include "AngleMeasure.hpp"
#include "AngleMeasureDialog.hpp" #include "AngleMeasureDialog.hpp"
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QPixmap> #include <QPixmap>
#include <QtNetwork>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMouseEvent> #include <QMouseEvent>
#include <cmath> #include <cmath>
//! This method is the one called automatically by the StelModuleMgr just //! This method is the one called automatically by the StelModuleMgr just
//! after loading the dynamic library //! after loading the dynamic library
StelModule* AngleMeasureStelPluginInterface::getStelModule() const StelModule* AngleMeasureStelPluginInterface::getStelModule() const
{ {
return new AngleMeasure(); return new AngleMeasure();
skipping to change at line 191 skipping to change at line 190
endPointHor = core->equinoxEquToAltAz(endPoint, StelCore::Re fractionAuto); endPointHor = core->equinoxEquToAltAz(endPoint, StelCore::Re fractionAuto);
calculateEnds(); calculateEnds();
} }
} }
void AngleMeasure::drawOne(StelCore *core, const StelCore::FrameType frameT ype, const StelCore::RefractionMode refractionMode, const Vec3f txtColor, c onst Vec3f lineColor) void AngleMeasure::drawOne(StelCore *core, const StelCore::FrameType frameT ype, const StelCore::RefractionMode refractionMode, const Vec3f txtColor, c onst Vec3f lineColor)
{ {
const StelProjectorP prj = core->getProjection(frameType, refraction Mode); const StelProjectorP prj = core->getProjection(frameType, refraction Mode);
StelPainter painter(prj); StelPainter painter(prj);
painter.setFont(font); painter.setFont(font);
painter.setBlending(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
if (lineVisible.getInterstate() > 0.000001f) if (lineVisible.getInterstate() > 0.000001f)
{ {
Vec3d xy; Vec3d xy;
QString displayedText; QString displayedText;
if (frameType==StelCore::FrameEquinoxEqu) if (frameType==StelCore::FrameEquinoxEqu)
{ {
if (prj->project(perp1EndPoint,xy)) if (prj->project(perp1EndPoint,xy))
{ {
painter.setColor(txtColor[0], txtColor[1], t xtColor[2], lineVisible.getInterstate()); painter.setColor(txtColor[0], txtColor[1], t xtColor[2], lineVisible.getInterstate());
if (flagShowPA) if (flagShowPA)
skipping to change at line 223 skipping to change at line 221
{ {
painter.setColor(txtColor[0], txtColor[1], t xtColor[2], lineVisible.getInterstate()); painter.setColor(txtColor[0], txtColor[1], t xtColor[2], lineVisible.getInterstate());
if (flagShowHorizontalPA) if (flagShowHorizontalPA)
displayedText = QString("%1 (%2%3)") .arg(calculateAngle(true), messagePA, calculatePositionAngle(startPointHor, endPointHor)); displayedText = QString("%1 (%2%3)") .arg(calculateAngle(true), messagePA, calculatePositionAngle(startPointHor, endPointHor));
else else
displayedText = calculateAngle(true) ; displayedText = calculateAngle(true) ;
painter.drawText(xy[0], xy[1], displayedText , 0, 15, -5); painter.drawText(xy[0], xy[1], displayedText , 0, 15, -5);
} }
} }
glDisable(GL_TEXTURE_2D); painter.setLineSmooth(true);
// OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH. But it looks m
uch better.
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableTyp
e()==QSurfaceFormat::OpenGL)
glEnable(GL_LINE_SMOOTH);
#endif
// main line is a great circle // main line is a great circle
painter.setColor(lineColor[0], lineColor[1], lineColor[2], l ineVisible.getInterstate()); painter.setColor(lineColor[0], lineColor[1], lineColor[2], l ineVisible.getInterstate());
if (frameType==StelCore::FrameEquinoxEqu) if (frameType==StelCore::FrameEquinoxEqu)
{ {
painter.drawGreatCircleArc(startPoint, endPoint, NUL L); painter.drawGreatCircleArc(startPoint, endPoint, NUL L);
// End lines // End lines
painter.drawGreatCircleArc(perp1StartPoint, perp1End Point, NULL); painter.drawGreatCircleArc(perp1StartPoint, perp1End Point, NULL);
painter.drawGreatCircleArc(perp2StartPoint, perp2End Point, NULL); painter.drawGreatCircleArc(perp2StartPoint, perp2End Point, NULL);
} }
else else
{ {
painter.drawGreatCircleArc(startPointHor, endPointHo r, NULL); painter.drawGreatCircleArc(startPointHor, endPointHo r, NULL);
// End lines // End lines
painter.drawGreatCircleArc(perp1StartPointHor, perp1 EndPointHor, NULL); painter.drawGreatCircleArc(perp1StartPointHor, perp1 EndPointHor, NULL);
painter.drawGreatCircleArc(perp2StartPointHor, perp2 EndPointHor, NULL); painter.drawGreatCircleArc(perp2StartPointHor, perp2 EndPointHor, NULL);
} }
#ifdef GL_LINE_SMOOTH
if (QOpenGLContext::currentContext()->format().renderableTyp painter.setLineSmooth(false);
e()==QSurfaceFormat::OpenGL)
glDisable(GL_LINE_SMOOTH);
#endif
} }
if (messageFader.getInterstate() > 0.000001f) if (messageFader.getInterstate() > 0.000001f)
{ {
painter.setColor(txtColor[0], txtColor[1], txtColor[2], mess ageFader.getInterstate()); painter.setColor(txtColor[0], txtColor[1], txtColor[2], mess ageFader.getInterstate());
int x = 83; int x = 83;
int y = 120; int y = 120;
int ls = painter.getFontMetrics().lineSpacing(); int ls = painter.getFontMetrics().lineSpacing();
painter.drawText(x, y, messageEnabled); painter.drawText(x, y, messageEnabled);
y -= ls; y -= ls;
painter.drawText(x, y, messageLeftButton); painter.drawText(x, y, messageLeftButton);
y -= ls; y -= ls;
painter.drawText(x, y, messageRightButton); painter.drawText(x, y, messageRightButton);
} }
glDisable(GL_BLEND); painter.setBlending(false);
} }
//! 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 (startPoint.lengthSquared()==0.0) // avoid crash on switch-on, lp :#1455839 if (startPoint.lengthSquared()==0.0) // avoid crash on switch-on, lp :#1455839
return; return;
if (lineVisible.getInterstate() < 0.000001f && messageFader.getInter state() < 0.000001f) if (lineVisible.getInterstate() < 0.000001f && messageFader.getInter state() < 0.000001f)
return; return;
if (flagShowHorizontal) if (flagShowHorizontal)
skipping to change at line 331 skipping to change at line 322
{ {
if (!flagShowAngleMeasure) if (!flagShowAngleMeasure)
{ {
event->setAccepted(false); event->setAccepted(false);
return; return;
} }
if (event->type()==QEvent::MouseButtonPress && event->button()==Qt:: LeftButton) if (event->type()==QEvent::MouseButtonPress && event->button()==Qt:: LeftButton)
{ {
const StelProjectorP prj = StelApp::getInstance().getCore()- >getProjection(StelCore::FrameEquinoxEqu); const StelProjectorP prj = StelApp::getInstance().getCore()- >getProjection(StelCore::FrameEquinoxEqu);
prj->unProject(event->x(),event->y(),startPoint); if (prj->unProject(event->x(),event->y(),startPoint))
{ // Nick Fedoseev patch: improve click match { // Nick Fedoseev patch: improve click match
Vec3d win; Vec3d win;
prj->project(startPoint,win); prj->project(startPoint,win);
float dx = event->x() - win.v[0]; float dx = event->x() - win.v[0];
float dy = event->y() - win.v[1]; float dy = event->y() - win.v[1];
prj->unProject(event->x()+dx, event->y()+dy, startPo int); prj->unProject(event->x()+dx, event->y()+dy, startPo int);
} }
const StelProjectorP prjHor = StelApp::getInstance().getCore ()->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff); const StelProjectorP prjHor = StelApp::getInstance().getCore ()->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff);
prjHor->unProject(event->x(),event->y(),startPointHor); prjHor->unProject(event->x(),event->y(),startPointHor);
skipping to change at line 367 skipping to change at line 358
else if (event->type()==QEvent::MouseButtonRelease && event->button( )==Qt::LeftButton) else if (event->type()==QEvent::MouseButtonRelease && event->button( )==Qt::LeftButton)
{ {
dragging = false; dragging = false;
calculateEnds(); calculateEnds();
event->setAccepted(true); event->setAccepted(true);
return; return;
} }
else if (event->type()==QEvent::MouseButtonPress && event->button()= =Qt::RightButton) else if (event->type()==QEvent::MouseButtonPress && event->button()= =Qt::RightButton)
{ {
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); if (prj->unProject(event->x(),event->y(),endPoint))
{ // Nick Fedoseev patch: improve click match { // Nick Fedoseev patch: improve click match
Vec3d win; Vec3d win;
prj->project(endPoint,win); prj->project(endPoint,win);
float dx = event->x() - win.v[0]; float dx = event->x() - win.v[0];
float dy = event->y() - win.v[1]; float dy = event->y() - win.v[1];
prj->unProject(event->x()+dx, event->y()+dy, endPoin t); prj->unProject(event->x()+dx, event->y()+dy, endPoin t);
} }
const StelProjectorP prjHor = StelApp::getInstance().getCore ()->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff); const StelProjectorP prjHor = StelApp::getInstance().getCore ()->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff);
prjHor->unProject(event->x(),event->y(),endPointHor); prjHor->unProject(event->x(),event->y(),endPointHor);
calculateEnds(); calculateEnds();
skipping to change at line 389 skipping to change at line 380
return; return;
} }
event->setAccepted(false); event->setAccepted(false);
} }
bool AngleMeasure::handleMouseMoves(int x, int y, Qt::MouseButtons) 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); if (prj->unProject(x,y,endPoint))
{ // Nick Fedoseev patch: improve click match { // Nick Fedoseev patch: improve click match
Vec3d win; Vec3d win;
prj->project(endPoint,win); prj->project(endPoint,win);
float dx = x - win.v[0]; float dx = x - win.v[0];
float dy = y - win.v[1]; float dy = y - win.v[1];
prj->unProject(x+dx, y+dy, endPoint); prj->unProject(x+dx, y+dy, endPoint);
} }
const StelProjectorP prjHor = StelApp::getInstance().getCore ()->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff); const StelProjectorP prjHor = StelApp::getInstance().getCore ()->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff);
prjHor->unProject(x,y,endPointHor); prjHor->unProject(x,y,endPointHor);
calculateEnds(); calculateEnds();
 End of changes. 9 change blocks. 
20 lines changed or deleted 8 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/