21 #ifndef mvdStackedLayerModel_h
22 #define mvdStackedLayerModel_h
27 #include "ConfigureMonteverdi.h"
29 #include "OTBMonteverdiCoreExport.h"
66 class AbstractLayerModel;
90 typedef std::map< std::string, AbstractLayerModel * >
LayerModelMap;
100 typedef std::vector< LayerModelMap::key_type >
KeyVector;
134 void CountSRT(
size_t & unknown,
137 size_t & sensor )
const;
139 inline ConstIterator End()
const;
141 inline void EndEditPixelInfo(
const QPoint &,
const PointType & );
143 void EndEditResolutions();
158 inline const KeyVector & GetKeys()
const;
160 template<
typename T >
161 T * GetCurrent()
const;
163 template<
typename T >
169 inline SizeType GetCurrentIndex()
const;
171 inline const KeyType & GetCurrentKey()
const;
173 template<
typename T >
174 T * GetReference()
const;
176 template<
typename T >
182 inline SizeType GetReferenceIndex()
const;
184 inline bool HasCurrent()
const;
186 inline bool HasReference()
const;
192 inline bool IsEmpty()
const;
197 inline void SetCurrent(
SizeType,
bool =
false );
198 void SetCurrent(
const KeyType & );
201 inline void SetReference(
SizeType,
bool =
false );
202 void SetReference(
const KeyType & );
211 void Deleting(
unsigned int index );
212 inline void Delete(
const KeyType & );
213 inline void DeleteCurrent();
214 inline void LowerCurrent();
215 inline void MoveCurrentToBottom();
216 inline void MoveCurrentToTop();
217 inline void RaiseCurrent();
218 inline void RotateLayers(
int );
219 inline void SelectFirst();
220 inline void SelectLast();
221 inline void SelectPrevious();
222 inline void SelectNext();
232 void ContentAboutToBeChanged();
233 void ContentAboutToBeReset();
234 void ContentChanged();
237 void CurrentAboutToBeChanged(
size_t );
238 void CurrentChanged(
size_t );
240 void LayerAboutToBeDeleted(
size_t index );
241 void LayerAdded(
size_t index );
242 void LayerDeleted(
size_t index );
244 void OrderAboutToBeChanged();
249 void ReferenceAboutToBeChanged(
size_t );
250 void ReferenceChanged(
size_t );
273 inline void ClearPixelInfos();
351 const AbstractLayerModel *
385 assert( !GetKey( i ).empty() );
387 LayerModelMap::const_iterator it(
388 m_LayerModels.find( GetKey( i ) )
391 assert( it!=m_LayerModels.end() );
402 return m_LayerModels.begin();
411 m_PixelInfos.reserve( 0 );
420 return m_LayerModels.find( key )!=m_LayerModels.end();
431 Delete( FindKey( key ) );
451 KeyVector::const_iterator it( std::find( m_Keys.begin(), m_Keys.end(), key ) );
453 if( it==m_Keys.end() )
456 return std::distance( m_Keys.begin(), it );
465 return m_LayerModels.size();
483 return m_Current<GetCount();
492 return m_Reference<GetCount();
501 return m_LayerModels.end();
510 emit PixelInfoChanged( screen, view, m_PixelInfos );
518 for( LayerModelMap::const_iterator it( m_LayerModels.begin() );
519 it!=m_LayerModels.end();
521 if( it->second==layer )
525 return m_LayerModels.end();
544 it==m_LayerModels.end()
550 template<
typename T >
556 return dynamic_cast< T *
>( GetCurrent() );
560 template<
typename T >
566 return dynamic_cast< T *
>( GetCurrent() );
575 if( m_Current>=GetCount() )
578 LayerModelMap::const_iterator it(
579 m_LayerModels.find( m_Keys[ m_Current ] )
582 if( it==m_LayerModels.end() )
612 return GetKey( m_Current );
621 if( index>=GetCount() )
624 return m_Keys[ index ];
628 template<
typename T >
634 return dynamic_cast< T *
>( GetReference() );
638 template<
typename T >
644 return dynamic_cast< T *
>( GetReference() );
653 if( m_Reference>=GetCount() )
656 LayerModelMap::const_iterator it(
657 m_LayerModels.find( m_Keys[ m_Reference ] )
660 if( it==m_LayerModels.end() )
696 for( KeyVector::size_type i=0;
699 if( m_Keys[ i ]==key )
711 return m_LayerModels.empty();
720 for( LayerModelMap::const_iterator it( m_LayerModels.begin() );
721 it!=m_LayerModels.end();
723 if( it->second==layerModel )
739 assert( m_Current<GetCount() );
741 if( m_Current==GetCount()-1 )
742 RotateLayerDown( 1 );
744 LowerLayer( m_Current );
752 if( m_Current>=GetCount() )
755 MoveToBottom( m_Current );
763 if( m_Current>=GetCount() )
766 MoveToTop( m_Current );
778 : ( index + 1 ) % GetCount();
806 index>=GetCount() || index==0
820 assert( m_Current<GetCount() );
825 RaiseLayer( m_Current );
838 RotateLayerUp( steps % GetCount() );
841 RotateLayerDown( ( -steps ) % GetCount() );
865 SetCurrent( m_Keys.size() - 1 );
877 SetCurrent( Next( m_Current ) );
889 SetCurrent( Prev( m_Current ) );
900 if( index==m_Current && !force )
903 KeyType key( GetKey( index ) );
910 emit CurrentAboutToBeChanged( index );
911 emit AboutToChangeSelectedLayerModel( key );
915 emit CurrentChanged( index );
916 emit SelectedLayerModelChanged( key );
927 if( index==m_Reference && !force )
930 emit ReferenceAboutToBeChanged( index );
934 emit ReferenceChanged( index );
946 for( StringVector::const_iterator it( strv.begin() );
949 qDebug() << QString(
"%1" ).arg( it->c_str() );
958 #endif // mvdStackedLayerModel_h
const AbstractLayerModel * Get(const KeyType &) const
itk::Size< Monteverdi_DIMENSION > SizeType
SizeType GetCurrentIndex() const
const AbstractLayerModel * operator[](SizeType) const
SizeType GetReferenceIndex() const
SizeType GetCount() const
static const SizeType NIL_INDEX
SizeType IndexOf(const AbstractLayerModel *) const
const KeyType & KeyOf(const AbstractLayerModel *) const
bool HasReference() const
LayerModelMap::size_type SizeType
const KeyType & GetCurrentKey() const
void MoveCurrentToBottom()
std::vector< PixelInfo > Vector
std::map< std::string, AbstractLayerModel * > LayerModelMap
void Delete(const KeyType &)
LayerModelMap m_LayerModels
std::vector< std::string > StringVector
const PixelInfo::Vector & PixelInfos() const
void EndEditPixelInfo(const QPoint &, const PointType &)
static const KeyType NIL_KEY
void BeginEditPixelInfo()
const AbstractLayerModel * At(SizeType) const
void SetReference(SizeType, bool=false)
PixelInfo::Vector m_PixelInfos
OTBGdalAdapters_EXPORT bool Contains(OGRGeometry const &lhs, OGRGeometry const &rhs)
Tests for containment.
void BeginEditResolutions()
bool Contains(const KeyType &key) const
ConstIterator Find(const AbstractLayerModel *) const
ConstIterator End() const
static SizeType m_LayerCount
SizeType FindKey(const KeyType &) const
ConstIterator Begin() const
void SetCurrent(SizeType, bool=false)
const KeyType & GetKey(SizeType) const
LayerModelMap::key_type KeyType
VectorImageType::PointType PointType
LayerModelMap::const_iterator ConstIterator
const KeyVector & GetKeys() const
std::vector< LayerModelMap::key_type > KeyVector