summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-08-21 08:01:45 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-08-21 08:01:45 (GMT)
commita520f0eca43caa9ffbe06271d2f063cd8bcc6486 (patch)
treef43c2969947d6282db349c07dbf3aa3a83ff8c88
parent6c9ddf1bf51053b3ed38e10b218683bf84212ea2 (diff)
Added support for FOV symbols. Solved the bug with incorrect display of EllipseNode
-rw-r--r--kstars/CMakeLists.txt6
-rw-r--r--kstars/auxiliary/fov.cpp2
-rw-r--r--kstars/kstarslite.cpp22
-rw-r--r--kstars/kstarslite.h6
-rw-r--r--kstars/kstarslite/qml/CMakeLists.txt1
-rw-r--r--kstars/kstarslite/qml/dialogs/FindDialog.qml10
-rw-r--r--kstars/kstarslite/qml/main.qml46
-rw-r--r--kstars/kstarslite/qml/modules/KSListView.qml34
-rw-r--r--kstars/kstarslite/qml/modules/SkyMapLiteWrapper.qml2
-rw-r--r--kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml2
-rw-r--r--kstars/kstarslite/qml/modules/menus/ContextMenu.qml10
-rw-r--r--kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml18
-rw-r--r--kstars/kstarslite/qml/modules/popups/FOVPopup.qml28
-rw-r--r--kstars/kstarslite/qml/modules/popups/ProjectionsPopup.qml7
-rw-r--r--kstars/kstarslite/skyitems/deepskyitem.cpp1
-rw-r--r--kstars/kstarslite/skyitems/fovitem.cpp97
-rw-r--r--kstars/kstarslite/skyitems/fovitem.h46
-rw-r--r--kstars/kstarslite/skyitems/rootnode.cpp6
-rw-r--r--kstars/kstarslite/skyitems/rootnode.h4
-rw-r--r--kstars/kstarslite/skyitems/skynodes/fovsymbolnode.cpp248
-rw-r--r--kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h130
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp2
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp36
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/rectnode.cpp56
-rw-r--r--kstars/kstarslite/skyitems/skynodes/nodes/rectnode.h64
-rw-r--r--kstars/kstarsliteinit.cpp2
-rw-r--r--kstars/projections/projector.h2
-rw-r--r--kstars/skymaplite.cpp290
-rw-r--r--kstars/skymaplite.h45
-rw-r--r--kstars/skymapliteevents.cpp4
30 files changed, 893 insertions, 334 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index a5f96f9..ba66220 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -516,7 +516,6 @@ set(kstars_projection_SRCS
set(kstars_extra_SRCS
auxiliary/colorscheme.cpp
auxiliary/dms.cpp
- auxiliary/fov.cpp
auxiliary/geolocation.cpp
auxiliary/ksfilereader.cpp
auxiliary/ksuserdb.cpp
@@ -541,6 +540,7 @@ set(kstars_extra_SRCS
if(NOT BUILD_KSTARS_LITE)
LIST(APPEND kstars_extra_SRCS
auxiliary/imageviewer.cpp
+ auxiliary/fov.cpp
auxiliary/thumbnailpicker.cpp
auxiliary/thumbnaileditor.cpp
auxiliary/imageexporter.cpp
@@ -604,6 +604,7 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/constellationartitem.cpp
kstarslite/skyitems/satellitesitem.cpp
kstarslite/skyitems/supernovaeitem.cpp
+ kstarslite/skyitems/fovitem.cpp
#Line
kstarslite/skyitems/lines/linesitem.cpp
kstarslite/skyitems/lines/equatoritem.cpp
@@ -625,11 +626,13 @@ if(BUILD_KSTARS_LITE)
kstarslite/skyitems/skynodes/satellitenode.cpp
kstarslite/skyitems/skynodes/supernovanode.cpp
kstarslite/skyitems/skynodes/trixelnode.cpp
+ kstarslite/skyitems/skynodes/fovsymbolnode.cpp
#Nodes
kstarslite/skyitems/skynodes/nodes/pointnode.cpp
kstarslite/skyitems/skynodes/nodes/polynode.cpp
kstarslite/skyitems/skynodes/nodes/linenode.cpp
kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
+ kstarslite/skyitems/skynodes/nodes/rectnode.cpp
#Material
#kstarslite/skyitems/skynodes/material/dashedshader.cpp
#libtess
@@ -669,6 +672,7 @@ if(BUILD_KSTARS_LITE)
kstarslite/qml/modules/KSTab.qml
#Popups
kstarslite/qml/modules/popups/ProjectionsPopup.qml
+ kstarslite/qml/modules/popups/FOVPopup.qml
kstarslite/qml/modules/popups/ColorSchemePopup.qml
kstarslite/qml/modules/popups/AddLinkPopup.qml
kstarslite/qml/modules/popups/LinkMenu.qml
diff --git a/kstars/auxiliary/fov.cpp b/kstars/auxiliary/fov.cpp
index 0de887a..411bf66 100644
--- a/kstars/auxiliary/fov.cpp
+++ b/kstars/auxiliary/fov.cpp
@@ -69,7 +69,6 @@ FOV::FOV()
}
void FOV::draw( QPainter &p, float zoomFactor ) {
-#ifndef KSTARS_LITE
p.setPen( QColor( color() ) );
p.setBrush( Qt::NoBrush );
@@ -151,7 +150,6 @@ void FOV::draw( QPainter &p, float zoomFactor ) {
}
p.restore();
-#endif
}
void FOV::draw(QPainter &p, float x, float y)
diff --git a/kstars/kstarslite.cpp b/kstars/kstarslite.cpp
index fb3ac0b..44bcb34 100644
--- a/kstars/kstarslite.cpp
+++ b/kstars/kstarslite.cpp
@@ -94,6 +94,11 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
QString main = QString(QML_IMPORT) + QString("/kstarslite/qml/main.qml");
#endif
+ /*SkyMapLite has to be loaded before KStarsData is initialized because SkyComponents derived classes
+ have to add SkyItems to the SkyMapLite*/
+ m_SkyMapLite = SkyMapLite::createInstance();
+ m_Engine.rootContext()->setContextProperty("SkyMapLite", m_SkyMapLite);
+
m_Engine.load(QUrl(main));
Q_ASSERT_X(m_Engine.rootObjects().size(),"loading root object of main.qml",
"QML file was not loaded. Probably syntax error or failed module import.");
@@ -102,28 +107,16 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
QQuickItem *skyMapLiteWrapper = m_RootObject->findChild<QQuickItem*>("skyMapLiteWrapper");
- /*SkyMapLite has to be loaded before KStarsData is initialized because SkyComponents derived classes
- have to add SkyItems to the SkyMapLite*/
- m_SkyMapLite = SkyMapLite::createInstance(skyMapLiteWrapper);
-
+ m_SkyMapLite->initialize(skyMapLiteWrapper);
m_detailDialogLite->initialize();
- m_Engine.rootContext()->setContextProperty("SkyMapLite", m_SkyMapLite);
m_imgProvider = new ImageProvider;
m_Engine.addImageProvider(QLatin1String("images"), m_imgProvider);
- // Whenever the wrapper's(parent) dimensions changed, change SkyMapLite too
- connect(skyMapLiteWrapper, &QQuickItem::widthChanged, m_SkyMapLite, &SkyMapLite::resizeItem);
- connect(skyMapLiteWrapper, &QQuickItem::heightChanged, m_SkyMapLite, &SkyMapLite::resizeItem);
-
- m_SkyMapLite->resizeItem(); /* Set initial size pf SkyMapLite. Without it on Android SkyMapLite is
- not displayed until screen orientation is not changed */
-
- //QQuickWindow *mainWindow = m_RootObject->findChild<QQuickWindow*>("window");
QQuickWindow *mainWindow = static_cast<QQuickWindow *>(m_Engine.rootObjects()[0]);
QSurfaceFormat format = mainWindow->format();
- format.setSamples(16);
+ format.setSamples(4);
format.setSwapBehavior(QSurfaceFormat::TripleBuffer);
mainWindow->setFormat(format);
@@ -363,7 +356,6 @@ void KStarsLite::setProjection(uint proj) {
Options::setProjection(proj);
//We update SkyMapLite 2 times because of the bug in Projector::updateClipPoly()
SkyMapLite::Instance()->forceUpdate();
- SkyMapLite::Instance()->forceUpdate();
}
QColor KStarsLite::getColor(QString schemeColor) {
diff --git a/kstars/kstarslite.h b/kstars/kstarslite.h
index 60db35f..476d1cf 100644
--- a/kstars/kstarslite.h
+++ b/kstars/kstarslite.h
@@ -121,11 +121,13 @@ public:
Satellites,
Supernovae
};
+
Q_ENUMS(ObjectsToToggle)
/**
* @short setProjection calls Options::setProjection(proj) and updates SkyMapLite
*/
- //Having projection as uint is not good but it will go away once KConfig is fixed
+ /*Having projection as uint is not good but it will go away once KConfig is fixed
+ The reason for this is that you can't use Enums of another in class in Q_INVOKABLE function*/
Q_INVOKABLE void setProjection(uint proj);
Q_INVOKABLE QColor getColor(QString schemeColor);
@@ -188,13 +190,11 @@ private:
/** Initialize focus position */
void initFocus();
-
QQmlApplicationEngine m_Engine;
SkyMapLite *m_SkyMapLite;
QPalette OriginalPalette, DarkPalette;
QObject *m_RootObject;
- //QQuickItem *m_SkyMapLiteWrapper;
bool StartClockRunning;
KStarsData *m_KStarsData;
diff --git a/kstars/kstarslite/qml/CMakeLists.txt b/kstars/kstarslite/qml/CMakeLists.txt
index 40d1753..37959f6 100644
--- a/kstars/kstarslite/qml/CMakeLists.txt
+++ b/kstars/kstarslite/qml/CMakeLists.txt
@@ -22,6 +22,7 @@ install( FILES dialogs/FindDialog.qml
install( FILES modules/popups/ColorSchemePopup.qml
modules/popups/ProjectionsPopup.qml
+ modules/popups/FOVPopup.qml
modules/popups/AddLinkPopup.qml
modules/popups/LinkMenu.qml
DESTINATION ${KDE_INSTALL_DATADIR}/kstars/kstarslite/qml/modules/popups)
diff --git a/kstars/kstarslite/qml/dialogs/FindDialog.qml b/kstars/kstarslite/qml/dialogs/FindDialog.qml
index bb207da..fee39f5 100644
--- a/kstars/kstarslite/qml/dialogs/FindDialog.qml
+++ b/kstars/kstarslite/qml/dialogs/FindDialog.qml
@@ -62,18 +62,16 @@ KSPage {
model: FindDialogLite.filterModel
Layout.fillWidth: true
- //Init list with objects when they are loaded
+ //Init list with objects when everything is loaded
Connections {
target: window
- onLoadedChanged: {
- if(loaded) {
- FindDialogLite.filterByType(typeChoose.currentIndex)
- }
+ onLoaded: {
+ if(isLoaded) FindDialogLite.filterByType(typeChoose.currentIndex)
}
}
onCurrentIndexChanged: {
- if(loaded) FindDialogLite.filterByType(currentIndex)
+ if(isLoaded) FindDialogLite.filterByType(currentIndex)
}
}
}
diff --git a/kstars/kstarslite/qml/main.qml b/kstars/kstarslite/qml/main.qml
index 7455582..37f4623 100644
--- a/kstars/kstarslite/qml/main.qml
+++ b/kstars/kstarslite/qml/main.qml
@@ -22,11 +22,16 @@ ApplicationWindow {
width: Window.Screen.desktopAvailableWidth
height: Window.Screen.desktopAvailableHeight
visible: true
+
+ //Application properties
+ property bool isLoaded: false
property bool isPortrait: width < height ? true: false
property bool isSkyMapVisible: stackView.currentItem == initPage
+ signal loaded();
- //Application properties
- property bool loaded: false
+ onIsLoadedChanged: {
+ if(isLoaded) loaded()
+ }
header: ToolBar {
id: toolBar
@@ -100,12 +105,12 @@ ApplicationWindow {
z:1
anchors.fill:parent
onTimeout: {
- loaded = true
+ isLoaded = true
}
}
StackView {
- visible: loaded
+ visible: isLoaded
id: stackView
anchors.fill: parent
initialItem: initPage
@@ -167,6 +172,12 @@ ApplicationWindow {
y: (window.height - height)/2
}
+ FOVPopup {
+ id: fovPopup
+ x: (window.width - width)/2
+ y: (window.height - height)/2
+ }
+
//Menus
ContextMenu {
id: contextMenu
@@ -192,7 +203,7 @@ ApplicationWindow {
width: Math.min(window.width, window.height) / 4 * 2
height: window.height
//Disable drawer while loading
- dragMargin: loaded ? Qt.styleHints.startDragDistance : -Qt.styleHints.startDragDistance
+ dragMargin: isLoaded ? Qt.styleHints.startDragDistance : -Qt.styleHints.startDragDistance
onOpened: {
contextDrawer.close()
@@ -212,7 +223,6 @@ ApplicationWindow {
ListView {
id: pagesList
- currentIndex: -1
anchors {
left: parent.left
top: drawerBanner.bottom
@@ -233,7 +243,6 @@ ApplicationWindow {
width: parent.width
text: model.objID.title
- highlighted: ListView.isCurrentItem
onClicked: {
if (pagesList.currentIndex != index) {
pagesList.currentIndex = index
@@ -248,7 +257,6 @@ ApplicationWindow {
}
}
globalDrawer.close()
- pagesList.currentIndex = -1
}
}
}
@@ -273,7 +281,8 @@ ApplicationWindow {
width: Math.min(window.width, window.height) / 4 * 2
height: window.height
//Disable drawer while loading and if SkyMapLite is not visible
- dragMargin: isSkyMapVisible && loaded ? Qt.styleHints.startDragDistance : -Qt.styleHints.startDragDistance
+ dragMargin: isSkyMapVisible && isLoaded ? Qt.styleHints.startDragDistance : -Qt.styleHints.startDragDistance
+
onOpened: {
globalDrawer.close()
}
@@ -294,7 +303,6 @@ ApplicationWindow {
ListView {
id: contextList
- currentIndex: -1
anchors {
left: parent.left
top: contextTitle.bottom
@@ -317,21 +325,20 @@ ApplicationWindow {
width: parent.width
text: model.title
- highlighted: ListView.isCurrentItem
onClicked: {
if(model.type == "popup") {
objID.open()
}
contextDrawer.close()
- contextList.currentIndex = -1
}
}
property ListModel drawerModel : ListModel {
//Trick to enable storing of object ids
Component.onCompleted: {
- append({title: "Projection systems", objID: projPopup, type: "popup"});
- append({title: "Color Schemes", objID: colorSchemePopup, type: "popup"});
+ append({title: xi18n("Projection systems"), objID: projPopup, type: "popup"});
+ append({title: xi18n("Color Schemes"), objID: colorSchemePopup, type: "popup"});
+ append({title: xi18n("FOV Symbols"), objID: fovPopup, type: "popup"});
}
}
@@ -347,8 +354,6 @@ ApplicationWindow {
RowLayout {
id: row
- spacing: 5
- Layout.fillWidth: true
anchors {
leftMargin: 10
left: parent.left
@@ -358,8 +363,8 @@ ApplicationWindow {
Rectangle {
anchors{
- verticalCenter: parent.verticalCenter
left: parent.left
+ bottom: smallestMag.bottom
}
width: 24
@@ -370,7 +375,8 @@ ApplicationWindow {
Rectangle {
anchors{
- centerIn: parent
+ horizontalCenter: parent.horizontalCenter
+ bottom: smallestMag.bottom
}
width: 16
@@ -380,9 +386,11 @@ ApplicationWindow {
}
Rectangle {
+ id: smallestMag
+
anchors {
- verticalCenter: parent.verticalCenter
right: parent.right
+ verticalCenter: parent.bottom
}
width: 8
diff --git a/kstars/kstarslite/qml/modules/KSListView.qml b/kstars/kstarslite/qml/modules/KSListView.qml
index 6e2ed5a..911c191 100644
--- a/kstars/kstarslite/qml/modules/KSListView.qml
+++ b/kstars/kstarslite/qml/modules/KSListView.qml
@@ -7,28 +7,24 @@ ListView {
id: listView
clip: true
property bool checkCurrent: false
+ property bool checkable: false
+ property int maxWidth: 0
+ property bool modelIsChanged: false
+ implicitWidth: maxWidth
+ //To skip the case when contentItem.height equals to 99000+
+ implicitHeight: contentItem.height >= window.height ? window.height : contentItem.height
onCountChanged: {
- var root = listView.visibleChildren[0]
- if(root) {
- var listViewHeight = 0
- var listViewWidth = 0
-
- // iterate over each delegate item to get their sizes
- // FIX IT: We don't add the height of last child because list becomes longer than we need
- for (var i = 0; i < root.visibleChildren.length - 1; i++) {
- var childWidth = root.visibleChildren[i].textWidth
- if(childWidth > listViewWidth) listViewWidth = childWidth
- listViewHeight += root.visibleChildren[i].height
- }
- listView.implicitWidth = listViewWidth
- listView.implicitHeight = listViewHeight
+ for(var child in listView.contentItem.children) {
+ var childWidth = listView.contentItem.children[child].textWidth
+ maxWidth = maxWidth > childWidth ? maxWidth : childWidth
}
}
ScrollIndicator.vertical: ScrollIndicator { }
property string textRole: ""
- signal clicked(var index)
+
+ signal clicked(var index, var checked)
property bool modelIsArray: false
onModelChanged: {
@@ -38,8 +34,9 @@ ListView {
delegate: Rectangle {
id: delegateRect
width: parent.width
- height: objName.height + 30
+ height: objName.contentHeight + 30
property int textWidth: objRow.width + objRow.anchors.leftMargin*2
+ property bool checked: false
border {
color: "#becad5"
@@ -113,7 +110,8 @@ ListView {
onClicked: {
listView.currentIndex = model.index
- listView.clicked(model.index)
+ if(checkable) delegateRect.checked = !delegateRect.checked
+ listView.clicked(model.index, delegateRect.checked)
}
}
@@ -126,7 +124,7 @@ ListView {
}
Rectangle {
- visible: checkCurrent && listView.currentIndex == model.index
+ visible: (checkCurrent && listView.currentIndex == model.index) || (checkable && delegateRect.checked)
color: "#2173f3"
width: height
height: objName.height/2
diff --git a/kstars/kstarslite/qml/modules/SkyMapLiteWrapper.qml b/kstars/kstarslite/qml/modules/SkyMapLiteWrapper.qml
index 210c150..bc4e6f6 100644
--- a/kstars/kstarslite/qml/modules/SkyMapLiteWrapper.qml
+++ b/kstars/kstarslite/qml/modules/SkyMapLiteWrapper.qml
@@ -5,7 +5,7 @@ import "../constants" 1.0
Item {
id: skyMapLiteItem
anchors.fill: parent
- visible: loaded
+ visible: isLoaded
Rectangle {
id: skyMapLiteWrapper
diff --git a/kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml b/kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml
index eddad5d..1482f17 100644
--- a/kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml
+++ b/kstars/kstarslite/qml/modules/helpers/TopMenuButton.qml
@@ -19,7 +19,7 @@ AbstractButton {
}
onToggledChanged: {
- if(loaded) { //Disable while loading
+ if(isLoaded) { //Disable while loading
if(toggled) {
if(titlePlural) {
notification.showNotification(xi18n("%1 are toggled on", title))
diff --git a/kstars/kstarslite/qml/modules/menus/ContextMenu.qml b/kstars/kstarslite/qml/modules/menus/ContextMenu.qml
index 516f42e..f841fad 100644
--- a/kstars/kstarslite/qml/modules/menus/ContextMenu.qml
+++ b/kstars/kstarslite/qml/modules/menus/ContextMenu.qml
@@ -29,6 +29,8 @@ Menu {
Text {
id: objectName
text: isPoint ? xi18n("Empty Sky") : SkyMapLite.clickedObjectLite.translatedName
+ wrapMode: Text.Wrap
+ width: parent.width
font.pointSize: 12
anchors {
left: parent.left
@@ -57,6 +59,11 @@ Menu {
onTriggered: stackView.push(objectDetails)
}
+ Item {
+ id: hSpacer
+ height: telescopeCol.isTelescope ? 15 : 0
+ }
+
ColumnLayout {
id: telescopeCol
width: parent.width
@@ -72,7 +79,7 @@ Menu {
target: ClientManagerLite
onTelescopeAdded: {
- if(!isTelescope) {
+ if(!telescopeCol.isTelescope) {
telescopeCol.telescope = newTelescope
telescopeName.text = newTelescope.deviceName
}
@@ -86,6 +93,7 @@ Menu {
Text {
id: telescopeName
visible: telescopeCol.isTelescope
+ wrapMode: Text.Wrap
font.pointSize: 12
anchors {
left: parent.left
diff --git a/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml b/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
index 62cc425..afc8c1e 100644
--- a/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
+++ b/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
@@ -29,19 +29,13 @@ Popup {
append({ name: xi18n("Star Chart"), scheme: "cs_chart" });
append({ name: xi18n("Night Vision"), scheme: "cs_night" });
append({ name: xi18n("Moonless Night"), scheme: "cs_moonless-night" });
- }
-
- onCountChanged: {
- colorsList.currentIndex = 2
- }
- }
- Component.onCompleted: {
- //Set current index to current scheme color
- var currentScheme = KStarsData.colorSchemeName()
- for(var i = 0; i < colorsList.model.count; ++i) {
- if(formatColorScheme(colorsList.model.get(i).scheme) == currentScheme) {
- colorsList.currentIndex = 1
+ //Set current index to current scheme color
+ var currentScheme = KStarsData.colorSchemeName()
+ for(var i = 0; i < colorsList.model.count; ++i) {
+ if(formatColorScheme(colorsList.model.get(i).scheme) == currentScheme) {
+ colorsList.currentIndex = i
+ }
}
}
}
diff --git a/kstars/kstarslite/qml/modules/popups/FOVPopup.qml b/kstars/kstarslite/qml/modules/popups/FOVPopup.qml
new file mode 100644
index 0000000..afb7abd
--- /dev/null
+++ b/kstars/kstarslite/qml/modules/popups/FOVPopup.qml
@@ -0,0 +1,28 @@
+import QtQuick.Controls 2.0
+import QtQuick 2.6
+import QtQuick.Layouts 1.1
+import "../../constants" 1.0
+import "../../modules"
+import KStarsLiteEnums 1.0
+
+Popup {
+ id: fovPopup
+ focus: true
+ modal: true
+ width: fovList.implicitWidth
+ height: parent.height > fovList.implicitHeight ? fovList.implicitHeight : parent.height
+
+ KSListView {
+ id: fovList
+ anchors {
+ fill: parent
+ centerIn: parent
+ }
+ checkable: true
+
+ model: SkyMapLite.FOVSymbols
+ onClicked: {
+ SkyMapLite.setFOVVisible(index, checked)
+ }
+ }
+}
diff --git a/kstars/kstarslite/qml/modules/popups/ProjectionsPopup.qml b/kstars/kstarslite/qml/modules/popups/ProjectionsPopup.qml
index 4353c57..ee0a0d6 100644
--- a/kstars/kstarslite/qml/modules/popups/ProjectionsPopup.qml
+++ b/kstars/kstarslite/qml/modules/popups/ProjectionsPopup.qml
@@ -29,6 +29,13 @@ Popup {
projModel.append({ name: xi18n("Equirectangular"), proj: Projection.Equirectangular });
projModel.append({ name: xi18n("Stereographic"), proj: Projection.Stereographic });
projModel.append({ name: xi18n("Gnomonic"), proj: Projection.Gnomonic });
+
+ //Initialize projector
+ for(var i = 0; i < projList.model.count; ++i) {
+ if(projList.model.get(i).proj == SkyMapLite.projType()) {
+ projList.currentIndex = i
+ }
+ }
}
}
diff --git a/kstars/kstarslite/skyitems/deepskyitem.cpp b/kstars/kstarslite/skyitems/deepskyitem.cpp
index ead2257..0e5ebfb 100644
--- a/kstars/kstarslite/skyitems/deepskyitem.cpp
+++ b/kstars/kstarslite/skyitems/deepskyitem.cpp
@@ -94,7 +94,6 @@ DeepSkyItem::DeepSkyItem(DeepSkyComponent *dsoComp, RootNode *rootNode)
QSGNode *symbols = new QSGNode;
for(int c = 0; c < dsoList->size(); ++c) {
-
DeepSkyObject *dso = dsoList->at(c);
trixel->m_nodes.append(QPair<SkyObject *, SkyNode *>(dso, 0));
}
diff --git a/kstars/kstarslite/skyitems/fovitem.cpp b/kstars/kstarslite/skyitems/fovitem.cpp
index b2cd77b..2897eb9 100644
--- a/kstars/kstarslite/skyitems/fovitem.cpp
+++ b/kstars/kstarslite/skyitems/fovitem.cpp
@@ -1,7 +1,7 @@
/** *************************************************************************
- telescopesymbolsitem.cpp - K Desktop Planetarium
+ fovitem.h - K Desktop Planetarium
-------------------
- begin : 17/07/2016
+ begin : 20/08/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -14,71 +14,48 @@
* *
***************************************************************************/
-#include "skynodes/crosshairnode.h"
-#include "indi/clientmanagerlite.h"
-#include "telescopesymbolsitem.h"
-#include "Options.h"
-#include "projections/projector.h"
-#include "kstarslite/skyitems/rootnode.h"
-#include "kstarslite.h"
-
+#include "fovitem.h"
#include "labelsitem.h"
+#include "skynodes/fovsymbolnode.h"
+#include "Options.h"
-TelescopeSymbolsItem::TelescopeSymbolsItem(RootNode *rootNode)
- :SkyItem(LabelsItem::label_t::TELESCOPE_SYMBOL, rootNode)
+FOVItem::FOVItem(RootNode * rootNode)
+ :SkyItem(LabelsItem::label_t::NO_LABEL, rootNode)
{
- m_clientManager = KStarsLite::Instance()->clientManagerLite();
- m_KStarsData = KStarsData::Instance();
-}
-
-void TelescopeSymbolsItem::addTelescope(INDI::BaseDevice *bd) {
- if(!m_telescopes.value(bd)) {
- CrosshairNode *crossHair = new CrosshairNode(bd, rootNode());
- appendChildNode(crossHair);
-
- m_telescopes.insert(bd, crossHair);
- }
+ addSymbol(i18nc("use field-of-view for binoculars", "7x35 Binoculars" ),
+ 558, 558, 0,0,0, CIRCLE,"#AAAAAA");
+ addSymbol(i18nc("use a Telrad field-of-view indicator", "Telrad" ),
+ 30, 30, 0,0,0, BULLSEYE,"#AA0000");
+ addSymbol(i18nc("use 1-degree field-of-view indicator", "One Degree"),
+ 60, 60, 0,0,0, CIRCLE,"#AAAAAA");
+ addSymbol(i18nc("use HST field-of-view indicator", "HST WFPC2"),
+ 2.4, 2.4, 0,0,0, SQUARE,"#AAAAAA");
+ addSymbol(i18nc("use Radiotelescope HPBW", "30m at 1.3cm" ),
+ 1.79, 1.79, 0,0,0, SQUARE,"#AAAAAA");
}
-void TelescopeSymbolsItem::removeTelescope(INDI::BaseDevice *bd) {
- CrosshairNode *crossHair = m_telescopes.value(bd);
- if(crossHair) {
- removeChildNode(crossHair);
- delete crossHair;
- }
- m_telescopes.remove(bd);
+void FOVItem::addSymbol(const QString &name, float a, float b, float xoffset, float yoffset,
+ float rot, FOVItem::Shape shape, const QString &color)
+{
+ SkyMapLite::Instance()->addFOVSymbol(name, false);
+ appendChildNode(new FOVSymbolNode(name, a, b, xoffset, yoffset, rot, shape,color));
}
-void TelescopeSymbolsItem::update() {
- QHash<INDI::BaseDevice *, CrosshairNode *>::iterator i;
- bool deleteAll = !m_clientManager->isConnected();
-
- QColor color = m_KStarsData->colorScheme()->colorNamed("TargetColor" );
-
- bool show = Options::showTargetCrosshair();
- if(!show) {
- hide();
- }
-
- for (i = m_telescopes.begin(); i != m_telescopes.end(); ++i) {
- CrosshairNode *crossHair = i.value();
- INDI::BaseDevice *device = i.key();
- if(crossHair) {
- if(deleteAll || !(device->isConnected())) {
- removeChildNode(crossHair);
- delete crossHair;
- m_telescopes.insert(device, nullptr);
- } else if(show) {
- if(device->isConnected()){
- crossHair->setColor(color);
- crossHair->update();
- } else {
- crossHair->hide();
- }
- }
+void FOVItem::update() {
+ float zoomFactor = Options::zoomFactor();
+ SkyMapLite *map = SkyMapLite::Instance();
+
+ QSGNode *n = firstChild();
+ int index = 0;
+ while(n != 0) {
+ FOVSymbolNode *fov = static_cast<FOVSymbolNode *>(n);
+ if(map->isFOVVisible(index)) {
+ fov->update(zoomFactor);
+ } else {
+ fov->hide();
}
- }
- if(deleteAll) {
- m_telescopes.clear();
+ n = n->nextSibling();
+ index++;
}
}
+
diff --git a/kstars/kstarslite/skyitems/fovitem.h b/kstars/kstarslite/skyitems/fovitem.h
index 1b3f0da..9e660f2 100644
--- a/kstars/kstarslite/skyitems/fovitem.h
+++ b/kstars/kstarslite/skyitems/fovitem.h
@@ -1,7 +1,7 @@
/** *************************************************************************
- telescopesymbolsitem.h - K Desktop Planetarium
+ fovitem.h - K Desktop Planetarium
-------------------
- begin : 17/07/2016
+ begin : 20/08/2016
copyright : (C) 2016 by Artem Fedoskin
email : afedoskin3@gmail.com
***************************************************************************/
@@ -13,45 +13,37 @@
* (at your option) any later version. *
* *
***************************************************************************/
-#ifndef TELESCOPESYMBOLSITEM_H_
-#define TELESCOPESYMBOLSITEM_H_
+#ifndef FOVITEM_H_
+#define FOVITEM_H_
#include "skyitem.h"
-#include "basedevice.h"
-
-class KSAsteroid;
-class SkyObject;
-class RootNode;
-class EllipseNode;
-class LineNode;
-class CrosshairNode;
-class ClientManagerLite;
-
/**
- * @class TelescopeSymbolsItem
- * This class handles telescope symbols in SkyMapLite
+ * @class FOVItem
+ * This class handles FOV symbols in SkyMapLite
*
* @author Artem Fedoskin
* @version 1.0
*/
-class TelescopeSymbolsItem : public SkyItem {
+class FOVItem : public SkyItem {
public:
+ enum Shape { SQUARE,
+ CIRCLE,
+ CROSSHAIRS,
+ BULLSEYE,
+ SOLIDCIRCLE,
+ UNKNOWN };
+
+ FOVItem(RootNode * rootNode);
+
/**
- * @short Constructor
- * @param asteroidsList const reference to list of asteroids
- * @param rootNode parent RootNode that instantiates PlanetsItem
+ * @short Adds symbol to QVariantMap in SkyMap and creates new FOVSymbolNode
*/
- TelescopeSymbolsItem(RootNode *rootNode);
+ void addSymbol(const QString &name, float a, float b, float xoffset, float yoffset,
+ float rot, FOVItem::Shape shape, const QString &color);
virtual void update() override;
- void addTelescope(INDI::BaseDevice *bd);
- void removeTelescope(INDI::BaseDevice *bd);
private:
- QHash<INDI::BaseDevice *, CrosshairNode *> m_telescopes;
- ClientManagerLite *m_clientManager;
- QColor m_color;
- KStarsData *m_KStarsData;
};
#endif
diff --git a/kstars/kstarslite/skyitems/rootnode.cpp b/kstars/kstarslite/skyitems/rootnode.cpp
index 0ace330..56c1851 100644
--- a/kstars/kstarslite/skyitems/rootnode.cpp
+++ b/kstars/kstarslite/skyitems/rootnode.cpp
@@ -40,6 +40,7 @@
#ifdef INDI_FOUND
//Symbols
#include "kstarslite/skyitems/telescopesymbolsitem.h"
+#include "kstarslite/skyitems/fovitem.h"
#endif
#include <QSGFlatColorMaterial>
@@ -89,6 +90,8 @@ RootNode::RootNode()
m_horizonItem = new HorizonItem(m_skyComposite->horizon(), this);
+ m_FOVItem = new FOVItem(this);
+
#ifdef INDI_FOUND
m_telescopeSymbols = new TelescopeSymbolsItem(this);
#endif
@@ -268,9 +271,10 @@ void RootNode::update(bool clearTextures) {
#ifdef INDI_FOUND
m_telescopeSymbols->update();
#endif
-
m_labelsItem->update();
+ m_FOVItem->update();
+
if(clearTextures) {
//Delete old textures
if(m_oldTextureCache.length()) {
diff --git a/kstars/kstarslite/skyitems/rootnode.h b/kstars/kstarslite/skyitems/rootnode.h
index 2edc284..f8313de 100644
--- a/kstars/kstarslite/skyitems/rootnode.h
+++ b/kstars/kstarslite/skyitems/rootnode.h
@@ -42,6 +42,8 @@ class MilkyWayItem;
class SkyMapComposite;
class SolarSystemComposite;
+
+class FOVItem;
#ifdef INDI_FOUND
class TelescopeSymbolsItem;
#endif
@@ -127,6 +129,8 @@ private:
SkyMapComposite *m_skyComposite;
SolarSystemComposite *m_solarSystem;
QSGGeometryNode *m_visualizeClipping;
+
+ FOVItem *m_FOVItem;
#ifdef INDI_FOUND
TelescopeSymbolsItem *m_telescopeSymbols;
#endif
diff --git a/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.cpp b/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.cpp
new file mode 100644
index 0000000..1afd8cc
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.cpp
@@ -0,0 +1,248 @@
+/** *************************************************************************
+ fovsymbolnode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 20/08/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "fovsymbolnode.h"
+
+#include "nodes/rectnode.h"
+#include "nodes/ellipsenode.h"
+
+#include <QSGFlatColorMaterial>
+
+FOVSymbolNode::FOVSymbolNode(const QString &name, float a, float b, float xoffset, float yoffset, float rot, FOVItem::Shape shape, const QString &color)
+ :m_symbol(nullptr)
+{
+ m_name = name;
+ m_sizeX = a;
+ m_sizeY = (b < 0.0) ? a : b;
+
+ m_offsetX = xoffset;
+ m_offsetY = yoffset;
+ m_rotation = rot;
+ m_color = color;
+ m_northPA = 0;
+ m_center.setRA(0);
+ m_center.setDec(0);
+
+ switch(shape)
+ {
+ case FOVItem::SQUARE:
+ m_symbol = new SquareFOV();
+ break;
+ case FOVItem::CIRCLE:
+ m_symbol = new CircleFOV();
+ break;
+ case FOVItem::CROSSHAIRS:
+ m_symbol = new CrosshairFOV();
+ break;
+ case FOVItem::BULLSEYE:
+ m_symbol = new BullsEyeFOV();
+ break;
+ case FOVItem::SOLIDCIRCLE: {
+ m_symbol = new SolidCircleFOV();
+ break;
+ }
+ default: ;
+ }
+
+ if(m_symbol) addChildNode(m_symbol);
+}
+
+void FOVSymbolNode::update(float zoomFactor) {
+ show();
+ float pixelSizeX = m_sizeX * zoomFactor / 57.3 / 60.0;
+ float pixelSizeY = m_sizeY * zoomFactor / 57.3 / 60.0;
+
+ float offsetXPixelSize = m_offsetX * zoomFactor / 57.3 / 60.0;
+ float offsetYPixelSize = m_offsetY * zoomFactor / 57.3 / 60.0;
+ SkyMapLite *map = SkyMapLite::Instance();
+
+ QMatrix4x4 newMatrix;
+
+ if (m_center.ra().Degrees() > 0)
+ {
+ m_center.EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat());
+ QPointF skypoint_center = map->projector()->toScreen(&m_center);
+ newMatrix.translate(skypoint_center.toPoint().x(), skypoint_center.toPoint().y());
+ } else {
+ QPoint center(map->width()/2, map->height()/2);
+ newMatrix.translate(center.x(), center.y());
+ }
+
+ newMatrix.translate(offsetXPixelSize, offsetYPixelSize);
+ newMatrix.rotate(m_rotation+m_northPA,0, 0, 1);
+
+ m_symbol->setMatrix(newMatrix);
+
+ m_symbol->updateSymbol(m_color, pixelSizeX, pixelSizeY);
+}
+
+FOVSymbolBase::FOVSymbolBase(FOVItem::Shape shape)
+ :m_shape(shape) //Will be changed by the subclass
+{
+
+}
+
+SquareFOV::SquareFOV()
+ :FOVSymbolBase(FOVItem::SQUARE)
+{
+ rect1 = new RectNode();
+ appendChildNode(rect1);
+
+ rect2 = new RectNode();
+ appendChildNode(rect2);
+
+ lines = new QSGGeometryNode;
+ appendChildNode(lines);
+
+ lines->setGeometry(new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0));
+ lines->setOpaqueMaterial(new QSGFlatColorMaterial);
+ lines->setFlag(QSGNode::OwnsGeometry);
+ lines->setFlag(QSGNode::OwnsMaterial);
+ lines->geometry()->allocate(6);
+ lines->geometry()->setDrawingMode(GL_LINES);
+}
+
+void SquareFOV::updateSymbol(QColor color, float pixelSizeX, float pixelSizeY ) {
+ QPoint center(0,0);
+
+ /*if (m_imageDisplay)
+ {
+ //QTransform imageT;
+ //imageT.rotate(m_rotation+m_northPA);
+ //p.drawImage(targetRect, m_image.transformed(imageT));
+ p.drawImage(targetRect, m_image);
+ }*/
+
+ rect1->setRect(center.x() - pixelSizeX/2, center.y() - pixelSizeY/2, pixelSizeX, pixelSizeY);
+ rect1->setColor(color);
+
+ rect2->setRect(center.x() , center.y() - (3 * pixelSizeY/5), pixelSizeX/40, pixelSizeX/10);
+ rect2->setColor(color);
+
+ QSGFlatColorMaterial *material = static_cast<QSGFlatColorMaterial *>(lines->opaqueMaterial());
+ if(material->color() != color) {
+ material->setColor(color);
+ lines->markDirty(QSGNode::DirtyMaterial);
+ }
+
+ QSGGeometry::Point2D * vertex = lines->geometry()->vertexDataAsPoint2D();
+ vertex[0].set(center.x() - pixelSizeX/30, center.y() - (3 * pixelSizeY/5));
+ vertex[1].set(center.x() + pixelSizeX/20, center.y() - (3 * pixelSizeY/5));
+
+ vertex[2].set(center.x() - pixelSizeX/30, center.y() - (3 * pixelSizeY/5));
+ vertex[3].set(center.x() + pixelSizeX/70, center.y() - (0.7 * pixelSizeY));
+
+ vertex[4].set(center.x() + pixelSizeX/20, center.y() - (3 * pixelSizeY/5));
+ vertex[5].set(center.x() + pixelSizeX/70, center.y() - (0.7 * pixelSizeY));
+
+ lines->markDirty(QSGNode::DirtyGeometry);
+}
+
+CircleFOV::CircleFOV()
+ :FOVSymbolBase(FOVItem::CIRCLE)
+{
+ el = new EllipseNode();
+ appendChildNode(el);
+}
+
+void CircleFOV::updateSymbol(QColor color, float pixelSizeX, float pixelSizeY ) {
+ el->setColor(color);
+ el->updateGeometry(0,0, pixelSizeX/2, pixelSizeY/2,false);
+}
+
+CrosshairFOV::CrosshairFOV()
+ :FOVSymbolBase(FOVItem::CROSSHAIRS)
+{
+ lines = new QSGGeometryNode;
+ appendChildNode(lines);
+
+ lines->setGeometry(new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0));
+ lines->setOpaqueMaterial(new QSGFlatColorMaterial);
+ lines->setFlag(QSGNode::OwnsGeometry);
+ lines->setFlag(QSGNode::OwnsMaterial);
+ lines->geometry()->allocate(8);
+ lines->geometry()->setDrawingMode(GL_LINES);
+
+ el1 = new EllipseNode;
+ appendChildNode(el1);
+
+ el2 = new EllipseNode;
+ appendChildNode(el2);
+}
+
+void CrosshairFOV::updateSymbol( QColor color, float pixelSizeX, float pixelSizeY ) {
+ QPoint center(0,0);
+
+ QSGGeometry::Point2D * vertex = lines->geometry()->vertexDataAsPoint2D();
+ vertex[0].set(center.x() + 0.5*pixelSizeX, center.y());
+ vertex[1].set(center.x() + 1.5*pixelSizeX, center.y());
+
+ vertex[2].set(center.x() - 0.5*pixelSizeX, center.y());
+ vertex[3].set(center.x() - 1.5*pixelSizeX, center.y());
+
+ vertex[4].set(center.x(), center.y() + 0.5*pixelSizeY);
+ vertex[5].set(center.x(), center.y() + 1.5*pixelSizeY);
+
+ vertex[6].set(center.x(), center.y() - 0.5*pixelSizeY);
+ vertex[7].set(center.x(), center.y() - 1.5*pixelSizeY);
+
+ lines->markDirty(QSGNode::DirtyGeometry);
+
+ //Draw circles at 0.5 & 1 degrees
+ el1->setColor(color);
+ el1->updateGeometry(center.x(), center.y(), 0.5 * pixelSizeX, 0.5 * pixelSizeY, false);
+
+ el2->setColor(color);
+ el1->updateGeometry(center.x(), center.y(), pixelSizeX, pixelSizeY, false);
+}
+
+BullsEyeFOV::BullsEyeFOV()
+ :FOVSymbolBase(FOVItem::BULLSEYE)
+{
+ el1 = new EllipseNode;
+ appendChildNode(el1);
+
+ el2 = new EllipseNode;
+ appendChildNode(el2);
+
+ el3 = new EllipseNode;
+ appendChildNode(el3);
+}
+
+void BullsEyeFOV::updateSymbol( QColor color, float pixelSizeX, float pixelSizeY ) {
+ el1->setColor(color);
+ el1->updateGeometry(0, 0, 0.5 * pixelSizeX, 0.5 * pixelSizeY, false);
+
+ el2->setColor(color);
+ el2->updateGeometry(0, 0, 2.0 * pixelSizeX, 2.0 * pixelSizeY, false);
+
+ el3->setColor(color);
+ el3->updateGeometry(0, 0, 4.0 * pixelSizeX, 4.0 * pixelSizeY, false);
+}
+
+SolidCircleFOV::SolidCircleFOV()
+ :FOVSymbolBase(FOVItem::SOLIDCIRCLE)
+{
+ el = new EllipseNode;
+ appendChildNode(el);
+}
+
+void SolidCircleFOV::updateSymbol( QColor color, float pixelSizeX, float pixelSizeY ) {
+ QColor colorAlpha = color;
+ colorAlpha.setAlpha(127);
+ el->setColor(colorAlpha);
+ el->updateGeometry( 0, 0, pixelSizeX/2, pixelSizeY/2, false );
+}
+
diff --git a/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h b/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h
new file mode 100644
index 0000000..e8d33b9
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/fovsymbolnode.h
@@ -0,0 +1,130 @@
+/** *************************************************************************
+ fovsymbolnode.h - K Desktop Planetarium
+ -------------------
+ begin : 20/08/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef FOVSYMBOLNODE_H_
+#define FOVSYMBOLNODE_H_
+
+#include <QSGTransformNode>
+#include <QSGSimpleRectNode>
+#include "../fovitem.h"
+
+class EllipseNode;
+class RectNode;
+
+/** @class FOVSymbolBase
+ *
+ * FOVSymbolBase is a virtual class that should be subclassed by every type of FOV symbol. It is derived
+ * from QSGTransformNode to provide transform matrix for updating coordinates of FOV symbol.
+ *
+ *@short A QSGTransformNode derived base class of every type of FOV symbol
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class FOVSymbolBase : public QSGTransformNode {
+public:
+ /**
+ * @brief updateSymbol updates geometry (position, size) of elements of this FOV symbol
+ */
+ virtual void updateSymbol(QColor color, float pixelSizeX, float pixelSizeY ) =0;
+ FOVItem::Shape type() { return m_shape; }
+protected:
+ /**
+ * @param shape of the symbol. Each subclass sets its own type. Returned in type()
+ */
+ FOVSymbolBase(FOVItem::Shape shape);
+/* QImage m_image; //Not supported yet
+ bool m_imageDisplay;*/
+ FOVItem::Shape m_shape;
+};
+
+class SquareFOV : public FOVSymbolBase {
+public:
+ SquareFOV();
+ virtual void updateSymbol( QColor color, float pixelSizeX, float pixelSizeY );
+private:
+ RectNode *rect1;
+ RectNode *rect2;
+ QSGGeometryNode *lines;
+};
+class CircleFOV : public FOVSymbolBase {
+public:
+ CircleFOV();
+ virtual void updateSymbol( QColor color, float pixelSizeX, float pixelSizeY );
+private:
+ EllipseNode *el;
+};
+
+class CrosshairFOV : public FOVSymbolBase {
+public:
+ CrosshairFOV();
+ virtual void updateSymbol( QColor color, float pixelSizeX, float pixelSizeY );
+private:
+ QSGGeometryNode *lines;
+ EllipseNode *el1;
+ EllipseNode *el2;
+};
+
+class BullsEyeFOV : public FOVSymbolBase {
+public:
+ BullsEyeFOV();
+ virtual void updateSymbol( QColor color, float pixelSizeX, float pixelSizeY );
+private:
+ EllipseNode *el1;
+ EllipseNode *el2;
+ EllipseNode *el3;
+};
+
+class SolidCircleFOV : public FOVSymbolBase {
+public:
+ SolidCircleFOV();
+ virtual void updateSymbol( QColor color, float pixelSizeX, float pixelSizeY );
+private:
+ EllipseNode *el;
+};
+
+/** @class FOVSymbolNode
+ *
+ * A SkyNode derived class used for displaying FOV symbol. FOVSymbolNade handles creation of FOVSymbolBase
+ * and its update.
+ *
+ *@short A SkyNode derived class that is used for displaying FOV symbol
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+
+class FOVSymbolNode : public SkyNode {
+public:
+ FOVSymbolNode(const QString &name, float a, float b, float xoffset, float yoffset, float rot, FOVItem::Shape shape = FOVItem::SQUARE, const QString &color = "#FFFFFF");
+ /**
+ * @brief updates
+ * @param zoomFactor
+ */
+ void update(float zoomFactor);
+
+ QString getName() { return m_name; }
+private:
+ QString m_name, m_color;
+ float m_sizeX, m_sizeY;
+ float m_offsetX, m_offsetY;
+ float m_rotation;
+ float m_northPA;
+ SkyPoint m_center;
+
+ FOVSymbolBase *m_symbol;
+};
+
+#endif
+
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
index 5f67323..bf01d60 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/ellipsenode.cpp
@@ -23,7 +23,7 @@
EllipseNode::EllipseNode(QColor color, int width)
:m_geometryNode(new QSGGeometryNode), m_geometry(0),
- m_material(new QSGFlatColorMaterial), m_width(0), m_height(0), m_x(-1),
+ m_material(new QSGFlatColorMaterial), m_width(-1), m_height(-1), m_x(-1),
m_y(-1), m_fillMode(false)
{
m_geometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0);
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
index dab6d08..d648087 100644
--- a/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/linenode.cpp
@@ -88,8 +88,6 @@ void LineNode::updateGeometry() {
/*In regular KStars we first call checkVisibility and then toScreen
Here we minimize the number of calls to toScreen by proceeding only if
checkVisibility is true*/
- //bool vis = false;
- //if( vis ) {
oThis = m_proj->toScreen( pThis, true, &isVisible );
// & with the result of checkVisibility to clip away things below horizon
isVisible &= m_proj->checkVisibility(pThis);
@@ -99,50 +97,16 @@ void LineNode::updateGeometry() {
}
if ( !doSkip ) {
- //if ( (isVisible && isVisibleLast) ) {
if ( (isVisible ) ) {
newPoints.append(oLast);
newPoints.append(oThis);
- //if ( label )
- // label->updateLabelCandidates( oThis.x(), oThis.y(), list, j );
}
}
oLast = oThis;
isVisibleLast = isVisible;
-// }
}
- /*SkyList *points = list->points();
- bool isVisible, isVisibleLast;
-
- QPointF oLast = m_proj->toScreen( points->first(), true, &isVisibleLast );
- // & with the result of checkVisibility to clip away things below horizon
- isVisibleLast &= m_proj->checkVisibility( points->first() );
- QPointF oThis, oThis2;
-
- for ( int j = 1 ; j < points->size() ; j++ ) {
- SkyPoint* pThis = points->at( j );
- oThis2 = oThis = m_proj->toScreen( pThis, true, &isVisible );
- // & with the result of checkVisibility to clip away things below horizon
- isVisible &= m_proj->checkVisibility(pThis);
- bool doSkip = false;
- if( skipList ) {
- doSkip = skipList->skip(j);
- }
-
- if ( !doSkip ) {
- if ( isVisible && isVisibleLast ) {
- drawLine( oLast, oThis );
- if ( label )
- label->updateLabelCandidates( oThis.x(), oThis.y(), list, j );
- }
- }
-
- oLast = oThis2;
- isVisibleLast = isVisible;
- }*/
-
int size = newPoints.size();
m_geometry->allocate(size);
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/rectnode.cpp b/kstars/kstarslite/skyitems/skynodes/nodes/rectnode.cpp
new file mode 100644
index 0000000..6ac4368
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/rectnode.cpp
@@ -0,0 +1,56 @@
+/** *************************************************************************
+ rectnode.cpp - K Desktop Planetarium
+ -------------------
+ begin : 20/08/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "rectnode.h"
+#include <QSGGeometryNode>
+#include <QSGFlatColorMaterial>
+
+RectNode::RectNode(bool filled, QColor color) {
+ m_geometry = new QSGGeometry (QSGGeometry::defaultAttributes_Point2D(),0);
+ m_geometry->allocate(4);
+ setGeometry(m_geometry);
+ setFlag(QSGNode::OwnsGeometry);
+
+ m_material = new QSGFlatColorMaterial;
+ setMaterial(m_material);
+ setFlag(QSGNode::OwnsMaterial);
+
+ setFilled(filled);
+}
+
+void RectNode::setRect(int x, int y, int w, int h) {
+ QSGGeometry::Point2D * vertex = m_geometry->vertexDataAsPoint2D();
+ vertex[0].set(x,y);
+ vertex[1].set(x + w,y);
+ vertex[2].set(x + w,y + h);
+ vertex[3].set(x,y + h);
+ markDirty(QSGNode::DirtyGeometry);
+}
+
+void RectNode::setColor(QColor color) {
+ if(m_material->color() != color) {
+ m_material->setColor(color);
+ markDirty(QSGNode::DirtyMaterial);
+ }
+}
+
+void RectNode::setFilled(bool filled) {
+ m_filled = filled;
+ if(filled) {
+ m_geometry->setDrawingMode(GL_TRIANGLE_FAN);
+ } else {
+ m_geometry->setDrawingMode(GL_LINE_LOOP);
+ }
+}
diff --git a/kstars/kstarslite/skyitems/skynodes/nodes/rectnode.h b/kstars/kstarslite/skyitems/skynodes/nodes/rectnode.h
new file mode 100644
index 0000000..161edf4
--- /dev/null
+++ b/kstars/kstarslite/skyitems/skynodes/nodes/rectnode.h
@@ -0,0 +1,64 @@
+/** *************************************************************************
+ rectnode.h - K Desktop Planetarium
+ -------------------
+ begin : 20/08/2016
+ copyright : (C) 2016 by Artem Fedoskin
+ email : afedoskin3@gmail.com
+ ***************************************************************************/
+/** *************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef RECTNODE_H_
+#define RECTNODE_H_
+
+/** @class RectNode
+ *
+ * A QSGGeometryNode derived node that encapsulates everything needed for drawing both filled and
+ * non-filled rectangles
+ *
+ *@short QSGGeometryNode derived class that draws filled and non-filled rectangles
+ *@author Artem Fedoskin
+ *@version 1.0
+ */
+#include <QColor>
+#include <QSGGeometryNode>
+
+class QSGGeometryNode;
+class QSGGeometry;
+class QSGFlatColorMaterial;
+
+class RectNode : public QSGGeometryNode {
+public:
+ RectNode(bool filled = false, QColor color = "#FFFFFF");
+ /**
+ * @brief setRect sets rectangle to display
+ * @param x - x coordinate of left-top corner
+ * @param y - y coordinate of left-top corner
+ * @param w - width
+ * @param h - height
+ */
+ void setRect(int x, int y, int w, int h);
+ /**
+ * @brief setColor sets the color of rectangle
+ */
+ void setColor(QColor color);
+ /**
+ * @brief setFilled sets whether the rectangle should be filled or no
+ * @param filled true to be filled, false otherwise
+ */
+ void setFilled(bool filled);
+
+private:
+ QSGGeometryNode *m_geometryNode;
+ QSGGeometry *m_geometry;
+ QSGFlatColorMaterial *m_material;
+ bool m_filled;
+};
+
+#endif
+
diff --git a/kstars/kstarsliteinit.cpp b/kstars/kstarsliteinit.cpp
index a910a60..8ed8826 100644
--- a/kstars/kstarsliteinit.cpp
+++ b/kstars/kstarsliteinit.cpp
@@ -22,7 +22,7 @@ void KStarsLite::datainitFinished() {
connect( data(), SIGNAL(skyUpdate(bool)), map(), SLOT( forceUpdateNow() ) );
connect( this, SIGNAL( scaleChanged(float) ), data(), SLOT( setTimeDirection( float ) ) );
connect( this, SIGNAL( scaleChanged(float) ), data()->clock(), SLOT( setClockScale( float )) );
- connect( this, SIGNAL( scaleChanged(float) ), map(), SLOT( setFocus() ) );
+ //connect( this, SIGNAL( scaleChanged(float) ), map(), SLOT( setFocus() ) ); Why did we need this connection in KStars?
//Do not start the clock if "--paused" specified on the cmd line
if ( StartClockRunning ) data()->clock()->start();
diff --git a/kstars/projections/projector.h b/kstars/projections/projector.h
index 4a21fbe..f8707a6 100644
--- a/kstars/projections/projector.h
+++ b/kstars/projections/projector.h
@@ -78,7 +78,7 @@ public:
Q_ENUM(Projection)
/** Return the type of this projection */
- virtual Projection type() const = 0;
+ Q_INVOKABLE virtual Projection type() const = 0;
/** Return the FOV of this projection */
double fov() const;
diff --git a/kstars/skymaplite.cpp b/kstars/skymaplite.cpp
index ce97239..7e87774 100644
--- a/kstars/skymaplite.cpp
+++ b/kstars/skymaplite.cpp
@@ -100,10 +100,10 @@ int SkyMapLite::m_updatesCountTemp = 0;
int SkyMapLite::starColorMode = 0;
-SkyMapLite::SkyMapLite(QQuickItem* parent)
- :QQuickItem(parent), m_proj(0), count(0), data(KStarsData::Instance()),
+SkyMapLite::SkyMapLite()
+ :m_proj(0), count(0), data(KStarsData::Instance()),
nStarSizes(15), nSPclasses(7), pinch(false), m_loadingFinished(false), m_sizeMagLim(10.0),
- clearTextures(false)
+ clearTextures(false), isInitialized(false)
{
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::AllButtons);
@@ -133,8 +133,6 @@ SkyMapLite::SkyMapLite(QQuickItem* parent)
setupProjector();
- //Initialize images for stars
- initStarImages();
// Set pinstance to yourself
pinstance = this;
@@ -170,7 +168,7 @@ QSGNode* SkyMapLite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upda
qDeleteAll(m_deleteNodes);
m_deleteNodes.clear();
- if(m_loadingFinished) {
+ if(m_loadingFinished && isInitialized) {
if(!n) {
n = new RootNode();
m_rootNode = n;
@@ -226,12 +224,29 @@ QSGTexture* SkyMapLite::getCachedTexture(int size, char spType) {
return textureCache[harvardToIndex(spType)][size];
}
-SkyMapLite* SkyMapLite::createInstance(QQuickItem* parent) {
+SkyMapLite* SkyMapLite::createInstance() {
delete pinstance;
- pinstance = new SkyMapLite(parent);
+ pinstance = new SkyMapLite();
return pinstance;
}
+void SkyMapLite::initialize(QQuickItem *parent) {
+ if(parent) {
+ setParentItem(parent);
+ // Whenever the wrapper's(parent) dimensions changed, change SkyMapLite too
+ connect(parent, &QQuickItem::widthChanged, this, &SkyMapLite::resizeItem);
+ connect(parent, &QQuickItem::heightChanged, this, &SkyMapLite::resizeItem);
+
+ isInitialized = true;
+ }
+
+ resizeItem(); /* Set initial size pf SkyMapLite. Without it on Android SkyMapLite is
+ not displayed until screen orientation is not changed*/
+
+ //Initialize images for stars
+ initStarImages();
+}
+
SkyMapLite::~SkyMapLite() {
// Delete image cache
foreach(QVector<QPixmap*> imgCache, imageCache) {
@@ -725,143 +740,168 @@ QVector<QVector<QPixmap*>> SkyMapLite::getImageCache()
}
QSGTexture *SkyMapLite::textToTexture(QString text, QColor color, bool zoomFont) {
- QFont f;
+ if(isInitialized) {
+ QFont f;
- if(zoomFont) {
- f = SkyLabeler::Instance()->drawFont();
- } else {
- f = SkyLabeler::Instance()->stdFont();
- }
+ if(zoomFont) {
+ f = SkyLabeler::Instance()->drawFont();
+ } else {
+ f = SkyLabeler::Instance()->stdFont();
+ }
+
+ qreal ratio = window()->effectiveDevicePixelRatio();
- qreal ratio = window()->effectiveDevicePixelRatio();
+ QFontMetrics fm(f);
- QFontMetrics fm(f);
+ int width = fm.width(text);
+ int height = fm.height();
+ f.setPointSizeF(f.pointSizeF()*ratio);
- int width = fm.width(text);
- int height = fm.height();
- f.setPointSizeF(f.pointSizeF()*ratio);
+ QImage label(width*ratio, height*ratio, QImage::Format_ARGB32_Premultiplied);
- QImage label(width*ratio, height*ratio, QImage::Format_ARGB32_Premultiplied);
+ label.fill(Qt::transparent);
- label.fill(Qt::transparent);
+ m_painter.begin(&label);
- m_painter.begin(&label);
+ m_painter.setFont(f);
+
+ m_painter.setPen( color );
+ m_painter.drawText(0,(height - fm.descent())*ratio,text);
+
+ m_painter.end();
+
+ QSGTexture *texture = window()->createTextureFromImage(label,
+ QQuickWindow::TextureCanUseAtlas);
+ return texture;
+ } else {
+ return nullptr;
+ }
+}
- m_painter.setFont(f);
+void SkyMapLite::addFOVSymbol(const QString &FOVName, bool initialState) {
+ m_FOVSymbols.append(FOVName);
+ //Emit signal whenever new value was added
+ emit symbolsFOVChanged(m_FOVSymbols);
- m_painter.setPen( color );
- m_painter.drawText(0,(height - fm.descent())*ratio,text);
+ m_FOVSymVisible.append(initialState);
+}
- m_painter.end();
+bool SkyMapLite::isFOVVisible(int index) {
+ return m_FOVSymVisible.value(index);
+}
- QSGTexture *texture = window()->createTextureFromImage(label,
- QQuickWindow::TextureCanUseAtlas);
- return texture;
+void SkyMapLite::setFOVVisible(int index, bool visible) {
+ if(index >= 0 && index < m_FOVSymVisible.size()) {
+ m_FOVSymVisible[index] = visible;
+ forceUpdate();
+ }
}
void SkyMapLite::initStarImages()
{
- //Delete all existing pixmaps
- if(imageCache.length() != 0) {
- foreach(QVector<QPixmap*> vec, imageCache) {
- qDeleteAll(vec.begin(), vec.end());
+ if(isInitialized) {
+ //Delete all existing pixmaps
+ if(imageCache.length() != 0) {
+ foreach(QVector<QPixmap*> vec, imageCache) {
+ qDeleteAll(vec.begin(), vec.end());
+ }
+ clearTextures = true;
}
- clearTextures = true;
- }
- imageCache = QVector<QVector<QPixmap*>>(nSPclasses);
-
- QMap<char, QColor> ColorMap;
- const int starColorIntensity = Options::starColorIntensity();
-
- //On high-dpi screens star will look pixelized if don't multiply scaling factor by this ratio
- //Check PointNode::setNode() to see how it works
- qreal ratio = window()->effectiveDevicePixelRatio();
-
- switch( Options::starColorMode() ) {
- case 1: // Red stars.
- ColorMap.insert( 'O', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'B', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'A', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'F', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'G', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'K', QColor::fromRgb( 255, 0, 0 ) );
- ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
- break;
- case 2: // Black stars.
- ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'B', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'A', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'F', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'G', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'K', QColor::fromRgb( 0, 0, 0 ) );
- ColorMap.insert( 'M', QColor::fromRgb( 0, 0, 0 ) );
- break;
- case 3: // White stars
- ColorMap.insert( 'O', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'B', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'A', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'F', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'K', QColor::fromRgb( 255, 255, 255 ) );
- ColorMap.insert( 'M', QColor::fromRgb( 255, 255, 255 ) );
- case 0: // Real color
- default: // And use real color for everything else
- ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 255 ) );
- ColorMap.insert( 'B', QColor::fromRgb( 0, 200, 255 ) );
- ColorMap.insert( 'A', QColor::fromRgb( 0, 255, 255 ) );
- ColorMap.insert( 'F', QColor::fromRgb( 200, 255, 100 ) );
- ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 0 ) );
- ColorMap.insert( 'K', QColor::fromRgb( 255, 100, 0 ) );
- ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
- }
+ imageCache = QVector<QVector<QPixmap*>>(nSPclasses);
+
+ QMap<char, QColor> ColorMap;
+ const int starColorIntensity = Options::starColorIntensity();
- foreach( char color, ColorMap.keys() ) {
- //Add new spectral class
-
- QPixmap BigImage( 15, 15 );
- BigImage.fill( Qt::transparent );
-
- QPainter p;
- p.begin( &BigImage );
-
- if ( Options::starColorMode() == 0 ) {
- qreal h, s, v, a;
- p.setRenderHint( QPainter::Antialiasing, false );
- QColor starColor = ColorMap[color];
- starColor.getHsvF(&h, &s, &v, &a);
- for (int i = 0; i < 8; i++ ) {
- for (int j = 0; j < 8; j++ ) {
- qreal x = i - 7;
- qreal y = j - 7;
- qreal dist = sqrt( x*x + y*y ) / 7.0;
- starColor.setHsvF(h,
- qMin( qreal(1), dist < (10-starColorIntensity)/10.0 ? 0 : dist ),
- v,
- qMax( qreal(0), dist < (10-starColorIntensity)/20.0 ? 1 : 1-dist ) );
- p.setPen( starColor );
- p.drawPoint( i, j );
- p.drawPoint( (14-i), j );
- p.drawPoint( i, (14-j) );
- p.drawPoint ((14-i), (14-j));
+ //On high-dpi screens star will look pixelized if don't multiply scaling factor by this ratio
+ //Check PointNode::setNode() to see how it works
+ qreal ratio = window()->effectiveDevicePixelRatio();
+
+ switch( Options::starColorMode() ) {
+ case 1: // Red stars.
+ ColorMap.insert( 'O', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 255, 0, 0 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
+ break;
+ case 2: // Black stars.
+ ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 0, 0, 0 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 0, 0, 0 ) );
+ break;
+ case 3: // White stars
+ ColorMap.insert( 'O', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 255, 255, 255 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 255, 255, 255 ) );
+ case 0: // Real color
+ default: // And use real color for everything else
+ ColorMap.insert( 'O', QColor::fromRgb( 0, 0, 255 ) );
+ ColorMap.insert( 'B', QColor::fromRgb( 0, 200, 255 ) );
+ ColorMap.insert( 'A', QColor::fromRgb( 0, 255, 255 ) );
+ ColorMap.insert( 'F', QColor::fromRgb( 200, 255, 100 ) );
+ ColorMap.insert( 'G', QColor::fromRgb( 255, 255, 0 ) );
+ ColorMap.insert( 'K', QColor::fromRgb( 255, 100, 0 ) );
+ ColorMap.insert( 'M', QColor::fromRgb( 255, 0, 0 ) );
+ }
+
+ foreach( char color, ColorMap.keys() ) {
+ //Add new spectral class
+
+ QPixmap BigImage( 15, 15 );
+ BigImage.fill( Qt::transparent );
+
+ QPainter p;
+ p.begin( &BigImage );
+
+ if ( Options::starColorMode() == 0 ) {
+ qreal h, s, v, a;
+ p.setRenderHint( QPainter::Antialiasing, false );
+ QColor starColor = ColorMap[color];
+ starColor.getHsvF(&h, &s, &v, &a);
+ for (int i = 0; i < 8; i++ ) {
+ for (int j = 0; j < 8; j++ ) {
+ qreal x = i - 7;
+ qreal y = j - 7;
+ qreal dist = sqrt( x*x + y*y ) / 7.0;
+ starColor.setHsvF(h,
+ qMin( qreal(1), dist < (10-starColorIntensity)/10.0 ? 0 : dist ),
+ v,
+ qMax( qreal(0), dist < (10-starColorIntensity)/20.0 ? 1 : 1-dist ) );
+ p.setPen( starColor );
+ p.drawPoint( i, j );
+ p.drawPoint( (14-i), j );
+ p.drawPoint( i, (14-j) );
+ p.drawPoint ((14-i), (14-j));
+ }
}
+ } else {
+ p.setRenderHint(QPainter::Antialiasing, true );
+ p.setPen( QPen(ColorMap[color], 2.0 ) );
+ p.setBrush( p.pen().color() );
+ p.drawEllipse( QRectF( 2, 2, 10, 10 ) );
+ }
+ p.end();
+ //[nSPclasses][nStarSizes];
+ // Cache array slice
+
+ QVector<QPixmap *> *pmap = &imageCache[ harvardToIndex(color) ];
+ pmap->append(new QPixmap(BigImage));
+ for( int size = 1; size < nStarSizes; size++ ) {
+ pmap->append(new QPixmap(BigImage.scaled( size*ratio, size*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation )));
}
- } else {
- p.setRenderHint(QPainter::Antialiasing, true );
- p.setPen( QPen(ColorMap[color], 2.0 ) );
- p.setBrush( p.pen().color() );
- p.drawEllipse( QRectF( 2, 2, 10, 10 ) );
- }
- p.end();
- //[nSPclasses][nStarSizes];
- // Cache array slice
-
- QVector<QPixmap *> *pmap = &imageCache[ harvardToIndex(color) ];
- pmap->append(new QPixmap(BigImage));
- for( int size = 1; size < nStarSizes; size++ ) {
- pmap->append(new QPixmap(BigImage.scaled( size*ratio, size*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation )));
}
+ //}
+ starColorMode = Options::starColorMode();
}
- //}
- starColorMode = Options::starColorMode();
}
diff --git a/kstars/skymaplite.h b/kstars/skymaplite.h
index 7aa9060..c7277da 100644
--- a/kstars/skymaplite.h
+++ b/kstars/skymaplite.h
@@ -79,18 +79,21 @@ class SkyMapLite : public QQuickItem {
Q_PROPERTY(SkyPointLite *clickedPointLite READ getClickedPointLite NOTIFY pointLiteChanged)
Q_PROPERTY(SkyObjectLite *clickedObjectLite READ getClickedObjectLite NOTIFY objectLiteChanged)
+ Q_PROPERTY(QStringList FOVSymbols READ getFOVSymbols NOTIFY symbolsFOVChanged)
protected:
/**
*Constructor.
*/
- explicit SkyMapLite(QQuickItem* parent = 0);
+ explicit SkyMapLite();
virtual QSGNode* updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
static RootNode *m_rootNode;
public:
- static SkyMapLite* createInstance(QQuickItem* parent = 0);
+ static SkyMapLite* createInstance();
+
+ void initialize(QQuickItem *parent);
static SkyMapLite* Instance() { return pinstance; }
@@ -298,6 +301,12 @@ public:
@return a pointer to the current projector. */
inline const Projector * projector() const { return m_proj; }
+ /**
+ * @short used in QML
+ * @return type of current projection system
+ */
+ Q_INVOKABLE uint projType() const;
+
/** Set magnitude limit for size of stars. Used in StarItem **/
inline void setSizeMagLim(float sizeMagLim) { m_sizeMagLim = sizeMagLim; }
@@ -313,6 +322,29 @@ public:
/** return limit of hides for the node to delete it **/
static double deleteLimit();
+ /**
+ * @short adds FOV symbol to m_FOVSymbols
+ * @param FOVName name of a FOV symbol
+ */
+ Q_INVOKABLE void addFOVSymbol(const QString& FOVName, bool initialState = false);
+
+ /**
+ * @param index of FOVSymbol in m_FOVSymbols
+ * @return true if FOV symbol with name FOVName should be drawn.
+ */
+ bool isFOVVisible(int index);
+
+ /**
+ * @param index of FOVSymbol in m_FOVSymbols
+ * @short updates visibility of FOV symbol according to visible
+ */
+ Q_INVOKABLE void setFOVVisible(int index, bool visible);
+
+ /**
+ * @short this QList should be used as a model in QML to switch on/off FOV symbols
+ **/
+ Q_INVOKABLE inline QStringList getFOVSymbols() { return m_FOVSymbols; }
+
/** @short Initializes images of Stars and puts them in cache (copied from SkyQPainter)*/
void initStarImages();
@@ -490,6 +522,9 @@ signals:
/** Emitted when magnitude limit is changed */
void magLimChanged(double magLim);
+ /** Emitted when FOVSymbols list was changed (new value appended) **/
+ void symbolsFOVChanged(QStringList);
+
protected:
/** Process keystrokes:
* @li arrow keys Slew the map
@@ -608,6 +643,9 @@ private:
*/
void zoomOutOrMagStep( const int modifier );
+ //True if SkyMapLite was initialized (star images were initialized etc.)
+ bool isInitialized;
+
bool mouseButtonDown, midMouseButtonDown;
// true if mouseMoveEvent; needed by setMouseMoveCursor
bool mouseMoveCursor;
@@ -685,6 +723,9 @@ private:
const SkyPoint *m_rulerStartPoint; // Good to keep the original ruler start-point for purposes of dynamic_cast
+ QStringList m_FOVSymbols;
+ QList<bool> m_FOVSymVisible;
+
// This can be later changed
// Total number of sizes of stars.
const int nStarSizes;
diff --git a/kstars/skymapliteevents.cpp b/kstars/skymapliteevents.cpp
index 4329fe2..e83c077 100644
--- a/kstars/skymapliteevents.cpp
+++ b/kstars/skymapliteevents.cpp
@@ -431,6 +431,10 @@ void SkyMapLite::stopTracking() {
kstars->slotTrack();
}
+uint SkyMapLite::projType() const {
+ return m_proj->type();
+}
+
void SkyMapLite::incMagLimit( const int modifier ) {
m_magLim = 2.222 * log10(static_cast<double>( Options::starDensity() )) + 0.35;
m_magLim += magFactor( modifier );