Commit f00c155d authored by Stéphane Albert's avatar Stéphane Albert

ENH: Moved generated quicklook image-file into dataset directory; Added...

ENH: Moved generated quicklook image-file into dataset directory; Added DatasetModel::GetDirectory() accessor; Added QuicklookModel::GetImageModel<>() accessors; Added VectorImageModel::GetDatasetModel() accessor; Remove unnecessary typedefs in QuicklookModel.h.
parent 8d123df9
......@@ -97,7 +97,7 @@ DatasetModel
::ImportImage( const QString& filename , int w, int h )
{
// 1. Instanciate local image model.
VectorImageModel* vectorImageModel = new VectorImageModel();
VectorImageModel* vectorImageModel = new VectorImageModel( this );
vectorImageModel->setObjectName( filename );
......
......@@ -130,6 +130,10 @@ public:
/** */
inline AbstractImageModel* GetSelectedImageModel();
/**
*/
inline const QDir& GetDirectory() const;
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
......@@ -209,6 +213,15 @@ private slots:
namespace mvd
{
/*****************************************************************************/
inline
const QDir&
DatasetModel
::GetDirectory() const
{
return m_Directory;
}
/*****************************************************************************/
inline
bool
......
......@@ -276,7 +276,7 @@ I18nApplication
QDir cacheDir( homeDir );
if( !cacheDir.cd( I18nApplication::CACHE_DIR ) )
if( !cacheDir.cd( I18nApplication::CACHE_DIR_NAME ) )
throw SystemError(
ToStdString(
QString( "('%1')" ).arg( homeDir.filePath( I18nApplication::CACHE_DIR_NAME ) )
......@@ -335,8 +335,6 @@ I18nApplication
return true;
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
......
......@@ -134,6 +134,22 @@ private slots:
/*****************************************************************************/
/* INLINE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
} // end namespace 'mvd'
......
......@@ -52,6 +52,15 @@ namespace mvd
*/
/*****************************************************************************/
/* CONSTANTS */
const char* QuicklookModel::IMAGE_FILE_EXT = ".ql";
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
......@@ -75,37 +84,44 @@ QuicklookModel
{
//
// get the parent vector image model
VectorImageModel * viModel = qobject_cast< VectorImageModel* >( parent() );
const VectorImageModel* viModel = GetImageModel< VectorImageModel >();
assert( viModel!=NULL );
// get the filename and use it to compose the quicklook filename
const char* filename = viModel->GetFilename().toAscii().constData();
std::string fnameNoExt = itksys::SystemTools::GetFilenameWithoutExtension( filename );
std::string path = itksys::SystemTools::GetFilenamePath( filename );
std::string ext = itksys::SystemTools::GetFilenameExtension( filename );
const DatasetModel* datasetModel = viModel->GetDatasetModel();
assert( datasetModel!=NULL );
std::ostringstream qlfname;
// Source image file information.
QFileInfo imageFileInfo( viModel->GetFilename() );
if(path!="")
{
qlfname << path<<"/";
}
// Quicklook file information.
QFileInfo quicklookFileInfo(
datasetModel->GetDirectory().path(),
imageFileInfo.completeBaseName()
+ QuicklookModel::IMAGE_FILE_EXT
+ "."
+ imageFileInfo.suffix()
);
qlfname<<fnameNoExt<<"_quicklook.tif";
// Quicklook filename.
QString quicklookFilename( quicklookFileInfo.filePath() );
// check if the file exists
if (!itksys::SystemTools::FileExists(qlfname.str().c_str()))
// First time?
if( !quicklookFileInfo.exists() )
{
// write the file on the disk
VectorImageFileWriterType::Pointer writer = VectorImageFileWriterType::New();
writer->SetFileName(qlfname.str());
writer->SetInput(viModel->ToImage());
writer->Update();
// Instanciate a quicklook file writer.
VectorImageFileWriterType::Pointer fileWriter(
VectorImageFileWriterType::New()
);
// Write quicklook file on the disk.
fileWriter->SetFileName( ToStdString( quicklookFilename ) + ".toto" );
fileWriter->SetInput( viModel->ToImage() );
fileWriter->Update();
}
// reload the quicklook
QString qlname(qlfname.str().c_str());
SetFilename(qlname, 512, 512);
// Source stored quicklook image-file.
// TODO: Remove hard-coded 512x512 px size.
SetFilename( quicklookFilename, 512, 512 );
// Initialize RgbaImageModel.
InitializeRgbaPipeline();
......
......@@ -89,11 +89,45 @@ public:
public:
/** Constructor */
QuicklookModel( QObject * parent =NULL );
QuicklookModel( QObject* parent =NULL );
/** Destructor */
virtual ~QuicklookModel();
/**
* \brief Get the parent image-model of this quicklook image as an
* AbstractImageModel.
*
* \return The parent image-model of this quicklook image.
*/
inline const AbstractImageModel* GetImageModel() const;
/**
* \brief Get the parent image-model of this quicklook image as an
* AbstractImageModel.
*
* \return The parent image-model of this quicklook image.
*/
inline AbstractImageModel* GetImageModel();
/**
* \brief Get the parent image-model of this quicklook image as a
* TImageModel.
*
* \return The parent image-model of this quicklook image.
*/
template< typename TImageModel >
inline const TImageModel* GetImageModel() const;
/**
* \brief Get the parent image-model of this quicklook image as a
* TImageModel.
*
* \return The parent image-model of this quicklook image.
*/
template< typename TImageModel >
inline TImageModel* GetImageModel();
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
//
......@@ -127,17 +161,6 @@ protected:
//
// Private types.
private:
/**
* Display type of source image (to OpenGL).
*/
typedef RGBAImageType DisplayImageType;
// /**
// * Extract filter.
// */
// typedef
// itk::ExtractImageFilter< SourceImageType, SourceImageType >
// ExtractFilterType;
//
// Private methods.
......@@ -146,17 +169,60 @@ private:
//
// Private attributes.
private:
/**
* \brief The quicklook image-file extension
* (e.g. '/tmp/my_source_image.tif.ql'.)
*/
static const char* IMAGE_FILE_EXT;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Slots.
private slots:
/** */
};
} // end namespace 'mvd'
/*****************************************************************************/
/* INLINE SECTION */
namespace mvd
{
/*****************************************************************************/
const AbstractImageModel*
QuicklookModel
::GetImageModel() const
{
return GetImageModel< AbstractImageModel >();
}
/*****************************************************************************/
AbstractImageModel*
QuicklookModel
::GetImageModel()
{
return GetImageModel< AbstractImageModel >();
}
/*****************************************************************************/
template< typename TImageModel >
const TImageModel*
QuicklookModel
::GetImageModel() const
{
return qobject_cast< const TImageModel* >( parent() );
}
/*****************************************************************************/
template< typename TImageModel >
TImageModel*
QuicklookModel
::GetImageModel()
{
return qobject_cast< TImageModel* >( parent() );
}
} // end namespace 'mvd'
......
......@@ -29,12 +29,6 @@
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdColorSetupWidget.h"
#include "mvdAbstractImageModel.h"
#include "mvdTypes.h"
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
......@@ -51,6 +45,12 @@
#include "otbRenderingImageFilter.h"
#include "otbGenericRSTransform.h"
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdColorSetupWidget.h"
#include "mvdAbstractImageModel.h"
#include "mvdTypes.h"
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
......@@ -64,6 +64,7 @@ namespace mvd
{
//
// Internal classes pre-declaration.
class DatasetModel;
/*****************************************************************************/
......@@ -256,6 +257,20 @@ public:
/** Destructor */
virtual ~VectorImageModel();
/**
* \brief Get the parent DatasetModel.
*
* \return The parent DatasetModel.
*/
inline const DatasetModel* GetDatasetModel() const;
/**
* \brief Get the parent DatasetModel.
*
* \return The parent DatasetModel.
*/
inline DatasetModel* GetDatasetModel();
/** */
// TODO: Move into template wrapper base-class.
SourceImageType::ConstPointer ToImage() const;
......@@ -526,9 +541,29 @@ private slots:
/*****************************************************************************/
/* INLINE SECTION */
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdDatasetModel.h"
namespace mvd
{
/*****************************************************************************/
const DatasetModel*
VectorImageModel
::GetDatasetModel() const
{
return qobject_cast< const DatasetModel* >( parent() );
}
/*****************************************************************************/
DatasetModel*
VectorImageModel
::GetDatasetModel()
{
return qobject_cast< DatasetModel* >( parent() );
}
/*****************************************************************************/
inline
VectorImageModel::SourceImageType::ConstPointer
......
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