Commit 756d6c8d authored by Stéphane Albert's avatar Stéphane Albert
Browse files

ENH: Applied settings read from XML descriptor to VectorImageModel when loading existing dataset.

parent 931a00b5
......@@ -93,7 +93,7 @@ DatasetModel
}
/*******************************************************************************/
void
AbstractImageModel*
DatasetModel
::LoadImage( const QString& filename,
int width,
......@@ -101,6 +101,10 @@ DatasetModel
int id,
const QString& quicklook )
{
// Check input parameters.
assert( (id<0 && quicklook.isEmpty()) ||
(id>=0 && !quicklook.isEmpty()) );
// 1. Instanciate local image model.
VectorImageModel* vectorImageModel = new VectorImageModel( this );
......@@ -120,13 +124,14 @@ DatasetModel
context.m_Id = aimList.indexOf( vectorImageModel );
qDebug()
<< "Generated ID: #" << context.m_Id << " for image-file " << filename;
<< "Generated ID" << context.m_Id
<< "for image-file " << context.m_Filename << ".";
}
//
// 2.2. Set image-model content.
// TODO: SetFilename() into VectorImageModel::virtual_BuildModel().
vectorImageModel->SetFilename( filename, width, height );
vectorImageModel->SetFilename( context.m_Filename, width, height );
//
......@@ -161,6 +166,8 @@ DatasetModel
// Forward exception to upper level (GUI).
throw;
}
return vectorImageModel;
}
/*******************************************************************************/
......@@ -221,36 +228,48 @@ DatasetModel
/*******************************************************************************/
void
DatasetModel
::ParseDescriptor(BuildContext* bContext )
::ParseDescriptor( BuildContext* context )
{
assert( context );
for( QDomElement imageElt( m_Descriptor->FirstImageElement() );
!imageElt.isNull();
imageElt = DatasetDescriptor::NextImageSiblingElement( imageElt ) )
{
// Locals.
int id = -1;
QString filename;
QString quicklook;
VectorImageModel::Settings settings;
// Read image-model descriptor information.
DatasetDescriptor::GetImageModel(
imageElt,
id, filename, &settings, quicklook
);
// Traces.
qDebug()
<< "Input image:"
<< "\nID: #" << id
<< "\nfilename: " << filename
<< "\nquicklook: " << quicklook;
<< "\nID:" << id
<< "\nfilename:" << filename
<< "\nquicklook:" << quicklook;
// TODO: 2) Assign rendering-settings.
// TODO: 3) Remove WxH for screen best-fit during loading of model!
LoadImage(
AbstractImageModel* imageModel = LoadImage(
filename,
bContext->m_Width, bContext->m_Height,
context->m_Width, context->m_Height,
id,
quicklook
);
// Access vector image-model.
VectorImageModel* vectorImageModel =
qobject_cast< VectorImageModel* >( imageModel );
assert( vectorImageModel!=NULL );
// Re-assign rendering-settings to image-model.
vectorImageModel->SetSettings( settings );
}
}
......
......@@ -204,11 +204,11 @@ private:
inline AbstractImageModelList GetImageModels();
/** */
void LoadImage( const QString& filename,
int width,
int height,
int id,
const QString& quicklook );
AbstractImageModel* LoadImage( const QString& filename,
int width,
int height,
int id,
const QString& quicklook );
/** */
void ParseDescriptor(BuildContext* bContext );
......
......@@ -752,7 +752,7 @@ void
VectorImageModel
::OnModelUpdated()
{
qDebug() << "OnModelUpdated()";
qDebug() << "ID " << GetId() << " - OnModelUpdated()";
RenderingFilterType::RenderingFunctionType* renderingFunc =
m_RenderingFilter->GetRenderingFunction();
......@@ -768,19 +768,18 @@ VectorImageModel
// TODO: Remove temporary hack (rendering settings).
QuicklookModel* quicklookModel = GetQuicklookModel();
// If image-model is not quicklook-model.
if( quicklookModel!=NULL )
{
// Update quicklook rendering-settings.
quicklookModel->SetSettings( GetSettings() );
quicklookModel->OnModelUpdated();
}
#if 0
// Ensure type of parent model.
assert( GetDatasetModel()!=NULL );
qDebug() << GetDatasetModel();
// Get parent dataset model.
DatasetModel* datasetModel = GetDatasetModel();
#endif
// Ensure parent model is dataset-model.
assert( GetDatasetModel()!=NULL );
// Get parent dataset-model.
DatasetModel* datasetModel = GetDatasetModel();
}
// TODO: Update DatasetDescriptor.
// datasetModel->Foo();
......
......@@ -324,6 +324,9 @@ public:
/** */
inline Settings& GetSettings();
/** */
inline void SetSettings( const Settings& settings );
/** */
inline otb::GenericRSTransform<> * GetGenericRSTransform();
......@@ -405,9 +408,6 @@ signals:
// Protected methods.
protected:
/** */
inline void SetSettings( const Settings& settings );
/** Clear buffer */
void ClearBuffer();
......@@ -632,7 +632,7 @@ VectorImageModel
inline
void
VectorImageModel
::SetSettings(const Settings& settings)
::SetSettings( const Settings& settings )
{
m_Settings = settings;
}
......
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