26 #ifndef GRALE_SOURCEIMAGE_H
28 #define GRALE_SOURCEIMAGE_H
30 #include "graleconfig.h"
31 #include "sourceplane.h"
32 #include "constants.h"
38 class GRALE_IMPORTEXPORT SourceImage :
public errut::ErrorBase
41 enum SourceType { Circle, Ellipse, Polygon, Discrete, Point };
44 SourceImage(SourceType t, Vector2D<double> angularpos,
double angle,
double brightnessScale);
46 virtual ~SourceImage();
48 SourceType getSourceType()
const {
return stype; }
51 virtual SourceImage *createCopy()
const = 0;
52 virtual bool isSerializable()
const {
return false; }
54 bool attach(SourcePlane *parentplane, uint16_t srcid);
56 SourcePlane *getParentPlane() {
return parentplane; }
57 uint64_t getID()
const {
return id; }
59 double getIntensity(Vector2D<double> beta)
const;
60 bool isSourceInRange(Vector2D<double> beta,
double radius)
const;
62 double getD_s()
const {
return parentplane->getD_s(); }
63 double getD_ds()
const {
return parentplane->getD_ds(); }
64 Vector2D<double> getAngularPosition()
const {
return pos; }
65 void addToAngularPosition(Vector2D<double> p) { pos += p; }
66 void setAngularPosition(Vector2D<double> p) { pos = p; }
67 void addToAngle(
double ang) { angle += ang; theta = (angle/180.0)*CONST_PI; }
68 void setAngle(
double ang) { angle = ang; theta = (angle/180.0)*CONST_PI; }
69 double getAngle()
const {
return angle; }
71 bool write(serut::SerializationInterface &si)
const;
72 static bool read(serut::SerializationInterface &si,SourceImage **source,std::string &errstr);
74 double getBrightnessScale()
const {
return m_brightnessScale; }
76 virtual bool writeInternal(serut::SerializationInterface &si)
const;
77 virtual bool readInternal(serut::SerializationInterface &si);
78 virtual double getIntensityInternal(Vector2D<double> diff)
const {
return 0; }
79 virtual double getMaxRadius()
const {
return 0; }
83 SourcePlane *parentplane;
86 double m_brightnessScale;
88 friend class SourcePlane;
91 inline double SourceImage::getIntensity(Vector2D<double> beta)
const
93 Vector2D<double> diff = beta - pos;
94 Vector2D<double> diff2(diff.getX()*COS(theta) + diff.getY()*SIN(theta),
95 -diff.getX()*SIN(theta) + diff.getY()*COS(theta));
97 return m_brightnessScale*getIntensityInternal(diff2);
100 inline bool SourceImage::isSourceInRange(Vector2D<double> beta,
double radius)
const
102 Vector2D<double> diff = beta - pos;
103 Vector2D<double> diff2(diff.getX()*COS(theta) + diff.getY()*SIN(theta),
104 -diff.getX()*SIN(theta) + diff.getY()*COS(theta));
106 double d = diff2.getLength() - radius;
108 if (d < getMaxRadius())
115 #endif // GRALE_SOURCEIMAGE_H