summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Lancaster <rlancaste@gmail.com>2016-10-09 20:44:16 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-09 20:44:16 (GMT)
commitf40ddf7208ae3a0f23b04fb880db708d325d8af0 (patch)
tree033ee0c0d9f09d818a299c6110f606f5d38d5226
parent6d23b0c93639ef2f9244a5bf6c8f9f07a2748e57 (diff)
Adding zoom to fit and central crosshair. Grid lines TODO
-rw-r--r--kstars/data/fitsviewerui.rc7
-rw-r--r--kstars/data/icons/breeze/default/map-flat.svg14
-rw-r--r--kstars/data/icons/breeze/default/zoom-fit-width.svg14
-rw-r--r--kstars/data/kstars.qrc5
-rw-r--r--kstars/fitsviewer/fitstab.cpp4
-rw-r--r--kstars/fitsviewer/fitsview.cpp78
-rw-r--r--kstars/fitsviewer/fitsview.h12
-rw-r--r--kstars/fitsviewer/fitsviewer.cpp54
-rw-r--r--kstars/fitsviewer/fitsviewer.h4
9 files changed, 184 insertions, 8 deletions
diff --git a/kstars/data/fitsviewerui.rc b/kstars/data/fitsviewerui.rc
index 9cb57bd..5bb4204 100644
--- a/kstars/data/fitsviewerui.rc
+++ b/kstars/data/fitsviewerui.rc
@@ -62,15 +62,20 @@
<Action name="view_zoom_in" />
<Action name="view_zoom_out" />
<Action name="view_actual_size"/>
+ <Action name="view_zoom_fit"/>
<Separator/>
<Action name="rotate_right" />
<Action name="rotate_left" />
<Action name="flip_horizontal" />
<Action name="flip_vertical" />
<Separator/>
+ <Action name="view_crosshair" />
+ <Action name="view_eq_grid" />
+ <Separator/>
</ToolBar>
-<ToolBar noMerge="1" name="processToolBar"><text>Process ToolBar</text>
+<ToolBar noMerge="1" name="processToolBar" iconText="icononly"><text>Process ToolBar</text>
+
<Action name="image_histogram" />
<Action name="image_stats" />
<Action name="image_stretch" />
diff --git a/kstars/data/icons/breeze/default/map-flat.svg b/kstars/data/icons/breeze/default/map-flat.svg
new file mode 100644
index 0000000..d988a0a
--- /dev/null
+++ b/kstars/data/icons/breeze/default/map-flat.svg
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
+ <defs id="defs3051">
+ <style type="text/css" id="current-color-scheme">
+ .ColorScheme-Text {
+ color:#4d4d4d;
+ }
+ </style>
+ </defs>
+ <path
+ style="fill:currentColor;fill-opacity:1;stroke:none"
+ d="M 3 3 L 3 19 L 19 19 L 19 3 L 3 3 z M 4 4 L 8 4 L 8 8 L 4 8 L 4 4 z M 9 4 L 13 4 L 13 8 L 9 8 L 9 4 z M 14 4 L 18 4 L 18 8 L 14 8 L 14 4 z M 4 9 L 8 9 L 8 13 L 4 13 L 4 9 z M 9 9 L 13 9 L 13 13 L 9 13 L 9 9 z M 14 9 L 18 9 L 18 13 L 14 13 L 14 9 z M 4 14 L 8 14 L 8 18 L 4 18 L 4 14 z M 9 14 L 13 14 L 13 18 L 9 18 L 9 14 z M 14 14 L 18 14 L 18 18 L 14 18 L 14 14 z "
+ class="ColorScheme-Text"
+ />
+</svg>
diff --git a/kstars/data/icons/breeze/default/zoom-fit-width.svg b/kstars/data/icons/breeze/default/zoom-fit-width.svg
new file mode 100644
index 0000000..523cae3
--- /dev/null
+++ b/kstars/data/icons/breeze/default/zoom-fit-width.svg
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
+ <defs id="defs3051">
+ <style type="text/css" id="current-color-scheme">
+ .ColorScheme-Text {
+ color:#4d4d4d;
+ }
+ </style>
+ </defs>
+ <path
+ style="fill:currentColor;fill-opacity:1;stroke:none"
+ d="M 6 6 L 6 16 L 16 16 L 16 6 L 6 6 z M 7 7 L 15 7 L 15 15 L 7 15 L 7 7 z M 5 9 L 3 11 L 5 13 L 5 9 z M 17 9 L 17 13 L 19 11 L 17 9 z "
+ class="ColorScheme-Text"
+ />
+</svg>
diff --git a/kstars/data/kstars.qrc b/kstars/data/kstars.qrc
index 36368da..d72dbaf 100644
--- a/kstars/data/kstars.qrc
+++ b/kstars/data/kstars.qrc
@@ -12,7 +12,7 @@
<file>icons/ekos_scheduler.png</file>
<file>icons/ekos_setup.png</file>
<file>icons/fov.png</file>
- <file>icons/histogram.png</file>
+ <file>icons/histogram.png</file>
<file>icons/breeze/index.theme</file>
<file>icons/breeze/default/accessories-calculator.svg</file>
<file>icons/breeze/default/application-exit.svg</file>
@@ -119,7 +119,8 @@
<file>icons/go-nw.png</file>
<file>icons/go-se.png</file>
<file>icons/go-sw.png</file>
- <file>icons/histogram.png</file>
+ <file>icons/breeze/default/zoom-fit-width.svg</file>
+ <file>icons/breeze/default/map-flat.svg</file>
</qresource>
<qresource prefix="/kconfig">
<file>kstars.knsrc</file>
diff --git a/kstars/fitsviewer/fitstab.cpp b/kstars/fitsviewer/fitstab.cpp
index 4cbb421..037b1e5 100644
--- a/kstars/fitsviewer/fitstab.cpp
+++ b/kstars/fitsviewer/fitstab.cpp
@@ -333,7 +333,9 @@ void FITSTab::ZoomOut()
void FITSTab::ZoomDefault()
{
- view->ZoomDefault();
+ QPoint oldCenter=view->getImagePoint(view->viewport()->rect().center());
+ view->ZoomDefault();
+ view->cleanUpZoom(oldCenter);
}
void FITSTab::tabPositionUpdated()
diff --git a/kstars/fitsviewer/fitsview.cpp b/kstars/fitsviewer/fitsview.cpp
index 0001826..326192f 100644
--- a/kstars/fitsviewer/fitsview.cpp
+++ b/kstars/fitsviewer/fitsview.cpp
@@ -519,7 +519,12 @@ int FITSView::rescale(FITSZoom type)
int w = baseSize().width() - BASE_OFFSET;
int h = baseSize().height() - BASE_OFFSET;
- // Find the zoom level which will enclose the current FITS in the default window size (640x480)
+ if(!firstLoad){
+ w = viewport()->rect().width() - BASE_OFFSET;
+ h = viewport()->rect().height() - BASE_OFFSET;
+ }
+
+ // Find the zoom level which will enclose the current FITS in the current window size
currentZoom = floor( (w / currentWidth) * 10.) * 10.;
/* If width is not the problem, try height */
@@ -615,6 +620,12 @@ void FITSView::ZoomOut()
newStatus(QString("%1%").arg(currentZoom), FITS_ZOOM);
}
+void FITSView::ZoomToFit()
+{
+ rescale(ZOOM_FIT_WINDOW);
+ updateFrame();
+}
+
void FITSView::updateFrame()
{
@@ -670,6 +681,12 @@ void FITSView::drawOverlay(QPainter *painter)
if (markerCrosshair.isNull() == false)
drawMarker(painter);
+
+ if (showCrosshair)
+ drawCrosshair(painter);
+ if (showEQGrid)
+ drawEQGrid(painter);
+
}
void FITSView::updateMode(FITSMode fmode)
@@ -738,6 +755,42 @@ void FITSView::drawTrackingBox(QPainter *painter)
painter->drawRect(x1, y1, w, h);
}
+void FITSView::drawCrosshair(QPainter *painter){
+
+ float scale=(currentZoom / ZOOM_DEFAULT);
+ QPointF c=QPointF(image_width/2 *scale,image_height/2 * scale);
+ float midX=image_width/2 * scale;
+ float midY=image_height/2 * scale;
+ float maxX=image_width * scale;
+ float maxY=image_height * scale;
+ float r=50*scale;
+
+
+ painter->setPen( QPen( QColor( KStarsData::Instance()->colorScheme()->colorNamed("TargetColor" ) ) ) );
+
+ //Horizontal Line to Circle
+ painter->drawLine(0, midY, midX - r, midY);
+
+ //Horizontal Line past Circle
+ painter->drawLine(midX + r, midY, maxX, midY);
+
+ //Vertical Line to Circle
+ painter->drawLine(midX, 0, midX, midY - r);
+
+ //Vertical Line past Circle
+ painter->drawLine(midX, midY + r, midX, maxY);
+
+ //Circles
+ painter->drawEllipse(c,r,r);
+ painter->drawEllipse(c, r/2, r/2);
+
+}
+
+void FITSView::drawEQGrid(QPainter *painter){
+
+
+}
+
QPixmap & FITSView::getTrackingBoxPixmap()
{
if (trackingBox.isNull())
@@ -763,6 +816,29 @@ void FITSView::setTrackingBox(const QRect & rect)
}
}
+bool FITSView::isCrosshairShown()
+{
+ return showCrosshair;
+}
+
+bool FITSView::isEQGridShown()
+{
+ return showEQGrid;
+}
+
+void FITSView::toggleCrosshair()
+{
+ showCrosshair=!showCrosshair;
+ updateFrame();
+}
+
+void FITSView::toggleEQGrid()
+{
+ showEQGrid=!showEQGrid;
+ updateFrame();
+
+}
+
void FITSView::toggleStars(bool enable)
{
markStars = enable;
diff --git a/kstars/fitsviewer/fitsview.h b/kstars/fitsviewer/fitsview.h
index 89190fa..49d78db 100644
--- a/kstars/fitsviewer/fitsview.h
+++ b/kstars/fitsviewer/fitsview.h
@@ -110,6 +110,11 @@ public:
void drawStarCentroid(QPainter *);
void drawTrackingBox(QPainter *);
void drawMarker(QPainter *);
+ bool isCrosshairShown();
+ bool isEQGridShown();
+
+ void drawCrosshair(QPainter *);
+ void drawEQGrid(QPainter *);
void updateFrame();
// Zoom related
@@ -118,6 +123,8 @@ public:
// Star Detection
void toggleStars(bool enable);
+ void toggleEQGrid();
+ void toggleCrosshair();
// FITS Mode
void updateMode(FITSMode mode);
@@ -131,7 +138,8 @@ protected:
public slots:
void ZoomIn();
void ZoomOut();
- void ZoomDefault();
+ void ZoomDefault();
+ void ZoomToFit();
void processPointSelection(int x, int y);
void processMarkerSelection(int x, int y);
@@ -159,6 +167,8 @@ private:
bool firstLoad;
bool markStars;
+ bool showCrosshair=false;
+ bool showEQGrid=false;
bool starsSearched;
bool hasWCS;
diff --git a/kstars/fitsviewer/fitsviewer.cpp b/kstars/fitsviewer/fitsviewer.cpp
index ec74f78..95c6444 100644
--- a/kstars/fitsviewer/fitsviewer.cpp
+++ b/kstars/fitsviewer/fitsviewer.cpp
@@ -181,6 +181,23 @@ FITSViewer::FITSViewer (QWidget *parent)
action->setText(i18n( "Statistics"));
connect(action, SIGNAL(triggered(bool)), SLOT(statFITS()));
+ action = actionCollection()->addAction("view_crosshair");
+ action->setIcon(QIcon::fromTheme("crosshairs", QIcon(":/icons/breeze/default/crosshairs.svg")));
+ action->setText(i18n( "Show Cross Hairs"));
+ action->setCheckable(true);
+ connect(action, SIGNAL(triggered(bool)), SLOT(toggleCrossHair()));
+
+ action = actionCollection()->addAction("view_eq_grid");
+ action->setIcon(QIcon::fromTheme("map-flat", QIcon(":/icons/breeze/default/map-flat.svg")));
+ action->setText(i18n( "Show Equatorial Gridlines"));
+ action->setCheckable(true);
+ connect(action, SIGNAL(triggered(bool)), SLOT(toggleEQGrid()));
+
+ action = actionCollection()->addAction("view_zoom_fit");
+ action->setIcon(QIcon::fromTheme("zoom-fit-width", QIcon(":/icons/breeze/default/zoom-fit-width.svg")));
+ action->setText(i18n( "Zoom To Fit"));
+ connect(action, SIGNAL(triggered(bool)), SLOT(ZoomToFit()));
+
action = actionCollection()->addAction("mark_stars");
action->setText(i18n( "Mark Stars"));
connect(action, SIGNAL(triggered(bool)), SLOT(toggleStars()));
@@ -446,6 +463,9 @@ void FITSViewer::tabFocusUpdated(int currentIndex)
actionCollection()->action("fits_debayer")->setEnabled(false);
updateStatusBar("", FITS_WCS);
+ updateButtonStatus("view_crosshair", "Cross Hairs", getCurrentView()->isCrosshairShown());
+ updateButtonStatus("view_eq_grid", "Equatorial Gridines", getCurrentView()->isEQGridShown());
+
}
@@ -693,6 +713,14 @@ void FITSViewer::ZoomDefault()
fitsTabs[fitsTab->currentIndex()]->ZoomDefault();
}
+void FITSViewer::ZoomToFit()
+{
+ if (fitsTabs.empty())
+ return;
+
+ getCurrentView()->ZoomToFit();
+}
+
void FITSViewer::updateAction(const QString &name, bool enable)
{
QAction *toolAction = NULL;
@@ -747,10 +775,32 @@ void FITSViewer::closeTab(int index)
}
}
+void FITSViewer::updateButtonStatus(QString action, QString item, bool showing){
+ QAction *a=actionCollection()->action(action);
+ if (showing)
+ {
+ a->setText( "Hide " + item );
+ a->setChecked(true);
+ }
+ else
+ {
+ a->setText( "Show " + item );
+ a->setChecked(false);
+ }
+}
+
+void FITSViewer::toggleCrossHair()
+{
+ getCurrentView()->toggleCrosshair();
+ updateButtonStatus("view_crosshair", "Cross Hairs", getCurrentView()->isCrosshairShown());
+}
+void FITSViewer::toggleEQGrid()
+{
+ getCurrentView()->toggleEQGrid();
+ updateButtonStatus("view_eq_grid", "Equatorial Gridines", getCurrentView()->isEQGridShown());
+}
void FITSViewer::toggleStars()
{
-
-
if (markStars)
{
markStars = false;
diff --git a/kstars/fitsviewer/fitsviewer.h b/kstars/fitsviewer/fitsviewer.h
index bc67315..31e068b 100644
--- a/kstars/fitsviewer/fitsviewer.h
+++ b/kstars/fitsviewer/fitsviewer.h
@@ -104,11 +104,14 @@ public slots:
void ZoomIn();
void ZoomOut();
void ZoomDefault();
+ void ZoomToFit();
void updateAction(const QString &name, bool enable);
void updateTabStatus(bool clean);
int saveUnsaved(int index);
void closeTab(int index);
void toggleStars();
+ void toggleCrossHair();
+ void toggleEQGrid();
void applyFilter(int ftype);
void rotateCW();
void rotateCCW();
@@ -129,6 +132,7 @@ private:
bool markStars;
QMap<int, FITSTab*> fitsMap;
QUrl lastURL;
+ void updateButtonStatus(QString action, QString item, bool showing);
signals:
void trackingStarSelected(int x, int y);