summaryrefslogtreecommitdiff
path: root/src/gui/OSPMainDialog.hpp
blob: c6d37f8115928c69f0de63f209e7557ceb6878a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/*
 * Copyright (C) 2016 Dhiraj Salian
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
 */

#ifndef OSPMAINDIALOG_H
#define OSPMAINDIALOG_H

#include "Calibrate.hpp"
#include "StelDialog.hpp"
#include "LaserDev.hpp"
#include "StarMgr.hpp"
#include<QMediaPlayer>
#include <QWidget>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include<QList>
#include<QHash>
#include <QMediaPlaylist>
#include <QAbstractSlider>


class Ui_OSPMainDialog;

//! This is the main class used in connecting all the signals to gui.
class OSPMainDialog : public StelDialog
{
    	Q_OBJECT

public:
        OSPMainDialog();

    	~OSPMainDialog();


	/**
	*	This function connects the various gui signals to its corresponding slots.
	*   This function is called in the createDialogContent() function of this class.
	*/
	void setSignals();

	/**
	*	This function is called to display error/information messages
	*/
	void showMessage(QString m);
	
	
public slots:

	/**
	*	This function retranslate the language of plugin.
	*/
	void retranslate();
	/**
	*	This funtion is connected to many signals for debugging purpose.
	*	\param s Debug string
	*/
    void debug_received(QString s);
	/**
	*	This slot is called when the laser device sends us the coordinates
	*	The coordinates are then used for setting the references in transformation matrix
	* 	\param x Azimuth in string.
	*	\param y Altitude in string.
	*/	
    void pos_received(QString x,QString y);
	/**
	*	This slot is connected to the selectDev button of the gui.
	*	This slot shows a list of connected device to select from after selection enables many buttons.
	*/
    void selectDevice();
	/**
	*	This function initiates the arduino device i-e: Counts the no. of steps and sets device's postion.
	*	This function is connected to "Start Calibration" (startCal) button of the gui
	*/
	void initDevice();
	/**
	*	This function is called when the Up(mvUp), Down(mvDown), Right(mvRight) and Left(mvLeft) button is released
	*	This function sends the stop command to the arduino device to stop its movement along any of the four directions
	*/    
	void arrow_released();
	/**
	*	This functions is called when the buttons Up(mvUp) is pressed
	*/
    void upPressed();    
	/**
	*	This functions is called when the buttons Down(mvDown) is pressed
	*/
	void downPressed();
	/**
	*	This functions is called when the buttons Right(mvRight) is pressed
	*/
    void rightPressed();
	/**
	*	This functions is called when the buttons Left(mvLeft) is pressed
	*/
    void leftPressed();
	/**
	*	This function is connected to the laser turnOn/turnOff radioButtons of the gui
	*/
	void laserToggled();

	/**
	*	This function sets three references for the matrix transformation basically it sends three references for matrix transformation to the device for its calculations  
    */
    void setReference();

    /**
    *    This function is connected to the laser intensity control slider
    */
    void setIntensity(int x);

    /**
    *    This function is connected to the close button of gui
    */
    void closeWin();

    /**
    *	This function is connected to the motor control radioButtons of the gui
    */
    void adjToggled();

    /**
	*	This function sends the coordinates from stellarium to device so that the laser could point the star. This function is enabled only after calibration is performed
	*/	
	void goTo();

	/**
	*	This function opens an existing file if present in the script directory of our module.
	*/		
	void openScript();

	/**
	*	This function is used to save the script
	*/	
	void saveScript();

	/**
	*	This function is used to execute script. This function calls compile function before executing
	*/	
	void execScript();

	/**
	*	This function is used to compile script. This function maps the user script commands to the C++ functions
	*/	
	void compileScript();

	/**
	*	This is a slot for our script engine emit signal comTURN. This is used when playing the script
	*/
	void laser(bool stat);
	
	/**
	*		This function is used to play audio files. This is used to give play Audio functionality in our script
	*/
	void playAudio(QString fname);

	/**
	*	This is used when playing the script. This is used to give wait functionality in the script
	*	\param min time in minute
	*	\param sec time in second
	*/
	void waitforsec(int min,int sec);

	/**
	*	This is slot connected to goto command from our script engine. It takes ra/dec of star as its parameters and converts them to move
	*	\param sra Right Ascension (equatorial coordinates).
 	*	\param dec Declination (equatorial coordinates).
	*/
	void move(QString,QString);
	
	/**
	*	This slot is connected to Goto Button of the Script Engine. Adds the goto command to your script
	*/
	void gt();

	/**
	*	This slot is connected to Play Button of the Script Engine. Adds the play audio command to your script
	*/
	void pl();

	/**
	*	This slot is connected to laser on/off button of the Script Engine. Adds the laser on/off command to your script
	*/
	void lo();

	/**
	*	This slot is connected to wait button of the Script Engine. Adds the wait command to your script
	*/
	void wt();
    /**
    *   This slot is for hard reset of the arduino.
    */
    void reset();

signals:

	/**
	*	This signal is connected to move of OSPMainDialog class 
	*	\param sra Right Ascension (equatorial coordinates).
 	*	\param dec Declination (equatorial coordinates).
	*/
	void comGOTO(QString sra,QString sdec);

	/**
	*	This signal is connected to laser of OSPMainDialog class 
	*	\param stat status of laser
	*/
	void comTURN(bool stat);

	/**
	*	This signal is connected to waitforsec of OSPMainDialog class 
	*	\param min time in minute
	*	\param sec time in second
	*/
	void comWAIT(int min,int sec);


	/**
	*	This signal is connected to playAudio of OSPMainDialog class 
	*	\param fname file name
	*/
	void comPLAY(QString fname);
        
protected:

	/**
	*	This function is used to create a dialog box and set the current index of the box
	*/
    void createDialogContent();

private:
	OpenSkyPlanetarium *osp;
	Ui_OSPMainDialog *ui;
	LaserDev device;
	Calibrate calib;
        QString acTemp;
        QString altTemp;
	double osp_time;
	double osp_ra;
	double osp_dec;
	bool buildStatus;
	QString portName;
	QHash<QString,QString> i18n_to_coords;
	QString moduleDirectoryPath;
	QString scriptDirectoryPath;
	QString audioDirectoryPath;
	QStringList commandsList;
    bool calMode;
    int nRef;

	// Audio functions

signals:

	/**
	*	This signal is connected to play of QMediaPlayer class 
	*/
    void play();


	/**
	*	This signal is connected to pause of QMediaPlayer class 
	*/
    void pause();

	/**
	*	This signal is connected to stop of QMediaPlayer class 
	*/
    void stop();

public slots:

	/**
	*	This slot is connected to volume slider.
	*	\param volume by slider
	*/
    void setVolume(int volume);
    
	/**
	*	This slot is connected to play and pause button.
	*/
	void playClicked();

	/**
	*	This slot is connected to stop button.
	*/
    void stopClick();

private:
    QMediaPlayer* player;
    QMediaPlaylist* playlist;
    QMediaPlayer::State playerState;
    QAbstractSlider *volumeSlider;
	QTime dieTime;
	QTime pauseWait;
	qint32 remtim;
};

#endif // OSPMAINDIALOG_H