Commit 931a00b5 authored by Stéphane Albert's avatar Stéphane Albert
Browse files

ENH: Added AbstractImageModel::BuildContext; Added iamge-model ID support.

parent dfc225af
......@@ -59,6 +59,7 @@ AbstractImageModel
::AbstractImageModel( QObject* parent ) :
AbstractModel( parent ),
m_NativeLargestRegion(),
m_Id( -1 ),
m_CurrentLod( 0 )
{
}
......@@ -166,6 +167,12 @@ void
AbstractImageModel
::virtual_BuildModel( void* context )
{
if( context!=NULL )
{
BuildContext* buildContext = static_cast< BuildContext* >( context );
m_Id = buildContext->m_Id;
}
newChildModel< HistogramModel >();
newChildModel< QuicklookModel >();
}
......
......@@ -82,6 +82,36 @@ class Monteverdi2_EXPORT AbstractImageModel :
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public types.
public:
/**
* \class BuildContext
* \brief WIP.
*/
class BuildContext
{
//
// Public methods.
public:
/** \brief Constructor. */
BuildContext( const QString& filename =QString(),
int id =-1,
const QString& quicklook =QString() ) :
m_Id( id ),
m_Filename( filename ),
m_Quicklook( quicklook )
{
}
//
// Public attributes
public:
int m_Id;
QString m_Filename;
QString m_Quicklook;
};
//
// Public methods.
public:
......@@ -89,6 +119,9 @@ public:
/** Destructor */
virtual ~AbstractImageModel();
/** */
inline int GetId() const;
/** */
const QuicklookModel* GetQuicklookModel() const;
......@@ -217,6 +250,12 @@ private:
//
// Private attributes.
private:
/**
*/
int m_Id;
/**
*/
CountType m_CurrentLod;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
......@@ -244,6 +283,14 @@ private slots:
namespace mvd
{
/*****************************************************************************/
int
AbstractImageModel
::GetId() const
{
return m_Id;
}
/*****************************************************************************/
const HistogramModel*
AbstractImageModel
......
......@@ -84,28 +84,22 @@ DatasetModel
{
}
/*******************************************************************************/
#if 0
bool
DatasetModel
::SetContent( const QString& path, const QString& name )
{
return true;
}
#endif
/*******************************************************************************/
void
DatasetModel
::ImportImage( const QString& filename , int width, int height )
::ImportImage( const QString& filename, int width, int height )
{
LoadImage( filename, true, width, height );
LoadImage( filename, width, height, -1, QString() );
}
/*******************************************************************************/
void
DatasetModel
::LoadImage( const QString& filename, bool foo, int width, int height )
::LoadImage( const QString& filename,
int width,
int height,
int id,
const QString& quicklook )
{
// 1. Instanciate local image model.
VectorImageModel* vectorImageModel = new VectorImageModel( this );
......@@ -114,26 +108,40 @@ DatasetModel
try
{
//
// 2.1. Information.
// 2.1. Fill-in image-model build-contex with provided id (which
// may be -1 if first-time import of image-model.
AbstractImageModel::BuildContext context( filename, id, quicklook );
// Assign image-model ID to build-context if there is none
// provided but keep provided one to test if it's first time
// import or next time loading of image-model.
if( id<0 )
{
AbstractImageModelList aimList( GetImageModels() );
context.m_Id = aimList.indexOf( vectorImageModel );
qDebug()
<< "Generated ID: #" << context.m_Id << " for image-file " << filename;
}
//
// 2.2. Set image-model content.
// TODO: SetFilename() into VectorImageModel::virtual_BuildModel().
vectorImageModel->SetFilename( filename, width, height );
//
// 2.2. Generate cached data.
// TODO: generate image-model cached data (quicklook,
// histogram-list etc.)
vectorImageModel->BuildModel();
// 2.3. Build image-model structure and generate cached data).
vectorImageModel->BuildModel( &context );
assert( vectorImageModel->GetQuicklookModel()!=NULL );
// If first time, import image into descriptor.
if( foo )
// If it's first time, import image-model into descriptor.
if( id<0 )
{
AbstractImageModelList aimList( GetImageModels() );
int id = aimList.indexOf( vectorImageModel );
//
// 2.3: Add image to Dataset descriptor file.
// 2.3: Add image to Dataset descriptor file...
m_Descriptor->InsertImageModel(
id,
// ...providing newly calculated image-model ID.
context.m_Id,
vectorImageModel->GetFilename(),
&vectorImageModel->GetSettings(),
vectorImageModel->GetQuicklookModel()->GetFilename()
......@@ -205,6 +213,7 @@ DatasetModel
m_Descriptor = newChildModel< DatasetDescriptor >( &context );
// Load image-models from descriptor.
// TODO: Replace DatasetModel::BuildContext() by (width, height).
ParseDescriptor(buildContext);
}
}
......@@ -230,14 +239,18 @@ DatasetModel
qDebug()
<< "Input image:"
<< "\nid: " << id
<< "\nID: #" << id
<< "\nfilename: " << filename
<< "\nquicklook: " << quicklook;
// TODO: 1) Re-use quicklook filename.
// TODO: 2) Assign rendering-settings.
// TODO: 3) Remove WxH for screen best-fit during loading of model!
LoadImage( filename, false, bContext->m_Width, bContext->m_Height );
LoadImage(
filename,
bContext->m_Width, bContext->m_Height,
id,
quicklook
);
}
}
......
......@@ -97,11 +97,14 @@ public:
//
// Public methods.
public:
BuildContext( const QString& path, const QString& name, int width, int height ) :
BuildContext( const QString& path,
const QString& name,
int width =-1,
int height =-1 ) :
m_Path( path ),
m_Name( name ),
m_Width(width),
m_Height(height)
m_Width( width ),
m_Height( height )
{
}
......@@ -201,7 +204,11 @@ private:
inline AbstractImageModelList GetImageModels();
/** */
void LoadImage( const QString& filename, bool foo, int width, int height );
void LoadImage( const QString& filename,
int width,
int height,
int id,
const QString& quicklook );
/** */
void ParseDescriptor(BuildContext* bContext );
......
......@@ -472,10 +472,10 @@ private:
private:
/** Compute the linear buffer index according to the 2D region and
* its 2D index.This method is used when OTB_GL_USE_ACCEL is ON.
* \param index 2D index
* \param region 2D region
*/
* its 2D index.This method is used when OTB_GL_USE_ACCEL is ON.
* \param index 2D index
* \param region 2D region
*/
static inline
unsigned int
ComputeBufferIndex(const IndexType& index,
......
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