Commit daa50679 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE #59] parsing ROI info from file done. These info are not yet applied. Thats the next step.

parent 31acf5e6
......@@ -24,6 +24,14 @@
#include <string>
#include <boost/regex.hpp>
#include "../common/WStringUtils.h"
#include "../common/WProperties.h"
#include "../common/WPropertyBase.h"
#include "../common/WPropertyVariable.h"
#include "../common/WPropertyTypes.h"
#include "../common/exceptions/WFileNotFound.h"
#include "../common/WLogger.h"
#include "../graphicsEngine/WROI.h"
#include "../graphicsEngine/WROIBox.h"
......@@ -43,10 +51,59 @@ WRoiProjectFileIO::~WRoiProjectFileIO()
// cleanup
}
bool WRoiProjectFileIO::parse( std::string /* line */, unsigned int /* lineNumber */ )
bool WRoiProjectFileIO::parse( std::string line, unsigned int lineNumber )
{
// this is the proper regular expression for modules
static const boost::regex branchRe( "^ *SELECTOR_BRANCH:([0-9]*)$" );
static const boost::regex roiBoxRe( "^ *SELECTOR_ROIBOX:([0-9]*):SELECTOR_BRANCH([0-9]*)$" );
static const boost::regex branchPropRe( "^ *PROPERTY:\\(SELECTOR_BRANCH([0-9]*),(.*)\\)=(.*)$" );
static const boost::regex roiBoxPropRe( "^ *PROPERTY:\\(SELECTOR_ROIBOX([0-9]*),(.*)\\)=(.*)$" );
boost::smatch matches; // the list of matches
if( boost::regex_match( line, matches, branchRe ) )
{
Branch branch = string_utils::fromString< Branch >( matches[1] );
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Branch with ID " << branch;
// store info
m_branches.push_back( branch );
}
else if( boost::regex_match( line, matches, roiBoxRe ) )
{
Branch parentBranch = string_utils::fromString< Branch >( matches[2] );
RoiID roiID = string_utils::fromString< RoiID >( matches[1] );
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": ROI with ID " << roiID << " in Branch " << parentBranch;
// store info
m_rois.push_back( Roi( roiID, parentBranch ) );
}
else if( boost::regex_match( line, matches, branchPropRe ) )
{
Branch branch = string_utils::fromString< Branch >( matches[1] );
std::string prop = matches[2];
std::string propValue = matches[3];
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Property \"" << prop << "\" of Branch " << branch
<< " set to " << propValue;
// store info
m_branchProperties[ branch ] = Property( prop, propValue );
}
else if( boost::regex_match( line, matches, roiBoxPropRe ) )
{
RoiID roiID = string_utils::fromString< RoiID >( matches[1] );
std::string prop = matches[2];
std::string propValue = matches[3];
wlog::debug( "Project Loader [Parser]" ) << "Line " << lineNumber << ": Property \"" << prop << "\" of ROI " << roiID
<< " set to " << propValue;
// store info
m_roiProperties[ roiID ] = Property( prop, propValue );
}
else
{
return false;
}
// read something
return false;
return true;
}
void WRoiProjectFileIO::done()
......
......@@ -26,6 +26,10 @@
#define WROIPROJECTFILEIO_H
#include <string>
#include <vector>
#include <map>
#include "boost/tuple/tuple.hpp"
#include "../common/WProjectFileIO.h"
......@@ -70,6 +74,45 @@ public:
protected:
private:
/**
* Branch by ID
*/
typedef unsigned int Branch;
/**
* Property for branch/roi with ID. Property name and value are stored as string
*/
typedef boost::tuple< std::string, std::string > Property;
/**
* All loaded branch IDs
*/
std::vector< Branch > m_branches;
/**
* Properties of each branch
*/
std::map< Branch, Property > m_branchProperties;
/**
* ID of a ROI
*/
typedef unsigned int RoiID;
/**
* ROI by ID, second is parent branch ID
*/
typedef boost::tuple< RoiID, Branch > Roi;
/**
* All loaded rois
*/
std::vector< Roi > m_rois;
/**
* Properties of each branch
*/
std::map< RoiID, Property > m_roiProperties;
};
#endif // WROIPROJECTFILEIO_H
......
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