Commit a520f0ec authored by Artem Fedoskin's avatar Artem Fedoskin
Browse files

Added support for FOV symbols. Solved the bug with incorrect display of EllipseNode

parent 6c9ddf1b
......@@ -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
......
......@@ -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)
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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)
......
......@@ -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)
}
}
}
......
......@@ -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
......
......@@ -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
......
......@@ -5,7 +5,7 @@ import "../constants" 1.0
Item {
id: skyMapLiteItem
anchors.fill: parent
visible: loaded
visible: isLoaded
Rectangle {
id: skyMapLiteWrapper
......
......@@ -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))
......
......@@ -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
......
......@@ -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
}
}
}
}
......
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)
}
}
}
......@@ -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
}
}
}
}
......
......@@ -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));
}
......
/** *************************************************************************
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() {