Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
cf02dfd9
Commit
cf02dfd9
authored
Mar 14, 2013
by
Stéphane Albert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Added Core/mvdApplication (factorized code common to viewer and catalogue applications).
parent
e95baaa3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
533 additions
and
2 deletions
+533
-2
Code/Application/Catalogue/main.cxx
Code/Application/Catalogue/main.cxx
+2
-2
Code/Common/Core/CMakeLists.txt
Code/Common/Core/CMakeLists.txt
+2
-0
Code/Common/Core/mvdApplication.cxx
Code/Common/Core/mvdApplication.cxx
+243
-0
Code/Common/Core/mvdApplication.h
Code/Common/Core/mvdApplication.h
+286
-0
No files found.
Code/Application/Catalogue/main.cxx
View file @
cf02dfd9
...
...
@@ -63,7 +63,7 @@ main( int argc, char* argv[] )
// TODO: Move into I18nApplication.
setlocale
(
LC_NUMERIC
,
"C"
);
/*
#if 0
// TODO: 1) MVD2-viewer: Factorize settings loading between Viewer & Catalogue // Check if the application have a settings file already available
bool appHasSettingsFile = application.HasSettingsFile();
bool appHasIncorrectCacheDir(false);
...
...
@@ -77,7 +77,7 @@ main( int argc, char* argv[] )
appHasIncorrectCacheDir = true;
}
}
*/
#endif
mvd
::
MainWindow
mainWindow
;
...
...
Code/Common/Core/CMakeLists.txt
View file @
cf02dfd9
...
...
@@ -6,6 +6,7 @@ set( Common_Core_SOURCES
mvdAbstractImageModel.cxx
mvdAbstractModel.cxx
mvdAlgorithm.cxx
mvdApplication.cxx
mvdDatasetDescriptor.cxx
mvdDatasetModel.cxx
mvdHistogramModel.cxx
...
...
@@ -26,6 +27,7 @@ set( Common_Core_HEADERS_MOC
mvdAbstractImageModel.h
mvdAbstractModel.h
mvdAlgorithm.h
mvdApplication.h
mvdDatasetDescriptor.h
mvdDatasetModel.h
mvdHistogramModel.h
...
...
Code/Common/Core/mvdApplication.cxx
0 → 100644
View file @
cf02dfd9
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdApplication.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdAbstractModel.h"
#include "Core/mvdDatasetModel.h"
#include "Core/mvdVectorImageModel.h"
//
// Class implementation.
namespace
mvd
{
/*
TRANSLATOR mvd::Application
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
/* CONSTANTS */
const
char
*
Application
::
DATASET_EXT
=
".ds"
;
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
/*****************************************************************************/
void
Application
::
DatasetPathName
(
QString
&
path
,
QString
&
name
,
const
QString
&
imageFilename
)
{
// '/tmp/archive.tar.gz'
QFileInfo
fileInfo
(
imageFilename
);
#if 0
// Dataset is stored into image-file path.
// E.g. '/tmp'
path = fileInfo.path();
#else
// Dataset is stored into application cache-directory.
// E.g. '$HOME/<CACHE_DIR>'
path
=
Application
::
Instance
()
->
GetCacheDir
().
path
();
#endif
// '[_tmp_]archive.tar.gz.<SUFFIX>'
name
=
#if 1
fileInfo
.
canonicalPath
().
replace
(
QRegExp
(
"[/
\\\\
:]+"
),
"_"
)
+
"_"
+
#endif
fileInfo
.
fileName
()
+
Application
::
DATASET_EXT
;
}
/*****************************************************************************/
DatasetModel
*
Application
::
LoadDatasetModel
(
const
QString
&
imageFilename
,
int
width
,
int
height
)
{
// New model.
DatasetModel
*
model
=
new
DatasetModel
();
// Retrive path and name.
QString
path
;
QString
name
;
Application
::
DatasetPathName
(
path
,
name
,
imageFilename
);
qDebug
()
<<
"Dataset path: "
<<
path
;
qDebug
()
<<
"Dataset name: "
<<
name
;
// Setup QObject
model
->
setObjectName
(
QDir
(
path
).
filePath
(
name
)
);
try
{
// try if the filename is valid
VectorImageModel
::
EnsureValidImage
(
imageFilename
);
// Build model (relink to cached data).
DatasetModel
::
BuildContext
context
(
path
,
name
,
width
,
height
);
model
->
BuildModel
(
&
context
);
// Load image if DatasetModel is empty.
if
(
!
model
->
HasSelectedImageModel
()
)
{
// Import image from filename given (w; h) size to choose
// best-fit resolution.
model
->
ImportImage
(
imageFilename
,
width
,
height
);
}
}
catch
(
std
::
exception
&
exc
)
{
delete
model
;
model
=
NULL
;
throw
;
}
return
model
;
}
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
/*******************************************************************************/
Application
::
Application
(
int
&
argc
,
char
**
argv
)
:
I18nApplication
(
argc
,
argv
),
m_Model
(
NULL
)
{
InitializeCore
();
}
/*******************************************************************************/
Application
::~
Application
()
{
}
/*******************************************************************************/
void
Application
::
SetModel
(
AbstractModel
*
model
)
{
emit
AboutToChangeSelectedModel
(
model
);
delete
m_Model
;
m_Model
=
model
;
if
(
model
!=
NULL
)
m_Model
->
setParent
(
this
);
emit
SelectedModelChanged
(
m_Model
);
}
/*******************************************************************************/
void
Application
::
InitializeCore
()
{
setObjectName
(
"Application"
);
//
// Setup application tags.
//
QCoreApplication
::
setApplicationName
(
PROJECT_NAME
);
QCoreApplication
::
setApplicationVersion
(
Monteverdi2_VERSION_STRING
);
//
// Setup organization tags.
//
QCoreApplication
::
setOrganizationName
(
"OrfeoToolBox"
);
QCoreApplication
::
setOrganizationDomain
(
"orfeo-toolbox.org"
);
#ifndef Q_WS_MAC
setWindowIcon
(
QIcon
(
QLatin1String
(
":/images/application_icon"
)));
#endif
}
/*******************************************************************************/
bool
Application
::
HasSettingsFile
()
{
// The settings file should contain the cacheDir key to be valid
QSettings
settings
;
settings
.
sync
();
return
(
(
settings
.
status
()
==
QSettings
::
NoError
)
&&
settings
.
contains
(
"cacheDir"
));
}
/*******************************************************************************/
void
Application
::
ReadCacheDirFromSettings
()
{
QSettings
settings
;
QString
cacheDirSetting
=
settings
.
value
(
"cacheDir"
).
toString
();
m_CacheDir
.
setPath
(
cacheDirSetting
);
}
/*******************************************************************************/
void
Application
::
WriteCacheDirIntoSettings
()
{
QSettings
settings
;
settings
.
setValue
(
"cacheDir"
,
m_CacheDir
.
path
());
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
}
// end namespace 'mvd'
Code/Common/Core/mvdApplication.h
0 → 100644
View file @
cf02dfd9
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __mvdApplication_h
#define __mvdApplication_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE 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)
#include "Core/mvdI18nApplication.h"
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace
mvd
{
//
// Class declaration.
class
AbstractModel
;
class
DatasetModel
;
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/** \class Application
*
*/
class
Monteverdi2_EXPORT
Application
:
public
I18nApplication
{
/*-[ QOBJECT SECTION ]-----------------------------------------------------*/
Q_OBJECT
;
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public constants.
public:
static
const
char
*
DATASET_EXT
;
//
// Public methods.
public:
/**
* \brief Constructor.
*
* \param argc Command-line argument count in the argv array.
* \param argv Array of command-argument (whitespace-separated) strings.
*/
Application
(
int
&
argc
,
char
**
argv
);
/** \brief Destructor. */
virtual
~
Application
();
/**
*/
inline
const
AbstractModel
*
GetModel
()
const
;
/**
*/
inline
AbstractModel
*
GetModel
();
/**
*/
template
<
typename
TModel
>
inline
const
TModel
*
GetModel
()
const
;
/**
*/
template
<
typename
TModel
>
inline
TModel
*
GetModel
();
/**
*
*/
bool
HasSettingsFile
();
/**
*
*/
void
ReadCacheDirFromSettings
();
/**
*
*/
void
WriteCacheDirIntoSettings
();
//
// STATIC METHODS.
/**
* \brief Get the singleton instance of application as an
* Application pointer.
*
* \return The singleton instance of Application.
*/
inline
static
Application
*
Instance
();
/**
* \brief Get the singleton constant instance of application as an
* Application pointer.
*
* \return The singleton constant instance of I18nApplication.
*/
inline
static
const
Application
*
ConstInstance
();
/**
*/
static
void
DatasetPathName
(
QString
&
path
,
QString
&
name
,
const
QString
&
imageFilename
);
/**
*/
static
DatasetModel
*
LoadDatasetModel
(
const
QString
&
imageFilename
,
int
width
,
int
height
);
public
slots
:
/**
*/
// Method could be inline but it's better not new/delete in inline
// methods (heap and memory-alignment contexts).
void
SetModel
(
AbstractModel
*
model
);
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// Signals.
signals:
/**
*/
void
AboutToChangeSelectedModel
(
const
AbstractModel
*
);
/**
*/
void
SelectedModelChanged
(
AbstractModel
*
);
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
//
// Protected attributes.
protected:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private methods.
private:
/**
*/
void
InitializeCore
();
//
// Private attributes.
private:
/**
*/
AbstractModel
*
m_Model
;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
// Slots
private
slots
:
};
/*****************************************************************************/
/* INLINE SECTION */
/*****************************************************************************/
inline
Application
*
Application
::
Instance
()
{
return
I18nApplication
::
Instance
<
Application
>
();
}
/*****************************************************************************/
inline
const
Application
*
Application
::
ConstInstance
()
{
return
I18nApplication
::
ConstInstance
<
Application
>
();
}
/*****************************************************************************/
inline
const
AbstractModel
*
Application
::
GetModel
()
const
{
return
m_Model
;
}
/*****************************************************************************/
inline
AbstractModel
*
Application
::
GetModel
()
{
return
m_Model
;
}
/*****************************************************************************/
template
<
typename
TModel
>
inline
const
TModel
*
Application
::
GetModel
()
const
{
return
qobject_cast
<
const
TModel
*
>
(
m_Model
);
}
/*****************************************************************************/
template
<
typename
TModel
>
inline
TModel
*
Application
::
GetModel
()
{
return
qobject_cast
<
TModel
*
>
(
m_Model
);
}
/*****************************************************************************/
}
// end namespace 'mvd'
#endif // __Application_h
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment