Commit 316cfe27 authored by ahoms's avatar ahoms
Browse files

* fixed CtImage get/setRoi when roi is not active

* uncommented and fixed CtMaxImageSizeCB and HwFlipCtrlObj code
* removed DEB_CLASS_NAMESPC header from struct CtSaving::Parameters
* miscellaneous style changes


git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@193 45c4679d-1946-429d-baad-37912b19538b
parent c0a5dc18
#include "FrelonInterface.h"
#include "CtControl.h"
#include "CtAcquisition.h"
#include "CtImage.h"
using namespace lima;
......@@ -25,12 +27,31 @@ void test_frelon_control()
DEB_TRACE() << "Done!";
CtControl control(&hw_inter);
CtAcquisition* ct_acq = control.acquisition();
CtAcquisition *ct_acq = control.acquisition();
CtSaving *ct_saving = control.saving();
CtImage *ct_image = control.image();
CtBuffer *ct_buffer = control.buffer();
AcqMode acq_mode;
ct_acq->getAcqMode(acq_mode);
DEB_TRACE() << "Default " << DEB_VAR1(acq_mode);
ImageType image_type;
ct_image->getImageType(image_type);
DEB_TRACE() << "Default " << DEB_VAR1(image_type);
Size max_size;
ct_image->getMaxImageSize(max_size);
DEB_TRACE() << "Default " << DEB_VAR1(max_size);
Bin bin;
ct_image->getBin(bin);
DEB_TRACE() << "Default " << DEB_VAR1(bin);
Roi roi;
ct_image->getRoi(roi);
DEB_TRACE() << "Default " << DEB_VAR1(roi);
double exp_time;
ct_acq->getAcqExpoTime(exp_time);
DEB_TRACE() << "Default " << DEB_VAR1(exp_time);
......@@ -39,11 +60,6 @@ void test_frelon_control()
ct_acq->getAcqNbFrames(nb_frame);
DEB_TRACE() << "Default " << DEB_VAR1(nb_frame);
// ct_acq->setAcqMode(Single);
// ct_acq->setAcqExpoTime(exp_time);
// ct_acq->setAcqNbFrames(nframe);
}
int main(int argc, char *argv[])
......
......@@ -408,9 +408,8 @@ inline bool Roi::isEmpty() const
inline void Roi::reset()
{
m_top_left.x= 0;
m_top_left.y= 0;
m_size= Size(0,0);
m_top_left = Point(0, 0);
m_size = Size(0, 0);
}
inline Roi& Roi::operator =(const Roi& r)
......
......@@ -8,152 +8,154 @@
namespace lima {
class CtImage;
class CtSwBinRoi {
DEB_CLASS_NAMESPC(DebModControl,"Sofware BinRoi","Control");
public:
friend std::ostream& operator<<(std::ostream &os,const CtSwBinRoi &binroi);
CtSwBinRoi(Size& size);
void setMaxSize(Size& size);
void setBin(const Bin& bin);
void setRoi(const Roi& roi);
void resetBin();
void resetRoi();
void reset();
const Bin& getBin() const { return m_bin; }
const Roi& getRoi() const { return m_roi; }
const Size& getSize();
bool apply(SoftOpInternalMgr *op);
private:
Size m_max_size, m_size;
Bin m_bin;
Roi m_roi, m_max_roi;
};
class CtHwBinRoi {
DEB_CLASS_NAMESPC(DebModControl,"Hardware BinRoi","Control");
public:
CtHwBinRoi(HwInterface *hw, CtSwBinRoi *sw_bin_roi, Size& size);
~CtHwBinRoi();
bool hasBinCapability() { return m_has_bin; }
bool hasRoiCapability() { return m_has_roi; }
void setMaxSize(const Size& size);
void setBin(Bin& bin, bool round);
void setRoi(Roi& roi, bool round);
void resetBin();
void resetRoi();
void reset();
const Bin& getBin() const { return m_bin; }
const Roi& getRoi() const { return m_roi; }
const Size& getSize() const { return m_size; }
void apply();
private:
void _updateSize();
HwBinCtrlObj *m_hw_bin;
HwRoiCtrlObj *m_hw_roi;
CtSwBinRoi *m_sw_bin_roi;
bool m_has_bin, m_has_roi;
Size m_max_size, m_size;
Bin m_bin;
Roi m_roi, m_max_roi;
};
/* -- link probleme with this one !?
class CtMaxImageSizeCB : public HwMaxImageSizeCallback
{
public:
CtMaxImageSizeCB(CtImage *ct) : m_ct(ct) {}
protected:
void maxImageSizeChanged(const Size& size, ImageType image_type);
private:
CtImage *m_ct;
};
*/
class CtImage {
DEB_CLASS_NAMESPC(DebModControl,"Image","Control");
public:
friend class CtMaxImageSizeCB;
class CtImage;
class CtSwBinRoi {
DEB_CLASS_NAMESPC(DebModControl,"Sofware BinRoi","Control");
public:
friend std::ostream& operator<<(std::ostream &os,const CtSwBinRoi &binroi);
CtSwBinRoi(Size& size);
void setMaxSize(Size& size);
void setBin(const Bin& bin);
void setRoi(const Roi& roi);
void resetBin();
void resetRoi();
void reset();
const Bin& getBin() const { return m_bin; }
const Roi& getRoi() const { return m_roi; }
const Size& getSize();
bool apply(SoftOpInternalMgr *op);
enum ImageOpMode {
HardOnly,
SoftOnly,
HardAndSoft,
};
private:
Size m_max_size, m_size;
Bin m_bin;
Roi m_roi, m_max_roi;
};
CtImage(HwInterface *hw);
~CtImage();
void getMaxImageSize(Size& size) const;
void setMaxImage(const Size &size, ImageType type);
class CtHwBinRoi {
DEB_CLASS_NAMESPC(DebModControl,"Hardware BinRoi","Control");
public:
CtHwBinRoi(HwInterface *hw, CtSwBinRoi *sw_bin_roi, Size& size);
~CtHwBinRoi();
void getImageType(ImageType& type) const;
void getHwImageDim(FrameDim& dim) const;
void getImageDim(FrameDim& dim) const;
bool hasBinCapability() { return m_has_bin; }
bool hasRoiCapability() { return m_has_roi; }
// --- soft
void getSoft(CtSwBinRoi *& soft) const;
void getHard(CtHwBinRoi *& hard) const;
void setMaxSize(const Size& size);
void setBin(Bin& bin, bool round);
void setRoi(Roi& roi, bool round);
// --- wizard
void setMode(ImageOpMode mode);
void getMode(ImageOpMode& mode) const;
void resetBin();
void resetRoi();
void reset();
void setRoi(Roi& roi);
void setBin(Bin& bin);
const Bin& getBin() const { return m_bin; }
const Roi& getRoi() const { return m_roi; }
const Size& getSize() const { return m_size; }
void apply();
private:
void _updateSize();
HwBinCtrlObj *m_hw_bin;
HwRoiCtrlObj *m_hw_roi;
HwFlipCtrlObj *m_hw_flip;
CtSwBinRoi *m_sw_bin_roi;
bool m_has_bin, m_has_roi, m_has_flip;
Size m_max_size, m_size;
Bin m_bin;
Roi m_roi, m_max_roi;
};
class CtMaxImageSizeCB : public HwMaxImageSizeCallback
{
public:
CtMaxImageSizeCB(CtImage *ct) : m_ct(ct) {}
protected:
void maxImageSizeChanged(const Size& size, ImageType image_type);
private:
CtImage *m_ct;
};
void resetRoi();
void resetBin();
// --- effective
void getRoi(Roi& roi) const;
void getBin(Bin& bin) const;
void reset();
void applyHard();
bool applySoft(SoftOpInternalMgr *op);
private:
void _setHSRoi(const Roi &roi);
void _setHSBin(const Bin &bin);
HwDetInfoCtrlObj *m_hw_det;
// HwFlipCtrlObj *m_hw_flip;
// CtMaxImageSizeCB *m_cb_size;
CtSwBinRoi *m_sw;
CtHwBinRoi *m_hw;
Size m_max_size;
ImageType m_img_type;
ImageOpMode m_mode;
};
inline std::ostream& operator<<(std::ostream &os,const CtSwBinRoi &binroi)
{
os << "<"
<< "m_max_size=" << binroi.m_max_size << ", "
<< "m_size=" << binroi.m_size << ", "
<< "m_bin=" << binroi.m_bin << ", "
<< "m_roi=" << binroi.m_roi << ", "
<< "m_max_roi=" << binroi.m_max_roi
<< ">";
return os;
}
class CtImage {
DEB_CLASS_NAMESPC(DebModControl,"Image","Control");
public:
friend class CtMaxImageSizeCB;
enum ImageOpMode {
HardOnly,
SoftOnly,
HardAndSoft,
};
CtImage(HwInterface *hw);
~CtImage();
void getMaxImageSize(Size& size) const;
void setMaxImage(const Size &size, ImageType type);
void getImageType(ImageType& type) const;
void getHwImageDim(FrameDim& dim) const;
void getImageDim(FrameDim& dim) const;
// --- soft
void getSoft(CtSwBinRoi *& soft) const;
void getHard(CtHwBinRoi *& hard) const;
// --- wizard
void setMode(ImageOpMode mode);
void getMode(ImageOpMode& mode) const;
void setRoi(Roi& roi);
void setBin(Bin& bin);
void resetRoi();
void resetBin();
// --- effective
void getRoi(Roi& roi) const;
void getBin(Bin& bin) const;
void reset();
void applyHard();
bool applySoft(SoftOpInternalMgr *op);
private:
void _setHSRoi(const Roi &roi);
void _setHSBin(const Bin &bin);
HwDetInfoCtrlObj *m_hw_det;
CtMaxImageSizeCB *m_cb_size;
CtSwBinRoi *m_sw;
CtHwBinRoi *m_hw;
Size m_max_size;
ImageType m_img_type;
ImageOpMode m_mode;
};
inline std::ostream& operator<<(std::ostream &os,const CtSwBinRoi &binroi)
{
os << "<"
<< "m_max_size=" << binroi.m_max_size << ", "
<< "m_size=" << binroi.m_size << ", "
<< "m_bin=" << binroi.m_bin << ", "
<< "m_roi=" << binroi.m_roi << ", "
<< "m_max_roi=" << binroi.m_max_roi
<< ">";
return os;
}
} // namespace lima
#endif // CTIMAGE_H
......@@ -46,9 +46,6 @@ namespace lima {
struct Parameters
{
DEB_CLASS_NAMESPC(DebModControl,"Saving parameters",
"Control");
public:
std::string directory;
std::string prefix;
std::string suffix;
......
......@@ -8,103 +8,104 @@ using namespace lima;
// ----------------------------------------------------------------------------
CtSwBinRoi::CtSwBinRoi(Size& size)
{
DEB_CONSTRUCTOR();
DEB_PARAM() << DEB_VAR1(size);
DEB_CONSTRUCTOR();
DEB_PARAM() << DEB_VAR1(size);
m_max_size= size;
m_max_roi= Roi(Point(0,0), m_max_size);
m_max_size= size;
m_max_roi= Roi(Point(0,0), m_max_size);
}
void CtSwBinRoi::setMaxSize(Size& size)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(size);
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(size);
m_max_size= size;
m_max_roi.setSize(m_max_size / m_bin);
m_max_size= size;
m_max_roi.setSize(m_max_size / m_bin);
if (!m_max_roi.containsPoint(m_roi.getTopLeft()))
m_roi.reset();
else if (!m_max_roi.containsPoint(m_roi.getBottomRight()))
m_roi.setCorners(m_roi.getTopLeft(), m_max_roi.getBottomRight());
if (!m_max_roi.containsPoint(m_roi.getTopLeft())) {
m_roi.reset();
}
else if (!m_max_roi.containsPoint(m_roi.getBottomRight())) {
m_roi.setCorners(m_roi.getTopLeft(), m_max_roi.getBottomRight());
}
}
void CtSwBinRoi::setBin(const Bin& bin)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(bin);
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(bin);
if (bin != m_bin)
{
m_roi= m_roi.getUnbinned(m_bin);
m_bin= bin;
if (!m_bin.isOne())
m_roi= m_roi.getBinned(m_bin);
m_max_roi.setSize(m_max_size / m_bin);
}
if (bin != m_bin) {
m_roi= m_roi.getUnbinned(m_bin);
m_bin= bin;
if (!m_bin.isOne())
m_roi= m_roi.getBinned(m_bin);
m_max_roi.setSize(m_max_size / m_bin);
}
}
void CtSwBinRoi::setRoi(const Roi& roi)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(roi);
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(roi);
if (roi.isEmpty())
throw LIMA_CTL_EXC(InvalidValue, "Hardware roi is empty");
if (!m_max_roi.containsRoi(roi))
throw LIMA_CTL_EXC(InvalidValue, "Roi out of limts");
m_roi= roi;
if (roi.isEmpty())
throw LIMA_CTL_EXC(InvalidValue, "Hardware roi is empty");
if (!m_max_roi.containsRoi(roi))
throw LIMA_CTL_EXC(InvalidValue, "Roi out of limts");
m_roi= roi;
}
const Size& CtSwBinRoi::getSize()
{
DEB_MEMBER_FUNCT();
DEB_MEMBER_FUNCT();
if (m_roi.isEmpty())
m_size= m_max_size / m_bin;
else
m_size= Size(m_roi.getSize());
DEB_RETURN() << DEB_VAR1(m_size);
if (m_roi.isEmpty())
m_size= m_max_size / m_bin;
else
m_size= Size(m_roi.getSize());
DEB_RETURN() << DEB_VAR1(m_size);
return m_size;
return m_size;
}
void CtSwBinRoi::resetBin()
{
DEB_MEMBER_FUNCT();
DEB_MEMBER_FUNCT();
m_roi= m_roi.getUnbinned(m_bin);
m_bin.reset();
m_roi= m_roi.getUnbinned(m_bin);
m_bin.reset();
}
void CtSwBinRoi::resetRoi()
{
DEB_MEMBER_FUNCT();
DEB_MEMBER_FUNCT();
m_roi.reset();
m_roi.reset();
}
void CtSwBinRoi::reset()
{
DEB_MEMBER_FUNCT();
DEB_MEMBER_FUNCT();
m_bin.reset();
m_roi.reset();
m_bin.reset();
m_roi.reset();
}
bool CtSwBinRoi::apply(SoftOpInternalMgr *op)
{
DEB_MEMBER_FUNCT();
op->setBin(m_bin);
op->setRoi(m_roi);
bool aReturnValue = !m_bin.isOne() || !m_roi.isEmpty();
DEB_RETURN() << aReturnValue;
DEB_MEMBER_FUNCT();
op->setBin(m_bin);
op->setRoi(m_roi);
bool is_active = !m_bin.isOne() || !m_roi.isEmpty();
DEB_RETURN() << DEB_VAR1(is_active);
return aReturnValue;
return is_active;
}
// ----------------------------------------------------------------------------
......@@ -112,444 +113,445 @@ bool CtSwBinRoi::apply(SoftOpInternalMgr *op)
// ----------------------------------------------------------------------------
CtHwBinRoi::CtHwBinRoi(HwInterface *hw, CtSwBinRoi *sw_bin_roi, Size& size)
: m_sw_bin_roi(sw_bin_roi)
: m_sw_bin_roi(sw_bin_roi)
{
DEB_CONSTRUCTOR();
DEB_PARAM() << DEB_VAR2(*sw_bin_roi,size);
DEB_CONSTRUCTOR();
DEB_PARAM() << DEB_VAR2(*sw_bin_roi,size);
m_has_bin= hw->getHwCtrlObj(m_hw_bin);
m_has_roi= hw->getHwCtrlObj(m_hw_roi);
// m_has_hwflip= hw->getHwCtrlObj(m_hw_flip);
m_has_bin= hw->getHwCtrlObj(m_hw_bin);
m_has_roi= hw->getHwCtrlObj(m_hw_roi);
m_has_flip= hw->getHwCtrlObj(m_hw_flip);
m_max_size= size;
m_max_roi= Roi(Point(0,0), m_max_size);
m_size= m_max_size;
m_max_size= size;
m_max_roi= Roi(Point(0,0), m_max_size);
m_size= m_max_size;
}
CtHwBinRoi::~CtHwBinRoi()
{
DEB_DESTRUCTOR();
DEB_DESTRUCTOR();
}
void CtHwBinRoi::setMaxSize(const Size& size)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(size);
m_max_size= size;
m_max_roi.setSize(m_max_size / m_bin);
if (!m_max_roi.containsPoint(m_roi.getTopLeft()))
m_roi.reset();
else if (!m_max_roi.containsPoint(m_roi.getBottomRight()))
m_roi.setCorners(m_roi.getTopLeft(), m_max_roi.getBottomRight());
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(size);
_updateSize();
m_max_size= size;
m_max_roi.setSize(m_max_size / m_bin);
if (!m_max_roi.containsPoint(m_roi.getTopLeft())) {
m_roi.reset();
}
else if (!m_max_roi.containsPoint(m_roi.getBottomRight())) {
m_roi.setCorners(m_roi.getTopLeft(), m_max_roi.getBottomRight());
}
_updateSize();
}
void CtHwBinRoi::setBin(Bin& bin, bool round)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(bin,round);
if (!m_has_bin)
{
if (!round)
throw LIMA_CTL_EXC(NotSupported, "No hardware binning available");
}
else
{
Bin set_bin(bin);
if (!set_bin.isOne())
m_hw_bin->checkBin(set_bin);
if ((!round)&&(set_bin!=bin))
throw LIMA_CTL_EXC(InvalidValue, "Given hardware binning not possible");
if (set_bin != m_bin) {
m_roi= m_roi.getUnbinned(m_bin);