From 09c89f6242ecf2495f86140a3f53ef4678f8563b Mon Sep 17 00:00:00 2001 From: SudhakarKuma Date: Wed, 25 Oct 2017 15:53:45 +0530 Subject: Updated OSP-plugin --- src/gui/OSPMainDialog.cpp | 838 ++++++++++++++++++++++++++++++++++++++++++++++ src/gui/OSPMainDialog.hpp | 312 +++++++++++++++++ src/gui/OSPMainDialog.ui | 758 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1908 insertions(+) create mode 100755 src/gui/OSPMainDialog.cpp create mode 100755 src/gui/OSPMainDialog.hpp create mode 100755 src/gui/OSPMainDialog.ui (limited to 'src/gui') diff --git a/src/gui/OSPMainDialog.cpp b/src/gui/OSPMainDialog.cpp new file mode 100755 index 0000000..fe3cbbb --- /dev/null +++ b/src/gui/OSPMainDialog.cpp @@ -0,0 +1,838 @@ +/* + * 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. + */ + +#include "OpenSkyPlanetarium.hpp" +#include "OSPMainDialog.hpp" +#include "ui_OSPMainDialog.h" +#include "Calibrate.hpp" + +#include "StelApp.hpp" +#include "StelLocaleMgr.hpp" +#include "StelModule.hpp" +#include "StelModuleMgr.hpp" +#include "StelObjectMgr.hpp" +#include "StelUtils.hpp" +#include "StelFileMgr.hpp" +#include "StarMgr.hpp" +#include "StelAudioMgr.hpp" +#include "StelObjectMgr.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +OSPMainDialog::OSPMainDialog() +{ + ui = new Ui_OSPMainDialog(); + calMode = false; + nRef = 0; + moduleDirectoryPath = StelFileMgr::getUserDir() + "/modules/OpenSkyPlanetarium"; + if(!StelFileMgr::exists(moduleDirectoryPath)){ + StelFileMgr::mkDir(moduleDirectoryPath); + } + scriptDirectoryPath = StelFileMgr::getUserDir() + "/modules/OpenSkyPlanetarium/script"; + if(!StelFileMgr::exists(scriptDirectoryPath)){ + StelFileMgr::mkDir(scriptDirectoryPath); + } + audioDirectoryPath = StelFileMgr::getUserDir() + "/modules/OpenSkyPlanetarium/audio"; + if(!StelFileMgr::exists(audioDirectoryPath)){ + StelFileMgr::mkDir(audioDirectoryPath); + } + + // Objects Initialization + player = new QMediaPlayer(); + playlist = new QMediaPlaylist(); + volumeSlider = new QAbstractSlider(); + player->setPlaylist(playlist); + player->setVolume(50); + playerState = QMediaPlayer::StoppedState; + remtim = 0; +} + +OSPMainDialog::~OSPMainDialog() +{ + //qDebug()<<"Closing Window"<retranslateUi(dialog); + } +} + + +void OSPMainDialog::createDialogContent() +{ + ui->setupUi(dialog); + ui->tabWidg->setCurrentIndex(2); + setSignals(); + connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); + connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(closeWin())); +} + +/* +setSignals(): + THis function connects the various gui signals to its corresponding slots + this function is called in the createDialogContent() function of this classs +*/ +void OSPMainDialog :: setSignals(){ + + //Setting signals for the laser movements + connect(ui->mvUp,SIGNAL(pressed()),this,SLOT(upPressed())); + connect(ui->mvDown,SIGNAL(pressed()),this,SLOT(downPressed())); + connect(ui->mvLeft,SIGNAL(pressed()),this,SLOT(leftPressed())); + connect(ui->mvRight,SIGNAL(pressed()),this,SLOT(rightPressed())); + connect(ui->mvUp,SIGNAL(released()),this,SLOT(arrow_released())); + connect(ui->mvDown,SIGNAL(released()),this,SLOT(arrow_released())); + connect(ui->mvRight,SIGNAL(released()),this,SLOT(arrow_released())); + connect(ui->mvLeft,SIGNAL(released()),this,SLOT(arrow_released())); + connect(ui->reset,SIGNAL(clicked()),this,SLOT(reset())); + + //Connecting LaserDev signals to their respective slots + connect(&device,SIGNAL(debug_send(QString)),this,SLOT(debug_received(QString))); + connect(&device,SIGNAL(pos_received(QString,QString)),this,SLOT(pos_received(QString,QString))); + + //Device connection and Calibration buttons + connect(ui->selectDev,SIGNAL(clicked()),this,SLOT(selectDevice())); + connect(ui->startCal,SIGNAL(clicked()),this,SLOT(initDevice())); + + //LASER on/off + connect(ui->laserOn,SIGNAL(clicked()),this,SLOT(laserToggled())); + connect(ui->laserOff,SIGNAL(clicked()),this,SLOT(laserToggled())); + connect(ui->intensity,SIGNAL(valueChanged(int)),this,SLOT(setIntensity(int))); + + // Motor speed control + connect(ui->CoarseAdj,SIGNAL(clicked()),this,SLOT(adjToggled())); + connect(ui->FineAdj,SIGNAL(clicked()),this,SLOT(adjToggled())); + + //setReference and goTo button + connect(ui->setRef,SIGNAL(clicked()),this,SLOT(setReference())); + connect(ui->goTo,SIGNAL(clicked()),this,SLOT(goTo())); + + //script engine buttons + connect(ui->compScript,SIGNAL(clicked()),this,SLOT(compileScript())); + connect(ui->openScript,SIGNAL(clicked()),this,SLOT(openScript())); + connect(ui->saveScript,SIGNAL(clicked()),this,SLOT(saveScript())); + connect(ui->execScript,SIGNAL(clicked()),this,SLOT(execScript())); + + //scriptEngine Command Buttons + connect(ui->gt,SIGNAL(clicked()),this,SLOT(gt())); + connect(ui->pl,SIGNAL(clicked()),this,SLOT(pl())); + connect(ui->wt,SIGNAL(clicked()),this,SLOT(wt())); + connect(ui->lo,SIGNAL(clicked()),this,SLOT(lo())); + + //all emit signals for our scriptEngine connected to their respective functions + connect(this,SIGNAL(comGOTO(QString,QString)),this,SLOT(move(QString,QString))); + connect(this,SIGNAL(comTURN(bool)),this,SLOT(laser(bool))); + connect(this,SIGNAL(comPLAY(QString)),this,SLOT(playAudio(QString))); + connect(this,SIGNAL(comWAIT(int,int)),this,SLOT(waitforsec(int,int))); + + //Signals for audio + connect(ui->playui,SIGNAL(clicked()),this,SLOT(playClicked())); + connect(ui->stopui,SIGNAL(clicked()),this,SLOT(stopClick())); + connect(ui->volumeChanged,SIGNAL(sliderMoved(int)),this,SLOT(setVolume(int))); + connect(this,SIGNAL(play()),player,SLOT(play())); + connect(this,SIGNAL(pause()),player,SLOT(pause())); + connect(this,SIGNAL(stop()),player,SLOT(stop())); +} + + +/* +/////////////////////////////////////User Defined Functions and Slots////////////////////////////////////// + All the required functions and slots for the gui written below +*/ + +///////////////////////////////////////////////Programmer helper slots//////////////////////////////////////////// + +/* +debug_received(): + Connected to many signals for debugging purpose +*/ +void OSPMainDialog :: debug_received(QString s){ + qDebug() << "[OpenSkyPlanetarium] __debug__"<X->setText(s); + ui->Y->setText(t); + +} + +/* +showMessage(QString): + this function is called to display error/information messages +*/ +void OSPMainDialog :: showMessage(QString m){ + QMessageBox msgBox; + msgBox.setWindowTitle("OpenSkyPlanetarium"); + msgBox.setText(m); + msgBox.exec(); +} + +//////////////////////////////////////////DEvice RElated slots//////////////////////////////////////////////////////////////////////////// + +/* +initDevice(): + 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 OSPMainDialog :: initDevice(){ + nRef=0; + QDateTime dt = QDateTime::currentDateTime(); + double time = StelUtils::hmsToRad (dt.time().hour(), dt.time().minute(), dt.time().second()); + calib.setTime(time); + qDebug() << "t0 =["<setRef->setEnabled(true); + ui->goTo->setEnabled(false); + ui->execScript->setEnabled(true); //change after testing to false + ui->mvUp->setEnabled(true); + ui->mvLeft->setEnabled(true); + ui->mvDown->setEnabled(true); + ui->mvRight->setEnabled(true); + ui->reset->setEnabled(true); + ui->refStat->setText("0/3"); +} + +/* +selectDevice(): + 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 OSPMainDialog :: selectDevice(){ + nRef=0; + QStringList itemsList; + bool ok; + foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) + itemsList.append(info.portName()); + portName = QInputDialog::getItem(NULL, "Open Sky Planetarium","Select Device:",itemsList, 0, false, &ok); + device.setPortName(portName); + if (ok && !portName.isEmpty()){ + ui->mvUp->setEnabled(false); + ui->mvDown->setEnabled(false); + ui->mvRight->setEnabled(false); + ui->mvLeft->setEnabled(false); + ui->selectDev->setEnabled(true); + ui->startCal->setEnabled(true); + ui->reset->setEnabled(false); + ui->setRef->setEnabled(false); + ui->goTo->setEnabled(false); + ui->execScript->setEnabled(true); //change after testing to false + ui->laserOn->setEnabled(true); + ui->laserOff->setEnabled(true); + ui->CoarseAdj->setEnabled(true); + ui->FineAdj->setEnabled(true); + ui->refStat->setText("0/3"); + } + else{ + showMessage("Please select the device"); + } +} + +/* +arrow_released(): + 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 OSPMainDialog :: arrow_released(){ + device.stop(); +} + +/* +upPressed(), downPressed(), rightPressed(), leftPressed(): + these functions are called when the buttons Up(mvUp), Down(mvDown), Right(mvRight) and Left(mvLeft) is pressed + these functions send appropriate move signals to the arduino device +*/ +void OSPMainDialog :: upPressed(){ + device.movy(1); +} + +void OSPMainDialog :: downPressed(){ + device.movy(0); +} + +void OSPMainDialog :: rightPressed(){ + device.movx(1); +} + +void OSPMainDialog :: leftPressed(){ + device.movx(0); +} +/* + reset(): + this function is called when the reset button is clicked. + this function calls move(0,0) and takes the laser to the initial coordinates. + */ + +void OSPMainDialog ::reset(){ + //this->initDevice(); + device.resetAll(); + QString val="0.000000"; + ui->X->setText(val); + ui->Y->setText(val); +} + + +/* +laserToggled(): + this slot is connected to the laser turnOn/turnOff radioButtons of the gui +*/ +void OSPMainDialog :: laserToggled(){ + if (ui->laserOn->isChecked()){ + device.laserOn(); + ui->intensity->setEnabled(true); + qDebug() << "[OpenSkyPlanetarium]:Turning LASER on" << endl; + } + else{ + ui->intensity->setEnabled(false); + // ui->intensity->setSliderPosition(50); + device.laserOff(); + qDebug() << "[OpenSkyPlanetarium]:Turning LASER off" << endl; + } +} + +/* +closeWin(): + this slot is connected to the close button of the gui +*/ +void OSPMainDialog :: closeWin(){ + debug_received("closing window"); + device.closeWindow(); + close(); + +} + + +///////////////////////////////////Calibration Related SLots///////////////////////////////////////////////////////////////////////// + +/* + setIntensity(): + this function is connected to the laser intensity control slider of the gui +*/ +void OSPMainDialog :: setIntensity(int x){ + int l=ui->intensity->value(); + device.setIntensity(l); + qDebug() << "[OpenSkyPlanetarium]:Changing intensity" << endl; +} + +/* +adjToggled(): + this slot is connected to the motor speed control radio buttons of the gui +*/ +void OSPMainDialog :: adjToggled(){ + if (ui->CoarseAdj->isChecked()){ + device.CoarseAdj(); + qDebug() << "[OpenSkyPlanetarium]:High Speed ON" << endl; + } + else{ + device.FineAdj(); + qDebug() << "[OpenSkyPlanetarium]:Low Speed ON" << endl; + } +} + + +/* +setReference(): + this function sets three references for the matrix transformation + basically it sends three references for matrix transformation to the device for its calculations +*/ + +void OSPMainDialog :: setReference(){ + nRef++; + QString sRef; + double dec = 0,ra = 0; + QDateTime dt = QDateTime::currentDateTime(); + double time = StelUtils::hmsToRad (dt.time().hour(), dt.time().minute(), dt.time().second()); + const QList& selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject(); + if(nRef>3) + { + nRef=3; + ui->setRef->setEnabled(false); + } + if (!selected.isEmpty()) { + StelUtils::rectToSphe(&ra,&dec,selected[0]->getEquinoxEquatorialPos(StelApp::getInstance().getCore())); + osp_ra=ra - 3.14159; + osp_dec=dec; + osp_time=time; + qDebug() << "Star = ["<goTo->setEnabled(true); + ui->execScript->setEnabled(true); + showMessage(QString("Second reference point has been set\n az = %1; alt = %2").arg(ac).arg(alt)); + //showMessage("Second reference point has been set"); + break; + case 3: + device.getPos(); + ac = acTemp.toDouble(); + alt = altTemp.toDouble(); + calib.setRef_3(osp_ra,osp_dec,osp_time,ac,alt); + ui->setRef->setEnabled(false); + ui->goTo->setEnabled(true); + ui->execScript->setEnabled(true); + ui->mvDown->setEnabled(false); + ui->mvUp->setEnabled(false); + ui->mvRight->setEnabled(false); + ui->mvLeft->setEnabled(false); + showMessage(QString("Third reference point has been set\n az = %1; alt = %2").arg(ac).arg(alt)); + //showMessage("Third reference point has been set"); + break; + + + } + sRef.setNum(nRef); + ui->refStat->setText(sRef+"/3"); + + } + else{ + showMessage("Please select a star to set as a Reference"); + } +} + +/* +goTo(): + 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 OSPMainDialog :: goTo(){ + QString sora,sodec,snra,sndec,sac,salt; //for testing purpose + double dec=0,ra=0,ac=0,alt=0; + QDateTime dt = QDateTime::currentDateTime(); + double time = StelUtils::hmsToRad (dt.time().hour(), dt.time().minute(), dt.time().second()); + const QList& selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject(); + if (!selected.isEmpty()) { + StelUtils::rectToSphe(&ra,&dec,selected[0]->getEquinoxEquatorialPos(StelApp::getInstance().getCore())); + } + qDebug() << "[goto_star_ra,dec,time]:"<X->setText(s); + ui->Y->setText(t); + qDebug() << "[goto_telescope_ac,alt]:"<scriptEdit->setText(file.readAll()); + file.close(); + } + +} + +/* +saveScript(): + This function is used to save the script +*/ +void OSPMainDialog :: saveScript(){ + if(!ui->scriptEdit->toPlainText().isEmpty()){ + QString fileName = QFileDialog::getSaveFileName(NULL,QString("Save Script"), scriptDirectoryPath,QString("Script Files (*.osp)")); + if(!fileName.isNull()){ + QFile file(fileName+".osp"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)){ + showMessage("File Not Accessible"); + return; + } + file.write(ui->scriptEdit->toPlainText().toLocal8Bit()); + file.close(); + } + } +} + + +/* +execScript(): + This function is used to execute script + This function calls compile function before executing +*/ +void OSPMainDialog :: execScript(){ + compileScript(); + if(buildStatus){ + foreach(QString commands, commandsList){ + QStringList com = commands.split("_"); + if(com[0].compare("goto")==0){ + qDebug()<clear(); + + if(nRef<2) + { + compileStatus=false; + showMessage(QString("Please do the calibration")); + } + else{ + + foreach(QString w, ui->scriptEdit->toPlainText().split("\n")){ + line_count++; + if(!scriptExp.exactMatch(w) && w.compare("")!=0){ + compileStatus=false; + showMessage(QString("Syntax Error at line %1").arg(line_count)); + } + else{ + QStringList com_par=scriptExp.capturedTexts(); + if(com_par[1].compare("goto")==0){ + double ra=0.0,dec=0.0; + QString sra,sdec; + //Todo:add checks before going down + StelObjectP star = GETSTELMODULE(StelObjectMgr)->searchByNameI18n(com_par[2].trimmed()); + if(!star.isNull()){ + StelUtils::rectToSphe(&ra,&dec,star->getEquinoxEquatorialPos(StelApp::getInstance().getCore())); + sra.setNum(ra); + sdec.setNum(dec); + commandsList << QString("goto_"+sra+"_"+sdec); + qDebug()<laserOn->setChecked(true); + ui->laserOff->setChecked(false); + } + else{ + device.laserOff(); + ui->laserOff->setChecked(true); + ui->laserOn->setChecked(false); + } +} + +/* +waitforsec(int,int): + this is used when playing the script + this is used to give wait functionality in the script +*/ +void OSPMainDialog :: waitforsec(int min,int sec){ + dieTime = QTime::currentTime().addSecs(min*60 + sec); + qDebug()<<"Current Time"<addMedia(QUrl::fromLocalFile(QString(audioDirectoryPath+QString("/")+fname))); + emit play(); + ui->playui->setEnabled(true); + ui->playui->setText(QString("Pause")); + playerState = QMediaPlayer::PlayingState; +} + + +//////////////////////////////////////////////////////////////////SLOTS FOR SCRIPT ENGINE COMMAND BUTTONS/////////////////////////////// + + + +/* +gt(): + This slot is connected to Goto Button of the Script Engine + Adds the goto command to your script +*/ +void OSPMainDialog :: gt(){ + QString sra,sdec; + const QList& selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject(); + if (!selected.isEmpty()) { + double dec_equinox = 0; + double ra_equinox = 0; + StelUtils::rectToSphe(&ra_equinox,&dec_equinox,selected[0]->getEquinoxEquatorialPos(StelApp::getInstance().getCore())); + ui->scriptEdit->setText(ui->scriptEdit->toPlainText().append(QString("goto %1;\n").arg(selected[0]->getNameI18n()))); + } + else { + showMessage("Please select an object first"); + } +} + +/* +pl(): + This slot is connected to Play Button of the Script Engine + Adds the play audio command to your script +*/ +void OSPMainDialog :: pl(){ + QString fileName = QFileDialog::getOpenFileName(NULL,QString("Select Audio File"), audioDirectoryPath,QString("Audio Files (*.wav)")); + if (!fileName.isNull()){ + QFileInfo f(fileName); + ui->scriptEdit->setText(ui->scriptEdit->toPlainText().append(QString("play %1;\n").arg(f.fileName()))); + } + else{ + showMessage("Please select the audio file"); + } +} + +/* +lo(): + This slot is connected to laser on/off button of the Script Engine + Adds the laser on/off command to your script +*/ +void OSPMainDialog :: lo(){ + QStringList items; + items << "on"<<"off"; + bool ok; + QString item = QInputDialog::getItem(NULL, "Open Sky Planetarium","Select State(on/off):", items, 0, false, &ok); + if (ok && !item.isEmpty()){ + ui->scriptEdit->setText(ui->scriptEdit->toPlainText().append(QString("turn %1;\n").arg(item))); + } + else{ + showMessage("Please select either on/off"); + } +} + +/* +wt(): + This slot is connected to wait button of the Script Engine + Adds the wait command to your script +*/ +void OSPMainDialog :: wt(){ + bool ok; + QRegExp a("([1-5][0-9])\\s*m\\s*([1-5][0-9])\\s*s"); + QString time = QInputDialog::getText(NULL,"Open Sky Planetarium","Enter time(in [X]m[Y]s):",QLineEdit::Normal,"", &ok); + if (ok && !time.isEmpty() && !a.exactMatch(time)){ + ui->scriptEdit->setText(ui->scriptEdit->toPlainText().append(QString("wait %1;\n").arg(time))); + } + else{ + showMessage("Please enter time in (X)m(Y)s format"); + } +} + +////////////////////// Media Functions ///////////////////////////// + +/* +setVolume(int): + This slot is connected to the volume slider of the Script Engine + Sets the volume for the player. +*/ + +void OSPMainDialog::setVolume(int volume) +{ + player->setVolume(volume); +} + +/* +stopClick(): + This slot is connected to the stopui function of the Script Engine + Stops the player. +*/ + +void OSPMainDialog::stopClick() +{ + playerState = QMediaPlayer::StoppedState; + ui->playui->setText(QString("Play")); + player->stop(); +} + +/* +playClicked(): + This slot is connected to the playui function of the Script Engine + Play or pause the audio in the script engine. +*/ + +void OSPMainDialog::playClicked() +{ + switch (playerState) { + case QMediaPlayer::StoppedState: + emit play(); + emit execScript(); + ui->playui->setText(QString("Pause")); + playerState = QMediaPlayer::PlayingState; + break; + case QMediaPlayer::PausedState: + emit play(); + ui->playui->setText(QString("Pause")); + remtim = pauseWait.restart(); + dieTime = dieTime.addMSecs(remtim); + playerState = QMediaPlayer::PlayingState; + break; + case QMediaPlayer::PlayingState: + emit pause(); + pauseWait.start(); + ui->playui->setText(QString("Play")); + playerState = QMediaPlayer::PausedState; + break; + } +} + diff --git a/src/gui/OSPMainDialog.hpp b/src/gui/OSPMainDialog.hpp new file mode 100755 index 0000000..c6d37f8 --- /dev/null +++ b/src/gui/OSPMainDialog.hpp @@ -0,0 +1,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 +#include +#include +#include +#include +#include +#include +#include + + +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 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 diff --git a/src/gui/OSPMainDialog.ui b/src/gui/OSPMainDialog.ui new file mode 100755 index 0000000..4a509ae --- /dev/null +++ b/src/gui/OSPMainDialog.ui @@ -0,0 +1,758 @@ + + + OSPMainDialog + + + + 0 + 0 + 510 + 461 + + + + Qt::ClickFocus + + + Form + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + + 16777215 + 30 + + + + Qt::NoFocus + + + false + + + QFrame::StyledPanel + + + + 6 + + + 0 + + + 0 + + + 4 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Open Sky Planetarium + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 16 + 16 + + + + + 16 + 16 + + + + Qt::NoFocus + + + + + + + + + + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 2 + + + false + + + false + + + + Calibration + + + + + + + + + + + LASER Direction Control + + + + + + false + + + Makes the LASER move downward only if it is not at (0,0). + + + down + + + + + + + false + + + Makes the LASER move upwards upto 90 degrees from (0,0). + + + up + + + + + + + false + + + Makes the LASER move rightwards upto 360 degrees from (0,0). + + + right + + + + + + + false + + + Makes the LASER move leftwards only if it is not at (0,0). + + + left + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Takes the LASER to (0,0). + + + reset + + + + + + + + + + Motor Speed Control + + + + + + Qt::Horizontal + + + + 46 + 20 + + + + + + + + false + + + Qt::StrongFocus + + + Makes the movement of LASER fast during its direction control. + + + Coarse + + + false + + + + + + + false + + + Makes the movement of LASER slow during its direction control. + + + Fine + + + true + + + + + + + Qt::Horizontal + + + + 45 + 20 + + + + + + + + + + + Qt::PreventContextMenu + + + + + + LASER Light Control + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Qt::StrongFocus + + + Turns the LASER on and enables slider to control intensity. + + + Turn ON + + + false + + + buttonGroup + + + + + + + false + + + Turns the LASER off and sends the slider to its initial position. + + + Turn OFF + + + true + + + buttonGroup + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Controls the intensity of LASER. Drag the slider to change the intensity. + + + 50 + + + 255 + + + 50 + + + 50 + + + false + + + Qt::Horizontal + + + + + + + + + + + + + + Device Configuration + + + + + + true + + + Selects the connected device. + + + Select + + + + + + + false + + + Initializes calibration using 2 or 3 reference stars. Also, it sets the current position of LASER as (0,0). + + + Start Calibrate + + + + + + + false + + + Takes the LASER to selected star after calibration has been accomplished. + + + GoTo + + + + + + + + + + Reference Status + + + + + + false + + + Sets reference when a star is selected. It is disabled when three references have been set successfully. + + + Set Ref. + + + + + + + true + + + Displays the number of references set. + + + 0/3 + + + Qt::AlignCenter + + + true + + + + + + + + + + + + + Current Coordinates + + + + + + + + Displays the current horizontal position of LASER in degrees. + + + X: + + + + + + + + + + + + + + + + + + Displays the current vertical position of LASER in degrees. + + + Y: + + + + + + + + + + + + + + + + + + + + + + ScriptEngine + + + + + 341 + 41 + 101 + 291 + + + + Qt::Vertical + + + + true + + + + 0 + 0 + + + + BusyCursor + + + 50 + + + Qt::Horizontal + + + + + false + + + Play + + + + + true + + + Stop + + + + + Open + + + + + Save + + + + + Build + + + + + true + + + Build + Run + + + + + + + 10 + 10 + 431 + 23 + + + + Qt::Horizontal + + + + Goto + + + + + Audio + + + + + WAIT + + + + + LASER ON/OFF + + + + + + + 13 + 42 + 321 + 291 + + + + true + + + Qt::ImhLowercaseOnly|Qt::ImhMultiLine|Qt::ImhNoAutoUppercase + + + QFrame::StyledPanel + + + false + + + + + + About + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt; font-weight:600; text-decoration: underline;">OpenSkyPlanetarium</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">An Open Source Initiative by IIT Bombay to bring interesting objects in the Open Sky closer to the common masses and school childrens.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Contact: IIT Bombay</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Email: openskyplanetarium@fossee.in</p></body></html> + + + + + + + + + + + + BarFrame + QFrame +
Dialog.hpp
+ 1 +
+
+ + + + + +
-- cgit