CompassMarks.cpp   CompassMarks.cpp 
skipping to change at line 21 skipping to change at line 21
* 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 "VecMath.hpp" #include "VecMath.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "CompassMarks.hpp" #include "CompassMarks.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "renderer/StelCircleArcRenderer.hpp"
#include "renderer/StelRenderer.hpp"
#include <QtOpenGL>
#include <QAction> #include <QAction>
#include <QDebug> #include <QDebug>
#include <QPixmap> #include <QPixmap>
#include <QSettings> #include <QSettings>
#include <QKeyEvent> #include <QKeyEvent>
#include <QtNetwork> #include <QtNetwork>
#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
skipping to change at line 126 skipping to change at line 126
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 QAction *showCompassAction = gui->getGuiAction("actionShow_C
arks"), "", N_("Plugin Key Bindings"), true, false); ompass_Marks");
//gui->getGuiActions("actionShow_Compass_Marks")->setChecked(markFa //showCompassAction->setChecked(markFader);
der); toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff
toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff Icon, *pxmapGlow, showCompassAction);
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 connect(showCompassAction, SIGNAL(toggled(bool)), this, SLOT
AL(toggled(bool)), this, SLOT(setCompassMarks(bool))); (setCompassMarks(bool)));
connect(gui->getGuiActions("actionShow_Cardinal_Points"), SI connect(gui->getGuiAction("actionShow_Cardinal_Points"), SIG
GNAL(toggled(bool)), this, SLOT(cardinalPointsChanged(bool))); NAL(toggled(bool)), this, SLOT(cardinalPointsChanged(bool)));
cardinalPointsState = false; cardinalPointsState = false;
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
setCompassMarks(conf->value("CompassMarks/enable_at_startup" , false).toBool()); setCompassMarks(conf->value("CompassMarks/enable_at_startup" , false).toBool());
// GZ: This must go here, else button may show wrong state // GZ: This must go here, else button may show wrong state
gui->getGuiActions("actionShow_Compass_Marks")->setChecked(markFade gui->getGuiAction("actionShow_Compass_Marks")->setChecked(ma
r); rkFader);
} }
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, StelRenderer* renderer)
{ {
if (markFader.getInterstate() <= 0.0) { return; } if (markFader.getInterstate() <= 0.0) { return; }
Vec3d pos; Vec3f pos;
StelProjectorP prj = core->getProjection(StelCore::FrameAltAz, StelC StelProjectorP prj = core->getProjection(StelCore::FrameAltAz, StelC
ore::RefractionOff); // Maybe conflict with Scenery3d branch. AW20120214 ore::RefractionOff); // Maybe conflict with Scenery3d branch. AW20120214 No
StelPainter painter(prj); . GZ20120826.yy
painter.setFont(font);
renderer->setFont(font);
Vec3f mColor; const Vec3f mColor = StelApp::getInstance().getVisionModeNight()
if (StelApp::getInstance().getVisionModeNight()) ? StelUtils::getNightColor(markColor) : markColor
mColor = StelUtils::getNightColor(markColor); ;
else
mColor = markColor; renderer->setGlobalColor(mColor[0], mColor[1], mColor[2], markFader.
getInterstate());
renderer->setBlendMode(BlendMode_Alpha);
glColor4f(mColor[0], mColor[1], mColor[2], markFader.getInterstate() const QFontMetrics fontMetrics(font);
);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
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); 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
QString s = QString("%1").arg((i+90)%360); QString s = QString("%1").arg((i+90)%360);
float shiftx = painter.getFontMetrics().width(s) / 2 const float shiftx = fontMetrics.width(s) / 2.;
.; const float shifty = fontMetrics.height() / 2.;
float shifty = painter.getFontMetrics().height() / 2 renderer->drawText(TextParams(pos, prj, s).shift(-sh
.; iftx, shifty));
painter.drawText(pos, 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 mark every 5 degrees
} }
glDisable(GL_TEXTURE_2D); Vec3f win1, win2;
painter.drawGreatCircleArc(pos, Vec3d(pos[0], pos[1], h), NU if(prj->project(pos, win1) && prj->project(Vec3f(pos[0], pos
LL); [1], h), win2))
{
renderer->drawLine(win1[0], win1[1], win2[0], win2[1
]);
}
} }
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)
{ {
markFader = b; markFader = b;
skipping to change at line 215 skipping to change at line 211
cardinalPointsState = GETSTELMODULE(LandscapeMgr)->getFlagCa rdinalsPoints(); cardinalPointsState = GETSTELMODULE(LandscapeMgr)->getFlagCa rdinalsPoints();
} }
else else
{ {
} }
if(cardinalPointsState) if(cardinalPointsState)
{ {
// Using QActions instead of directly calling // Using QActions instead of directly calling
// setFlagCardinalsPoints() in order to sync with the button s // setFlagCardinalsPoints() in order to sync with the button s
dynamic_cast<StelGui*>(StelApp::getInstance().getGui())->get GuiActions("actionShow_Cardinal_Points")->trigger(); dynamic_cast<StelGui*>(StelApp::getInstance().getGui())->get GuiAction("actionShow_Cardinal_Points")->trigger();
} }
} }
void CompassMarks::cardinalPointsChanged(bool b) void CompassMarks::cardinalPointsChanged(bool b)
{ {
if(b) if(b)
{ {
// If the compass marks are displayed when cardinal points // If the compass marks are displayed when cardinal points
// are about to be shown, hide the compass marks // are about to be shown, hide the compass marks
if(markFader) if(markFader)
{ {
cardinalPointsState = false; // actionShow_Cardinal_ Points should not be triggered again cardinalPointsState = false; // actionShow_Cardinal_ Points should not be triggered again
dynamic_cast<StelGui*>(StelApp::getInstance().getGui ())->getGuiActions("actionShow_Compass_Marks")->trigger(); dynamic_cast<StelGui*>(StelApp::getInstance().getGui ())->getGuiAction("actionShow_Compass_Marks")->trigger();
} }
} }
} }
 End of changes. 16 change blocks. 
46 lines changed or deleted 43 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/