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

ENH: Added mvdGui.h RgbBounds() and RgbaBounds() convenience functions; Added...

ENH: Added mvdGui.h RgbBounds() and RgbaBounds() convenience functions; Added per channel reset method in ColorSetupController. DOC: Improved some class documentation.
parent a55d58d1
......@@ -139,7 +139,7 @@ ColorDynamicsController
::ResetWidget()
{
//
// Setup color-dynamics controller.
// Reset color-dynamics widget.
ResetIntensityRanges( RGBA_CHANNEL_RGB );
ResetQuantiles( RGBA_CHANNEL_RGB );
......@@ -223,7 +223,7 @@ ColorDynamicsController
CountType begin = -1;
CountType end = -1;
if( !ColorDynamicsController::RgbBounds( begin, end, channels ) )
if( !mvd::RgbBounds( begin, end, channels ) )
return;
//
......@@ -278,7 +278,7 @@ ColorDynamicsController
CountType begin = -1;
CountType end = -1;
if( !ColorDynamicsController::RgbBounds( begin, end, channels ) )
if( !mvd::RgbBounds( begin, end, channels ) )
return;
//
......@@ -349,7 +349,7 @@ ColorDynamicsController
CountType begin = 0;
CountType end = 0;
if( !ColorDynamicsController::RgbBounds( begin, end, channels ) )
if( !mvd::RgbBounds( begin, end, channels ) )
return;
//
......
......@@ -45,7 +45,6 @@
// Monteverdi includes (sorted by alphabetic order)
#include "mvdAbstractModelController.h"
#include "mvdGui.h"
#include "mvdTypes.h"
/*****************************************************************************/
......@@ -138,13 +137,6 @@ private:
/** */
void ResetQuantiles( RgbaChannel );
/** */
inline static
bool
RgbBounds( CountType& begin,
CountType& end,
RgbaChannel channel );
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
......@@ -171,48 +163,6 @@ private slots:
namespace mvd
{
/*****************************************************************************/
inline
bool
ColorDynamicsController
::RgbBounds( CountType& begin, CountType& end, RgbaChannel channel )
{
assert(
channel==RGBA_CHANNEL_NONE ||
channel==RGBA_CHANNEL_RED ||
channel==RGBA_CHANNEL_GREEN ||
channel==RGBA_CHANNEL_BLUE ||
channel==RGBA_CHANNEL_RGB
);
switch( channel )
{
case RGBA_CHANNEL_NONE:
case RGBA_CHANNEL_ALPHA:
begin = RGBA_CHANNEL_NONE;
end = RGBA_CHANNEL_NONE;
break;
case RGBA_CHANNEL_RED:
case RGBA_CHANNEL_GREEN:
case RGBA_CHANNEL_BLUE:
begin = channel;
end = channel + 1;
break;
case RGBA_CHANNEL_RGB:
begin = RGBA_CHANNEL_RED;
end = RGBA_CHANNEL_ALPHA;
break;
default:
return false;
break;
}
return true;
}
} // end namespace 'mvd'
#endif // __mvdColorDynamicsController_h
......@@ -98,25 +98,8 @@ void
ColorSetupController
::ResetWidget()
{
//
// Access color-dynamics widget.
ColorSetupWidget* colorSetupWidget = GetWidget< ColorSetupWidget >();
//
// Access image-model.
VectorImageModel* imageModel = GetModel< VectorImageModel >();
assert( imageModel!=NULL );
// Setup color-setup controller.
colorSetupWidget->SetComponents( imageModel->GetBandNames() );
for( int i=0; i<RGBA_CHANNEL_ALPHA; ++i )
{
colorSetupWidget->SetCurrentIndex(
static_cast< RgbaChannel >( i ),
imageModel->GetSettings().RgbChannel( i )
);
}
// Reset color-setup widget.
ResetIndices( RGBA_CHANNEL_RGB );
// Signal model has been updated.
emit ModelUpdated();
......@@ -149,6 +132,38 @@ ColorSetupController
}
/*******************************************************************************/
void
ColorSetupController
::ResetIndices( RgbaChannel channels )
{
//
// Calculate loop bounds. Return if nothing to do.
CountType begin = 0;
CountType end = 0;
if( !mvd::RgbBounds( begin, end, channels ) )
return;
//
// Access color-dynamics widget.
ColorSetupWidget* colorSetupWidget = GetWidget< ColorSetupWidget >();
//
// Access image-model.
VectorImageModel* imageModel = GetModel< VectorImageModel >();
assert( imageModel!=NULL );
// Setup color-setup controller.
colorSetupWidget->SetComponents( imageModel->GetBandNames() );
for( CountType i=begin; i<end; ++i )
{
colorSetupWidget->SetCurrentIndex(
static_cast< RgbaChannel >( i ),
imageModel->GetSettings().RgbChannel( i )
);
}
}
/*******************************************************************************/
/* SLOTS */
......
......@@ -45,7 +45,6 @@
// Monteverdi includes (sorted by alphabetic order)
#include "mvdAbstractModelController.h"
#include "mvdGui.h"
#include "mvdTypes.h"
/*****************************************************************************/
......@@ -68,6 +67,8 @@ class ColorSetupWidget;
/**
* \class ColorSetupController
*
* \brief Color-setup widget controller forVectorImageModel objects.
*/
class Monteverdi2_EXPORT ColorSetupController :
public AbstractModelController
......@@ -83,10 +84,17 @@ class Monteverdi2_EXPORT ColorSetupController :
// Public methods.
public:
/** Constructor */
/**
* \brief Constructor.
*
* \param widget Controlled widget.
* \param parent Parent QObject of this QObject.
*/
ColorSetupController( ColorSetupWidget* widget, QObject* parent =NULL );
/** Destructor */
/**
* \brief Destructor.
*/
virtual ~ColorSetupController();
......@@ -105,13 +113,10 @@ protected:
//
// AbstractModelController overrides.
/** */
virtual void Connect( AbstractModel* );
/** */
virtual void ResetWidget();
/** */
virtual void Disconnect( AbstractModel* );
//
......@@ -124,6 +129,15 @@ protected:
// Private methods.
private:
/**
* \brief Convenience method which resets current band-index to
* default values for given RGB channels.
*
* \param channels Given channels for which to reset current-band
* index. \see RgbBound() for valid values.
*/
void ResetIndices( RgbaChannel channels );
//
// Private attributes.
private:
......@@ -134,9 +148,14 @@ private:
// Slots.
private slots:
/**
* \brief Slot called when the current index of a RGB channel of the
* controlled widget has changed.
*
* \param channel The RGB video-channel for which the current
* band-index has changed.
*
* \param index The new band-index of the RGB video-channel.
*/
// TODO: Separate RenderingFilter and Settings (QObject) from
// VectorImageModel and move slot.
void OnCurrentIndexChanged( RgbaChannel channel, int index );
};
......
......@@ -66,7 +66,8 @@ class Monteverdi2_EXPORT ColorSetupWidget :
Q_OBJECT;
/**
* The (user) component-name list.
* \brief The list of (user) component names.
* \sa ColorSetupWidget::m_Components member.
*/
Q_PROPERTY( QStringList components
READ GetComponents
......@@ -80,14 +81,14 @@ public:
// Public methods.
public:
/** Constructor */
/** \brief Constructor. */
ColorSetupWidget( QWidget* parent =NULL, Qt::WindowFlags flags =0 );
/** Destructor */
/** \brief Destructor. */
virtual ~ColorSetupWidget();
/**
* Set the component-name list.
* \brief Set the component-name list.
*
* This sets up the content of the red, green and blue combo
* boxes. Each component name is prepended with its index
......@@ -107,7 +108,7 @@ public:
void SetComponents( const QStringList& component );
/**
* Get the component-name list.
* \brief Get the component-name list.
*
* Example: The user { "Red", "Green", "Blue", "" } list as it were
* set and not the displayed { "0: Red", "1: Green", "2: Blue",
......@@ -123,7 +124,7 @@ public:
}
/**
* Set the current (selected) index of a video channel.
* \brief Set the current (selected) index of a video channel.
*
* Calling SetCurrentIndex() let the CurrentIndexChanged()
* signal to be emitted.
......@@ -148,8 +149,8 @@ public:
// SIGNALS.
signals:
/**
* Signal emitted when the current-index of a video-channel has been
* modified.
* \brief 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.
......@@ -172,12 +173,13 @@ private:
// Private attributes.
private:
/**
* uic generated.
* \brief uic generated.
*/
Ui::ColorSetupWidget* m_UI;
/**
* The (user) component-name list.
* \brief The list of (user) component names.
* \sa ColorSetupWidget::component Q_PROPERTY.
*/
QStringList m_Components;
......@@ -185,8 +187,10 @@ private:
// SLOTS.
private slots:
/**
* Slot called when the curernt-index of the red video-channel has
* been modified.
* \brief Slot called when the curernt-index of the red
* video-channel has been modified.
*
* \param index The new current-index of the red combo-box.
*/
inline
void
......@@ -196,8 +200,10 @@ private slots:
}
/**
* Slot called when the curernt-index of the green video-channel has
* been modified.
* \brief Slot called when the curernt-index of the green
* video-channel has been modified.
*
* \param index The new current-index of the green combo-box.
*/
inline
void
......@@ -207,8 +213,10 @@ private slots:
}
/**
* Slot called when the curernt-index of the blue video-channel has
* been modified.
* \brief Slot called when the curernt-index of the blue
* video-channel has been modified.
*
* \param index The new current-index of the blue combo-box.
*/
inline
void
......
......@@ -44,6 +44,7 @@
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdTypes.h"
/*****************************************************************************/
......@@ -94,6 +95,134 @@ extern
const char*
RGBA_CHANNEL_NAMES[ RGBA_CHANNEL_COUNT ];
/**
* \brief Convenience method used to compute integer indices in order
* to iterate through RGB channels such as, for example:
* \code
* for( i=begin; i<end; ++i ) {}
* \endcode
*
* \param begin The resulting first index where to begin iteration.
* \param end The resulting upper-boundary index of the iteration.
* \param channels The channels to be iterated. Valid values are:
* _ RGBA_CHANNEL_NONE to select no video-channel at all;
* - RGBA_CHANNEL_RED to select red video-channel;
* - RGBA_CHANNEL_GREEN to select green video-channel;
* - RGBA_CHANNEL_BLUE to select blue video-channel;
* - RGBA_CHANNEL_ALPHA is equivalent to RGBA_CHANNEL_NONE;
* - RGBA_CHANNEL_RGB to select all RGB video-channels;
* - RGBA_CHANNEL_ALL to select all RGB (without the alpha) video-channels.
*
* \return true if iteration indices have been set and loop can be
* processed.
*/
bool RgbBounds( CountType& begin, CountType& end, RgbaChannel channels );
/**
* \brief Convenience method used to compute integer indices in order
* to iterate through RGBA channels such as, for example:
* \code
* for( i=begin; i<end; ++i ) {}
* \endcode
*
* \param begin The first index where to begin iteration.
* \param end The upper-boundary index of the iteration.
* \param channels The channels to be iterated. Valid values are:
* _ RGBA_CHANNEL_NONE to select no video-channel at all;
* - RGBA_CHANNEL_RED to select red video-channel;
* - RGBA_CHANNEL_GREEN to select green video-channel;
* - RGBA_CHANNEL_BLUE to select blue video-channel;
* - RGBA_CHANNEL_ALPHA to select the alpha video-channel;
* - RGBA_CHANNEL_RGB to select all RGB (without the alpha) video-channels;
* - RGBA_CHANNEL_ALL to select all RGBA video-channels.
*
* \return true if iteration indices have been set and loop can be
* processed.
*/
bool RgbaBounds( CountType& begin, CountType& end, RgbaChannel channels );
} // end namespace 'mvd'.
/*****************************************************************************/
/* INLINE SECTION */
namespace mvd
{
/*****************************************************************************/
inline
bool
RgbBounds( CountType& begin, CountType& end, RgbaChannel channels )
{
assert( channels!=RGBA_CHANNEL_COUNT );
switch( channels )
{
case RGBA_CHANNEL_NONE:
case RGBA_CHANNEL_ALPHA:
begin = RGBA_CHANNEL_NONE;
end = RGBA_CHANNEL_NONE;
break;
case RGBA_CHANNEL_RED:
case RGBA_CHANNEL_GREEN:
case RGBA_CHANNEL_BLUE:
begin = channels;
end = channels + 1;
break;
case RGBA_CHANNEL_RGB:
case RGBA_CHANNEL_ALL:
begin = RGBA_CHANNEL_RED;
end = RGBA_CHANNEL_ALPHA;
break;
default:
return false;
break;
}
return true;
}
/*****************************************************************************/
inline
bool
RgbaBounds( CountType& begin, CountType& end, RgbaChannel channels )
{
assert( channels!=RGBA_CHANNEL_COUNT );
switch( channels )
{
case RGBA_CHANNEL_NONE:
begin = RGBA_CHANNEL_NONE;
end = RGBA_CHANNEL_NONE;
break;
case RGBA_CHANNEL_RED:
case RGBA_CHANNEL_GREEN:
case RGBA_CHANNEL_BLUE:
case RGBA_CHANNEL_ALPHA:
begin = channels;
end = channels + 1;
break;
case RGBA_CHANNEL_RGB:
begin = RGBA_CHANNEL_RED;
end = RGBA_CHANNEL_ALPHA;
break;
case RGBA_CHANNEL_ALL:
begin = RGBA_CHANNEL_RED;
end = RGBA_CHANNEL_RGB;
break;
default:
return false;
break;
}
return true;
}
} // end namespace 'mvd'.
#endif // __mvdGui_h
......@@ -70,6 +70,9 @@ class MyWidget;
/**
* \class MyWidget
*
* \brief Widget template skeleton to copy-paste when adding a new
* widget class.
*/
class Monteverdi2_EXPORT MyWidget :
public QWidget
......@@ -85,10 +88,10 @@ class Monteverdi2_EXPORT MyWidget :
// Public methods.
public:
/** Constructor */
/** \brief Constructor. */
MyWidget( QWidget* parent =NULL, Qt::WindowFlags flags =0 );
/** Destructor */
/** \brief Destructor. */
virtual ~MyWidget();
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
......@@ -117,7 +120,7 @@ private:
// Private attributes.
private:
/**
* uic generated.
* \brief uic generated.
*/
Ui::MyWidget* m_UI;
......
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