Kstars

polaralignwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2022 Hy Murveit <hy@murveit.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#include "polaralignwidget.h"
7
8namespace Ekos
9{
10PolarAlignWidget::PolarAlignWidget(QWidget * parent) : QWidget(parent)
11{
12 setupUi(this);
13 init();
14}
15
16namespace
17{
18void initLed(KLed *led)
19{
20 led->setColor(Qt::gray);
21 led->setLook(KLed::Flat);
22 led->setShape(KLed::Circular);
23 led->setState(KLed::Off);
24}
25} // namespace
26
27void PolarAlignWidget::init()
28{
29 initLed(PAcapture1Led);
30 initLed(PAcapture2Led);
31 initLed(PAcapture3Led);
32 initLed(PAslew1Led);
33 initLed(PAslew2Led);
34 initLed(PAsolve1Led);
35 initLed(PAsolve2Led);
36 initLed(PAsolve3Led);
37 initLed(PAsetupLed);
38 initLed(PAadjustLed);
39}
40
41void PolarAlignWidget::setPreviousGreen(PAState state)
42{
43 switch (state)
44 {
45 case ADJUST:
46 PAsetupLed->setColor(Qt::green);
47 PAsetupLed->on();
48 // fall through
49 case SETUP:
50 PAsolve3Led->setColor(Qt::green);
51 PAsolve3Led->on();
52 // fall through
53 case SOLVE3:
54 PAcapture3Led->setColor(Qt::green);
55 PAcapture3Led->on();
56 // fall through
57 case CAPTURE3:
58 PAslew2Led->setColor(Qt::green);
59 PAslew2Led->on();
60 // fall through
61 case SLEW2:
62 PAsolve2Led->setColor(Qt::green);
63 PAsolve2Led->on();
64 // fall through
65 case SOLVE2:
66 PAcapture2Led->setColor(Qt::green);
67 PAcapture2Led->on();
68 // fall through
69 case CAPTURE2:
70 PAslew1Led->setColor(Qt::green);
71 PAslew1Led->on();
72 // fall through
73 case SLEW1:
74 PAsolve1Led->setColor(Qt::green);
75 PAsolve1Led->on();
76 // fall through
77 case SOLVE1:
78 PAcapture1Led->setColor(Qt::green);
79 PAcapture1Led->on();
80 // fall through
81 case CAPTURE1:
82 break;
83 default:
84 break;
85 }
86}
87
88void PolarAlignWidget::updatePAHStage(PolarAlignmentAssistant::Stage stage)
89{
90 switch(stage)
91 {
92 case PolarAlignmentAssistant::PAH_IDLE:
93 init();
94 break;
95 case PolarAlignmentAssistant::PAH_FIRST_CAPTURE:
96 update(CAPTURE1);
97 break;
98 case PolarAlignmentAssistant::PAH_FIRST_SOLVE:
99 update(SOLVE1);
100 break;
101 case PolarAlignmentAssistant::PAH_FIRST_ROTATE:
102 update(SLEW1);
103 break;
104 case PolarAlignmentAssistant::PAH_SECOND_CAPTURE:
105 update(CAPTURE2);
106 break;
107 case PolarAlignmentAssistant::PAH_SECOND_SOLVE:
108 update(SOLVE2);
109 break;
110 case PolarAlignmentAssistant::PAH_SECOND_ROTATE:
111 update(SLEW2);
112 break;
113 case PolarAlignmentAssistant::PAH_THIRD_CAPTURE:
114 update(CAPTURE3);
115 break;
116 case PolarAlignmentAssistant::PAH_THIRD_SOLVE:
117 update(SOLVE3);
118 break;
119 case PolarAlignmentAssistant::PAH_STAR_SELECT:
120 update(SETUP);
121 break;
122 case PolarAlignmentAssistant::PAH_REFRESH:
123 update(ADJUST);
124 break;
125 case PolarAlignmentAssistant::PAH_POST_REFRESH:
126 init();
127 break;
128
129 // These are ignored in the widget.
130 case PolarAlignmentAssistant::PAH_FIRST_SETTLE:
131 case PolarAlignmentAssistant::PAH_SECOND_SETTLE:
132 case PolarAlignmentAssistant::PAH_FIND_CP:
133 break;
134 }
135}
136
137void PolarAlignWidget::update(PAState state)
138{
139 // turn off all leds
140 init();
141
142 switch (state)
143 {
144 case CAPTURE1:
145 PAcapture1Led->setColor(Qt::yellow);
146 PAcapture1Led->on();
147 break;
148 case SOLVE1:
149 setPreviousGreen(SOLVE1);
150 PAsolve1Led->setColor(Qt::yellow);
151 PAsolve1Led->on();
152 break;
153 case SLEW1:
154 setPreviousGreen(SLEW1);
155 PAslew1Led->setColor(Qt::yellow);
156 PAslew1Led->on();
157 break;
158 case CAPTURE2:
159 setPreviousGreen(CAPTURE2);
160 PAcapture2Led->setColor(Qt::yellow);
161 PAcapture2Led->on();
162 break;
163 case SOLVE2:
164 setPreviousGreen(SOLVE2);
165 PAsolve2Led->setColor(Qt::yellow);
166 PAsolve2Led->on();
167 break;
168 case SLEW2:
169 setPreviousGreen(SLEW2);
170 PAslew2Led->setColor(Qt::yellow);
171 PAslew2Led->on();
172 break;
173 case CAPTURE3:
174 setPreviousGreen(CAPTURE3);
175 PAcapture3Led->setColor(Qt::yellow);
176 PAcapture3Led->on();
177 break;
178 case SOLVE3:
179 setPreviousGreen(SOLVE3);
180 PAsolve3Led->setColor(Qt::yellow);
181 PAsolve3Led->on();
182 break;
183 case SETUP:
184 setPreviousGreen(SETUP);
185 PAsetupLed->setColor(Qt::yellow);
186 PAsetupLed->on();
187 break;
188 case ADJUST:
189 setPreviousGreen(ADJUST);
190 PAadjustLed->setColor(Qt::yellow);
191 PAadjustLed->on();
192 break;
193 default:
194 break;
195 }
196}
197}
void setColor(const QColor &color)
void setShape(Shape shape)
void setState(State state)
void setLook(Look look)
void update(Part *part, const QByteArray &data, qint64 dataSize)
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.