diff --git a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp index 2bb694c36e..6b86252992 100644 --- a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp +++ b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp @@ -1,86 +1,88 @@ $(license) // Blueberry #include #include // Qmitk #include "$(view-file-name).h" // Qt #include +//mitk image +#include const std::string $(view-class-name)::VIEW_ID = "$(view-id)"; void $(view-class-name)::SetFocus() { m_Controls.buttonPerformImageProcessing->setFocus(); } void $(view-class-name)::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); connect( m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoImageProcessing()) ); } void $(view-class-name)::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) { // iterate all selected objects, adjust warning visibility foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() && dynamic_cast(node->GetData()) ) { m_Controls.labelWarning->setVisible( false ); m_Controls.buttonPerformImageProcessing->setEnabled( true ); return; } } m_Controls.labelWarning->setVisible( true ); m_Controls.buttonPerformImageProcessing->setEnabled( false ); } void $(view-class-name)::DoImageProcessing() { QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode* node = nodes.front(); if (!node) { // Nothing selected. Inform the user and return QMessageBox::information( NULL, "Template", "Please load and select an image before starting image processing."); return; } // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item (the image) mitk::BaseData* data = node->GetData(); if (data) { // test if this data item is an image or not (could also be a surface or something totally different) mitk::Image* image = dynamic_cast( data ); if (image) { std::stringstream message; std::string name; message << "Performing image processing for image "; if (node->GetName(name)) { // a property called "name" was found for this DataNode message << "'" << name << "'"; } message << "."; MITK_INFO << message.str(); // actually do something here... } } }