GUI widget for handling mitk::PointSet. More...
#include <QmitkPointListView.h>

Signals | |
| void | SignalPointSelectionChanged () |
| this signal is emmitted, if the selection of a point in the pointset is changed | |
Public Member Functions | |
| QmitkPointListView (QWidget *parent=0) | |
| ~QmitkPointListView () | |
| void | SetPointSetNode (mitk::DataNode *pointSetNode) |
| assign a point set for observation | |
| const mitk::PointSet * | GetPointSet () const |
| which point set to work on | |
| void | SetMultiWidget (QmitkStdMultiWidget *multiWidget) |
| assign a QmitkStdMultiWidget for updating render window crosshair | |
| QmitkStdMultiWidget * | GetMultiWidget () const |
| return the QmitkStdMultiWidget that is used for updating render window crosshair | |
| void | SetTimesStep (int i) |
| which time step to display/model | |
Protected Slots | |
| void | OnPointDoubleClicked (const QModelIndex &index) |
| Filtering double click event for editing point coordinates via a dialog. | |
| void | OnPointSetSelectionChanged () |
| called when the point set data structure changes | |
| void | OnListViewSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected) |
| called when the selection of the view widget changes | |
| void | fadeTimeStepOut () |
| fade the shown timestep out | |
| void | ctxMenu (const QPoint &pos) |
| open ContextMenu | |
| void | SetFading (bool onOff) |
| Turn TimeStep Fading On/Off. | |
| void | ClearPointList () |
| Delete all points in the list. | |
| void | ClearPointListTS () |
| delete all points in the list in the current timestep | |
Protected Member Functions | |
| void | keyPressEvent (QKeyEvent *e) |
| react to F2, F3 and DEL keys | |
| void | wheelEvent (QWheelEvent *event) |
| change timestep of the current pointset by mouse wheel | |
| void | fadeTimeStepIn () |
| fade a label with the currently shown timestep in | |
Protected Attributes | |
| QmitkPointListModel * | m_PointListModel |
| bool | m_SelfCall |
| bool | m_showFading |
| QmitkStdMultiWidget * | m_MultiWidget |
| used to position the planes on a selected point | |
| QLabel * | m_TimeStepFaderLabel |
GUI widget for handling mitk::PointSet.
Displays all the points in a mitk::PointSet graphically. Reacts automatically to changes in the PointSet's selection status. Updates PointSet's selection status when this list's selection changes.
If a QmitkStdMultiWidget is assigned via SetMultiWidget(), the crosshair of the QmitkStdMultiWidget is moved to the currently selected point.
Definition at line 41 of file QmitkPointListView.h.
| QmitkPointListView::QmitkPointListView | ( | QWidget * | parent = 0 ) |
Definition at line 32 of file QmitkPointListView.cpp.
References ctxMenu(), m_PointListModel, m_TimeStepFaderLabel, OnListViewSelectionChanged(), OnPointDoubleClicked(), and OnPointSetSelectionChanged().
:QListView( parent ), m_PointListModel( new QmitkPointListModel() ), m_SelfCall( false ), m_showFading(false), m_MultiWidget( NULL) { QListView::setAlternatingRowColors( true ); // logic QListView::setSelectionBehavior( QAbstractItemView::SelectRows ); QListView::setSelectionMode( QAbstractItemView::SingleSelection ); QListView::setModel( m_PointListModel ); QString tooltip = QString("Use the F2/F3 keys to move a point up/down, the Del key to remove a point\nand the mouse wheel to change the timestep.\n\nTimeStep:\t%1").arg(0); QListView::setToolTip(tooltip); //m_FadeTimer = new QTimer(); this->setContextMenuPolicy(Qt::CustomContextMenu); m_TimeStepFaderLabel = new QLabel(this); QFont font("Arial", 17); m_TimeStepFaderLabel->setFont(font); //Define Size this->setMinimumHeight(40); //horizontal, vertical this->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); //connect connect( m_PointListModel, SIGNAL(SignalUpdateSelection()), this, SLOT(OnPointSetSelectionChanged()) ); connect( this, SIGNAL(doubleClicked ( const QModelIndex & )), this, SLOT(OnPointDoubleClicked( const QModelIndex & )) ); connect( QListView::selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(OnListViewSelectionChanged(const QItemSelection& , const QItemSelection&)) ); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ctxMenu(const QPoint &))); }
| QmitkPointListView::~QmitkPointListView | ( | ) |
Definition at line 75 of file QmitkPointListView.cpp.
References m_PointListModel.
{
delete m_PointListModel;
}
| void QmitkPointListView::ClearPointList | ( | ) | [protected, slot] |
Delete all points in the list.
Definition at line 348 of file QmitkPointListView.cpp.
References mitk::RenderingManager::GetInstance(), mitk::PointSet::GetPointSet(), QmitkPointListModel::GetPointSet(), m_PointListModel, and QmitkPointListModel::RemoveSelectedPoint().
Referenced by ctxMenu().
{
if(!m_PointListModel->GetPointSet())
return;
mitk::PointSet::Pointer curPS = m_PointListModel->GetPointSet();
if ( curPS->GetSize() == 0)
return;
switch( QMessageBox::question( this, tr("Clear Points"),
tr("Remove all points from the displayed list?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
{
case QMessageBox::Yes:
{
// m_PointListModel->ClearList();
// /*
// if (curPS)
// {
// curPS->Clear();
// }
// */
// mitk::RenderingManager::GetInstance()->RequestUpdateAll();
// break;
mitk::PointSet::PointsIterator it;
mitk::PointSet::PointsContainer *curPsPoints;
while( !curPS->IsEmpty(0))
{
curPsPoints = curPS->GetPointSet()->GetPoints();
it = curPsPoints->Begin();
curPS->SetSelectInfo(it->Index(),true);
m_PointListModel->RemoveSelectedPoint();
}
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
break;
}
case QMessageBox::No:
default:
break;
}
// emit PointListChanged();
}
| void QmitkPointListView::ClearPointListTS | ( | ) | [protected, slot] |
delete all points in the list in the current timestep
Definition at line 391 of file QmitkPointListView.cpp.
Referenced by ctxMenu().
{
// mitk::PointSet* /*::Pointer*/ curPS = m_PointListModel->GetPointSet();
// if ( curPS->GetSize() == 0)
// return;
// int ts = this->m_PointListModel->GetTimeStep();
// switch( QMessageBox::question( this, tr("Clear Points in Timestep"),
// tr("Remove all points from the list with the timestep %1?").arg(ts),
// QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
// {
// case QMessageBox::Yes:
// if (curPS)
// {
// mitk::PointSet::DataType::Pointer curPSwithTS = curPS->GetPointSet(ts);
// //curPSwithTS->Clear();
// }
// mitk::RenderingManager::GetInstance()->RequestUpdateAll();
// break;
// case QMessageBox::No:
// default:
// break;
// }
// // emit PointListChanged();
}
| void QmitkPointListView::ctxMenu | ( | const QPoint & | pos ) | [protected, slot] |
open ContextMenu
Definition at line 303 of file QmitkPointListView.cpp.
References ClearPointList(), ClearPointListTS(), and SetFading().
Referenced by QmitkPointListView().
{
QMenu *menu = new QMenu;
// menu->setStyle();
// menu->addAction(tr("Test Item"), this, SLOT(test_slot()));
//add Fading check
QAction *showFading = new QAction(this);
showFading->setCheckable(false); //TODO: reset when fading is working
showFading->setEnabled(false); //TODO: reset when fading is working
showFading->setText("Fade TimeStep");
connect(showFading, SIGNAL(triggered(bool)), this, SLOT(SetFading(bool)));
menu->addAction(showFading);
//add Clear action
QAction *clearList = new QAction(this);
clearList->setText("Clear List");
connect(clearList, SIGNAL(triggered()), this, SLOT(ClearPointList()));
menu->addAction(clearList);
//add Clear TimeStep action
QAction *clearTS = new QAction(this);
clearTS->setText("Clear current time step");
connect(clearTS, SIGNAL(triggered()), this, SLOT(ClearPointListTS()));
menu->addAction(clearTS);
// //add "show time step in list" option
// QAction *viewTS = new QAction(this);
// viewTS->setText("Show time step in list");
// viewTS->setCheckable(true);
// viewTS->setChecked(false);
// connect(viewTS, SIGNAL(triggered(bool)), this, SLOT(ClearPointList(bool)));
// menu->addAction(viewTS);
menu->exec(this->mapToGlobal(pos));
}
| void QmitkPointListView::fadeTimeStepIn | ( | ) | [protected] |
fade a label with the currently shown timestep in
Definition at line 254 of file QmitkPointListView.cpp.
References fadeTimeStepOut(), QmitkPointListModel::GetTimeStep(), int(), m_PointListModel, and m_TimeStepFaderLabel.
Referenced by wheelEvent().
{
//Setup Widget
QWidget *m_TimeStepFader = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(m_TimeStepFader);
int x = (int)(this->geometry().x()+this->width()*0.6);
int y = (int)(this->geometry().y()+this->height()*0.8);
m_TimeStepFader->move(x,y);
m_TimeStepFader->resize(60, 55);
m_TimeStepFader->setLayout(layout);
m_TimeStepFader->setAttribute(Qt::WA_DeleteOnClose);
//setup Label
// QLabel *label = new QLabel(QString("%1").arg(this->m_PointListModel->GetTimeStep()));
layout->addWidget(m_TimeStepFaderLabel);
m_TimeStepFaderLabel->setAlignment(Qt::AlignCenter);
m_TimeStepFaderLabel->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
m_TimeStepFaderLabel->setLineWidth(2);
m_TimeStepFaderLabel->setText(QString("%1").arg(this->m_PointListModel->GetTimeStep()));
//give the widget opacity and some colour
QPalette pal = m_TimeStepFaderLabel->palette();
QColor semiTransparentColor(139, 192, 223, 50);
QColor labelTransparentColor(0,0,0,200);
pal.setColor(m_TimeStepFaderLabel->backgroundRole(), semiTransparentColor);
pal.setColor(m_TimeStepFaderLabel->foregroundRole(), labelTransparentColor);
m_TimeStepFaderLabel->setAutoFillBackground(true);
m_TimeStepFaderLabel->setPalette(pal);
//show the widget
m_TimeStepFader->show();
//and start the timer
m_TimeStepFaderLabel->setVisible(true);
QTimer::singleShot(2000, this, SLOT(fadeTimeStepOut()));
}
| void QmitkPointListView::fadeTimeStepOut | ( | ) | [protected, slot] |
fade the shown timestep out
Definition at line 296 of file QmitkPointListView.cpp.
References m_TimeStepFaderLabel.
Referenced by fadeTimeStepIn().
{
m_TimeStepFaderLabel->hide();
}
| QmitkStdMultiWidget * QmitkPointListView::GetMultiWidget | ( | ) | const |
return the QmitkStdMultiWidget that is used for updating render window crosshair
Definition at line 97 of file QmitkPointListView.cpp.
References m_MultiWidget.
{
return m_MultiWidget;
}
| const mitk::PointSet * QmitkPointListView::GetPointSet | ( | ) | const |
which point set to work on
Definition at line 85 of file QmitkPointListView.cpp.
References QmitkPointListModel::GetPointSet(), and m_PointListModel.
{
return m_PointListModel->GetPointSet();
}
| void QmitkPointListView::keyPressEvent | ( | QKeyEvent * | e ) | [protected] |
react to F2, F3 and DEL keys
Definition at line 193 of file QmitkPointListView.cpp.
References mitk::Key_Delete, mitk::Key_F2, mitk::Key_F3, m_PointListModel, QmitkPointListModel::MoveSelectedPointDown(), QmitkPointListModel::MoveSelectedPointUp(), and QmitkPointListModel::RemoveSelectedPoint().
{
if (m_PointListModel == NULL)
return;
int key = e->key();
switch (key)
{
case Qt::Key_F2:
m_PointListModel->MoveSelectedPointUp();
break;
case Qt::Key_F3:
m_PointListModel->MoveSelectedPointDown();
break;
case Qt::Key_Delete:
m_PointListModel->RemoveSelectedPoint();
break;
default:
break;
}
}
| void QmitkPointListView::OnListViewSelectionChanged | ( | const QItemSelection & | selected, |
| const QItemSelection & | deselected | ||
| ) | [protected, slot] |
called when the selection of the view widget changes
Definition at line 148 of file QmitkPointListView.cpp.
References mitk::RenderingManager::GetInstance(), QmitkPointListModel::GetModelIndexForPointID(), mitk::PointSet::GetPoint(), mitk::PointSet::GetPointSet(), QmitkPointListModel::GetPointSet(), QmitkPointListModel::GetTimeStep(), m_MultiWidget, m_PointListModel, m_SelfCall, QmitkStdMultiWidget::MoveCrossToPosition(), mitk::PointSet::SetSelectInfo(), and SignalPointSelectionChanged().
Referenced by QmitkPointListView().
{
if (m_SelfCall)
return;
mitk::PointSet* pointSet = const_cast<mitk::PointSet*>( m_PointListModel->GetPointSet() );
if (pointSet == NULL)
return;
// (take care that this widget doesn't react to self-induced changes by setting m_SelfCall)
m_SelfCall = true;
// update selection of all points in pointset: select the one(s) that are selected in the view, deselect all others
QModelIndexList selectedIndexes = selected.indexes();
for (mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_PointListModel->GetTimeStep())->GetPoints()->Begin();
it != pointSet->GetPointSet(m_PointListModel->GetTimeStep())->GetPoints()->End(); ++it)
{
QModelIndex index;
if (m_PointListModel->GetModelIndexForPointID(it->Index(), index))
{
if (selectedIndexes.indexOf(index) != -1) // index is found in the selected indices list
{
pointSet->SetSelectInfo(it->Index(), true, m_PointListModel->GetTimeStep());
if ( m_MultiWidget != NULL)
{
m_MultiWidget->MoveCrossToPosition(pointSet->GetPoint(it->Index(), m_PointListModel->GetTimeStep()));
}
}
else
{
pointSet->SetSelectInfo(it->Index(), false, m_PointListModel->GetTimeStep());
}
}
}
m_SelfCall = false;
emit SignalPointSelectionChanged();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
| void QmitkPointListView::OnPointDoubleClicked | ( | const QModelIndex & | index ) | [protected, slot] |
Filtering double click event for editing point coordinates via a dialog.
Definition at line 102 of file QmitkPointListView.cpp.
References QmitkPointListModel::GetPointForModelIndex(), QmitkPointListModel::GetPointSet(), QmitkPointListModel::GetTimeStep(), m_PointListModel, and QmitkEditPointDialog::SetPoint().
Referenced by QmitkPointListView().
{
mitk::PointSet::PointType p;
mitk::PointSet::PointIdentifier id;
m_PointListModel->GetPointForModelIndex(index, p, id);
QmitkEditPointDialog _EditPointDialog(this);
_EditPointDialog.SetPoint(m_PointListModel->GetPointSet(), id, m_PointListModel->GetTimeStep());
_EditPointDialog.exec();
}
| void QmitkPointListView::OnPointSetSelectionChanged | ( | ) | [protected, slot] |
called when the point set data structure changes
Definition at line 112 of file QmitkPointListView.cpp.
References QmitkPointListModel::GetModelIndexForPointID(), mitk::PointSet::GetNumberOfSelected(), QmitkPointListModel::GetPointSet(), QmitkPointListModel::GetTimeStep(), m_PointListModel, m_SelfCall, MITK_ERROR, mitk::PointSet::SearchSelectedPoint(), and SignalPointSelectionChanged().
Referenced by QmitkPointListView().
{
const mitk::PointSet* pointSet = m_PointListModel->GetPointSet();
if (pointSet == NULL)
return;
// update this view's selection status as a result to changes in the point set data structure
m_SelfCall = true;
int timeStep = m_PointListModel->GetTimeStep();
if ( pointSet->GetNumberOfSelected( timeStep ) > 1 )
{
MITK_ERROR << "Point set has multiple selected points. This view is not designed for more than one selected point.";
}
int selectedIndex = pointSet->SearchSelectedPoint( timeStep );
if (selectedIndex == -1) // no selected point is found
{
m_SelfCall = false;
return;
}
QModelIndex index;
bool modelIndexOkay = m_PointListModel->GetModelIndexForPointID(selectedIndex, index);
if (modelIndexOkay == true)
QListView::selectionModel()->select( index , QItemSelectionModel::ClearAndSelect );
emit SignalPointSelectionChanged();
m_SelfCall = false;
}
| void QmitkPointListView::SetFading | ( | bool | onOff ) | [protected, slot] |
Turn TimeStep Fading On/Off.
Definition at line 343 of file QmitkPointListView.cpp.
References m_showFading.
Referenced by ctxMenu().
{
m_showFading = onOff;
}
| void QmitkPointListView::SetMultiWidget | ( | QmitkStdMultiWidget * | multiWidget ) |
assign a QmitkStdMultiWidget for updating render window crosshair
Definition at line 90 of file QmitkPointListView.cpp.
References m_MultiWidget.
Referenced by QmitkPointListWidget::SetMultiWidget().
{
m_MultiWidget = multiWidget;
}
| void QmitkPointListView::SetPointSetNode | ( | mitk::DataNode * | pointSetNode ) |
assign a point set for observation
Definition at line 80 of file QmitkPointListView.cpp.
References m_PointListModel, and QmitkPointListModel::SetPointSetNode().
Referenced by QmitkPointListWidget::OnNodeDeleted().
{
m_PointListModel->SetPointSetNode( pointSetNode);
}
| void QmitkPointListView::SetTimesStep | ( | int | i ) |
which time step to display/model
| void QmitkPointListView::SignalPointSelectionChanged | ( | ) | [signal] |
this signal is emmitted, if the selection of a point in the pointset is changed
Referenced by OnListViewSelectionChanged(), and OnPointSetSelectionChanged().
| void QmitkPointListView::wheelEvent | ( | QWheelEvent * | event ) | [protected] |
change timestep of the current pointset by mouse wheel
Definition at line 216 of file QmitkPointListView.cpp.
References fadeTimeStepIn(), QmitkPointListModel::GetPointSet(), QmitkPointListModel::GetTimeStep(), mitk::BaseData::GetTimeSteps(), int(), m_PointListModel, and QmitkPointListModel::SetTimeStep().
{
if (!m_PointListModel || !m_PointListModel->GetPointSet() || (int)(m_PointListModel->GetPointSet()->GetTimeSteps()) == 1 /*|| !m_4DPointSet*/)
return;
int whe = event->delta();
mitk::PointSet::Pointer ps = dynamic_cast<mitk::PointSet*>(m_PointListModel->GetPointSet());
unsigned int numberOfTS = ps->GetTimeSteps();
if(numberOfTS == 1)
return;
int currentTS = this->m_PointListModel->GetTimeStep();
if(whe > 0)
{
if((currentTS >= (int)(m_PointListModel->GetPointSet()->GetTimeSteps())))
return;
this->m_PointListModel->SetTimeStep(++currentTS);
}
else
{
if((currentTS <= 0))
return;
this->m_PointListModel->SetTimeStep(--currentTS);
}
QString tooltip = QString("Use the F2/F3 keys to move a point up/down, the Del key to remove a point\nand the mouse wheel to change the timestep.\n\nTimeStep:\t%1").arg(currentTS);
this->setToolTip(tooltip);
fadeTimeStepIn();
}
QmitkStdMultiWidget* QmitkPointListView::m_MultiWidget [protected] |
used to position the planes on a selected point
Definition at line 108 of file QmitkPointListView.h.
Referenced by GetMultiWidget(), OnListViewSelectionChanged(), and SetMultiWidget().
QmitkPointListModel* QmitkPointListView::m_PointListModel [protected] |
Definition at line 101 of file QmitkPointListView.h.
Referenced by ClearPointList(), fadeTimeStepIn(), GetPointSet(), keyPressEvent(), OnListViewSelectionChanged(), OnPointDoubleClicked(), OnPointSetSelectionChanged(), QmitkPointListView(), SetPointSetNode(), wheelEvent(), and ~QmitkPointListView().
bool QmitkPointListView::m_SelfCall [protected] |
Definition at line 103 of file QmitkPointListView.h.
Referenced by OnListViewSelectionChanged(), and OnPointSetSelectionChanged().
bool QmitkPointListView::m_showFading [protected] |
Definition at line 105 of file QmitkPointListView.h.
Referenced by SetFading().
QLabel* QmitkPointListView::m_TimeStepFaderLabel [protected] |
Definition at line 110 of file QmitkPointListView.h.
Referenced by fadeTimeStepIn(), fadeTimeStepOut(), and QmitkPointListView().
1.7.2