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

ENH: Added ColorSetupWidget::Set/GetCurrentIndex(); Documented...

ENH: Added ColorSetupWidget::Set/GetCurrentIndex(); Documented ColorSetupWidget; Initialized ColorSetupWidget and VectorImageModel::Settings with ImageMetadataInterface::GetDefaultDisplay() on File/Load.
parent e6a33a51
......@@ -187,6 +187,14 @@ MainWindow::onSelectedModelChanged( const AbstractModel* model )
dynamic_cast< const VectorImageModel* >( model );
colorSetupWidget->SetComponents( vectorImageModel->GetBandNames() );
for( int i=0; i<ColorSetupWidget::CHANNEL_COUNT; ++i )
{
colorSetupWidget->SetCurrentIndex(
ColorSetupWidget::Channel( i ),
vectorImageModel->GetSettings().m_RGBChannels[ i ]
);
}
}
/*****************************************************************************/
......
......@@ -62,7 +62,8 @@ namespace mvd
* Because Qt uses a shallow mecanism to copy containers, the returned
* QStringList is shallow-copied.
*/
inline QStringList ToQStringList( const StringVector& sv );
inline
QStringList ToQStringList( const StringVector& sv );
/**
* Append the content of a StringVector object to the content of a
......@@ -71,8 +72,9 @@ inline QStringList ToQStringList( const StringVector& sv );
* Because Qt uses a shallow mecanism to copy containers, the returned
* QStringList is shallow-copied.
*/
inline QStringList AppendToQStringList( QStringList& qsl,
const StringVector& sv );
inline
QStringList AppendToQStringList( QStringList& qsl,
const StringVector& sv );
//
// Inlined-functions implementations.
......
......@@ -37,6 +37,18 @@
namespace mvd
{
namespace
{
const char* QCOMBOBOX_NAMES[ /* ColorSetupWidget::CHANNEL_COUNT */ ] = {
"m_RedComboBox",
"m_GreenComboBox",
"m_BlueComboBox"
};
}
/*
TRANSLATOR mvd::ColorSetupWidget
......@@ -77,7 +89,8 @@ ColorSetupWidget
/*******************************************************************************/
void
ColorSetupWidget::SetComponents( const QStringList& components )
ColorSetupWidget
::SetComponents( const QStringList& components )
{
m_Components = components;
......@@ -87,7 +100,7 @@ ColorSetupWidget::SetComponents( const QStringList& components )
QStringList itemTexts( components );
itemTexts.prepend( "NIL" );
itemTexts.prepend( tr( "none" ) );
for( int i=1;
i<itemTexts.size();
......@@ -107,6 +120,7 @@ ColorSetupWidget::SetComponents( const QStringList& components )
m_UI->m_GreenComboBox->addItems( itemTexts );
m_UI->m_BlueComboBox->addItems( itemTexts );
/*
switch( components.size() )
{
case 0:
......@@ -131,6 +145,32 @@ ColorSetupWidget::SetComponents( const QStringList& components )
m_UI->m_BlueComboBox->setCurrentIndex( 3 );
break;
}
*/
// Black screen.
m_UI->m_RedComboBox->setCurrentIndex( 0 );
m_UI->m_GreenComboBox->setCurrentIndex( 0 );
m_UI->m_BlueComboBox->setCurrentIndex( 0 );
}
/*******************************************************************************/
void
ColorSetupWidget
::SetCurrentIndex( Channel channel, int index )
{
QComboBox* comboBox = findChild< QComboBox* >( QCOMBOBOX_NAMES[ channel ] );
comboBox->setCurrentIndex( index<0 ? 0 : index + 1 );
}
/*******************************************************************************/
int
ColorSetupWidget
::GetCurrentIndex( Channel channel )
{
QComboBox* comboBox = findChild< QComboBox* >( QCOMBOBOX_NAMES[ channel ] );
return comboBox->currentIndex() - 1;
}
/*******************************************************************************/
......
......@@ -56,15 +56,17 @@ namespace Ui
class ColorSetupWidget;
}
/** \class ColorSetupWidget
*
/**
* \class ColorSetupWidget
*/
class Monteverdi2_EXPORT ColorSetupWidget :
public QWidget
{
Q_OBJECT;
/** */
/**
* The (user) component-name list.
*/
Q_PROPERTY( QStringList m_Components
READ GetComponents
WRITE SetComponents );
......@@ -72,6 +74,9 @@ class Monteverdi2_EXPORT ColorSetupWidget :
//
// Public types.
public:
/**
* Constants identifying the video-channels.
*/
enum Channel
{
CHANNEL_NONE = -1,
......@@ -93,10 +98,37 @@ public:
/** Destructor */
virtual ~ColorSetupWidget();
/** */
void SetComponents( const QStringList& );
/** */
/**
* Set the component-name list.
*
* This sets up the content of the red, green and blue combo boxes
* prepending a undefined value as the first element. Each component
* name is prepended with its index (e.g. '<i>: NAME'), if
* non-empty. Otherwise, 'BAND <i>' is inserted into the combo-box.
*
* Calling SetComponents() resets the current-index of each
* combo-box to the first entry (i.e. the undefined value), which
* causes the currentIndexChanged() signal to be emitted for
* each component.
*
* Example: The user { "Red", "Green", "Blue", "" } component-name
* list will be displayed as the { UNDEFINED_ITEM, "0: Red", "1:
* Green", "2: Blue", "BAND 3" } combo-box list.
*
* \param component component-name list.
*/
void SetComponents( const QStringList& component );
/**
* Get the component-name list (as opposing to the component-name
* combo-box list).
*
* Example: The user { "Red", "Green", "Blue", "" } list as it were
* set and not the displayed { UNDEFINED_ITEM, "0: Red", "1: Green",
* "2: Blue", "BAND 3" } combo-box list.
*
* \return the component-name list.
*/
inline
QStringList
GetComponents() const
......@@ -104,11 +136,42 @@ public:
return m_Components;
}
/**
* Set the current (selected) index of a video channel.
*
* Calling SetCurrentIndex let the currentIndexChanged()
* signal to be emitted.
*
* \param channel The video channel for which to set the current
* index.
* \param index The index in the component-name list of a negative
* value to select the undefined value.
*
* Example: If the { "Red", "Green", "Blue", "" } component-name
* list has been set, index 1 set "1: Green" as the current select
* combo-box item.
*/
void SetCurrentIndex( Channel channel, int index );
/**
* \return the current (selected) index of a video-channel in the
* component-name list (not the displayed combo-box list) or -1 if
* the undefined value has been selected.
*/
int GetCurrentIndex( Channel channel );
//
// SIGNALS.
signals:
/** */
void currentChannelIndexChanged( Channel channel, int index );
/**
* Signal emitted when the current-index of a video-channel has been
* modified.
*
* \param channel The video-channel which has been modified.
* \param index The curren-index in the component-list or -1 if the
* undefined value has been selected.
*/
void currentIndexChanged( Channel channel, int index );
//
// Protected methods.
......@@ -125,37 +188,51 @@ private:
//
// Private attributes.
private:
/** */
/**
* uic generated.
*/
Ui::ColorSetupWidget* m_UI;
/** */
/**
* The (user) component-name list.
*/
QStringList m_Components;
//
// SLOTS.
private slots:
/** */
/**
* Slot called when the curernt-index of the red video-channel has
* been modified.
*/
inline
void
onRedIndexChanged( int index )
{
emit currentChannelIndexChanged( CHANNEL_RED, index );
emit currentIndexChanged( CHANNEL_RED, index );
}
/** */
/**
* Slot called when the curernt-index of the green video-channel has
* been modified.
*/
inline
void
onGreenIndexChanged( int index )
{
emit currentChannelIndexChanged( CHANNEL_GREEN, index );
emit currentIndexChanged( CHANNEL_GREEN, index );
}
/** */
/**
* Slot called when the curernt-index of the blue video-channel has
* been modified.
*/
inline
void
onBlueIndexChanged( int index )
{
emit currentChannelIndexChanged( CHANNEL_BLUE, index );
emit currentIndexChanged( CHANNEL_BLUE, index );
}
};
......
......@@ -91,7 +91,7 @@
</property>
<item>
<property name="text">
<string>NIL</string>
<string>none</string>
</property>
</item>
<item>
......@@ -170,7 +170,7 @@
</property>
<item>
<property name="text">
<string>NIL</string>
<string>none</string>
</property>
</item>
<item>
......@@ -249,7 +249,7 @@
</property>
<item>
<property name="text">
<string>NIL</string>
<string>none</string>
</property>
</item>
<item>
......
......@@ -52,8 +52,8 @@ namespace mvd
//
// Internal classes pre-declaration.
/** \class MyClass
*
/**
* \class MyClass
*/
class Monteverdi2_EXPORT MyClass :
public QObject
......
......@@ -77,13 +77,16 @@ VectorImageModel
assert( m_ImageFileReader->GetNumberOfOutputs()==1 );
DefaultImageType::Pointer output( m_ImageFileReader->GetOutput( 0 ) );
/*
itk::MetaDataDictionary dictionary( output->GetMetaDataDictionary() );
DefaultImageType::ImageMetadataInterfacePointerType metaData(
otb::ImageMetadataInterfaceFactory::CreateIMI( dictionary )
GetMetadataInferface()
);
*/
StringVector stdBandNames( metaData->GetBandName() );
StringVector stdBandNames( GetMetadataInterface()->GetBandName() );
assert( stdBandNames.empty() ||
stdBandNames.size()==output->GetNumberOfComponentsPerPixel() );
......@@ -127,8 +130,10 @@ VectorImageModel
m_Settings.m_RGBChannels[1] = 1;
m_Settings.m_RGBChannels[2] = 2;
}
#else
m_Settings.m_RGBChannels = GetMetadataInterface()->GetDefaultDisplay();
#endif
}
......
......@@ -128,7 +128,16 @@ public:
/**
*/
QStringList GetBandNames() const;
QStringList GetBandNames() const;
/**
*/
inline
const Settings&
GetSettings() const
{
return m_Settings;
}
/**
*/
......@@ -183,6 +192,20 @@ private:
// Private methods.
private:
/** */
inline
DefaultImageType::ImageMetadataInterfacePointerType
GetMetadataInterface() const
{
assert( m_ImageFileReader->GetNumberOfOutputs()==1 );
itk::MetaDataDictionary dictionary(
m_ImageFileReader->GetOutput( 0 )->GetMetaDataDictionary()
);
return otb::ImageMetadataInterfaceFactory::CreateIMI( dictionary );
}
/** 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
......
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