Public Member Functions | Protected Slots | Protected Attributes

QmitkPointSetInteractionView Class Reference

QmitkPointSetInteractionView. More...

#include <QmitkPointSetInteractionView.h>

Inheritance diagram for QmitkPointSetInteractionView:
Inheritance graph
[legend]
Collaboration diagram for QmitkPointSetInteractionView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 QmitkPointSetInteractionView (QObject *parent=0)
virtual ~QmitkPointSetInteractionView ()
virtual void CreateQtPartControl (QWidget *parent)
void OnSelectionChanged (std::vector< mitk::DataNode * > nodes)
void Activated ()
void Deactivated ()
void NodeChanged (const mitk::DataNode *node)
bool IsExclusiveFunctionality () const
virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget)
virtual void StdMultiWidgetClosed (QmitkStdMultiWidget &stdMultiWidget)

Protected Slots

void OnAddPointSetClicked ()

Protected Attributes

Ui::QmitkPointSetInteractionControlsm_Controls
mitk::WeakPointer< mitk::DataNodem_SelectedPointSetNode
mitk::WeakPointer
< mitk::Interactor
m_SelectedPointSetInteractor

Detailed Description

QmitkPointSetInteractionView.

Definition at line 35 of file QmitkPointSetInteractionView.h.


Constructor & Destructor Documentation

QmitkPointSetInteractionView::QmitkPointSetInteractionView ( QObject *  parent = 0 )

Definition at line 33 of file QmitkPointSetInteractionView.cpp.

: m_Controls(0)
{

}
QmitkPointSetInteractionView::~QmitkPointSetInteractionView (  ) [virtual]

Definition at line 39 of file QmitkPointSetInteractionView.cpp.

{
}

Member Function Documentation

void QmitkPointSetInteractionView::Activated (  ) [virtual]

Only called when IsExclusiveFunctionality() returns true.

See also:
IsExclusiveFunctionality()

Reimplemented from QmitkFunctionality.

Definition at line 51 of file QmitkPointSetInteractionView.cpp.

References QmitkFunctionality::GetDataManagerSelection(), and OnSelectionChanged().

{
  // emulate datamanager selection
  std::vector<mitk::DataNode*> selection = this->GetDataManagerSelection();
  this->OnSelectionChanged( selection );
}
void QmitkPointSetInteractionView::CreateQtPartControl ( QWidget *  parent ) [virtual]
void QmitkPointSetInteractionView::Deactivated (  ) [virtual]

Only called when IsExclusiveFunctionality() returns true.

See also:
IsExclusiveFunctionality()

Reimplemented from QmitkFunctionality.

Definition at line 58 of file QmitkPointSetInteractionView.cpp.

References QmitkPointListWidget::DeactivateInteractor(), m_Controls, Ui_QmitkPointSetInteractionControls::m_PointListWidget, and OnSelectionChanged().

{
  // emulate empty selection
  std::vector<mitk::DataNode*> selection;
  this->OnSelectionChanged( selection );
  m_Controls->m_PointListWidget->DeactivateInteractor(true);
}
bool QmitkPointSetInteractionView::IsExclusiveFunctionality (  ) const [virtual]

Some functionalities need to add special interactors, removes the crosshair from the stdmultiwidget, etc. In this case the functionality has to tidy up when changing to another functionality which also wants to change the "default configuration". In the old Qt3-based version of MITK, two functionalities could never be opened at the same time so that the methods Activated() and Deactivated() were the right place for the functionalitites to add/remove their interactors, etc. This is still true for the new MITK Workbench, but as there can be several functionalities visible at the same time, the behaviour concerning when Activated() and Deactivated() are called has changed:

1. Activated() and Deactivated() are only called if IsExclusiveFunctionality() returns true

2. If only one standalone functionality is or becomes visible, Activated() will be called on that functionality

3. If two or more standalone functionalities are visible, Activated() will be called on the functionality that receives focus, Deactivated() will be called on the one that looses focus, gets hidden or closed

As a consequence of 1. if you overwrite IsExclusiveFunctionality() and let it return false, you signalize the MITK Workbench that this functionality does nothing to the "default configuration" and can easily be visible while other functionalities are also visible.

By default the method returns true.

Returns:
true if this functionality is meant to work as a standalone view, false otherwise

Reimplemented from QmitkFunctionality.

Definition at line 136 of file QmitkPointSetInteractionView.cpp.

{
  return true;
}
void QmitkPointSetInteractionView::NodeChanged ( const mitk::DataNode  ) [virtual]

Called when a DataStorage Changed event was thrown. May be reimplemented by deriving classes.

Reimplemented from QmitkFunctionality.

Definition at line 141 of file QmitkPointSetInteractionView.cpp.

References mitk::DataNode::GetName(), m_Controls, Ui_QmitkPointSetInteractionControls::m_CurrentPointSetLabel, and m_SelectedPointSetNode.

{
  if(node == m_SelectedPointSetNode && m_Controls->m_CurrentPointSetLabel->text().toStdString() != node->GetName())
  {
    m_Controls->m_CurrentPointSetLabel->setText(QString::fromStdString(node->GetName()));
  }
}
void QmitkPointSetInteractionView::OnAddPointSetClicked (  ) [protected, slot]

