Commit 6de16523 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE #255] colormapper dock now uses dock title for its widgets

parent cb4d7dd6
......@@ -345,6 +345,62 @@ bool WGEColormapping::moveUp( osg::ref_ptr< WGETexture3D > texture )
return true;
}
bool WGEColormapping::moveToTop( osg::ref_ptr< WGETexture3D > texture )
{
TextureContainerType::WriteTicket w = m_textures.getWriteTicket();
// does the texture exist?
TextureContainerType::Iterator iter = std::find( w->get().begin(), w->get().end(), texture );
if( iter == w->get().end() )
{
return false;
}
// is it already the first item?
if( iter == w->get().begin() )
{
return false;
}
// do the op
w->get().erase( iter );
w->get().insert( w->get().begin(), texture );
// unlock and call callbacks
w.reset();
m_sortSignal();
return true;
}
bool WGEColormapping::moveToBottom( osg::ref_ptr< WGETexture3D > texture )
{
TextureContainerType::WriteTicket w = m_textures.getWriteTicket();
// does the texture exist?
TextureContainerType::Iterator iter = std::find( w->get().begin(), w->get().end(), texture );
if( iter == w->get().end() )
{
return false;
}
// is it already the last item?
if( iter + 1 == w->get().end() )
{
return false;
}
// do the op
w->get().erase( iter );
w->get().push_back( texture );
// unlock and call callbacks
w.reset();
m_sortSignal();
return true;
}
size_t WGEColormapping::size() const
{
return m_textures.size();
......
......@@ -190,6 +190,22 @@ public:
template < typename Comparator >
void sort( Comparator comp );
/**
* Move the specified texture up in the list, directly to the top. Causes the sort signal to fire.
*
* \param texture the texture swapped with its ascendant
* \return true if swap was successful. False if not (texture not found, texture already at beginning).
*/
bool moveToTop( osg::ref_ptr< WGETexture3D > texture );
/**
* Move the specified texture down in the list, directly to the bottom. Causes the sort signal to fire.
*
* \param texture the texture swapped with its descendant
* \return true if swap was successful. False if not (texture not found, texture already at end).
*/
bool moveToBottom( osg::ref_ptr< WGETexture3D > texture );
/**
* Move the specified texture one item up in the list. Causes the sort signal to fire.
*
......
......@@ -44,6 +44,8 @@
#include "core/graphicsEngine/WGETexture.h"
#include "../events/WUpdateTextureSorterEvent.h"
#include "../events/WEventTypes.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "WQtColormapper.h"
#include "WQtColormapper.moc"
......@@ -65,20 +67,25 @@ WQtColormapper::WQtColormapper( QWidget* parent )
m_layout = new QVBoxLayout();
m_layout->setContentsMargins( 0, 0, 0, 0 );
QHBoxLayout* buttonLayout = new QHBoxLayout();
m_downButton = new QPushButton();
m_downButton->setText( QString( "down" ) );
m_upButton = new QPushButton();
m_upButton->setText( QString( "up" ) );
// create the move-up/down buttons
QAction* downAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "go-down" ), "Move selected colormap down.", this );
connect( downAction, SIGNAL( triggered() ), this, SLOT( moveItemDown() ) );
buttonLayout->addWidget( m_downButton );
buttonLayout->addWidget( m_upButton );
QAction* upAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "go-up" ), "Move selected colormap up.", this );
connect( upAction, SIGNAL( triggered() ), this, SLOT( moveItemUp() ) );
connect( m_upButton, SIGNAL( pressed() ), this, SLOT( moveItemUp() ) );
connect( m_downButton, SIGNAL( pressed() ), this, SLOT( moveItemDown() ) );
QAction* bottomAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "go-bottom" ), "Move selected colormap to the bottom.", this );
connect( bottomAction, SIGNAL( triggered() ), this, SLOT( moveItemBottom() ) );
QAction* topAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "go-top" ), "Move selected colormap to the top.", this );
connect( topAction, SIGNAL( triggered() ), this, SLOT( moveItemTop() ) );
addTitleAction( bottomAction );
addTitleAction( downAction );
addTitleAction( upAction );
addTitleAction( topAction );
m_layout->addWidget( m_textureListWidget );
m_layout->addLayout( buttonLayout );
connect( m_textureListWidget, SIGNAL( itemClicked( QListWidgetItem* ) ), this, SLOT( handleTextureClicked() ) );
......@@ -206,6 +213,26 @@ void WQtColormapper::moveItemUp()
}
}
void WQtColormapper::moveItemBottom()
{
boost::shared_ptr< WGEColormapping > cm = WGEColormapping::instance();
WQtTextureListItem* item = dynamic_cast< WQtTextureListItem* >( m_textureListWidget->item( m_textureListWidget->currentIndex().row() ) );
if( item )
{
cm->moveToBottom( item->getTexture() );
}
}
void WQtColormapper::moveItemTop()
{
boost::shared_ptr< WGEColormapping > cm = WGEColormapping::instance();
WQtTextureListItem* item = dynamic_cast< WQtTextureListItem* >( m_textureListWidget->item( m_textureListWidget->currentIndex().row() ) );
if( item )
{
cm->moveToTop( item->getTexture() );
}
}
void WQtColormapper::selectTexture( boost::shared_ptr< WDataSet > dataSet )
{
// simply check each item against the texture in the specified dataset
......
......@@ -95,9 +95,6 @@ private:
QListWidget* m_textureListWidget; //!< pointer to the tree widget
QVBoxLayout* m_layout; //!< Layout of the widget
QPushButton* m_downButton; //!< button down
QPushButton* m_upButton; //!< button up
/**
* Connection of the WGEColormapping signal "registered" to the member function pushUpdateEvent.
*/
......@@ -183,6 +180,16 @@ private slots:
* change order of items, move currently selected item up
*/
void moveItemUp();
/**
* change order of items, move currently selected item to bottom
*/
void moveItemBottom();
/**
* change order of items, move currently selected item to top
*/
void moveItemTop();
};
#endif // WQTCOLORMAPPER_H
......
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