Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes

QmitkSimpleMeasurement Class Reference
[Internal]

mm More...

#include <QmitkSimpleMeasurement.h>

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

List of all members.

Public Member Functions

virtual ~QmitkSimpleMeasurement ()
virtual void Activated ()
virtual void Deactivated ()
virtual bool IsExclusiveFunctionality () const
virtual void OnSelectionChanged (std::vector< mitk::DataNode * > nodes)
virtual void NodeRemoved (const mitk::DataNode *node)

Protected Slots

void AddDistanceSimpleMeasurement ()
void AddAngleSimpleMeasurement ()
void AddPathSimpleMeasurement ()

Protected Member Functions

void CreateQtPartControl (QWidget *parent)

Protected Attributes

Ui::QmitkSimpleMeasurementControlsm_Controls
mitk::WeakPointer
< mitk::PointSetInteractor
m_PointSetInteractor
mitk::WeakPointer< mitk::DataNodem_SelectedPointSetNode
std::vector< mitk::DataNode * > m_CreatedPointSetNodes

Detailed Description

mm

SimpleMeasurement Allows to measure distances, angles, etc.

See also:
QmitkFunctionality

Definition at line 44 of file QmitkSimpleMeasurement.h.


Constructor & Destructor Documentation

QmitkSimpleMeasurement::~QmitkSimpleMeasurement (  ) [virtual]

Definition at line 40 of file QmitkSimpleMeasurement.cpp.

{
}

Member Function Documentation

void QmitkSimpleMeasurement::Activated (  ) [virtual]

Only called when IsExclusiveFunctionality() returns true.

See also:
IsExclusiveFunctionality()

Reimplemented from QmitkFunctionality.

Definition at line 44 of file QmitkSimpleMeasurement.cpp.

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

{
  std::vector<mitk::DataNode*> selection = this->GetDataManagerSelection();
  this->OnSelectionChanged( selection );
}
void QmitkSimpleMeasurement::AddAngleSimpleMeasurement (  ) [protected, slot]

Definition at line 77 of file QmitkSimpleMeasurement.cpp.

References QmitkFunctionality::FireNodesSelected(), QmitkFunctionality::GetDataStorage(), m_CreatedPointSetNodes, mitk::StringProperty::New(), mitk::BoolProperty::New(), mitk::DataNode::New(), mitk::PointSet::New(), and OnSelectionChanged().

Referenced by CreateQtPartControl().

{
  mitk::PointSet::Pointer pointSet = mitk::PointSet::New();

  mitk::DataNode::Pointer _CurrentPointSetNode = mitk::DataNode::New();
  _CurrentPointSetNode->SetData(pointSet);
  _CurrentPointSetNode->SetProperty("show contour", mitk::BoolProperty::New(true));
  _CurrentPointSetNode->SetProperty("name", mitk::StringProperty::New("angle"));
  _CurrentPointSetNode->SetProperty("show angles", mitk::BoolProperty::New(true));

  // add to ds and remember as created
  this->GetDataStorage()->Add(_CurrentPointSetNode);
  m_CreatedPointSetNodes.push_back( _CurrentPointSetNode );

  // make new selection
  std::vector<mitk::DataNode*> selection;
  selection.push_back( _CurrentPointSetNode );
  this->FireNodesSelected( selection );
  this->OnSelectionChanged( selection );
}
void QmitkSimpleMeasurement::AddDistanceSimpleMeasurement (  ) [protected, slot]

Definition at line 56 of file QmitkSimpleMeasurement.cpp.

References QmitkFunctionality::FireNodesSelected(), QmitkFunctionality::GetDataStorage(), m_CreatedPointSetNodes, mitk::StringProperty::New(), mitk::BoolProperty::New(), mitk::DataNode::New(), mitk::PointSet::New(), and OnSelectionChanged().

Referenced by CreateQtPartControl().

{
  mitk::PointSet::Pointer pointSet = mitk::PointSet::New();

  mitk::DataNode::Pointer _CurrentPointSetNode = mitk::DataNode::New();
  _CurrentPointSetNode->SetData(pointSet);
  _CurrentPointSetNode->SetProperty("show contour", mitk::BoolProperty::New(true));
  _CurrentPointSetNode->SetProperty("name", mitk::StringProperty::New("distance"));
  _CurrentPointSetNode->SetProperty("show distances", mitk::BoolProperty::New(true));

  // add to ds and remember as created
  this->GetDataStorage()->Add(_CurrentPointSetNode);
  m_CreatedPointSetNodes.push_back( _CurrentPointSetNode );

  // make new selection
  std::vector<mitk::DataNode*> selection;
  selection.push_back( _CurrentPointSetNode );
  this->FireNodesSelected( selection );
  this->OnSelectionChanged( selection );
}
void QmitkSimpleMeasurement::AddPathSimpleMeasurement (  ) [protected, slot]

Definition at line 98 of file QmitkSimpleMeasurement.cpp.

References QmitkFunctionality::FireNodesSelected(), QmitkFunctionality::GetDataStorage(), m_CreatedPointSetNodes, mitk::StringProperty::New(), mitk::BoolProperty::New(), mitk::DataNode::New(), mitk::PointSet::New(), and OnSelectionChanged().

Referenced by CreateQtPartControl().