Definition at line 66 of file QmitkPointSetInteractionView.cpp.

References QmitkFunctionality::FireNodesSelected(), QmitkFunctionality::GetDefaultDataStorage(), mitk::FloatProperty::New(), mitk::StringProperty::New(), mitk::DataNode::New(), mitk::PointSet::New(), and OnSelectionChanged().

Referenced by CreateQtPartControl().

{
  //Ask for the name of the point set
  bool ok = false;
  QString name = QInputDialog::getText( QApplication::activeWindow()
    , "Add point set...", "Enter name for the new point set", QLineEdit::Normal, "PointSet", &ok );
  if ( ! ok || name.isEmpty() )
    return;

  //
  //Create a new empty pointset
  //
  mitk::PointSet::Pointer pointSet = mitk::PointSet::New();
  //
  // Create a new data tree node
  //
  mitk::DataNode::Pointer pointSetNode = mitk::DataNode::New();
  //
  // fill the data tree node with the appropriate information
  //
  pointSetNode->SetData( pointSet );
  pointSetNode->SetProperty( "name", mitk::StringProperty::New( name.toStdString() ) );
  pointSetNode->SetProperty( "opacity", mitk::FloatProperty::New( 1 ) );
  pointSetNode->SetColor( 1.0, 1.0, 0.0 );
  //
  // add the node to the ds
  //
  this->GetDefaultDataStorage()->Add(pointSetNode);

  // make new selection and emulate selection for this
  std::vector<mitk::DataNode*> selection;
  selection.push_back( pointSetNode );
  this->FireNodesSelected( selection );
  this->OnSelectionChanged( selection );
}
void QmitkPointSetInteractionView::OnSelectionChanged ( std::vector< mitk::DataNode * >   ) [virtual]

Called when the selection in the workbench changed

Reimplemented from QmitkFunctionality.

Definition at line 102 of file QmitkPointSetInteractionView.cpp.

References mitk::DataNode::GetData(), mitk::DataNode::GetName(), m_Controls, Ui_QmitkPointSetInteractionControls::m_CurrentPointSetLabel, Ui_QmitkPointSetInteractionControls::m_PointListWidget, m_SelectedPointSetNode, and QmitkPointListWidget::SetPointSetNode().

Referenced by Activated(), Deactivated(), and OnAddPointSetClicked().

{
  mitk::DataNode* selectedNode = 0;
  if(nodes.size() > 0)
    selectedNode = nodes.front();

  mitk::PointSet* pointSet = 0;
  if(selectedNode)
    pointSet = dynamic_cast<mitk::PointSet*> ( selectedNode->GetData() );

  //if( m_SelectedPointSetInteractor.IsNotNull() )
  //{
  //  mitk::GlobalInteraction::GetInstance()->RemoveInteractor( m_SelectedPointSetInteractor );
  //  m_SelectedPointSetInteractor = NULL;
  //}

  if (pointSet /*&& this->IsActivated()*/)
  {
    m_SelectedPointSetNode = selectedNode;
    m_Controls->m_CurrentPointSetLabel->setText(QString::fromStdString(selectedNode->GetName()));
    m_Controls->m_PointListWidget->SetPointSetNode(selectedNode);
    // add interactor
    //mitk::PointSetInteractor::Pointer _Interactor = mitk::PointSetInteractor::New("pointsetinteractor", selectedNode);
    //mitk::GlobalInteraction::GetInstance()->AddInteractor( _Interactor );
    //m_SelectedPointSetInteractor = _Interactor;
  }
  else
  {
    m_Controls->m_CurrentPointSetLabel->setText("None");
    m_Controls->m_PointListWidget->SetPointSetNode(0);
  }

}
void QmitkPointSetInteractionView::StdMultiWidgetAvailable ( QmitkStdMultiWidget stdMultiWidget ) [virtual]

Called when a StdMultiWidget is available. Should not be used anymore, see GetActiveStdMultiWidget()

See also:
GetActiveStdMultiWidget()

Reimplemented from QmitkFunctionality.

Definition at line 149 of file QmitkPointSetInteractionView.cpp.

References m_Controls, Ui_QmitkPointSetInteractionControls::m_PointListWidget, and QmitkPointListWidget::SetMultiWidget().

{
  if(m_Controls)
    m_Controls->m_PointListWidget->SetMultiWidget( &stdMultiWidget );
}
void QmitkPointSetInteractionView::StdMultiWidgetClosed ( QmitkStdMultiWidget stdMultiWidget ) [virtual]

Called when a StdMultiWidget is available. Should not be used anymore, see GetActiveStdMultiWidget()

See also:
GetActiveStdMultiWidget()

Reimplemented from QmitkFunctionality.

Definition at line 155 of file QmitkPointSetInteractionView.cpp.

References m_Controls, Ui_QmitkPointSetInteractionControls::m_PointListWidget, and QmitkPointListWidget::SetMultiWidget().


Member Data Documentation

Definition at line 55 of file QmitkPointSetInteractionView.h.

Definition at line 54 of file QmitkPointSetInteractionView.h.

Referenced by NodeChanged(), and OnSelectionChanged().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines