33 #include <QApplication>
34 #include <QListWidgetItem>
35 #include <QScrollArea>
36 #include <QVBoxLayout>
37 #include <QWidgetAction>
38 #include <QtCore/QList>
39 #include <boost/bind/bind.hpp>
41 #include "../WMainWindow.h"
42 #include "../WQtGui.h"
43 #include "../events/WEventTypes.h"
44 #include "../events/WUpdateTextureSorterEvent.h"
45 #include "../guiElements/WScaleLabel.h"
46 #include "WPropertyBoolWidget.h"
47 #include "WPropertyDoubleWidget.h"
48 #include "WQtColormapper.h"
49 #include "WQtPropertyGroupWidget.h"
50 #include "core/common/WAssert.h"
51 #include "core/dataHandler/WDataHandler.h"
52 #include "core/dataHandler/WDataSet.h"
53 #include "core/dataHandler/exceptions/WDHNoSuchSubject.h"
54 #include "core/graphicsEngine/WGEColormapping.h"
55 #include "core/graphicsEngine/WGETexture.h"
60 setObjectName(
"Colormapper Dock" );
65 +
"</b> textures will be applied." );
66 this->setAllowedAreas( Qt::AllDockWidgetAreas );
67 this->setFeatures( QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
72 this, SLOT(
rowsMoved(
const QModelIndex&,
int,
int,
const QModelIndex&,
int ) ) );
75 QWidget* panel =
new QWidget(
this );
78 m_layout->setContentsMargins( 0, 0, 0, 0 );
82 connect( downAction, SIGNAL( triggered() ),
this, SLOT(
moveItemDown() ) );
85 connect( upAction, SIGNAL( triggered() ),
this, SLOT(
moveItemUp() ) );
89 connect( bottomAction, SIGNAL( triggered() ),
this, SLOT(
moveItemBottom() ) );
92 connect( topAction, SIGNAL( triggered() ),
this, SLOT(
moveItemTop() ) );
126 QListWidget* parent ):
128 m_texture( texture ),
133 QString name = QString::fromStdString( texture->name()->get() );
136 name = QString::fromStdString( names.back() );
141 QHBoxLayout* containerLayout =
new QHBoxLayout();
146 active->setToolTip(
"Turn this texture on or off. A turned off texture is completely invisible." );
150 QHBoxLayout* labelContainerLayout =
new QHBoxLayout();
151 labelContainer->setLayout( labelContainerLayout );
154 nameLabel->setToolTip(
"The name of this texture. This usually is the name of the file it was loaded from." );
158 labelContainerLayout->addWidget( nameLabel );
162 alpha->setToolTip(
"Change transparency of a texture. The higher this value, the more opaque is the texture. "
163 "This is very useful for mixing several datasets." );
170 m_texture->getProperties(), QString::fromStdString(
"Configure Colormap" ), 0, sa
172 sa->setWidget( props );
175 QWidgetAction* propAction =
new QWidgetAction(
m_itemWidget );
176 propAction->setDefaultWidget( sa );
180 propActionMenu->addAction( propAction );
183 QToolButton* propActionBtn =
new QToolButton(
m_itemWidget );
184 propActionBtn->setPopupMode( QToolButton::InstantPopup );
185 propActionBtn->setMenu( propActionMenu );
187 propActionBtn->setToolButtonStyle( Qt::ToolButtonIconOnly );
188 propActionBtn->setContentsMargins( 0, 0, 0, 0 );
189 propActionBtn->setAutoRaise(
true );
190 propActionBtn->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
191 propActionBtn->setToolTip(
"Show all the configuration options for this texture and its colormap." );
194 grabWidget->setPixmap(
WQtGui::getMainWindow()->getIconManager()->getIcon(
"touchpoint_small" ).pixmap( 24, 32 ) );
195 grabWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
196 grabWidget->setFixedWidth( 24 );
197 grabWidget->setToolTip(
"Drag and drop these textures to change their composition ordering." );
201 QColor defaultCol = palette.window().color();
204 QColor labelCol = defaultCol.darker( 115 );
206 QColor propertyCol = defaultCol;
208 propActionBtn->setStyleSheet(
"background-color:" + propertyCol.name() +
";" );
209 active->setStyleSheet(
"background-color:" + labelCol.name() +
";" );
210 alpha->setStyleSheet(
"#ControlPanelPropertyWidget{ background-color:" + propertyCol.name() +
";}" );
211 nameLabel->setStyleSheet(
"background-color:" + labelCol.name() +
";border:none;" );
212 labelContainer->setStyleSheet(
"background-color:" + labelCol.name() +
";" );
215 containerLayout->addWidget( grabWidget );
216 containerLayout->addWidget( active );
217 containerLayout->addWidget( labelContainer );
218 containerLayout->addWidget( alpha );
219 containerLayout->addWidget( propActionBtn );
222 containerLayout->setContentsMargins( 0, 2, 0, 2 );
223 containerLayout->setSpacing( 0 );
224 labelContainerLayout->setContentsMargins( 2, 2, 0, 2 );
225 labelContainerLayout->setSpacing( 0 );
228 containerLayout->setStretchFactor( active, 0 );
229 containerLayout->setStretchFactor( grabWidget, 0 );
230 containerLayout->setStretchFactor( labelContainer, 100 );
231 containerLayout->setStretchFactor( alpha, 75 );
232 containerLayout->setStretchFactor( propActionBtn, 0 );
235 m_itemWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
262 if(
event->type() == WQT_UPDATE_TEXTURE_SORTER_EVENT )
268 return WQtDockWidget::event(
event );
278 osg::ref_ptr< WGETexture3D > lastSelected;
293 item->setSizeHint( QSize( 0, widget->sizeHint().height() ) );
358 if( item && dataSet->isTexture() && ( item->
getTexture() == dataSet->getTexture() ) )
366 const QModelIndex& destinationParent,
int destinationRow )
368 WAssert( sourceStart == sourceEnd,
"Multiple texture items selected. This should not be the case." );
369 WAssert( sourceParent == destinationParent,
"Source and target parent are not the same. This should not be the case." );
376 cm->moveTo( item->
getTexture(), destinationRow );
TextureRegisterHandler TextureDeregisterHandler
The type of handler used for being notified about removed textures.
boost::function< void(void) > TextureSortHandler
The type of handler called whenever the texture list got resorted.
boost::function< void(osg::ref_ptr< WGETexture3D >, osg::ref_ptr< WGETexture3D >) > TextureReplaceHandler
The type of handler used for being notified about replaced textures.
static std::shared_ptr< WGEColormapping > instance()
Returns instance of the module factory to use to create modules.
@ Deregistered
texture got removed
@ Registered
texture got added
@ Sorted
texture list was resorted
@ Replaced
texture got replaced
TextureContainerType::ConstIterator TextureConstIterator
Const iterator to access the texture list.
boost::function< void(osg::ref_ptr< WGETexture3D >) > TextureRegisterHandler
The type of handler used for being notified about added textures.
static std::size_t const MAX_NUMBER_OF_TEXTURES
We support only 8 textures because some known hardware does not support more texture coordinates.
This class represents a texture item in the list widget.
const osg::ref_ptr< WGETexture3D > getTexture() const
Returns the associated texture.
const osg::ref_ptr< WGETexture3D > m_texture
The texture that gets handled.
virtual ~WQtTextureListItem()
Destructor.
QWidget * m_itemWidget
Widget representing the item.
QWidget * getWidget() const
Create a new widget for this item.
QListWidget * m_parent
Parent list.
WQtTextureListItem(const osg::ref_ptr< WGETexture3D > texture, WQtColormapper *cmapper, QListWidget *parent=0)
Creates new instance of list item.
This widget controls the colormapper of openwalnut.
void moveItemUp()
change order of items, move currently selected item up
WQtColormapper(QWidget *parent=0)
Default constructor.
QListWidget * m_textureListWidget
pointer to the tree widget
QVBoxLayout * m_layout
Layout of the widget.
void update()
Update the list view from the list of data sets.
void selectTexture(std::shared_ptr< WDataSet > dataSet)
Select a certain texture in the texture sorter belonging to the specified dataset.
virtual bool event(QEvent *event)
Custom event dispatcher.
boost::signals2::connection m_replaceConnection
Connection of the WGEColormapping signal "replaced" to the member function pushUpdateEvent.
void moveItemTop()
change order of items, move currently selected item to top
boost::signals2::connection m_deregisterConnection
Connection of the WGEColormapping signal "deregistered" to the member function pushUpdateEvent.
virtual ~WQtColormapper()
Destructor.
void moveItemBottom()
change order of items, move currently selected item to bottom
boost::signals2::connection m_sortConnection
Connection of the WGEColormapping signal "Sort" to the member function pushUpdateEvent.
void textureSelectionChanged(osg::ref_ptr< WGETexture3D > texture)
Indicates that a texture has been clicked and return the texture.
void handleTextureClicked()
Handles a click to a texture in the list.
void pushUpdateEvent()
Called by the colormapper causing an update event being pushed to the event queue.
void rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
A item was moved into another row.
void moveItemDown()
change order of items, move currently selected item down
boost::signals2::connection m_registerConnection
Connection of the WGEColormapping signal "registered" to the member function pushUpdateEvent.
static WMainWindow * getMainWindow()
Returns the current main window instance or NULL if not existent.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
Event signalling a new module has been associated with the root container in the kernel.
std::vector< std::string > tokenize(const std::string &source, const std::string &delim=WHITESPACE, bool compress=true)
Splits the given string into a vector of strings (so called tokens).