Commit abf81007 authored by kirov's avatar kirov
Browse files

+ added checkValid() to the FrameBuilder class

+ added getErrDesc(0 to the Exception class
+ added get/set m_pick



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@40 45c4679d-1946-429d-baad-37912b19538b
parent 6bc06d31
......@@ -32,6 +32,9 @@ class FrameBuilder {
void getRoi( Roi &roi ) const;
void setRoi( const Roi &roi );
void getPeaks( std::vector<struct GaussPeak> &peaks ) const;
void getPeaks( const std::vector<struct GaussPeak> &peaks );
void getNextFrame( unsigned char *ptr ) throw (Exception);
unsigned long getFrameNr();
void resetFrameNr( int frame_nr=0 );
......@@ -45,7 +48,7 @@ class FrameBuilder {
unsigned long m_frame_nr;
void checkValid() throw(Exception);
double dataXY( int x, int y );
template <class depth> void fillData( unsigned char *ptr );
};
......
......@@ -14,8 +14,8 @@ FrameBuilder::FrameBuilder()
{
m_frame_dim = FrameDim(1024, 1024, Bpp16);
m_bin = Bin(1,1);
m_roi = Roi(); // ???
GaussPeak p={512, 512, 100, 100};
m_roi = Roi(0, Size(0,0)); // Or the whole frame ???
GaussPeak p={512, 512, 100, 100}; // Binned or unbinned ???
m_peaks.push_back(p);
m_grow_factor = 1.00;
m_frame_nr = 0;
......@@ -31,6 +31,7 @@ FrameBuilder::FrameBuilder( FrameDim &frame_dim, Bin &bin, Roi &roi,
m_peaks(peaks),
m_grow_factor(grow_factor)
{
checkValid();
m_frame_nr = 0;
}
......@@ -40,6 +41,28 @@ FrameBuilder::~FrameBuilder()
}
void FrameBuilder::checkValid() throw(Exception)
{
FrameDim bin_dim = m_frame_dim / m_bin;
Roi roi;
if( m_roi.getSize() != 0 ) {
bin_dim.checkValidRoi(m_roi);
roi= m_roi;
} else {
roi = Roi(0, bin_dim.getSize());
}
// Check that the peaks set are compatible with the RoI
vector<GaussPeak>::iterator p;
for( p = m_peaks.begin( ); p != m_peaks.end( ); ++p) {
if( ! roi.containsPoint(Point(p->x0, p->y0)) )
throw Exception( Hardware, InvalidValue, "Peak",
__FILE__, __FUNCTION__, __LINE__ );
}
}
void FrameBuilder::getFrameDim( FrameDim &dim ) const
{
dim = m_frame_dim;
......@@ -49,6 +72,9 @@ void FrameBuilder::getFrameDim( FrameDim &dim ) const
void FrameBuilder::setFrameDim( const FrameDim &dim )
{
m_frame_dim = dim;
// Reset Bin and RoI or just check validity?
checkValid();
}
......@@ -61,6 +87,8 @@ void FrameBuilder::getBin( Bin &bin ) const
void FrameBuilder::setBin( const Bin &bin )
{
m_bin = bin;
checkValid();
}
......@@ -73,19 +101,24 @@ void FrameBuilder::getRoi( Roi &roi ) const
void FrameBuilder::setRoi( const Roi &roi )
{
m_roi = roi;
checkValid();
}
/*
FrameDim& FrameBuilder::getFrameDim() {
return m_frame_dim;
void FrameBuilder::getPeaks( std::vector<struct GaussPeak> &peaks ) const
{
peaks = m_peaks;
}
void FrameBuilder::setFrameDim(FrameDim &frame_dim) {
m_frame_dim = frame_dim;
void FrameBuilder::getPeaks( const std::vector<struct GaussPeak> &peaks )
{
m_peaks = peaks;
checkValid();
}
*/
#define SGM_FWHM 0.42466090014400952136075141705144 // 1/(2*sqrt(2*ln(2)))
......@@ -150,7 +183,7 @@ void FrameBuilder::getNextFrame( unsigned char *ptr ) throw (Exception)
fillData<unsigned long>(ptr);
break;
default:
throw Exception( Hardware, NotSupported, "",
throw Exception( Hardware, NotSupported, "Depth",
__FILE__, __FUNCTION__, __LINE__ );
}
++m_frame_nr;
......
#include <vector>
#include <exception>
#include <iostream>
#include "FrameBuilder.h"
#include "BufferSave.h"
#include "SizeUtils.h"
......@@ -11,6 +13,8 @@ using namespace lima;
int main( void )
{
try {
FrameBuilder fb;
FrameDim full_fd;
......@@ -22,7 +26,7 @@ int main( void )
FrameDim fd = full_fd / bin;
BufferSave bs(BufferSave::EDF, "boza");
bs.setTotFileFrames(5);
bs.setTotFileFrames(1);
int size = fd.getMemSize();
AutoPtr<unsigned char, true> buffer;
......@@ -40,4 +44,9 @@ int main( void )
}
return 0;
} catch (Exception &e) {
cout << "Exception: " << e.getErrDesc() << endl;
return -1;
}
}
......@@ -24,6 +24,8 @@ class Exception
String file_name, String funct_name, int line_nr);
String &getErrDesc();
private:
Layer m_layer;
ErrorType m_err_type;
......
#include <string>
#include "Exceptions.h"
using namespace lima;
using namespace std;
Exception::Exception(Layer layer, ErrorType err_type, String err_desc,
String file_name, String funct_name, int line_nr)
......@@ -8,3 +10,9 @@ Exception::Exception(Layer layer, ErrorType err_type, String err_desc,
m_file_name(file_name), m_funct_name(funct_name), m_line_nr(line_nr)
{
}
string & Exception::getErrDesc()
{
return m_err_desc;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment