summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Lancaster <rlancaste@gmail.com>2016-10-22 07:33:12 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-22 07:33:12 (GMT)
commit099173ed040faea8568877bf93b6dda69d4f1bec (patch)
treecf9f2973ac6c08be0a154bc96be1db0bf33d12e1
parent699a1b7113221fceedad40abb0963236188d6851 (diff)
Separating object info and gridlines. New telescope center icon. Speed improvements
-rw-r--r--kstars/data/fitsviewerui.rc1
-rw-r--r--kstars/data/icons/center_telescope.svg10
-rw-r--r--kstars/data/kstars.qrc1
-rw-r--r--kstars/fitsviewer/fitsdata.cpp91
-rw-r--r--kstars/fitsviewer/fitsview.cpp67
-rw-r--r--kstars/fitsviewer/fitsview.h3
-rw-r--r--kstars/fitsviewer/fitsviewer.cpp22
-rw-r--r--kstars/fitsviewer/fitsviewer.h1
8 files changed, 100 insertions, 96 deletions
diff --git a/kstars/data/fitsviewerui.rc b/kstars/data/fitsviewerui.rc
index 0fcc9d8..7d3e16f 100644
--- a/kstars/data/fitsviewerui.rc
+++ b/kstars/data/fitsviewerui.rc
@@ -73,6 +73,7 @@
<Action name="view_pixel_grid" />
<Separator/>
<Action name="view_eq_grid" />
+ <Action name="view_objects" />
<Action name="center_telescope" />
<Separator/>
diff --git a/kstars/data/icons/center_telescope.svg b/kstars/data/icons/center_telescope.svg
new file mode 100644
index 0000000..ef134f7
--- /dev/null
+++ b/kstars/data/icons/center_telescope.svg
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="100" height="100" id="svg2" version="1.0">
+ <g id="layer" >
+ <path style="stroke: #ff0000; stroke-width:10;" d="M 50,1 L 50,35 z " id="up"/>
+ <path style="stroke: #ff0000; stroke-width:10;" d="M 50,65 L 50,100 z " id="down"/>
+ <path style="stroke: #ff0000; stroke-width:10;" d="M 35,50 L 0,50 z " id="left"/>
+ <path style="stroke: #ff0000; stroke-width:10;" d="M 100,50 L 65,50 z " id="right"/>
+ <circle style="stroke:#ff0000; stroke-width:10;" cx="50" cy="50" r="33" fill="none"/>
+ </g>
+</svg> \ No newline at end of file
diff --git a/kstars/data/kstars.qrc b/kstars/data/kstars.qrc
index 9f573f5..c2db8fd 100644
--- a/kstars/data/kstars.qrc
+++ b/kstars/data/kstars.qrc
@@ -122,6 +122,7 @@
<file>icons/breeze/default/zoom-fit-width.svg</file>
<file>icons/breeze/default/map-flat.svg</file>
<file>icons/breeze/default/kstars_telescope.svg</file>
+ <file>icons/center_telescope.svg</file>
</qresource>
<qresource prefix="/kconfig">
<file>kstars.knsrc</file>
diff --git a/kstars/fitsviewer/fitsdata.cpp b/kstars/fitsviewer/fitsdata.cpp
index 194142c..368d0b2 100644
--- a/kstars/fitsviewer/fitsdata.cpp
+++ b/kstars/fitsviewer/fitsdata.cpp
@@ -1791,21 +1791,13 @@ void FITSData::findObjectsInImage(struct wcsprm *wcs, double world[], double phi
tsString = tsString.remove("'").trimmed();
QDateTime ts = QDateTime::fromString(tsString, Qt::ISODate);
- /*QString dateTime=QString(date).remove(QChar('\''), Qt::CaseInsensitive);
- QStringList dateTimeStringList=dateTime.split("T", QString::SkipEmptyParts );
- if(dateTimeStringList.size()>1){
- QTime t = QTime::fromString(dateTimeStringList[1],Qt::TextDate);
- QDate d = QDate::fromString(dateTimeStringList[0],"yyyy-MM-dd");
- num=new KSNumbers(KStarsDateTime(d,t).djd());*/
+
if (ts.isValid())
num = new KSNumbers(KStarsDateTime(ts).djd());
- //}
}
if (num == NULL)
num=new KSNumbers(KStarsData::Instance()->ut().djd());//Set to current time if the above does not work.
- int sampleSize=100;
-
SkyMapComposite *map=KStarsData::Instance()->skyComposite();
wcs_point * wcs_coord = getWCSCoord();
@@ -1813,74 +1805,45 @@ void FITSData::findObjectsInImage(struct wcsprm *wcs, double world[], double phi
{
int size=width*height;
- if(sampleSize>width)//Should also check if the wcs_coord is not big enough!
- return;
-
- double decSample=wcs_coord[sampleSize].dec-wcs_coord[0].dec;
- double raSample=wcs_coord[sampleSize].ra-wcs_coord[0].ra;
- double defaultSearchRadius=sqrt(decSample*decSample+raSample*raSample)*2;//Doubling it just to cast a wider net
-
objList.clear();
- for(int i=0;i<(size);i+=sampleSize)//This makes the x go in increments of the sample size
+ SkyPoint p1;
+ p1.setRA0(dms(wcs_coord[0].ra));
+ p1.setDec0(dms(wcs_coord[0].dec));
+ p1.updateCoordsNow(num);
+ SkyPoint p2;
+ p2.setRA0(dms(wcs_coord[size-1].ra));
+ p2.setDec0(dms(wcs_coord[size-1].dec));
+ p2.updateCoordsNow(num);
+ QList<SkyObject*> list= map->findObjectsInArea( p1, p2 );
+
+ foreach(SkyObject *object, list)
{
- if ((i>width) && (i % width < sampleSize))
- {//This checks if it is just on the next row.
- i+=(sampleSize)*width;//This makes it skip a few rows so the y goes in increments of the sample size.
- i-=i % width;//This corrects for diagonal drift when the image width is not divisible by the sample size
- }
- if(i>size)
- break;
-
- double ra = wcs_coord[i].ra;
- double dec = wcs_coord[i].dec;
- double searchRadius=defaultSearchRadius;//Because searchRadius gets reset each time you run Object Nearest!
+ int type=object->type();
+ if(object->name()=="star"||type==SkyObject::PLANET||type==SkyObject::ASTEROID||type==SkyObject::COMET||type==SkyObject::SUPERNOVA||type==SkyObject::MOON||type==SkyObject::SATELLITE){
+ //DO NOT DISPLAY, at least for now, becaus these things move and change.
+ }
- SkyPoint point;// = new SkyPoint();
- point.setRA0(dms(ra));
- point.setDec0(dms(dec));
- point.updateCoordsNow(num);
- SkyObject *object=(map->objectNearest(&point,searchRadius));
+ int x=-100;
+ int y=-100;
- if(object)
- {
+ world[0]=object->ra0().Degrees();
+ world[1]=object->dec0().Degrees();
- bool objInList=false;
- foreach(FITSSkyObject *listObject, objList)
+ if ((status = wcss2p(wcs, 1, 2, &world[0], &phi, &theta, &imgcrd[0], &pixcrd[0], &stat[0])))
{
- if(listObject->skyObject()->getUID()==object->getUID())
- objInList=true;
- }
-
- int type=object->type();
- if(type==SkyObject::PLANET||type==SkyObject::ASTEROID||type==SkyObject::COMET||type==SkyObject::SUPERNOVA||type==SkyObject::MOON||type==SkyObject::SATELLITE){
- //DO NOT DISPLAY, at least for now, becaus these things move and change.
+ fprintf(stderr, "wcsp2s ERROR %d: %s.\n", status, wcs_errmsg[status]);
}
- else if(!objInList)
+ else
{
- int x=(i % width);//If the coordinate transform doesn't work, we will use the position we found.
- int y=(i / width);
-
- world[0]=object->ra0().Degrees();
- world[1]=object->dec0().Degrees();
-
- if ((status = wcss2p(wcs, 1, 2, &world[0], &phi, &theta, &imgcrd[0], &pixcrd[0], &stat[0])))
- {
- fprintf(stderr, "wcsp2s ERROR %d: %s.\n", status, wcs_errmsg[status]);
- }
- else
- {
- x = pixcrd[0];//The X and Y are set to the found position if it does work.
- y = pixcrd[1];
- }
+ x = pixcrd[0];//The X and Y are set to the found position if it does work.
+ y = pixcrd[1];
+ }
- //objList.insert(objList.size(),new FITSSkyObject(object,x,y));
+ if(x>0&&y>0&&x<width&&y<height)
objList.append(new FITSSkyObject(object,x,y));
- }
}
- }
-
}
delete (num);
diff --git a/kstars/fitsviewer/fitsview.cpp b/kstars/fitsviewer/fitsview.cpp
index 7bca317..dbc95f9 100644
--- a/kstars/fitsviewer/fitsview.cpp
+++ b/kstars/fitsviewer/fitsview.cpp
@@ -20,6 +20,8 @@
#include <config-kstars.h>
#include "fitsview.h"
+#include "kspopupmenu.h"
+#include "skymap.h"
#include <cmath>
#include <cstdlib>
@@ -104,7 +106,7 @@ void FITSView::updateMouseCursor(){
viewport()->setCursor(Qt::CrossCursor);
}
if(mouseMode==scopeMouse){
- QPixmap scope_pix=QPixmap(":/icons/breeze/default/kstars_telescope.svg").scaled(32,32,Qt::KeepAspectRatio,Qt::FastTransformation);
+ QPixmap scope_pix=QPixmap(":/icons/center_telescope.svg").scaled(32,32,Qt::KeepAspectRatio,Qt::FastTransformation);
viewport()->setCursor(QCursor(scope_pix,0,0));
}
}
@@ -188,7 +190,7 @@ void FITSLabel::mouseMoveEvent(QMouseEvent *e)
emit newStatus(QLocale().toString(buffer[(int) (y * width + x)], 'f', 2), FITS_VALUE);
- if (image_data->hasWCS())
+ if (image_data->hasWCS()&&image->getMouseMode()!=FITSView::selectMouse)
{
int index = x + y * width;
@@ -205,12 +207,16 @@ void FITSLabel::mouseMoveEvent(QMouseEvent *e)
emit newStatus(QString("%1 , %2").arg( ra.toHMSString()).arg(dec.toDMSString()), FITS_WCS);
}
+ bool objFound=false;
foreach(FITSSkyObject *listObject, image_data->objList){
- if((abs(listObject->x()-x)<50)&&(abs(listObject->y()-y)<50)){
+ if((abs(listObject->x()-x)<20)&&(abs(listObject->y()-y)<20)){
QToolTip::showText(e->globalPos(), listObject->skyObject()->name(), this);
+ objFound=true;
break;
}
}
+ if(!objFound)
+ QToolTip::hideText();
}
//setCursor(Qt::CrossCursor);
@@ -264,33 +270,22 @@ void FITSLabel::mousePressEvent(QMouseEvent *e)
x = KSUtils::clamp(x, 1.0, width);
y = KSUtils::clamp(y, 1.0, height);
- /* The section below can probably be removed.
-
#ifdef HAVE_INDI
FITSData *image_data = image->getImageData();
- if (e->buttons() & Qt::RightButton)
+ if (e->buttons() & Qt::RightButton&&image->getMouseMode()!=FITSView::selectMouse)
{
mouseReleaseEvent(e);
if (image_data->hasWCS())
{
- QMenu fitspopup;
- QAction *trackAction = fitspopup.addAction(i18n("Center In Telescope"));
-
- if (fitspopup.exec(e->globalPos()) == trackAction)
- {
- int index = x + y * width;
-
- wcs_point * wcs_coord = image_data->getWCSCoord();
-
- if (wcs_coord)
- {
- if (index > size)
- return;
-
- centerTelescope(wcs_coord[index].ra/15.0, wcs_coord[index].dec);
-
- return;
+ foreach(FITSSkyObject *listObject, image_data->objList){
+ if((abs(listObject->x()-x)<20)&&(abs(listObject->y()-y)<20)){
+ SkyObject *object=listObject->skyObject();
+ KSPopupMenu *pmenu;
+ pmenu=new KSPopupMenu();
+ object->showPopupMenu(pmenu,e->globalPos());
+ KStars::Instance()->map()->setClickedObject(object);
+ break;
}
}
}
@@ -299,7 +294,7 @@ void FITSLabel::mousePressEvent(QMouseEvent *e)
emit markerSelected(0, 0);
}
#endif
-*/
+
emit pointSelected(x, y);
@@ -850,9 +845,13 @@ void FITSView::drawOverlay(QPainter *painter)
if (showCrosshair)
drawCrosshair(painter);
- if (showEQGrid){
+
+ if(showObjects)
+ drawObjectNames(painter);
+
+ if (showEQGrid)
drawEQGrid(painter);
- }
+
if (showPixelGrid)
drawPixelGrid(painter);
@@ -1012,8 +1011,7 @@ void FITSView::drawObjectNames(QPainter *painter)
float scale=(currentZoom / ZOOM_DEFAULT);
foreach(FITSSkyObject *listObject, image_data->getSkyObjects())
{
- if (listObject->skyObject()->name() != i18n("star"))
- painter->drawText(listObject->x()*scale,listObject->y()*scale,listObject->skyObject()->name());
+ painter->drawText(listObject->x()*scale+10,listObject->y()*scale+10,listObject->skyObject()->name());
}
}
@@ -1026,8 +1024,6 @@ to draw gridlines at those specific RA and Dec values.
void FITSView::drawEQGrid(QPainter *painter){
- drawObjectNames(painter);
-
if (image_data->hasWCS())
{
wcs_point * wcs_coord = image_data->getWCSCoord();
@@ -1208,6 +1204,11 @@ bool FITSView::isEQGridShown()
return showEQGrid;
}
+bool FITSView::areObjectsShown()
+{
+ return showObjects;
+}
+
bool FITSView::isPixelGridShown()
{
return showPixelGrid;
@@ -1225,6 +1226,12 @@ void FITSView::toggleEQGrid()
updateFrame();
}
+void FITSView::toggleObjects()
+{
+ showObjects=!showObjects;
+ updateFrame();
+
+}
void FITSView::togglePixelGrid()
{
diff --git a/kstars/fitsviewer/fitsview.h b/kstars/fitsviewer/fitsview.h
index 0c0bb85..46c7e78 100644
--- a/kstars/fitsviewer/fitsview.h
+++ b/kstars/fitsviewer/fitsview.h
@@ -122,6 +122,7 @@ public:
void drawTrackingBox(QPainter *);
void drawMarker(QPainter *);
bool isCrosshairShown();
+ bool areObjectsShown();
bool isEQGridShown();
bool isPixelGridShown();
bool imageHasWCS();
@@ -154,6 +155,7 @@ public:
// Grids
void toggleEQGrid();
+ void toggleObjects();
void togglePixelGrid();
void toggleCrosshair();
@@ -208,6 +210,7 @@ private:
bool firstLoad;
bool markStars;
bool showCrosshair=false;
+ bool showObjects=false;
bool showEQGrid=false;
bool showPixelGrid=false;
bool starsSearched=false;
diff --git a/kstars/fitsviewer/fitsviewer.cpp b/kstars/fitsviewer/fitsviewer.cpp
index 313cdac..15bf6e6 100644
--- a/kstars/fitsviewer/fitsviewer.cpp
+++ b/kstars/fitsviewer/fitsviewer.cpp
@@ -59,7 +59,7 @@
#include "Options.h"
#include "indi/indilistener.h"
-#define INITIAL_W 750
+#define INITIAL_W 785
#define INITIAL_H 650
QStringList FITSViewer::filterTypes = QStringList() << I18N_NOOP("Auto Stretch") << I18N_NOOP("High Contrast")
@@ -210,8 +210,15 @@ FITSViewer::FITSViewer (QWidget *parent)
action->setDisabled(true);
connect(action, SIGNAL(triggered(bool)), SLOT(toggleEQGrid()));
+ action = actionCollection()->addAction("view_objects");
+ action->setIcon(QIcon::fromTheme("help-hint", QIcon(":/icons/breeze/default/help-hint.svg")));
+ action->setText(i18n( "Show Objects in Image"));
+ action->setCheckable(true);
+ action->setDisabled(true);
+ connect(action, SIGNAL(triggered(bool)), SLOT(toggleObjects()));
+
action = actionCollection()->addAction("center_telescope");
- action->setIcon(QIcon(":/icons/breeze/default/kstars_telescope.svg"));
+ action->setIcon(QIcon(":/icons/center_telescope.svg"));
action->setText(i18n( "Center Telescope\n*No Telescopes Detected*"));
action->setDisabled(true);
action->setCheckable(true);
@@ -493,6 +500,7 @@ void FITSViewer::tabFocusUpdated(int currentIndex)
updateStatusBar("", FITS_WCS);
updateButtonStatus("view_crosshair", "Cross Hairs", getCurrentView()->isCrosshairShown());
updateButtonStatus("view_eq_grid", "Equatorial Gridines", getCurrentView()->isEQGridShown());
+ updateButtonStatus("view_objects", "Objects in Image", getCurrentView()->areObjectsShown());
updateButtonStatus("view_pixel_grid", "Pixel Gridines", getCurrentView()->isPixelGridShown());
updateScopeButton();
updateWCSFunctions();
@@ -838,6 +846,8 @@ void FITSViewer::updateWCSFunctions()
if(getCurrentView()->imageHasWCS()){
actionCollection()->action("view_eq_grid")->setDisabled(false);
actionCollection()->action("view_eq_grid")->setText( i18n( "Show Equatorial Gridlines" ));
+ actionCollection()->action("view_objects")->setDisabled(false);
+ actionCollection()->action("view_objects")->setText( i18n( "Show Objects in Image" ));
if(getCurrentView()->isTelescopeActive()){
actionCollection()->action("center_telescope")->setDisabled(false);
@@ -853,6 +863,8 @@ void FITSViewer::updateWCSFunctions()
actionCollection()->action("view_eq_grid")->setText( i18n( "Show Equatorial Gridlines\n*No WCS Info*" ));
actionCollection()->action("center_telescope")->setDisabled(true);
actionCollection()->action("center_telescope")->setText( i18n( "Center Telescope\n*No WCS Info*" ));
+ actionCollection()->action("view_objects")->setDisabled(false);
+ actionCollection()->action("view_objects")->setText( i18n( "Show Objects in Image\n*No WCS Info*" ));
}
}
@@ -892,6 +904,12 @@ void FITSViewer::toggleEQGrid()
updateButtonStatus("view_eq_grid", "Equatorial Gridines", getCurrentView()->isEQGridShown());
}
+void FITSViewer::toggleObjects()
+{
+ getCurrentView()->toggleObjects();
+ updateButtonStatus("view_objects", "Objects in Image", getCurrentView()->areObjectsShown());
+}
+
void FITSViewer::togglePixelGrid()
{
getCurrentView()->togglePixelGrid();
diff --git a/kstars/fitsviewer/fitsviewer.h b/kstars/fitsviewer/fitsviewer.h
index 3f092af..660c407 100644
--- a/kstars/fitsviewer/fitsviewer.h
+++ b/kstars/fitsviewer/fitsviewer.h
@@ -112,6 +112,7 @@ public slots:
void toggleStars();
void toggleCrossHair();
void toggleEQGrid();
+ void toggleObjects();
void togglePixelGrid();
void centerTelescope();
void updateWCSFunctions();