PointerCoordinates.cpp   PointerCoordinates.cpp 
skipping to change at line 26 skipping to change at line 26
* *
* 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, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "SkyGui.hpp" #include "SkyGui.hpp"
#include "StelMainView.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "PointerCoordinates.hpp" #include "PointerCoordinates.hpp"
#include "PointerCoordinatesWindow.hpp" #include "PointerCoordinatesWindow.hpp"
skipping to change at line 75 skipping to change at line 74
PointerCoordinates::PointerCoordinates() PointerCoordinates::PointerCoordinates()
: currentPlace(TopRight) : currentPlace(TopRight)
, currentCoordinateSystem(RaDecJ2000) , currentCoordinateSystem(RaDecJ2000)
, flagShowCoordinates(false) , flagShowCoordinates(false)
, flagEnableAtStartup(false) , flagEnableAtStartup(false)
, flagShowCoordinatesButton(false) , flagShowCoordinatesButton(false)
, flagShowConstellation(false) , flagShowConstellation(false)
, textColor(Vec3f(1,0.5,0)) , textColor(Vec3f(1,0.5,0))
, coordinatesPoint(Vec3d(0,0,0)) , coordinatesPoint(Vec3d(0,0,0))
, fontSize(14) , fontSize(14)
, toolbarButton(NULL) , toolbarButton(Q_NULLPTR)
{ {
setObjectName("PointerCoordinates"); setObjectName("PointerCoordinates");
mainWindow = new PointerCoordinatesWindow(); mainWindow = new PointerCoordinatesWindow();
StelApp &app = StelApp::getInstance(); StelApp &app = StelApp::getInstance();
conf = app.getSettings(); conf = app.getSettings();
gui = dynamic_cast<StelGui*>(app.getGui()); gui = dynamic_cast<StelGui*>(app.getGui());
} }
PointerCoordinates::~PointerCoordinates() PointerCoordinates::~PointerCoordinates()
{ {
skipping to change at line 123 skipping to change at line 122
{ {
if (!isEnabled()) if (!isEnabled())
return; return;
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionAuto); const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionAuto);
StelPainter sPainter(prj); StelPainter sPainter(prj);
sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f); sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f);
font.setPixelSize(getFontSize()); font.setPixelSize(getFontSize());
sPainter.setFont(font); sPainter.setFont(font);
QPoint p = StelMainView::getInstance().getMousePos(); // get screen Vec3d mousePosition = core->getMouseJ2000Pos();
coordinates of mouse cursor
Vec3d mousePosition;
float wh = prj->getViewportWidth()/2.; // get half of width of the s
creen
float hh = prj->getViewportHeight()/2.; // get half of height of the
screen
float mx = p.x()-wh; // point 0 in center of the screen, axis X dire
cted to right
float my = p.y()-hh; // point 0 in center of the screen, axis Y dire
cted to bottom
// calculate position of mouse cursor via position of center of the
screen (and invert axis Y)
// If coordinates are invalid, don't draw them.
bool coordsValid = prj->unProject(prj->getViewportPosX()+wh+mx, prj-
>getViewportPosY()+hh+1-my, mousePosition);
if (coordsValid)
{ // Nick Fedoseev patch
Vec3d win;
prj->project(mousePosition,win);
float dx = prj->getViewportPosX()+wh+mx - win.v[0];
float dy = prj->getViewportPosY()+hh+1-my - win.v[1];
prj->unProject(prj->getViewportPosX()+wh+mx+dx, prj->getView
portPosY()+hh+1-my+dy, mousePosition);
}
else
return;
bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDe grees(); bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDe grees();
bool useSouthAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsa ge(); bool useSouthAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsa ge();
QString coordsSystem, cxt, cyt; QString coordsSystem, cxt, cyt;
double cx, cy; double cx, cy;
switch (getCurrentCoordinateSystem()) switch (getCurrentCoordinateSystem())
{ {
case RaDecJ2000: case RaDecJ2000:
{ {
skipping to change at line 302 skipping to change at line 283
cxt = StelUtils::radToHmsStr(cx); cxt = StelUtils::radToHmsStr(cx);
cyt = StelUtils::radToDmsStr(cy); cyt = StelUtils::radToDmsStr(cy);
} }
break; break;
} }
} }
QString constel; QString constel;
if (flagShowConstellation) if (flagShowConstellation)
{ {
constel=QString(" (%1)").arg(core->getIAUConstellation(mouse Position)); constel=QString(" (%1)").arg(core->getIAUConstellation(core- >j2000ToEquinoxEqu(mousePosition)));
} }
QString coordsText = QString("%1: %2/%3%4").arg(coordsSystem).arg(cx t).arg(cyt).arg(constel); QString coordsText = QString("%1: %2/%3%4").arg(coordsSystem).arg(cx t).arg(cyt).arg(constel);
sPainter.drawText(getCoordinatesPlace(coordsText).first, getCoordina tesPlace(coordsText).second, coordsText); sPainter.drawText(getCoordinatesPlace(coordsText).first, getCoordina tesPlace(coordsText).second, coordsText);
} }
void PointerCoordinates::enableCoordinates(bool b) void PointerCoordinates::enableCoordinates(bool b)
{ {
if (b!=flagShowCoordinates) if (b!=flagShowCoordinates)
{ {
flagShowCoordinates = b; flagShowCoordinates = b;
skipping to change at line 384 skipping to change at line 365
conf->setValue("custom_coordinates", QString("%1,%2").arg(cc.first). arg(cc.second)); conf->setValue("custom_coordinates", QString("%1,%2").arg(cc.first). arg(cc.second));
//conf->setValue("text_color", "1,0.5,0"); //conf->setValue("text_color", "1,0.5,0");
conf->setValue("font_size", getFontSize()); conf->setValue("font_size", getFontSize());
conf->setValue("flag_show_constellation", getFlagShowConstellation() ); conf->setValue("flag_show_constellation", getFlagShowConstellation() );
conf->endGroup(); conf->endGroup();
} }
void PointerCoordinates::setFlagShowCoordinatesButton(bool b) void PointerCoordinates::setFlagShowCoordinatesButton(bool b)
{ {
if (gui!=NULL) if (gui!=Q_NULLPTR)
{ {
if (b==true) { if (b==true) {
if (toolbarButton==NULL) { if (toolbarButton==Q_NULLPTR) {
// Create the button // Create the button
toolbarButton = new StelButton(NULL, toolbarButton = new StelButton(Q_NULLPTR,
QPixmap(":/Po interCoordinates/bt_PointerCoordinates_On.png"), QPixmap(":/Po interCoordinates/bt_PointerCoordinates_On.png"),
QPixmap(":/Po interCoordinates/bt_PointerCoordinates_Off.png"), QPixmap(":/Po interCoordinates/bt_PointerCoordinates_Off.png"),
QPixmap(":/gr aphicGui/glow32x32.png"), QPixmap(":/gr aphicGui/glow32x32.png"),
"actionShow_M ousePointer_Coordinates"); "actionShow_M ousePointer_Coordinates");
} }
gui->getButtonBar()->addButton(toolbarButton, "065-p luginsGroup"); gui->getButtonBar()->addButton(toolbarButton, "065-p luginsGroup");
} else { } else {
gui->getButtonBar()->hideButton("actionShow_MousePoi nter_Coordinates"); gui->getButtonBar()->hideButton("actionShow_MousePoi nter_Coordinates");
} }
} }
 End of changes. 7 change blocks. 
33 lines changed or deleted 6 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/