CCD.cpp   CCD.cpp 
/* /*
* Copyright (C) 2010 Bernhard Reutner-Fischer * portions Copyright (C) 2010 Bernhard Reutner-Fischer
* * portions Copyright (C) 2010 Timothy Reaves
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License * This program is free software; you can redistribute it and/or
* as published by the Free Software Foundation; either version 2 * modify it under the terms of the GNU General Public License
* of the License, or (at your option) any later version. * 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 * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details. * 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 * You should have received a copy of the GNU General Public License
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * along with this program; if not, write to the Free Software
USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U
*/ SA.
*/
#include "CCD.hpp" #include "CCD.hpp"
#include "Ocular.hpp" #include "Telescope.hpp"
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
CCD::CCD(QSqlRecord record) #include <math.h>
CCD::CCD()
{
}
CCD::CCD(const QObject& other)
{ {
CCDID = record.value("id").toInt(); this->m_name = other.property("name").toString();
name = record.value("name").toString(); this->m_chipHeight = other.property("chipHeight").toFloat();
resolution_x = record.value("resolution_x").toInt(); this->m_chipWidth = other.property("chipWidth").toFloat();
resolution_y = record.value("resolution_y").toInt(); this->m_pixelHeight = other.property("pixelHeight").toFloat();
chip_width = record.value("chip_width").toFloat(); this->m_pixelWidth = other.property("pixelWidth").toFloat();
chip_height = record.value("chip_height").toFloat(); this->m_resolutionX = other.property("resolutionX").toInt();
pixel_width = record.value("pixel_width").toFloat(); this->m_resolutionY = other.property("resolutionY").toInt();
pixel_height = record.value("pixel_height").toFloat();
} }
CCD::~CCD() CCD::~CCD()
{ {
} }
float CCD::getActualFOVx(Ocular *ocular) static QMap<int, QString> mapping;
QMap<int, QString> CCD::propertyMap()
{
if(mapping.isEmpty()) {
mapping = QMap<int, QString>();
mapping[0] = "name";
mapping[1] = "chipHeight";
mapping[2] = "chipWidth";
mapping[3] = "pixelHeight";
mapping[4] = "pixelWidth";
mapping[5] = "resolutionX";
mapping[6] = "resolutionY";
}
return mapping;
}
/* ********************************************************************* */
#if 0
#pragma mark -
#pragma mark Instance Methods
#endif
/* ********************************************************************* */
QString CCD::name() const
{
return m_name;
}
void CCD::setName(QString name)
{
m_name = name;
}
int CCD::resolutionX() const
{
return m_resolutionX;
}
void CCD::setResolutionX(int resolution)
{
m_resolutionX = resolution;
}
int CCD::resolutionY() const
{
return m_resolutionY;
}
void CCD::setResolutionY(int resolution)
{
m_resolutionY = resolution;
}
float CCD::chipWidth() const
{
return m_chipWidth;
}
void CCD::setChipWidth(float width)
{ {
float FOVx = (chip_width * 206.265) / ocular->getEffectiveFocalLengt m_chipWidth = width;
h(); }
float CCD::chipHeight() const
{
return m_chipHeight;
}
void CCD::setChipHeight(float height)
{
m_chipHeight = height;
}
float CCD::pixelWidth() const
{
return m_pixelWidth;
}
void CCD::setPixelWidth(float width)
{
m_pixelWidth = width;
}
float CCD::pixelHeight() const
{
return m_pixelHeight;
}
void CCD::setPixelHeight(float height)
{
m_pixelHeight = height;
}
float CCD::getActualFOVx(Telescope *telescope) const
{
float FOVx = 6875.5 * atan(this->chipWidth() / telescope->focalLengt
h() / 2);
return FOVx; return FOVx;
} }
float CCD::getActualFOVy(Ocular *ocular) float CCD::getActualFOVy(Telescope *telescope) const
{ {
float FOVy = (chip_height * 206.265) / ocular->getEffectiveFocalLeng th(); float FOVy = 6875.5 * atan(this->chipWidth() / telescope->focalLengt h() / 2);
return FOVy; return FOVy;
} }
/* ********************************************************************* */
#if 0
#pragma mark -
#pragma mark Static Methods
#endif
/* ********************************************************************* */
CCD* CCD::ccdFromSettings(QSettings* theSettings, int ccdIndex)
{
CCD* ccd = new CCD();
QString prefix = "ccd/" + QVariant(ccdIndex).toString() + "/";
ccd->setName(theSettings->value(prefix + "name", "").toString());
ccd->setResolutionX(theSettings->value(prefix + "resolutionX", "0").
toInt());
ccd->setResolutionY(theSettings->value(prefix + "resolutionY", "0").
toInt());
ccd->setChipWidth(theSettings->value(prefix + "chip_width", "0.0").t
oFloat());
ccd->setChipHeight(theSettings->value(prefix + "chip_height", "0.0")
.toFloat());
ccd->setPixelWidth(theSettings->value(prefix + "pixel_width", "0.0")
.toFloat());
ccd->setPixelHeight(theSettings->value(prefix + "pixel_height", "0.0
").toFloat());
return ccd;
}
CCD* CCD::ccdModel()
{
CCD* model = new CCD();
model->setName("My CCD");
model->setChipHeight(36.8);
model->setChipWidth(36.8);
model->setPixelHeight(9);
model->setPixelWidth(9);
model->setResolutionX(4096);
model->setResolutionY(4096);
return model;
}
 End of changes. 9 change blocks. 
32 lines changed or deleted 131 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/