Commit cb0af551 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Now it compiles but nothing works as most functions disabled. Need to work...

Now it compiles but nothing works as most functions disabled. Need to work next on calibration and guiding options setup
parent e90f2e55
......@@ -152,7 +152,7 @@ Guide::Guide() : QWidget()
break;
case GUIDE_PHD2:
guider = new PHD2();
//guider = new PHD2();
break;
......@@ -385,13 +385,14 @@ void Guide::updateGuideParams()
}
binningCombo->setEnabled(targetChip->canBin());
int binX=1,binY=1;
if (targetChip->canBin())
{
int binX,binY, maxBinX, maxBinY;
targetChip->getBinning(&binX, &binY);
targetChip->getMaxBin(&maxBinX, &maxBinY);
binningCombo->disconnect();
binningCombo->blockSignals(true);
binningCombo->clear();
......@@ -400,7 +401,7 @@ void Guide::updateGuideParams()
binningCombo->setCurrentIndex(binX-1);
connect(binningCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCCDBin(int)));
binningCombo->blockSignals(false);
}
if (ccd_hor_pixel != -1 && ccd_ver_pixel != -1 && focal_length != -1 && aperture != -1)
......@@ -418,7 +419,7 @@ void Guide::updateGuideParams()
int x,y,w,h;
if (targetChip->getFrame(&x,&y,&w,&h))
{
guider->setFrameParams(w,h);
guider->setFrameParams(x,y,w,h, binX, binY);
//pmath->setVideoParameters(w, h);
}
......@@ -1214,6 +1215,12 @@ void Guide::syncTrackingBoxPosition()
}
}
bool Guide::setGuideType(int type)
{
// FIXME
return false;
}
void Guide::updateTrackingBoxSize(int currentIndex)
{
Options::setGuideSquareSizeIndex(currentIndex);
......
......@@ -169,8 +169,9 @@ public:
/** DBUS interface function.
* Selects which guiding process to utilize for calibration & guiding.
* @param type Type of guider process to use. 0 for internal guider, 1 for external PHD2, 2 for external lin_guider
* @return True if guiding is switched to the new requested type. False otherwise.
*/
Q_SCRIPTABLE Q_NOREPLY void setGuiderType(int type);
Q_SCRIPTABLE Q_NOREPLY bool setGuideType(int type);
/** @}*/
......@@ -289,7 +290,10 @@ protected slots:
void onEnableDirDEC( bool enable );
void onInputParamChanged();
void onRapidGuideChanged(bool enable);
void onSetDECSwap(bool enable);
// FIXME
//void onSetDECSwap(bool enable);
void onControlDirectionChanged(bool enable);
signals:
......
......@@ -41,7 +41,8 @@ namespace Ekos
GuideInterface::GuideInterface()
{
ccdFrameWidth=ccdFrameHeight=0;
subX=subY=subW=subH=0;
subBinX=subBinY=1;
ccdPixelSizeX=ccdPixelSizeY=mountAperture=mountFocalLength=0;
}
......@@ -55,13 +56,18 @@ bool GuideInterface::setGuiderParams(double ccdPixelSizeX, double ccdPixelSizeY,
return true;
}
bool GuideInterface::setFrameParams(uint16_t width, uint16_t height)
bool GuideInterface::setFrameParams(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t binX, uint8_t binY)
{
if( width <= 0 || height <= 0 )
if( w <= 0 || h <= 0 )
return false;
ccdFrameWidth = width;
ccdFrameHeight = height;
subX = x;
subY = y;
subW = w;
subH = h;
subBinX = binX;
subBinY = binY;
return true;
}
......
......@@ -42,7 +42,7 @@ public:
virtual bool dither(double pixels) = 0;
virtual bool setGuiderParams(double ccdPixelSizeX, double ccdPixelSizeY, double mountAperture, double mountFocalLength);
virtual bool setFrameParams(uint16_t width, uint16_t height);
virtual bool setFrameParams(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t binX, uint8_t binY);
signals:
void newLog(const QString &);
......@@ -52,10 +52,11 @@ signals:
void frameCaptureRequested();
private:
protected:
Ekos::GuideState state;
double ccdPixelSizeX, ccdPixelSizeY, mountAperture, mountFocalLength;
uint16_t ccdFrameWidth, ccdFrameHeight;
uint16_t subX, subY, subW, subH;
uint8_t subBinX, subBinY;
};
......
......@@ -14,35 +14,4 @@
#include <QMessageBox>
#include <sys/types.h>
// define some colors
const uint8_t DEF_BKGD_COLOR[3] = {0, 0, 0};
const uint8_t DEF_RA_COLOR[3] = {0, 255, 0};
const uint8_t DEF_DEC_COLOR[3] = {0, 165, 255};
const uint8_t DEF_GRID_COLOR[3] = {128, 128, 128};
const uint8_t DEF_WHITE_COLOR[3] = {255, 255, 255};
const uint8_t DEF_GRID_FONT_COLOR[3] = {0, 255, 128};
const uint8_t DEF_SQR_OVL_COLOR[3] = {0, 255, 0};
void u_msg( const char *fmt, ...)
{
/*
va_list args;
char buf[1024];
va_start(args, fmt);
int ret = vsnprintf( buf, sizeof(buf)-1, fmt, args );
va_end(args);
*/
va_list argptr;
QString text;
va_start (argptr,fmt);
text.vsprintf(fmt, argptr);
va_end (argptr);
QMessageBox::information( NULL, "Info...", text, QMessageBox::Ok, QMessageBox::Ok );
//QMessageBox::information( this, "Info...", QString().sprintf("test = %d", 13), QMessageBox::Ok, QMessageBox::Ok );
}
......@@ -19,16 +19,7 @@
#include "../indi/indicommon.h"
extern const uint8_t DEF_BKGD_COLOR[];
extern const uint8_t DEF_RA_COLOR[];
extern const uint8_t DEF_DEC_COLOR[];
extern const uint8_t DEF_GRID_COLOR[];
extern const uint8_t DEF_WHITE_COLOR[];
extern const uint8_t DEF_GRID_FONT_COLOR[];
extern const uint8_t DEF_SQR_OVL_COLOR[];
void u_msg( const char *fmt, ...);
struct guide_dir_desc
{
......@@ -36,77 +27,8 @@ struct guide_dir_desc
const char desc[10];
};
typedef struct
{
int x, y;
}point_t;
static const int LOOP_DELAY = 10000;
class mouse_delegate
{
public:
virtual void mouse_press( QMouseEvent *event ) = 0;
virtual void mouse_release( QMouseEvent *event ) = 0;
virtual void mouse_move( QMouseEvent *event ) = 0;
virtual ~mouse_delegate() {}
};
class custom_drawer : public QWidget
{
Q_OBJECT
public:
explicit custom_drawer(QWidget *parent = NULL ) : QWidget(parent), m_mouse(NULL), m_image(NULL)
{
}
~custom_drawer()
{
}
bool set_source( QImage *image, mouse_delegate *mouse )
{
m_image = image;
if( !m_image )
return false;
resize( m_image->size() );
m_mouse = mouse;
return true;
}
protected:
void paintEvent(QPaintEvent *)
{
if( !m_image )
return;
QPainter painter;
painter.begin(this);
painter.drawImage( 0, 0, *m_image );
painter.end();
};
void mouseMoveEvent ( QMouseEvent *event )
{
if( !m_mouse )
return;
m_mouse->mouse_move( event );
}
void mousePressEvent ( QMouseEvent *event )
{
if( !m_mouse )
return;
m_mouse->mouse_press( event );
}
void mouseReleaseEvent ( QMouseEvent *event )
{
if( !m_mouse )
return;
m_mouse->mouse_release( event );
}
private:
mouse_delegate *m_mouse;
QImage *m_image;
};
#endif /* COMMON_H_ */
......@@ -44,6 +44,12 @@ const square_alg_t guide_square_alg[] = {
{ -1, {0} }
};
// JM: Why not use QPoint?
typedef struct
{
int x, y;
}point_t;
cgmath::cgmath() : QObject()
{
// sys...
......@@ -1061,8 +1067,7 @@ void cproc_in_params::reset( void )
for( int k = GUIDE_RA;k <= GUIDE_DEC;k++ )
{
enabled[k] = true;
accum_frame_cnt[k] = 1;
proportional_gain[k] = cgmath::preCalculatePropotionalGain( guiding_rate );
accum_frame_cnt[k] = 1;
integral_gain[k] = 0;
derivative_gain[k] = 0;
max_pulse_length[k] = 5000;
......
......@@ -9,6 +9,8 @@
version 2 of the License, or (at your option) any later version.
*/
#include <KMessageBox>
#include "internalguider.h"
#include "gmath.h"
......@@ -55,7 +57,32 @@ InternalGuider::~InternalGuider()
{
}
InternalGuider::setSquareAlgorithm(int index)
bool InternalGuider::guide()
{
return false;
}
bool InternalGuider::stop()
{
return false;
}
bool InternalGuider::suspend()
{
return false;
}
bool InternalGuider::resume()
{
return false;
}
bool InternalGuider::dither(double pixels)
{
return false;
}
void InternalGuider::setSquareAlgorithm(int index)
{
pmath->setSquareAlgorithm(index);
}
......@@ -67,9 +94,12 @@ bool InternalGuider::setGuiderParams(double ccdPixelSizeX, double ccdPixelSizeY,
}
void InternalGuider::calibrate()
bool InternalGuider::calibrate()
{
//FIXME
#if 0
/* // Capture final image
if (calibrationType == CAL_MANUAL && calibrationStage == CAL_START)
{
......@@ -102,7 +132,7 @@ void InternalGuider::calibrate()
bool ccdInfo=true, scopeInfo=true;
QString errMsg;
if (ccdFrameWidth == 0 || ccdFrameHeight == 0)
if (subW == 0 || subH == 0)
{
errMsg = "CCD";
ccdInfo = false;
......@@ -131,19 +161,23 @@ void InternalGuider::calibrate()
emit newStatus(Ekos::GUIDE_CALIBRATING);
// Must reset dec swap before we run any calibration procedure!
guideModule->setDECSwap(false);
pmath->setDeclinationSwapEnabled(false);
// FIXME
//guideModule->setDECSwap(false);
//pmath->setDeclinationSwapEnabled(false);
pmath->setLostStar(false);
//pmain_wnd->capture();
Options::setCalibrationPulseDuration(ui.spinBox_Pulse->value());
// FIXME
/*Options::setCalibrationPulseDuration(ui.spinBox_Pulse->value());
Options::setUseAutoMode(ui.autoModeCheck->isChecked());
Options::setUseTwoAxis(ui.twoAxisCheck->isChecked());
Options::setAutoModeIterations(ui.spinBox_DriftTime->value());
Options::setAutoStar(ui.autoStarCheck->isChecked());
if (ui.autoStarCheck->isChecked())
Options::setAutoSquareSize(ui.autoSquareSizeCheck->isChecked());
*/
// manual
if( ui.autoModeCheck->checkState() != Qt::Checked )
......@@ -160,13 +194,15 @@ void InternalGuider::calibrate()
else
calibrateRADECRecticle(true);
#endif
return true;
}
bool internalCalibration::stopCalibration()
bool InternalGuider::stopCalibration()
{
if (!pmath)
return false;
......@@ -180,13 +216,17 @@ bool internalCalibration::stopCalibration()
return true;
}
bool internalCalibration::startCalibration()
bool InternalGuider::startCalibration()
{
return true;
}
void internalCalibration::processCalibration()
void InternalGuider::processCalibration()
{
//FIXME
#if 0
//if (pmath->get_image())
//guide_frame->setTrackingBox(QRect(pmath-> square_pos.x, square_pos.y, square_size*2, square_size*2));
//pmath->get_image()->setTrackingBoxSize(QSize(pmath->get_square_size(), pmath->get_square_size()));
......@@ -219,32 +259,43 @@ void internalCalibration::processCalibration()
calibrateRADECRecticle(false);
break;
}
#endif
}
bool internalCalibration::isCalibrating()
/*bool InternalGuider::isCalibrating()
{
if (calibrationStage >= CAL_START)
return true;
return false;
}
}*/
void internalCalibration::reset()
void InternalGuider::reset()
{
//FIXME
#if 0
is_started = false;
ui.pushButton_StartCalibration->setText( i18n("Start") );
ui.startCalibrationLED->setColor(idleColor);
ui.progressBar->setVisible(false);
connect(pmath->getImageView(), SIGNAL(trackingStarSelected(int,int)), this, SLOT(trackingStarSelected(int, int)), Qt::UniqueConnection);
#endif
}
void internalCalibration::calibrateManualReticle( void )
void InternalGuider::calibrateManualReticle( void )
{
//----- manual mode ----
// get start point
calibrationType = CAL_MANUAL;
// FIXME
#if 0
if( !is_started )
{
if( ui.twoAxisCheck->checkState() == Qt::Checked )
......@@ -340,10 +391,15 @@ void internalCalibration::calibrateManualReticle( void )
reset();
}
#endif
}
void internalCalibration::calibrateRADECRecticle( bool ra_only )
void InternalGuider::calibrateRADECRecticle( bool ra_only )
{
// FIXME
#if 0
bool auto_term_ok = false;
......@@ -699,10 +755,15 @@ void internalCalibration::calibrateRADECRecticle( bool ra_only )
}
#endif
}
void internalCalibration::trackingStarSelected(int x, int y)
void InternalGuider::trackingStarSelected(int x, int y)
{
// FIXME
#if 0
//int square_size = guide_squares[pmath->getSquareIndex()].size;
pmath->setReticleParameters(x, y, ui.spinBox_ReticleAngle->value());
......@@ -726,9 +787,12 @@ void internalCalibration::trackingStarSelected(int x, int y)
if (ui.autoStarCheck->isChecked())
startCalibration();
#endif
}
void internalCalibration::capture()
#if 0
void InternalGuider::capture()
{
/*
if (isCalibrating())
......@@ -749,8 +813,11 @@ void internalCalibration::capture()
}
*/
}
#endif
bool internalCalibration::setImageView(FITSView *image)
//FIXME
#if 0
bool InternalGuider::setImageView(FITSView *image)
{
guideFrame = image;
......@@ -796,31 +863,37 @@ bool internalCalibration::setImageView(FITSView *image)
return true;
}
#endif
void internalCalibration::setCalibrationTwoAxis(bool enable)
//FIXME
#if 0
void InternalGuider::setCalibrationTwoAxis(bool enable)
{
ui.twoAxisCheck->setChecked(enable);
}
void internalCalibration::setCalibrationAutoStar(bool enable)
void InternalGuider::setCalibrationAutoStar(bool enable)
{
ui.autoStarCheck->setChecked(enable);
}
void internalCalibration::setCalibrationAutoSquareSize(bool enable)
void InternalGuider::setCalibrationAutoSquareSize(bool enable)
{
ui.autoSquareSizeCheck->setChecked(enable);
}
void internalCalibration::setCalibrationPulseDuration(int pulseDuration)
void InternalGuider::setCalibrationPulseDuration(int pulseDuration)
{
ui.spinBox_Pulse->setValue(pulseDuration);
}
void internalCalibration::toggleAutoSquareSize(bool enable)
void InternalGuider::toggleAutoSquareSize(bool enable)
{
ui.autoSquareSizeCheck->setEnabled(enable);
}
#endif
}
......@@ -12,6 +12,11 @@
#ifndef INTERNALGUIDER_H
#define INTERNALGUIDER_H
#include <QFile>
#include <QPixmap>
#include "fitsviewer/fitsview.h"
#include "matr.h"
#include "../guideinterface.h"
......@@ -54,10 +59,8 @@ public:
void setHalfRefreshRate( bool is_half );
bool isGuiding( void ) const;
void setAO(bool enable);
void setInterface( void );
void setImageView(FITSView *image);
void setReady(bool enable) { m_isReady = enable;}
void setTargetChip(ISD::CCDChip *chip);
void setInterface( void );
void setReady(bool enable) { m_isReady = enable;}
bool isRapidGuide() { return m_useRapidGuide;}
double getAOLimit();
......@@ -98,11 +101,11 @@ private:
bool first_frame, first_subframe;
bool half_refresh_rate;
int m_lostStarTries;
bool m_useRapidGuide;
ISD::CCDChip *targetChip;
bool m_useRapidGuide;
int fx,fy,fw,fh;
double ret_x, ret_y, ret_angle;
bool m_isDithering;
QFile logFile;
QPixmap profilePixmap;
......@@ -112,6 +115,13 @@ private:
void calibrateManualReticle( void );
void calibrateRADECRecticle( bool ra_only ); // 1 or 2-axis calibration
bool startCalibration();
bool stopCalibration();
void processCalibration();
void reset();
bool is_started;
int axis;
......@@ -123,9 +133,7 @@ private:
double end_x2, end_y2;
int iterations, dec_iterations;