{
  mitk::PointSet::Pointer pointSet = mitk::PointSet::New();

  mitk::DataNode::Pointer _CurrentPointSetNode = mitk::DataNode::New();
  _CurrentPointSetNode->SetData(pointSet);
  _CurrentPointSetNode->SetProperty("show contour", mitk::BoolProperty::New(true));
  _CurrentPointSetNode->SetProperty("name", mitk::StringProperty::New("path"));
  _CurrentPointSetNode->SetProperty("show distances", mitk::BoolProperty::New(true));
  _CurrentPointSetNode->SetProperty("show angles", mitk::BoolProperty::New(true));

  // add to ds and remember as created
  this->GetDataStorage()->Add(_CurrentPointSetNode);
  m_CreatedPointSetNodes.push_back( _CurrentPointSetNode );

  // make new selection
  std::vector<mitk::DataNode*> selection;
  selection.push_back( _CurrentPointSetNode );
  this->FireNodesSelected( selection );
  this->OnSelectionChanged( selection );
}
void QmitkSimpleMeasurement::CreateQtPartControl ( QWidget *  parent ) [protected, virtual]
void QmitkSimpleMeasurement::Deactivated (  ) [virtual]

Only called when IsExclusiveFunctionality() returns true.

See also:
IsExclusiveFunctionality()

Reimplemented from QmitkFunctionality.

Definition at line 50 of file QmitkSimpleMeasurement.cpp.

References OnSelectionChanged().

{
  std::vector<mitk::DataNode*> selection;
  this->OnSelectionChanged( selection );
}
bool QmitkSimpleMeasurement::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 181 of file QmitkSimpleMeasurement.cpp.

{
  return true;
}
void QmitkSimpleMeasurement::NodeRemoved ( const mitk::DataNode node ) [virtual]

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

Reimplemented from QmitkFunctionality.

Definition at line 186 of file QmitkSimpleMeasurement.cpp.

References m_CreatedPointSetNodes.

{
  // remove a node if it is destroyed from our created array
  std::vector<mitk::DataNode*>::iterator it = std::find( m_CreatedPointSetNodes.begin()
    , m_CreatedPointSetNodes.end(), node);
  if(it != m_CreatedPointSetNodes.end())
    m_CreatedPointSetNodes.erase(it);
}
void QmitkSimpleMeasurement::OnSelectionChanged ( std::vector< mitk::DataNode * >  nodes ) [virtual]

Called when the selection in the workbench changed

Reimplemented from QmitkFunctionality.

Definition at line 130 of file QmitkSimpleMeasurement.cpp.

References mitk::DataNode::GetData(), mitk::GlobalInteraction::GetInstance(), mitk::DataNode::GetName(), QmitkFunctionality::IsActivated(), mitk::WeakPointer< TObjectType >::IsNotNull(), m_Controls, m_CreatedPointSetNodes, m_PointSetInteractor, m_SelectedPointSetNode, mitk::PointSetInteractor::New(), Ui_QmitkSimpleMeasurementControls::selectedPointSet, and mitk::DataNode::SetColor().

Referenced by Activated(), AddAngleSimpleMeasurement(), AddDistanceSimpleMeasurement(), AddPathSimpleMeasurement(), and Deactivated().

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

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

  // something else was selected. remove old interactor
  if (m_PointSetInteractor.IsNotNull())
  {
    mitk::GlobalInteraction::GetInstance()->RemoveInteractor(m_PointSetInteractor);
  }

  bool pointsetCreatedByThis = false;

  // only go further if a pointset was selected
  if(pointSet)
  {
    // see if this pointset was created by us
    std::vector<mitk::DataNode*>::iterator it = std::find( m_CreatedPointSetNodes.begin()
      , m_CreatedPointSetNodes.end(), selectedNode);
    if(it != m_CreatedPointSetNodes.end())
     pointsetCreatedByThis = true;
  }

  // do nothing if it was not created by us or it is no pointset node or we are not activated
  if(pointsetCreatedByThis && this->IsActivated())
  {
    // otherwise: set text and add interactor for the pointset
    m_Controls->selectedPointSet->setText( QString::fromStdString(selectedNode->GetName()) );
    mitk::PointSetInteractor::Pointer newPointSetInteractor 
      = mitk::PointSetInteractor::New("pointsetinteractor", selectedNode);
    mitk::GlobalInteraction::GetInstance()->AddInteractor(newPointSetInteractor);
    m_PointSetInteractor = newPointSetInteractor;
    float green[] = { 0, 255, 0 };
    float red[] = { 255, 0, 0 };
    selectedNode->SetColor(green);
    if(m_SelectedPointSetNode.IsNotNull())
      m_SelectedPointSetNode->SetColor(red);
    m_SelectedPointSetNode = selectedNode;
  }
  else
  {
    // revert text
    m_Controls->selectedPointSet->setText( "None" );
  }
}

Member Data Documentation

controls containing sliders for scrolling through the slices

Definition at line 78 of file QmitkSimpleMeasurement.h.

Referenced by CreateQtPartControl(), and OnSelectionChanged().

Definition at line 83 of file QmitkSimpleMeasurement.h.

Referenced by OnSelectionChanged().

Definition at line 88 of file QmitkSimpleMeasurement.h.

Referenced by OnSelectionChanged().


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