diff --git a/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.cpp b/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.cpp index d776e642cc..2fcca6604b 100644 --- a/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.cpp +++ b/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.cpp @@ -1,88 +1,89 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkAboutDialog.h" #include "QmitkModulesDialog.h" #include #include #include #include #include QmitkAboutDialog::QmitkAboutDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f) { m_GUI.setupUi(this); QString mitkRevision(MITK_REVISION); QString mitkRevisionDescription(MITK_REVISION_DESC); QString itkVersion = QString("%1.%2.%3").arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH); QString vtkVersion = QString("%1.%2.%3").arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION); QString revisionText = QString("Revision: %1").arg(MITK_REVISION); if (!QString(MITK_REVISION_DESC).isEmpty()) revisionText += QString("\nDescription: %1").arg(MITK_REVISION_DESC); m_GUI.m_RevisionLabel->setText(revisionText); m_GUI.m_ToolkitVersionsLabel->setText(QString("ITK %1, VTK %2, Qt %3").arg(itkVersion, vtkVersion, QT_VERSION_STR)); - QPushButton* btnModules = new QPushButton(QIcon(":/qmitk/ModuleView.png"), "Modules"); + QPushButton* btnModules = new QPushButton(QIcon(":/QtWidgetsExt/ModuleView.png"), "Modules"); m_GUI.m_ButtonBox->addButton(btnModules, QDialogButtonBox::ActionRole); connect(btnModules, SIGNAL(clicked()), this, SLOT(ShowModules())); connect(m_GUI.m_ButtonBox, SIGNAL(rejected()), this, SLOT(reject())); } QmitkAboutDialog::~QmitkAboutDialog() { } void QmitkAboutDialog::ShowModules() { QmitkModulesDialog dialog(this); dialog.exec(); } QString QmitkAboutDialog::GetAboutText() const { return m_GUI.m_AboutLabel->text(); } QString QmitkAboutDialog::GetCaptionText() const { return m_GUI.m_CaptionLabel->text(); } QString QmitkAboutDialog::GetRevisionText() const { return m_GUI.m_RevisionLabel->text(); } void QmitkAboutDialog::SetAboutText(const QString &text) { m_GUI.m_AboutLabel->setText(text); } void QmitkAboutDialog::SetCaptionText(const QString &text) { m_GUI.m_CaptionLabel->setText(text); } void QmitkAboutDialog::SetRevisionText(const QString &text) { m_GUI.m_RevisionLabel->setText(text); } + diff --git a/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.h b/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.h index 22d89ce2b7..88e3f37875 100644 --- a/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.h +++ b/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialog.h @@ -1,41 +1,42 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include "MitkQtWidgetsExtExports.h" class MitkQtWidgetsExt_EXPORT QmitkAboutDialog : public QDialog { Q_OBJECT public: QmitkAboutDialog(QWidget* parent = 0, Qt::WindowFlags f = Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); virtual ~QmitkAboutDialog(); QString GetAboutText() const; QString GetCaptionText() const; QString GetRevisionText() const; void SetAboutText(const QString &text); void SetCaptionText(const QString &text); void SetRevisionText(const QString &text); protected slots: void ShowModules(); private: Ui::QmitkAboutDialog m_GUI; }; + diff --git a/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialogGUI.ui b/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialogGUI.ui index 3bebfe418f..bc34b3facb 100644 --- a/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialogGUI.ui +++ b/Modules/QtWidgetsExt/QmitkAboutDialog/QmitkAboutDialogGUI.ui @@ -1,174 +1,174 @@ QmitkAboutDialog 0 0 534 421 About false 0 0 MS Sans Serif 48 75 true MITK Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft 0 0 Revision: hash Description: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop ITK x.x.x, VTK x.x.x, Qt x.x.x Qt::Horizontal QSizePolicy::Expanding 40 20 84 56 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.dkfz.de/en/mbi/"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/qmitk/Logo_mbiATdkfz_small.png" /></span></a></p></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.dkfz.de/en/mbi/"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/QtWidgetsExt/Logo_mbiATdkfz_small.png" /></span></a></p></body></html> true true true 0 0 514 236 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt; font-weight:600;">General Information</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">MITK [1] has been developed by the Division of Medical and Biological Informatics of the German Cancer Research Center (DKFZ) [2].</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">[1] <a href="http://www.mitk.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.mitk.org/</span></a></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">[2] <a href="http://www.dkfz.de/en/mbi/index.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.dkfz.de/en/mbi/index.php</span></a></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To contact the MITK team, see <a href="http://www.mitk.org/wiki/Contact"><span style=" text-decoration: underline; color:#0000ff;">http://www.mitk.org/wiki/Contact</span></a>.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">Third Party Libraries</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://docs.mitk.org/nightly-qt4/thirdpartylibs.html"><span style=" text-decoration: underline; color:#0000ff;">http://docs.mitk.org/nightly-qt4/thirdpartylibs.html</span></a></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"><br /></p></body></html> true true QDialogButtonBox::Close diff --git a/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.cpp b/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.cpp index 5d87121801..cea0357ac2 100644 --- a/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.cpp +++ b/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.cpp @@ -1,335 +1,327 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkIOUtil.h" #include #include #include // QT #include #include //ITK #include -void mitk::QmitkIOUtil::SaveBaseDataWithDialog(mitk::BaseData* data, std::string fileName, QWidget* parent) +void QmitkIOUtil::SaveBaseDataWithDialog(mitk::BaseData* data, std::string fileName, QWidget* parent) { - try + try + { + if (data != NULL) { - if (data != NULL) - { - /* //########### Check if we can save as standard image type via itkImageWriter - mitk::Image::Pointer image = dynamic_cast(data); - QString classname(data->GetNameOfClass()); - if ( image.IsNotNull() && (classname.compare("Image")==0 || classname.compare("SeedsImage")==0 ) ) - { - SaveImageWithDialog(image, fileName, parent); - return; //succes. we can return - } - //########### End Check if we can save as standard image type via itkImageWriter -*/ - //########### Check if we can save as standard pointset type via mitkPointSetWriter - mitk::PointSet::Pointer pointset = dynamic_cast(data); - if(pointset.IsNotNull()) - { - SavePointSetWithDialog(pointset, fileName, parent); - return; //succes. we can return - } - //########### End Check if we can save as standard pointset type via mitkPointSetWriter - - //########### Check if we can save as standard surface type via mitkVtkSurfaceWriter - mitk::Surface::Pointer surface = dynamic_cast(data); - if(surface.IsNotNull()) - { - SaveSurfaceWithDialog(surface, fileName, parent); - return; //succes. we can return - } - //########### End Check if we can save as standard surface type via mitkVtkSurfaceWriter - - //########### None standard data type was found, try to save with extensions. - // now try the file writers provided by the CoreObjectFactory - - mitk::CoreObjectFactory::FileWriterList fileWriters = mitk::CoreObjectFactory::GetInstance()->GetFileWriters(); - - mitk::CoreObjectFactory::FileWriterList fileWriterCandidates; - QString fileDialogPattern; - for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriters.begin() ; it != fileWriters.end() ; ++it) - { - if ( (*it)->CanWriteBaseDataType(data) ) - { - fileWriterCandidates.push_back(*it); - fileDialogPattern += QString::fromStdString((*it)->GetFileDialogPattern()) + ";;"; - } - } - - if (!fileWriterCandidates.empty()) - { - // remove last ';;' from pattern - fileDialogPattern.remove( fileDialogPattern.size()-2, 2); - - // Ensure a valid filename - QString qFileName(QString::fromStdString(fileName)); - QString qProposedFileName( qFileName ); - QString selectedFilter; - if(qFileName.isEmpty()) - { - qProposedFileName.append(fileWriterCandidates.front()->GetDefaultFilename()); - } - qProposedFileName.append(fileWriterCandidates.front()->GetDefaultExtension()); - qFileName = GetFileNameWithQDialog("Save file", qProposedFileName, - fileDialogPattern, &selectedFilter); - //do nothing if the user presses cancel - if ( qFileName.isEmpty() ) - return; - - std::string ext = itksys::SystemTools::GetFilenameLastExtension(qFileName.toStdString()); - QString extension = QString::fromStdString(ext); - - //QString extension = "."+QFileInfo(qFileName).completeSuffix(); - for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriterCandidates.begin() ; - it != fileWriterCandidates.end() ; ++it) - { - if ((*it)->IsExtensionValid(extension.toStdString())) - { - (*it)->SetFileName( qPrintable(qFileName) ); - (*it)->DoWrite( data ); - return; - } - } - - // if the image extension consists of two parts (e.g. *.nii.gz) we need to check again - // with the two last extensions. This is to allow points within the image name. - QString qFileNameCopy(qFileName); - qFileNameCopy.remove(QString::fromStdString(ext)); - std::string ext2 = itksys::SystemTools::GetFilenameLastExtension(qFileNameCopy.toStdString()); - ext2.append(ext); - extension = QString::fromStdString(ext2); - for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriterCandidates.begin() ; - it != fileWriterCandidates.end() ; ++it) - { - if ((*it)->IsExtensionValid(extension.toStdString())) - { - (*it)->SetFileName( qPrintable(qFileName) ); - (*it)->DoWrite( data ); - return; - } - } - // returns earlier when successful - } - - // no appropriate writer has been found - QMessageBox::critical(parent,"ERROR","Could not find file writer for this data type"); - return; - } - }catch(itk::ExceptionObject e) - { - QMessageBox::critical( parent, "Exception during saving", e.GetDescription(),QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); - } -} - -void mitk::QmitkIOUtil::SaveSurfaceWithDialog(mitk::Surface::Pointer surface, std::string fileName, QWidget* parent) -{ - //default selected suffix for surfaces - QString selected_suffix("STL File (*.stl)"); - QString possible_suffixes("STL File (*.stl);; VTK File (*.vtk);; VTP File (*.vtp)"); - //default initial file name - QString initialFilename("NewSurface"); - //default image extension - initialFilename.append((mitk::IOUtil::DEFAULTSURFACEEXTENSION).c_str()); - - //if any filename is supplied by the user, use it - if( !fileName.empty() ) - { - initialFilename = fileName.c_str(); - } - - QString qfileName = GetFileNameWithQDialog("Save Surface", initialFilename , possible_suffixes, &selected_suffix, parent); - - //do nothing if the user presses cancel - if ( qfileName.isEmpty() ) return; - try{ - mitk::IOUtil::SaveSurface(surface,qfileName.toLocal8Bit().constData()); - } - catch(mitk::Exception &e) - { - MITK_ERROR << "error saving file: " << e.what(); - - std::string msg("Could not save surface.\n Error: "); - msg.append(e.what()); + //########### Check if we can save as standard pointset type via mitkPointSetWriter + mitk::PointSet::Pointer pointset = dynamic_cast(data); + if(pointset.IsNotNull()) + { + SavePointSetWithDialog(pointset, fileName, parent); + return; //succes. we can return + } + //########### End Check if we can save as standard pointset type via mitkPointSetWriter - QMessageBox::critical( NULL, "Exception during saving", msg.c_str(), - QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); - } -} + //########### Check if we can save as standard surface type via mitkVtkSurfaceWriter + mitk::Surface::Pointer surface = dynamic_cast(data); + if(surface.IsNotNull()) + { + SaveSurfaceWithDialog(surface, fileName, parent); + return; //succes. we can return + } + //########### End Check if we can save as standard surface type via mitkVtkSurfaceWriter -void mitk::QmitkIOUtil::SaveImageWithDialog(mitk::Image::Pointer image, std::string fileName, QWidget *parent) -{ - //default selected suffix for images - QString selected_suffix("Nearly Raw Raster Data (*.nrrd)"); - //default initial file name - QString initialFilename("NewImage"); - //default image extension - initialFilename.append((mitk::IOUtil::DEFAULTIMAGEEXTENSION).c_str()); - - //if any filename is supplied by the user, use it - if( !fileName.empty() ) - { - initialFilename = fileName.c_str(); - } + //########### None standard data type was found, try to save with extensions. + // now try the file writers provided by the CoreObjectFactory - QString qfileName = GetFileNameWithQDialog("Save Image", initialFilename, - mitk::ImageWriter::New()->GetFileDialogPattern(), - &selected_suffix,parent); + mitk::CoreObjectFactory::FileWriterList fileWriters = mitk::CoreObjectFactory::GetInstance()->GetFileWriters(); - //do nothing if the user presses cancel - if ( qfileName.isEmpty() ) return; + mitk::CoreObjectFactory::FileWriterList fileWriterCandidates; + QString fileDialogPattern; + for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriters.begin() ; it != fileWriters.end() ; ++it) + { + if ( (*it)->CanWriteBaseDataType(data) ) + { + fileWriterCandidates.push_back(*it); + fileDialogPattern += QString::fromStdString((*it)->GetFileDialogPattern()) + ";;"; + } + } - try - { - mitk::IOUtil::SaveImage(image, qfileName.toLocal8Bit().constData()); - } - catch(mitk::Exception &e) - { - MITK_ERROR << "error saving file: " << e.what(); + if (!fileWriterCandidates.empty()) + { + // remove last ';;' from pattern + fileDialogPattern.remove( fileDialogPattern.size()-2, 2); + + // Ensure a valid filename + QString qFileName(QString::fromStdString(fileName)); + QString qProposedFileName( qFileName ); + QString selectedFilter; + if(qFileName.isEmpty()) + { + qProposedFileName.append(fileWriterCandidates.front()->GetDefaultFilename()); + } + qProposedFileName.append(fileWriterCandidates.front()->GetDefaultExtension()); + qFileName = GetFileNameWithQDialog("Save file", qProposedFileName, + fileDialogPattern, &selectedFilter); + //do nothing if the user presses cancel + if ( qFileName.isEmpty() ) + return; + + std::string ext = itksys::SystemTools::GetFilenameLastExtension(qFileName.toStdString()); + QString extension = QString::fromStdString(ext); + + //QString extension = "."+QFileInfo(qFileName).completeSuffix(); + for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriterCandidates.begin() ; + it != fileWriterCandidates.end() ; ++it) + { + if ((*it)->IsExtensionValid(extension.toStdString())) + { + (*it)->SetFileName( qPrintable(qFileName) ); + (*it)->DoWrite( data ); + return; + } + } - std::string msg("Could not save image.\n Error: "); - msg.append(e.what()); + // if the image extension consists of two parts (e.g. *.nii.gz) we need to check again + // with the two last extensions. This is to allow points within the image name. + QString qFileNameCopy(qFileName); + qFileNameCopy.remove(QString::fromStdString(ext)); + std::string ext2 = itksys::SystemTools::GetFilenameLastExtension(qFileNameCopy.toStdString()); + ext2.append(ext); + extension = QString::fromStdString(ext2); + for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriterCandidates.begin() ; + it != fileWriterCandidates.end() ; ++it) + { + if ((*it)->IsExtensionValid(extension.toStdString())) + { + (*it)->SetFileName( qPrintable(qFileName) ); + (*it)->DoWrite( data ); + return; + } + } + // returns earlier when successful + } - QMessageBox::critical( NULL, "Exception during saving", msg.c_str(), - QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); + // no appropriate writer has been found + QMessageBox::critical(parent,"ERROR","Could not find file writer for this data type"); + return; } + }catch(itk::ExceptionObject e) + { + QMessageBox::critical( parent, "Exception during saving", e.GetDescription(),QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); + } } -void mitk::QmitkIOUtil::SavePointSetWithDialog(mitk::PointSet::Pointer pointset, std::string fileName, QWidget *parent) -{ - //default selected suffix for point sets - QString selected_suffix("MITK Point-Sets (*.mps)"); - QString possible_suffixes("MITK Point-Sets (*.mps)"); - //default initial file name - QString initialFilename("NewPointSet"); - //default image extension - initialFilename.append((mitk::IOUtil::DEFAULTPOINTSETEXTENSION).c_str()); - - //if any filename is supplied by the user, use it - if( !fileName.empty() ) - { - initialFilename = fileName.c_str(); - } - - QString qfileName = GetFileNameWithQDialog("Save PointSet", initialFilename , possible_suffixes, &selected_suffix, parent); - //do nothing if the user presses cancel - if ( qfileName.isEmpty() ) return; - try{ - mitk::IOUtil::SavePointSet(pointset,qfileName.toLocal8Bit().constData()); - } - catch(mitk::Exception &e) - { - MITK_ERROR << "error saving file: " << e.what(); +void QmitkIOUtil::SaveSurfaceWithDialog(mitk::Surface::Pointer surface, std::string fileName, QWidget* parent) +{ + //default selected suffix for surfaces + QString selected_suffix("STL File (*.stl)"); + QString possible_suffixes("STL File (*.stl);; VTK File (*.vtk);; VTP File (*.vtp)"); + //default initial file name + QString initialFilename("NewSurface"); + //default image extension + initialFilename.append((mitk::IOUtil::DEFAULTSURFACEEXTENSION).c_str()); + + //if any filename is supplied by the user, use it + if( !fileName.empty() ) + { + initialFilename = fileName.c_str(); + } + + QString qfileName = GetFileNameWithQDialog("Save Surface", initialFilename , possible_suffixes, &selected_suffix, parent); + + //do nothing if the user presses cancel + if ( qfileName.isEmpty() ) return; + try{ + mitk::IOUtil::SaveSurface(surface,qfileName.toLocal8Bit().constData()); + } + catch(mitk::Exception &e) + { + MITK_ERROR << "error saving file: " << e.what(); + + std::string msg("Could not save surface.\n Error: "); + msg.append(e.what()); + + QMessageBox::critical( NULL, "Exception during saving", msg.c_str(), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); + } +} - std::string msg("Could not save pointset.\n Error: "); - msg.append(e.what()); +void QmitkIOUtil::SaveImageWithDialog(mitk::Image::Pointer image, std::string fileName, QWidget *parent) +{ + //default selected suffix for images + QString selected_suffix("Nearly Raw Raster Data (*.nrrd)"); + //default initial file name + QString initialFilename("NewImage"); + //default image extension + initialFilename.append((mitk::IOUtil::DEFAULTIMAGEEXTENSION).c_str()); + + //if any filename is supplied by the user, use it + if( !fileName.empty() ) + { + initialFilename = fileName.c_str(); + } + + QString qfileName = GetFileNameWithQDialog("Save Image", initialFilename, + mitk::ImageWriter::New()->GetFileDialogPattern(), + &selected_suffix,parent); + + //do nothing if the user presses cancel + if ( qfileName.isEmpty() ) return; + + try + { + mitk::IOUtil::SaveImage(image, qfileName.toLocal8Bit().constData()); + } + catch(mitk::Exception &e) + { + MITK_ERROR << "error saving file: " << e.what(); + + std::string msg("Could not save image.\n Error: "); + msg.append(e.what()); + + QMessageBox::critical( NULL, "Exception during saving", msg.c_str(), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); + } +} - QMessageBox::critical( NULL, "Exception during saving", msg.c_str(), - QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); - } +void QmitkIOUtil::SavePointSetWithDialog(mitk::PointSet::Pointer pointset, std::string fileName, QWidget *parent) +{ + //default selected suffix for point sets + QString selected_suffix("MITK Point-Sets (*.mps)"); + QString possible_suffixes("MITK Point-Sets (*.mps)"); + //default initial file name + QString initialFilename("NewPointSet"); + //default image extension + initialFilename.append((mitk::IOUtil::DEFAULTPOINTSETEXTENSION).c_str()); + + //if any filename is supplied by the user, use it + if( !fileName.empty() ) + { + initialFilename = fileName.c_str(); + } + + QString qfileName = GetFileNameWithQDialog("Save PointSet", initialFilename , possible_suffixes, &selected_suffix, parent); + + //do nothing if the user presses cancel + if ( qfileName.isEmpty() ) return; + try{ + mitk::IOUtil::SavePointSet(pointset,qfileName.toLocal8Bit().constData()); + } + catch(mitk::Exception &e) + { + MITK_ERROR << "error saving file: " << e.what(); + + std::string msg("Could not save pointset.\n Error: "); + msg.append(e.what()); + + QMessageBox::critical( NULL, "Exception during saving", msg.c_str(), + QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); + } } -QString mitk::QmitkIOUtil::GetFileNameWithQDialog(QString caption, QString defaultFilename, QString filter, QString* selectedFilter, QWidget* parent) +QString QmitkIOUtil::GetFileNameWithQDialog(QString caption, QString defaultFilename, QString filter, QString* selectedFilter, QWidget* parent) { - QString returnfileName = ""; - static QString lastDirectory = ""; - QString filename = lastDirectory +"/"+ defaultFilename; - QString selectedFilterInternal = selectedFilter ? *selectedFilter : QString::null; - returnfileName = QFileDialog::getSaveFileName(parent,caption,filename,filter,&selectedFilterInternal, QFileDialog::DontConfirmOverwrite); - if (selectedFilter) - { - *selectedFilter = selectedFilterInternal; - } - if (!returnfileName.isEmpty()) + QString returnfileName = ""; + static QString lastDirectory = ""; + QString filename = lastDirectory +"/"+ defaultFilename; + QString selectedFilterInternal = selectedFilter ? *selectedFilter : QString::null; + returnfileName = QFileDialog::getSaveFileName(parent,caption,filename,filter,&selectedFilterInternal, QFileDialog::DontConfirmOverwrite); + if (selectedFilter) + { + *selectedFilter = selectedFilterInternal; + } + if (!returnfileName.isEmpty()) + { + QFileInfo fileInfo(returnfileName); + lastDirectory = fileInfo.absolutePath(); // remember path for next save dialog + if(fileInfo.completeSuffix().isEmpty()) // if no extension has been entered manually into the filename { - QFileInfo fileInfo(returnfileName); - lastDirectory = fileInfo.absolutePath(); // remember path for next save dialog - if(fileInfo.completeSuffix().isEmpty()) // if no extension has been entered manually into the filename + // get from combobox selected file extension + QString selectedExtensions = selectedFilterInternal.split(" (", QString::SkipEmptyParts).back().trimmed(); + selectedExtensions = selectedExtensions.split(")", QString::SkipEmptyParts).front().trimmed(); + QString selectedExtension = selectedExtensions.split(" ", QString::SkipEmptyParts).front(); + if (selectedExtension.size() < 3) // at least something like "*.?" { - // get from combobox selected file extension - QString selectedExtensions = selectedFilterInternal.split(" (", QString::SkipEmptyParts).back().trimmed(); - selectedExtensions = selectedExtensions.split(")", QString::SkipEmptyParts).front().trimmed(); - QString selectedExtension = selectedExtensions.split(" ", QString::SkipEmptyParts).front(); - if (selectedExtension.size() < 3) // at least something like "*.?" - { - QMessageBox::critical(parent, "File extension error", "Unable to deduce a valid file extension."); - return QString::null; - } - selectedExtension = selectedExtension.mid(1); - returnfileName += selectedExtension; //add it to the path which is returned + QMessageBox::critical(parent, "File extension error", "Unable to deduce a valid file extension."); + return QString::null; } + selectedExtension = selectedExtension.mid(1); + returnfileName += selectedExtension; //add it to the path which is returned + } - //check if the file exists - if(fileInfo.exists()) + //check if the file exists + if(fileInfo.exists()) + { + int answer = QMessageBox::question( parent, "Warning", + QString("File %1 already exists. Overwrite?").arg( returnfileName ), + QMessageBox::Yes, + QMessageBox::No ); + if( answer == QMessageBox::No ) { - int answer = QMessageBox::question( parent, "Warning", - QString("File %1 already exists. Overwrite?").arg( returnfileName ), - QMessageBox::Yes, - QMessageBox::No ); - if( answer == QMessageBox::No ) - { - returnfileName.clear(); - } + returnfileName.clear(); } } + } - return returnfileName; + return returnfileName; } -bool mitk::QmitkIOUtil::SaveToFileWriter( mitk::FileWriterWithInformation::Pointer fileWriter, mitk::BaseData::Pointer data, const std::string fileName ) +bool QmitkIOUtil::SaveToFileWriter( mitk::FileWriterWithInformation::Pointer fileWriter, mitk::BaseData::Pointer data, const std::string fileName ) { - // Ensure a valid filename - QString qFileName(QString::fromStdString(fileName)); - QString qProposedFileName(qFileName); - if(qFileName.isEmpty()) + // Ensure a valid filename + QString qFileName(QString::fromStdString(fileName)); + QString qProposedFileName(qFileName); + if(qFileName.isEmpty()) + { + qProposedFileName.append(fileWriter->GetDefaultFilename()); + } + qProposedFileName.append(fileWriter->GetDefaultExtension()); + qFileName = GetFileNameWithQDialog("Save file", qProposedFileName, + QString::fromAscii(fileWriter->GetFileDialogPattern())); + //do nothing if the user presses cancel + if ( qFileName.isEmpty() ) + return false; + + // Check if an extension exists already and if not, append the default extension + if ( !qFileName.contains( QRegExp("\\.\\w+$") ) ) + { + qFileName.append( fileWriter->GetDefaultExtension() ); + } + else + { + std::string extension = itksys::SystemTools::GetFilenameLastExtension( qFileName.toLocal8Bit().constData() ); + if (!fileWriter->IsExtensionValid(extension)) { - qProposedFileName.append(fileWriter->GetDefaultFilename()); - } - qProposedFileName.append(fileWriter->GetDefaultExtension()); - qFileName = GetFileNameWithQDialog("Save file", qProposedFileName, - QString::fromAscii(fileWriter->GetFileDialogPattern())); - //do nothing if the user presses cancel - if ( qFileName.isEmpty() ) return false; - - // Check if an extension exists already and if not, append the default extension - if ( !qFileName.contains( QRegExp("\\.\\w+$") ) ) - { - qFileName.append( fileWriter->GetDefaultExtension() ); - } - else - { - std::string extension = itksys::SystemTools::GetFilenameLastExtension( qFileName.toLocal8Bit().constData() ); - if (!fileWriter->IsExtensionValid(extension)) - { - return false; - } } - //Write only if a valid name was set - if(qFileName.isEmpty() == false) - { - fileWriter->SetFileName( qFileName.toLocal8Bit().constData() ); - fileWriter->DoWrite( data ); - } - - return true; + } + //Write only if a valid name was set + if(qFileName.isEmpty() == false) + { + fileWriter->SetFileName( qFileName.toLocal8Bit().constData() ); + fileWriter->DoWrite( data ); + } + + return true; } + diff --git a/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.h b/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.h index 9e5cd63e68..cb3d33316b 100644 --- a/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.h +++ b/Modules/QtWidgetsExt/QmitkApplicationBase/QmitkIOUtil.h @@ -1,106 +1,103 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkIOUtil__h_ #define _QmitkIOUtil__h_ #include "MitkQtWidgetsExtExports.h" // std #include // mitk includes #include #include #include #include #include #include //Qt #include #include - -namespace mitk -{ - class MitkQtWidgetsExt_EXPORT QmitkIOUtil { - /** - * @brief QmitkIOUtil This is a static helper method to save any files with Qt dialogs. - * Methods of opening files with dialogs are currently implemented in QmitkFileOpenAction.h. - */ + /** + * @brief QmitkIOUtil This is a static helper method to save any files with Qt dialogs. + * Methods of opening files with dialogs are currently implemented in QmitkFileOpenAction.h. + */ public: - /** - * @brief SaveBaseDataWithDialog Convenience method to save any data with a Qt dialog. - * @param data BaseData holding the data you wish to save. + /** + * @brief SaveBaseDataWithDialog Convenience method to save any data with a Qt dialog. + * @param data BaseData holding the data you wish to save. + * @param fileName The file name where to save the data (including path and extension). + * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. + */ + static void SaveBaseDataWithDialog(BaseData *data, std::string fileName, QWidget* parent = NULL); + + /** + * @brief SaveSurfaceWithDialog Convenience method to save a surface with a Qt dialog. + * @param surface The surface to save. * @param fileName The file name where to save the data (including path and extension). * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. */ - static void SaveBaseDataWithDialog(BaseData *data, std::string fileName, QWidget* parent = NULL); - - /** - * @brief SaveSurfaceWithDialog Convenience method to save a surface with a Qt dialog. - * @param surface The surface to save. - * @param fileName The file name where to save the data (including path and extension). - * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. - */ - static void SaveSurfaceWithDialog(mitk::Surface::Pointer surface, std::string fileName = "", QWidget* parent = NULL); - - /** - * @brief SaveImageWithDialog Convenience method to save an image with a Qt dialog. - * @param image The image to save. - * @param fileName The file name where to save the data (including path and extension). - * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. - */ - static void SaveImageWithDialog(mitk::Image::Pointer image, std::string fileName = "", QWidget* parent = NULL); - - /** - * @brief SavePointSetWithDialog Convenience method to save a pointset with a Qt dialog. - * @param pointset The pointset to save. - * @param fileName The file name where to save the data (including path and extension). - * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. - */ - static void SavePointSetWithDialog(mitk::PointSet::Pointer pointset, std::string fileName = "", QWidget* parent = NULL); - -protected: + static void SaveSurfaceWithDialog(mitk::Surface::Pointer surface, std::string fileName = "", QWidget* parent = NULL); - /** - * @brief GetFileNameWithQDialog Opens a QDialog and returns the filename. - * @param caption Caption for the QDialog. - * @param defaultFilename Default filename (e.g. "NewImage.nrrd" for images). - * @param filter Filters the data according to data types (e.g. *.nrrd; *.png; etc. for images). - * @param selectedFilter Default selected filter for the data. - * @return The file name as QString. + /** + * @brief SaveImageWithDialog Convenience method to save an image with a Qt dialog. + * @param image The image to save. + * @param fileName The file name where to save the data (including path and extension). + * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. */ - static QString GetFileNameWithQDialog(QString caption, QString defaultFilename, QString filter, QString* selectedFilter = 0, QWidget* parent = NULL); - - /** - * @brief SaveToFileWriter Internal helper method to save data with writer's which have been supplied by extensions (e.g. TensorImage etc.). - * @param fileWriter The writer supplied by an extension. - * @param data The data to save in a specific format. - * @param aFileName The filename. - * @param propFileName Proposed file name? - * @return false if writing attempt failed, true otherwise + static void SaveImageWithDialog(mitk::Image::Pointer image, std::string fileName = "", QWidget* parent = NULL); + + /** + * @brief SavePointSetWithDialog Convenience method to save a pointset with a Qt dialog. + * @param pointset The pointset to save. + * @param fileName The file name where to save the data (including path and extension). + * @param parent An optional QWidget as parent. If no parent is supplied, the QFileDialog can occur anywhere on the screen. */ - static bool SaveToFileWriter(mitk::FileWriterWithInformation::Pointer fileWriter, mitk::BaseData::Pointer data, const std::string fileName); + static void SavePointSetWithDialog(mitk::PointSet::Pointer pointset, std::string fileName = "", QWidget* parent = NULL); + +protected: + + /** + * @brief GetFileNameWithQDialog Opens a QDialog and returns the filename. + * @param caption Caption for the QDialog. + * @param defaultFilename Default filename (e.g. "NewImage.nrrd" for images). + * @param filter Filters the data according to data types (e.g. *.nrrd; *.png; etc. for images). + * @param selectedFilter Default selected filter for the data. + * @return The file name as QString. + */ + static QString GetFileNameWithQDialog(QString caption, QString defaultFilename, QString filter, QString* selectedFilter = 0, QWidget* parent = NULL); + + /** + * @brief SaveToFileWriter Internal helper method to save data with writer's which have been supplied by extensions (e.g. TensorImage etc.). + * @param fileWriter The writer supplied by an extension. + * @param data The data to save in a specific format. + * @param aFileName The filename. + * @param propFileName Proposed file name? + * @return false if writing attempt failed, true otherwise + */ + static bool SaveToFileWriter(mitk::FileWriterWithInformation::Pointer fileWriter, mitk::BaseData::Pointer data, const std::string fileName); }; -} //end namespace mitk -#endif // _QmitkIOUtil__h_ + +#endif + diff --git a/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.cpp b/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.cpp index eb01aab444..3de52bd5fe 100644 --- a/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.cpp @@ -1,468 +1,450 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkBoundingObjectWidget.h" #include #include #include #include #include #include #include #include #include #include #include #include #include -#include "btnCube.xpm" -#include "btnCylinder.xpm" -#include "btnEllipsoid.xpm" -#include "btnPyramid.xpm" - - QmitkBoundingObjectWidget::QmitkBoundingObjectWidget (QWidget* parent, Qt::WindowFlags f ):QWidget( parent, f ), m_DataStorage(NULL), m_lastSelectedItem(NULL), m_lastAffineObserver(NULL), m_ItemNodeMap(), m_BoundingObjectCounter(1) { QBoxLayout* mainLayout = new QVBoxLayout(this); QHBoxLayout* buttonLayout = new QHBoxLayout(); QStringList boList; boList << tr("add") << tr("cube") << tr("cone") << tr("ellipse") << tr("cylinder"); m_addComboBox = new QComboBox(); m_addComboBox->addItems(boList); - m_addComboBox->setItemIcon(1, QIcon(btnCube_xpm)); - m_addComboBox->setItemIcon(2, QIcon(btnPyramid_xpm)); - m_addComboBox->setItemIcon(3, QIcon(btnEllipsoid_xpm)); - m_addComboBox->setItemIcon(4, QIcon(btnCylinder_xpm)); + m_addComboBox->setItemIcon(1, QIcon(":/QmitkWidgetsExt/btnCube.xpm")); + m_addComboBox->setItemIcon(2, QIcon(":/QmitkWidgetsExt/btnPyramid.xpm")); + m_addComboBox->setItemIcon(3, QIcon(":/QmitkWidgetsExt/btnEllipsoid.xpm")); + m_addComboBox->setItemIcon(4, QIcon(":/QmitkWidgetsExt/btnCylinder.xpm")); buttonLayout->addWidget(m_addComboBox); m_DelButton = new QPushButton("del"); buttonLayout->addWidget(m_DelButton); m_SaveButton = new QPushButton("save"); buttonLayout->addWidget(m_SaveButton); m_SaveButton->setEnabled(false); m_LoadButton = new QPushButton("load"); buttonLayout->addWidget(m_LoadButton); m_LoadButton->setEnabled(false); m_TreeWidget = new QTreeWidget(this); m_TreeWidget->setColumnCount(3); QStringList sList; sList << tr("name") << tr("inverted") << tr("visible"); m_TreeWidget->setHeaderLabels(sList); m_TreeWidget->setColumnWidth(0, 250); m_TreeWidget->setColumnWidth(1, 50); m_TreeWidget->setColumnWidth(2, 50); m_TreeWidget->setAutoScroll(true); m_TreeWidget->setSelectionMode(QAbstractItemView::SingleSelection); mainLayout->addWidget(m_TreeWidget); mainLayout->addLayout(buttonLayout); connect( m_addComboBox , SIGNAL(currentIndexChanged(int)), this, SLOT(CreateBoundingObject(int)) ); connect( m_TreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(SelectionChanged()) ); - /*connect( m_SaveButton, SIGNAL(clicked()), this, SLOT(OnSaveButtonClicked()) ); - connect( m_LoadButton, SIGNAL(clicked()), this, SLOT(OnLoadButtonClicked()) );*/ connect( m_DelButton, SIGNAL(clicked()), this, SLOT(OnDelButtonClicked()) ); connect(m_TreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(OnItemDoubleClicked(QTreeWidgetItem*, int)) ); connect(m_TreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(OnItemDataChanged(QTreeWidgetItem*, int)) ); } QmitkBoundingObjectWidget::~QmitkBoundingObjectWidget() { } void QmitkBoundingObjectWidget::setEnabled(bool flag) { ItemNodeMapType::iterator it = m_ItemNodeMap.begin(); while( it != m_ItemNodeMap.end()) { mitk::DataNode* node = it->second; QTreeWidgetItem* item = it->first; if (flag) node->SetVisibility(item->checkState(2)); else node->SetVisibility(flag); ++it; } QWidget::setEnabled(flag); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkBoundingObjectWidget::SelectionChanged() { QList selectedItems = m_TreeWidget->selectedItems(); if (selectedItems.size() < 1) return; QTreeWidgetItem* selectedItem = selectedItems.first(); if (selectedItem == m_lastSelectedItem) return; if (m_lastSelectedItem != NULL) { m_TreeWidget->closePersistentEditor(m_lastSelectedItem, 0); ItemNodeMapType::iterator it = m_ItemNodeMap.find(m_lastSelectedItem); if (it != m_ItemNodeMap.end()) { mitk::DataNode* last_node = it->second; //remove observer last_node->RemoveObserver(m_lastAffineObserver); //get and remove interactor mitk::AffineInteractor::Pointer last_interactor = dynamic_cast (last_node->GetInteractor()); if (last_interactor) mitk::GlobalInteraction::GetInstance()->RemoveInteractor(last_interactor); } } ItemNodeMapType::iterator it = m_ItemNodeMap.find(selectedItem); if (it == m_ItemNodeMap.end()) return; mitk::DataNode* new_node = it->second; mitk::AffineInteractor::Pointer new_interactor = mitk::AffineInteractor::New("AffineInteractions ctrl-drag", new_node); new_node->SetInteractor(new_interactor); mitk::GlobalInteraction::GetInstance()->AddInteractor(new_interactor); //create observer for node itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction(this, &QmitkBoundingObjectWidget::OnBoundingObjectModified); m_lastAffineObserver = new_node->AddObserver(mitk::AffineInteractionEvent(), command); m_lastSelectedItem = selectedItem; } void QmitkBoundingObjectWidget::AddItem(mitk::DataNode* node) { mitk::BoundingObject* boundingObject; boundingObject = dynamic_cast (node->GetData()); std::string name; node->GetStringProperty("name", name); if (boundingObject) { QTreeWidgetItem* item = new QTreeWidgetItem(); item->setData(0, Qt::EditRole, QString::fromLocal8Bit(name.c_str())); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); //checkbox for positive flag item->setData(1, Qt::CheckStateRole, tr("")); item->setCheckState(1, Qt::Unchecked); //checkbox for visibleflag item->setData(2, Qt::CheckStateRole, tr("")); item->setCheckState(2, Qt::Checked); m_TreeWidget->addTopLevelItem(item); m_ItemNodeMap.insert(std::make_pair(item, node)); m_TreeWidget->selectAll(); QList items = m_TreeWidget->selectedItems(); for( int i = 0; isetItemSelected(items.at(i), false); } m_TreeWidget->setItemSelected(item, true); } else MITK_ERROR << name << " is not a bounding object or does not exist in data storage" << endl; } void QmitkBoundingObjectWidget::OnItemDoubleClicked(QTreeWidgetItem* item, int col) { if (col == 0) { m_TreeWidget->openPersistentEditor(item, col); } } void QmitkBoundingObjectWidget::OnItemDataChanged(QTreeWidgetItem *item, int col) { if (m_ItemNodeMap.size() < 1) return; ItemNodeMapType::iterator it = m_ItemNodeMap.find(item); if (it == m_ItemNodeMap.end()) return; mitk::DataNode* node = it->second; //name if (col == 0) { m_TreeWidget->closePersistentEditor(item, col); node->SetName(item->text(0).toLocal8Bit().data()); } //positive else if (col == 1) { mitk::BoundingObject* boundingObject = dynamic_cast (node->GetData()); if (boundingObject) boundingObject->SetPositive(!(item->checkState(1))); emit BoundingObjectsChanged(); } //visible else if (col == 2) { node->SetVisibility(item->checkState(2)); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkBoundingObjectWidget::RemoveItem() { //selection mode is set to single selection, so there should not be more than one selected item QList selectedItems = m_TreeWidget->selectedItems(); QTreeWidgetItem* item = selectedItems.first(); QString str = item->text(0); ItemNodeMapType::iterator it = m_ItemNodeMap.find(item); if (it == m_ItemNodeMap.end()) return; mitk::DataNode* node = it->second; mitk::BoundingObject* boundingObject; if (node) { boundingObject = dynamic_cast (node->GetData()); if (boundingObject) { //delete item; m_TreeWidget->takeTopLevelItem(m_TreeWidget->indexOfTopLevelItem(item)); m_ItemNodeMap.erase(m_ItemNodeMap.find(item)); m_DataStorage->Remove(node); } } } void QmitkBoundingObjectWidget::RemoveAllItems() { ItemNodeMapType::iterator it = m_ItemNodeMap.begin(); while( it != m_ItemNodeMap.end() ) { m_TreeWidget->takeTopLevelItem( m_TreeWidget->indexOfTopLevelItem(it->first) ); m_ItemNodeMap.erase(m_ItemNodeMap.find(it->first)); ++it; } m_BoundingObjectCounter = 1; } mitk::BoundingObject::Pointer QmitkBoundingObjectWidget::GetSelectedBoundingObject() { mitk::BoundingObject* boundingObject; mitk::DataNode* node = this->GetSelectedBoundingObjectNode(); if (node) { boundingObject = dynamic_cast (node->GetData()); if (boundingObject) return boundingObject; } return NULL; } void QmitkBoundingObjectWidget::SetDataStorage(mitk::DataStorage* dataStorage) { m_DataStorage = dataStorage; } mitk::DataStorage* QmitkBoundingObjectWidget::GetDataStorage() { return m_DataStorage; } -//void QmitkBoundingObjectWidget::OnSaveButtonClicked() -//{ -// -//} -// -//void QmitkBoundingObjectWidget::OnLoadButtonClicked() -//{ -// -//} - void QmitkBoundingObjectWidget::OnDelButtonClicked() { RemoveItem(); } void QmitkBoundingObjectWidget::CreateBoundingObject(int type) { //get cross position mitk::Point3D pos; mitk::RenderingManager::RenderWindowVector windows = mitk::RenderingManager::GetInstance()->GetAllRegisteredRenderWindows(); //hopefully we have the renderwindows in the "normal" order const mitk::PlaneGeometry *plane1 = mitk::BaseRenderer::GetInstance(windows.at(0))->GetSliceNavigationController()->GetCurrentPlaneGeometry(); const mitk::PlaneGeometry *plane2 = mitk::BaseRenderer::GetInstance(windows.at(1))->GetSliceNavigationController()->GetCurrentPlaneGeometry(); const mitk::PlaneGeometry *plane3 = mitk::BaseRenderer::GetInstance(windows.at(2))->GetSliceNavigationController()->GetCurrentPlaneGeometry(); mitk::Line3D line; if ( (plane1 != NULL) && (plane2 != NULL) && (plane1->IntersectionLine( plane2, line )) ) { if ( !((plane3 != NULL) && (plane3->IntersectionPoint( line, pos ))) ) { return; } } if (type != 0) { mitk::BoundingObject::Pointer boundingObject; QString name; name.setNum(m_BoundingObjectCounter); switch (type-1) { case CUBOID: boundingObject = mitk::Cuboid::New(); name.prepend("Cube_"); break; case CONE: boundingObject = mitk::Cone::New(); name.prepend("Cone_"); break; case ELLIPSOID: boundingObject = mitk::Ellipsoid::New(); name.prepend("Ellipse_"); break; case CYLINDER: boundingObject = mitk::Cylinder::New(); name.prepend("Cylinder_"); break; default: return; break; } m_BoundingObjectCounter++; m_addComboBox->setCurrentIndex(0); // set initial size mitk::Vector3D size; size.Fill(10); boundingObject->GetGeometry()->SetSpacing( size ); boundingObject->GetGeometry()->Translate(pos.GetVectorFromOrigin()); boundingObject->GetTimeGeometry()->Update(); //create node mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData( boundingObject); node->SetProperty("name", mitk::StringProperty::New( name.toLocal8Bit().data())); node->SetProperty("color", mitk::ColorProperty::New(0.0, 0.0, 1.0)); node->SetProperty("opacity", mitk::FloatProperty::New(0.7)); node->SetProperty("bounding object", mitk::BoolProperty::New(true)); node->SetProperty("helper object", mitk::BoolProperty::New(true)); m_DataStorage->Add(node); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit BoundingObjectsChanged(); AddItem(node); } } mitk::DataNode::Pointer QmitkBoundingObjectWidget::GetAllBoundingObjects() { mitk::DataNode::Pointer boundingObjectGroupNode = mitk::DataNode::New(); mitk::BoundingObjectGroup::Pointer boundingObjectGroup = mitk::BoundingObjectGroup::New(); boundingObjectGroup->SetCSGMode(mitk::BoundingObjectGroup::Union); mitk::NodePredicateProperty::Pointer prop = mitk::NodePredicateProperty::New("bounding object", mitk::BoolProperty::New(true)); mitk::DataStorage::SetOfObjects::ConstPointer allBO = m_DataStorage->GetSubset(prop); for (mitk::DataStorage::SetOfObjects::const_iterator it = allBO->begin(); it != allBO->end(); ++it) { mitk::DataNode::Pointer node = *it; mitk::BoundingObject::Pointer boundingObject = dynamic_cast (node->GetData()); if (boundingObject) boundingObjectGroup->AddBoundingObject(boundingObject); } boundingObjectGroupNode->SetData(boundingObjectGroup); if (boundingObjectGroup->GetCount() >0) return boundingObjectGroupNode; return NULL; } mitk::DataNode::Pointer QmitkBoundingObjectWidget::GetSelectedBoundingObjectNode() { QList selectedItems = m_TreeWidget->selectedItems(); if (selectedItems.size() <1) return NULL; QTreeWidgetItem* item = selectedItems.first(); mitk::DataNode* node = m_ItemNodeMap.find(item)->second; return node; } void QmitkBoundingObjectWidget::OnBoundingObjectModified(const itk::EventObject& e) { emit BoundingObjectsChanged(); } diff --git a/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.h b/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.h index e4dab355e2..b8bc4870c0 100644 --- a/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.h +++ b/Modules/QtWidgetsExt/QmitkBoundingObjectWidget.h @@ -1,92 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QMITKBOUNDINGOBJECTWIDGET_H_INCLUDED #define _QMITKBOUNDINGOBJECTWIDGET_H_INCLUDED //includes #include #include "MitkQtWidgetsExtExports.h" #include #include #include #include #include #include #include class MitkQtWidgetsExt_EXPORT QmitkBoundingObjectWidget : public QWidget { Q_OBJECT public: QmitkBoundingObjectWidget (QWidget* parent = 0, Qt::WindowFlags f = 0 ); ~QmitkBoundingObjectWidget (); void SetDataStorage(mitk::DataStorage* dataStorage); mitk::DataStorage* GetDataStorage(); mitk::BoundingObject::Pointer GetSelectedBoundingObject(); mitk::DataNode::Pointer GetSelectedBoundingObjectNode(); mitk::DataNode::Pointer GetAllBoundingObjects(); void setEnabled(bool flag); void OnBoundingObjectModified( const itk::EventObject& e); void RemoveAllItems(); signals: //signal when bo has changed void BoundingObjectsChanged(); protected slots: void CreateBoundingObject(int type); void OnDelButtonClicked(); - /* void OnLoadButtonClicked(); - void OnSaveButtonClicked();*/ void SelectionChanged(); void OnItemDoubleClicked(QTreeWidgetItem* item, int col); void OnItemDataChanged(QTreeWidgetItem* item, int col); protected: void AddItem(mitk::DataNode* node); void RemoveItem(); mitk::DataStorage* m_DataStorage; QTreeWidget* m_TreeWidget; QComboBox* m_addComboBox; QPushButton* m_DelButton; QPushButton* m_SaveButton; QPushButton* m_LoadButton; QTreeWidgetItem* m_lastSelectedItem; unsigned long m_lastAffineObserver; typedef std::map< QTreeWidgetItem*, mitk::DataNode* > ItemNodeMapType; ItemNodeMapType m_ItemNodeMap; unsigned int m_BoundingObjectCounter; enum BoundingObjectType{ CUBOID, CONE, ELLIPSOID, CYLINDER, }; }; #endif diff --git a/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.cpp b/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.cpp index 7f4631b38f..df120bc9ff 100755 --- a/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.cpp +++ b/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.cpp @@ -1,171 +1,165 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkColorTransferFunctionCanvas.h" #include #include #include QmitkColorTransferFunctionCanvas::QmitkColorTransferFunctionCanvas( QWidget * parent, Qt::WindowFlags f) : QmitkTransferFunctionCanvas(parent, f), m_ColorTransferFunction(0) { // used for drawing a border setContentsMargins(1,1,1,1); } void QmitkColorTransferFunctionCanvas::SetTitle(const QString& title) { m_Title=title; } void QmitkColorTransferFunctionCanvas::paintEvent(QPaintEvent*) { QPainter painter(this); // Render gray background QRect contentsRect = this->contentsRect(); painter.setPen(Qt::gray); painter.drawRect(0, 0, contentsRect.width()+1, contentsRect.height()+1); if( ! this->isEnabled() ) return; if (m_ColorTransferFunction) { for (int x = contentsRect.x(); x < contentsRect.x() + contentsRect.width(); x++) { double xVal = m_Min + ((float) x) / contentsRect.width() * (m_Max - m_Min); QColor col((int) (m_ColorTransferFunction->GetRedValue(xVal) * 255), (int) (m_ColorTransferFunction->GetGreenValue(xVal) * 255), (int) (m_ColorTransferFunction->GetBlueValue(xVal) * 255)); painter.setPen(col); painter.drawLine(x, 1, x, contentsRect.height()); } } //paint title if (m_Title.size()>0) { painter.setPen(Qt::black); painter.drawText(QPoint(11,21),m_Title); painter.setPen(Qt::white); painter.drawText(QPoint(10,20),m_Title); } //paint min and max QString qs_min = QString::number( m_Min ); QString qs_max = QString::number( m_Max ); QRect qr_min = painter.fontMetrics().boundingRect( qs_min ); QRect qr_max = painter.fontMetrics().boundingRect( qs_max ); int y,x; y=this->contentsRect().height()-qr_min.height()+5; x=10; painter.setPen(Qt::black); painter.drawText(QPoint(x+1,y+1),qs_min); painter.setPen(Qt::white); painter.drawText(QPoint(x ,y ),qs_min); y=this->contentsRect().height()-qr_max.height()+5; x=this->contentsRect().width()-qr_max.width()-6; painter.setPen(Qt::black); painter.drawText(QPoint(x,y+1),qs_max); painter.setPen(Qt::white); painter.drawText(QPoint(x,y ),qs_max); if (m_ColorTransferFunction) { // now paint the handles painter.setBrush(Qt::black); painter.setPen(Qt::black); for (int i = 0; i < this->GetFunctionSize(); i++) { int handleHeight = (i == m_GrabbedHandle) ? (int) (contentsRect.height() / 1.5) : contentsRect.height() / 2; int handleWidth = (i == m_GrabbedHandle) ? 6 : 4; std::pair point = this->FunctionToCanvas(std::make_pair( GetFunctionX(i), 0.0f)); int y = height() / 2; painter.drawRoundRect(point.first - handleWidth / 2, y - handleHeight / 2, handleWidth, handleHeight, 50, 50); - if (i == m_GrabbedHandle) - { - if (m_LineEditAvailable) - { - m_XEdit->setText(QString::number(GetFunctionX(m_GrabbedHandle))); - //m_YEdit->setText(QString::number(GetFunctionY(m_GrabbedHandle))); - } - } - + if (i == m_GrabbedHandle && m_LineEditAvailable) + m_XEdit->setText(QString::number(GetFunctionX(m_GrabbedHandle))); } } } -int QmitkColorTransferFunctionCanvas::GetNearHandle(int x, int /*y*/, +int QmitkColorTransferFunctionCanvas::GetNearHandle(int x, int, unsigned int maxSquaredDistance) { for (int i = 0; i < this->GetFunctionSize(); i++) { std::pair point = this->FunctionToCanvas(std::make_pair( GetFunctionX(i), (double) 0.0)); if ((unsigned int) ((point.first - x) * (point.first - x)) < maxSquaredDistance) { return i; } } return -1; } void QmitkColorTransferFunctionCanvas::DoubleClickOnHandle(int handle) { double xVal = GetFunctionX(handle); QColor col((int) (m_ColorTransferFunction->GetRedValue(xVal) * 255), (int) (m_ColorTransferFunction->GetGreenValue(xVal) * 255), (int) (m_ColorTransferFunction->GetBlueValue(xVal) * 255)); QColor result = QColorDialog::getColor(col); if (result.isValid()) { m_ColorTransferFunction->AddRGBPoint(xVal, result.red() / 255.0, result.green() / 255.0, result.blue() / 255.0); this->update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void QmitkColorTransferFunctionCanvas::MoveFunctionPoint(int index, std::pair pos) { double color[3]; m_ColorTransferFunction->GetColor(GetFunctionX(index), color); RemoveFunctionPoint( GetFunctionX(index)); m_ColorTransferFunction->AddRGBPoint(pos.first, color[0], color[1], color[2]); } void QmitkColorTransferFunctionCanvas::AddRGB(double x, double r, double g, double b) { m_ColorTransferFunction->AddRGBPoint(x, r, g, b); } + diff --git a/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.h b/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.h index d603321451..750937158e 100755 --- a/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.h +++ b/Modules/QtWidgetsExt/QmitkColorTransferFunctionCanvas.h @@ -1,117 +1,119 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKCOLORTRANSFERFUNCTIONCANVAS_H_INCLUDED #define QMITKCOLORTRANSFERFUNCTIONCANVAS_H_INCLUDED #include "QmitkTransferFunctionCanvas.h" #include "MitkQtWidgetsExtExports.h" #include class MitkQtWidgetsExt_EXPORT QmitkColorTransferFunctionCanvas: public QmitkTransferFunctionCanvas { Q_OBJECT public: QmitkColorTransferFunctionCanvas( QWidget* parent = 0, Qt::WindowFlags f = 0 ) ; virtual void paintEvent( QPaintEvent* e ); int GetNearHandle(int x,int y,unsigned int maxSquaredDistance = 32); void SetTitle(const QString& title); void SetColorTransferFunction(vtkColorTransferFunction* colorTransferFunction) { this->m_ColorTransferFunction = colorTransferFunction; this->SetMin(colorTransferFunction->GetRange()[0]); this->SetMax(colorTransferFunction->GetRange()[1]); setEnabled(true); update(); } - void AddFunctionPoint(double x,double /*val*/) + void AddFunctionPoint(double x, double) { m_ColorTransferFunction->AddRGBPoint(x,m_ColorTransferFunction->GetRedValue(x),m_ColorTransferFunction->GetGreenValue(x),m_ColorTransferFunction->GetBlueValue(x)); } void RemoveFunctionPoint(double x) { int old_size = GetFunctionSize(); m_ColorTransferFunction->RemovePoint(x); if (GetFunctionSize() + 1 != old_size) { std::cout << "old/new size" << old_size << "/" << GetFunctionSize() << std::endl; std::cout << "called with x=" << x << std::endl; } } double GetFunctionX(int index) { return m_ColorTransferFunction->GetDataPointer()[index*4]; } int GetFunctionSize() { return m_ColorTransferFunction->GetSize(); } void DoubleClickOnHandle(int handle); void MoveFunctionPoint(int index, std::pair pos); void AddRGB(double x, double r, double g, double b); double GetFunctionMax() { return m_ColorTransferFunction->GetRange()[1]; } double GetFunctionMin() { return m_ColorTransferFunction->GetRange()[0]; } double GetFunctionRange() { double range; if((m_ColorTransferFunction->GetRange()[0])==0) { range = m_ColorTransferFunction->GetRange()[1]; return range; } else { range = (m_ColorTransferFunction->GetRange()[1])-(m_ColorTransferFunction->GetRange()[0]); return range; } } void RemoveAllFunctionPoints() { m_ColorTransferFunction->AddRGBSegment(this->GetFunctionMin(),1,0,0,this->GetFunctionMax(),1,1,0); } float GetFunctionY(int) { return 0.0; } protected: vtkColorTransferFunction* m_ColorTransferFunction; QString m_Title; }; + #endif + diff --git a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.cpp b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.cpp index 1a54923511..24af06bd4a 100644 --- a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.cpp +++ b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.cpp @@ -1,740 +1,739 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkCorrespondingPointSetsModel.h" #include #include "mitkInteractionConst.h" #include "mitkPointOperation.h" #include "mitkRenderingManager.h" #include #include #include #include #include #include #include QmitkCorrespondingPointSetsModel::QmitkCorrespondingPointSetsModel( int t, QObject* parent ) :QAbstractTableModel(parent), m_PointSetNode(NULL), m_ReferencePointSetNode(NULL), m_TimeStepper(NULL), m_Interactor(NULL), m_MultiWidget( NULL ), m_PointSetModifiedObserverTag(0), m_ReferencePointSetModifiedObserverTag(0), m_SelectedPointSetIndex(-1) { ; } Qt::ItemFlags QmitkCorrespondingPointSetsModel::flags(const QModelIndex& index) const { if (index.isValid()) return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled; else return Qt::ItemIsDropEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled; } Qt::DropActions QmitkCorrespondingPointSetsModel::supportedDropActions() const { return Qt::CopyAction | Qt::MoveAction; } bool QmitkCorrespondingPointSetsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { if (action == Qt::IgnoreAction) return true; int targetRow; if (row != -1) targetRow = row; else if (parent.isValid()) targetRow = parent.row(); else targetRow = rowCount(QModelIndex()); this->MoveSelectedPoint(mitk::PointSet::PointIdentifier(targetRow)); return true; } QmitkCorrespondingPointSetsModel::~QmitkCorrespondingPointSetsModel() { ; } void QmitkCorrespondingPointSetsModel::RemoveObservers(){ if (m_PointSetNode) { mitk::PointSet::Pointer oldPointSet = dynamic_cast(m_PointSetNode->GetData()); if (oldPointSet.IsNotNull()) { oldPointSet->RemoveObserver(m_PointSetModifiedObserverTag); } } if (m_ReferencePointSetNode) { mitk::PointSet::Pointer oldPointSet = dynamic_cast(m_ReferencePointSetNode->GetData()); if (oldPointSet.IsNotNull()) { oldPointSet->RemoveObserver(m_ReferencePointSetModifiedObserverTag); } } } void QmitkCorrespondingPointSetsModel::AddObservers() { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if ( pointSet.IsNotNull()) { // add new observer for modified if necessary itk::ReceptorMemberCommand::Pointer modCommand = itk::ReceptorMemberCommand::New(); modCommand->SetCallbackFunction( this, &QmitkCorrespondingPointSetsModel::OnPointSetChanged ); m_PointSetModifiedObserverTag = pointSet->AddObserver( itk::ModifiedEvent(), modCommand ); } else { m_PointSetModifiedObserverTag = 0; } pointSet = this->CheckForPointSetInNode(m_ReferencePointSetNode); if ( pointSet.IsNotNull()) { // add new observer for modified if necessary itk::ReceptorMemberCommand::Pointer modCommand = itk::ReceptorMemberCommand::New(); modCommand->SetCallbackFunction( this, &QmitkCorrespondingPointSetsModel::OnPointSetChanged ); m_ReferencePointSetModifiedObserverTag = pointSet->AddObserver( itk::ModifiedEvent(), modCommand ); } else { m_ReferencePointSetModifiedObserverTag = 0; } } -void QmitkCorrespondingPointSetsModel::OnPointSetChanged( const itk::EventObject & /*e*/ ) +void QmitkCorrespondingPointSetsModel::OnPointSetChanged(const itk::EventObject&) { QAbstractTableModel::reset(); } void QmitkCorrespondingPointSetsModel::SetPointSetNodes( std::vector nodes ) { this->RemoveObservers(); if ( nodes.size() > 1 ) { m_PointSetNode = nodes.front(); m_ReferencePointSetNode = nodes.back(); } else if ( nodes.size() == 1 ) { m_PointSetNode = nodes.front(); m_ReferencePointSetNode = NULL; } else { m_PointSetNode = NULL; m_ReferencePointSetNode = NULL; } this->AddObservers(); QAbstractTableModel::reset(); } void QmitkCorrespondingPointSetsModel::SetTimeStep(int t) { if (!m_TimeStepper) return; m_TimeStepper->SetPos(t); QAbstractTableModel::reset(); } int QmitkCorrespondingPointSetsModel::GetTimeStep() const { if (!m_TimeStepper) return 0; return m_TimeStepper->GetPos(); } -int QmitkCorrespondingPointSetsModel::rowCount( const QModelIndex& /*parent*/ ) const +int QmitkCorrespondingPointSetsModel::rowCount(const QModelIndex&) const { if (!m_TimeStepper) return 0; mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); mitk::PointSet::Pointer referencePointSet = this->CheckForPointSetInNode(m_ReferencePointSetNode); int sizePS = 0; int sizeRPS = 0; if ( pointSet.IsNotNull() ) { sizePS = pointSet->GetSize(m_TimeStepper->GetPos()); } if ( referencePointSet.IsNotNull() ) { sizeRPS = referencePointSet->GetSize(m_TimeStepper->GetPos()); } if ( sizePS > sizeRPS ) return sizePS; return sizeRPS; } -int QmitkCorrespondingPointSetsModel::columnCount( const QModelIndex& /*parent*/ ) const +int QmitkCorrespondingPointSetsModel::columnCount(const QModelIndex&) const { return 2; } QVariant QmitkCorrespondingPointSetsModel::data(const QModelIndex& index, int role) const { mitk::PointSet::Pointer pointSet = NULL; if ( index.column() == 0 ) pointSet = this->CheckForPointSetInNode(m_PointSetNode); else if ( index.column() == 1 ) pointSet = this->CheckForPointSetInNode(m_ReferencePointSetNode); if ( pointSet.IsNull() ) { return QVariant(); } if ( !index.isValid() ) { return QVariant(); } if ( index.row() >= pointSet->GetSize(m_TimeStepper->GetPos()) ) { return QVariant(); } if (role == Qt::DisplayRole) { mitk::PointSet::PointsContainer::ElementIdentifier id; mitk::PointSet::PointType p; bool pointFound = this->GetPointForModelIndex(index, p, id); if (pointFound == false) return QVariant(); QString s = ""; bool firstProp = true; if (this->QTPropIdsEnabled()) { s.append(QString("%0").arg( id, 3)); firstProp = false; } if (this->QTPropCoordinatesEnabled()) { if(!firstProp) s.append(QString(": ")); s.append(QString("(%0, %1, %2)") .arg( p[0], 0, 'f', 2 ) .arg( p[1], 0, 'f', 2 ) .arg( p[2], 0, 'f', 2 )); } return QVariant(s); } else { return QVariant(); } } QVariant QmitkCorrespondingPointSetsModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) { return QVariant(); } if (orientation == Qt::Horizontal) { if (section == 0) { if ( m_PointSetNode ) return QString::fromStdString(this->m_PointSetNode->GetName()); } else if (section == 1) { if ( m_ReferencePointSetNode ) return QString::fromStdString(this->m_ReferencePointSetNode->GetName()); } return QString(); } return QString("%1").arg(section); } bool QmitkCorrespondingPointSetsModel::GetPointForModelIndex( const QModelIndex &index, mitk::PointSet::PointType& p, mitk::PointSet::PointIdentifier& id) const { if (!m_TimeStepper) return false; mitk::PointSet::Pointer pointSet = NULL; if ( index.column() == 0 ) pointSet = this->CheckForPointSetInNode(m_PointSetNode); else if ( index.column() == 1 ) pointSet = this->CheckForPointSetInNode(m_ReferencePointSetNode); if (pointSet.IsNull() || !pointSet->GetPointSet(m_TimeStepper->GetPos())) return false; if ((index.row() < 0) || (index.row() >= (int)pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->Size())) return false; // get the nth. element, if it exists. // we can not use the index directly, because PointSet uses a map container, // where the index is not necessarily the same as the key. // Therefore we have to count the elements mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->Begin(); for (int i = 0; i < index.row(); ++i) { ++it; if (it == pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->End()) return false; } if (it != pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->End()) // not at the end, { p = it->Value(); id = it->Index(); return true; } return false; } bool QmitkCorrespondingPointSetsModel::GetPointForModelIndex( int row, int column, mitk::PointSet::PointType& p, mitk::PointSet::PointIdentifier& id) const { if (!m_TimeStepper) return false; mitk::PointSet::Pointer pointSet = NULL; if (column == 0 ) pointSet = this->CheckForPointSetInNode(m_PointSetNode); else if ( column == 1 ) pointSet = this->CheckForPointSetInNode(m_ReferencePointSetNode); if (pointSet.IsNull() || !pointSet->GetPointSet(m_TimeStepper->GetPos())) return false; if ((row < 0) || (row >= (int)pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->Size())) return false; // get the nth. element, if it exists. // we can not use the index directly, because PointSet uses a map container, // where the index is not necessarily the same as the key. // Therefore we have to count the elements mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->Begin(); for (int i = 0; i < row; ++i) { ++it; if (it == pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->End()) return false; } if (it != pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->End()) // not at the end, { p = it->Value(); id = it->Index(); return true; } return false; } bool QmitkCorrespondingPointSetsModel::GetModelIndexForPointID(mitk::PointSet::PointIdentifier id, QModelIndex& index, int column) const { if (!m_TimeStepper) return false; mitk::PointSet::Pointer pointSet = NULL; if (column == 0) pointSet = this->CheckForPointSetInNode(m_PointSetNode); else if (column == 1) pointSet = this->CheckForPointSetInNode(m_ReferencePointSetNode); if (!pointSet.IsNull() || !pointSet->GetPointSet(m_TimeStepper->GetPos())) { mitk::PointSet::PointsContainer::Pointer points = pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints(); if (!points->IndexExists(id)) return false; unsigned int idx = 0; for (mitk::PointSet::PointsContainer::Iterator it = points->Begin(); it != points->End(); ++it) { if (it->Index() == id) // we found the correct element { index = this->index(idx, column); return true; } idx++; } } return false; // nothing found } bool QmitkCorrespondingPointSetsModel::GetModelIndexForSelectedPoint(QModelIndex& index) const { if (!m_TimeStepper) return false; mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0) dataNode = this->m_PointSetNode; else if (this->m_SelectedPointSetIndex == 1) dataNode = this->m_ReferencePointSetNode; mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(dataNode); if (pointSet.IsNull()) return false; mitk::PointSet::PointIdentifier selectedID; selectedID = pointSet->SearchSelectedPoint(m_TimeStepper->GetPos()); return this->GetModelIndexForPointID(selectedID, index, this->m_SelectedPointSetIndex); } void QmitkCorrespondingPointSetsModel::MoveSelectedPointUp() { if (!m_TimeStepper) return; mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0) dataNode = this->m_PointSetNode; else if (this->m_SelectedPointSetIndex == 1) dataNode = this->m_ReferencePointSetNode; mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(dataNode); if (pointSet.IsNull()) return; mitk::PointSet::PointIdentifier selectedID; selectedID = pointSet->SearchSelectedPoint(m_TimeStepper->GetPos()); if (selectedID==-1) return; mitk::PointSet::PointType point = pointSet->GetPoint(selectedID, m_TimeStepper->GetPos()); mitk::ScalarType tsInMS = pointSet->GetTimeGeometry()->TimeStepToTimePoint(m_TimeStepper->GetPos()); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP,tsInMS, pointSet->GetPoint(selectedID, m_TimeStepper->GetPos()), selectedID, true); pointSet->ExecuteOperation(doOp); QAbstractTableModel::reset(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalPointSetChanged(); } void QmitkCorrespondingPointSetsModel::MoveSelectedPointDown() { - //QModelIndex; if (!m_TimeStepper) return; mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0) dataNode = this->m_PointSetNode; else if (this->m_SelectedPointSetIndex == 1) dataNode = this->m_ReferencePointSetNode; mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(dataNode); if (pointSet.IsNull()) return; mitk::PointSet::PointIdentifier selectedID; selectedID = pointSet->SearchSelectedPoint(m_TimeStepper->GetPos()); if (selectedID==-1) return; mitk::ScalarType tsInMS = pointSet->GetTimeGeometry()->TimeStepToTimePoint(m_TimeStepper->GetPos()); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, tsInMS, pointSet->GetPoint(selectedID, m_TimeStepper->GetPos()), selectedID, true); pointSet->ExecuteOperation(doOp); QAbstractTableModel::reset(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalPointSetChanged(); } mitk::PointSet::PointIdentifier QmitkCorrespondingPointSetsModel::SearchSelectedPoint() { if (!m_TimeStepper) return -1; mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0) dataNode = this->m_PointSetNode; else if (this->m_SelectedPointSetIndex == 1) dataNode = this->m_ReferencePointSetNode; mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(dataNode); if (pointSet.IsNull()) return -1; return pointSet->SearchSelectedPoint(m_TimeStepper->GetPos()); } void QmitkCorrespondingPointSetsModel::RemoveSelectedPoint() { if (!m_TimeStepper) return; mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0){ dataNode = this->m_PointSetNode; } else if (this->m_SelectedPointSetIndex == 1){ dataNode = this->m_ReferencePointSetNode; } if (dataNode == NULL) return; //send a DEL event to pointsetinteractor const mitk::Event* delEvent = new mitk::Event(this->m_MultiWidget->GetRenderWindow1()->GetRenderer(), mitk::Type_KeyPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_Delete); mitk::StateEvent* delStateEvent = new mitk::StateEvent(mitk::EIDDELETE, delEvent); m_Interactor->HandleEvent(delStateEvent); delete delEvent; delete delStateEvent; QAbstractTableModel::reset(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalPointSetChanged(); } void QmitkCorrespondingPointSetsModel::MoveSelectedPoint(mitk::PointSet::PointIdentifier targetID) { if (!m_TimeStepper) return; mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0) dataNode = this->m_PointSetNode; else if (this->m_SelectedPointSetIndex == 1) dataNode = this->m_ReferencePointSetNode; if (dataNode == NULL) return; mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(dataNode); if (pointSet.IsNull()) return; mitk::PointSet::PointIdentifier selectedID; selectedID = pointSet->SearchSelectedPoint(m_TimeStepper->GetPos()); if (targetID >= pointSet->GetSize()) targetID = pointSet->GetSize()-1; mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->Begin(); for (int i=0; iIndex(); if (selectedID<0 || targetID<0) return; int direction = mitk::OpNOTHING; if (selectedID>targetID) direction = mitk::OpMOVEPOINTUP; else if (selectedIDGetTimeGeometry()->TimeStepToTimePoint(m_TimeStepper->GetPos()); mitk::PointOperation* doOp = new mitk::PointOperation(direction, tsInMS, pointSet->GetPoint(selectedID, m_TimeStepper->GetPos()), selectedID, true); pointSet->ExecuteOperation(doOp); selectedID = pointSet->SearchSelectedPoint(m_TimeStepper->GetPos()); } QAbstractTableModel::reset(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalPointSetChanged(); } mitk::PointSet* QmitkCorrespondingPointSetsModel::CheckForPointSetInNode(mitk::DataNode* node) const { if (node != NULL) { mitk::PointSet::Pointer pointSet = dynamic_cast(node->GetData()); if (pointSet.IsNotNull()) return pointSet; } return NULL; } bool QmitkCorrespondingPointSetsModel::QTPropCoordinatesEnabled() const { return this->QTPropShowCoordinates; } void QmitkCorrespondingPointSetsModel::QTPropSetCoordinatesEnabled(bool showCoordinates) { this->QTPropShowCoordinates = showCoordinates; } bool QmitkCorrespondingPointSetsModel::QTPropIdsEnabled() const { return this->QTPropShowIds; } void QmitkCorrespondingPointSetsModel::QTPropSetIdsEnabled(bool showIds) { this->QTPropShowIds = showIds; } std::vector QmitkCorrespondingPointSetsModel::GetPointSetNodes(){ std::vector pointSetNodes; if ( this->m_PointSetNode ) pointSetNodes.push_back(this->m_PointSetNode); if ( this->m_ReferencePointSetNode ) pointSetNodes.push_back(this->m_ReferencePointSetNode); return pointSetNodes; } void QmitkCorrespondingPointSetsModel::SetSelectedPointSetIndex(int index) { if (index<-1 || index>1) return; this->m_SelectedPointSetIndex = index; } void QmitkCorrespondingPointSetsModel::ClearSelectedPointSet() { mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0) dataNode = this->m_PointSetNode; else if (this->m_SelectedPointSetIndex == 1) dataNode = this->m_ReferencePointSetNode; if (dataNode == NULL) return; mitk::PointSet* pointSet = dynamic_cast(dataNode->GetData()); - //pointSet->Clear(); mitk::PointSet::PointsContainer::Iterator it; if (this->m_TimeStepper->GetRangeMax()==-1) { while( !pointSet->IsEmptyTimeStep(0) ) { if (pointSet->GetPointSet(0)) { it = pointSet->GetPointSet(0)->GetPoints()->Begin(); pointSet->SetSelectInfo(it->Index(),true, 0); this->RemoveSelectedPoint(); } else { break; } } } else { int oldTimeStep = this->m_TimeStepper->GetPos(); for (int i=0; im_TimeStepper->GetRangeMax(); i++) { this->m_TimeStepper->SetPos(i); while( !pointSet->IsEmptyTimeStep(i) ) { if (pointSet->GetPointSet(i)) { it = pointSet->GetPointSet(i)->GetPoints()->Begin(); pointSet->SetSelectInfo(it->Index(),true, i); this->RemoveSelectedPoint(); } } } this->m_TimeStepper->SetPos(oldTimeStep); } QAbstractTableModel::reset(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalPointSetChanged(); } void QmitkCorrespondingPointSetsModel::ClearCurrentTimeStep() { if (!m_TimeStepper) return; mitk::DataNode* dataNode = NULL; if (this->m_SelectedPointSetIndex == 0) dataNode = this->m_PointSetNode; else if (this->m_SelectedPointSetIndex == 1) dataNode = this->m_ReferencePointSetNode; if (dataNode == NULL) return; mitk::PointSet* pointSet = dynamic_cast(dataNode->GetData()); mitk::PointSet::PointsContainer::Iterator it; while( !pointSet->IsEmptyTimeStep(m_TimeStepper->GetPos()) ) { it = pointSet->GetPointSet(m_TimeStepper->GetPos())->GetPoints()->Begin(); pointSet->SetSelectInfo(it->Index(),true, m_TimeStepper->GetPos()); this->RemoveSelectedPoint(); } QAbstractTableModel::reset(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalPointSetChanged(); } mitk::Stepper::Pointer QmitkCorrespondingPointSetsModel::GetStepper() { return this->m_TimeStepper; } void QmitkCorrespondingPointSetsModel::SetStepper(mitk::Stepper::Pointer stepper) { this->m_TimeStepper = stepper; } int QmitkCorrespondingPointSetsModel::GetSelectedPointSetIndex() { return this->m_SelectedPointSetIndex; } void QmitkCorrespondingPointSetsModel::UpdateSelection(mitk::DataNode* selectedNode) { this->RemoveInteractor(); if(!selectedNode) return; m_Interactor = dynamic_cast(selectedNode->GetInteractor()); if (m_Interactor.IsNull())//if not present, instanciate one m_Interactor = mitk::PointSetInteractor::New("pointsetinteractor", selectedNode); //add it to global interaction to activate it mitk::GlobalInteraction::GetInstance()->AddInteractor( m_Interactor ); } void QmitkCorrespondingPointSetsModel::RemoveInteractor() { if (m_Interactor){ mitk::GlobalInteraction::GetInstance()->RemoveInteractor( m_Interactor ); m_Interactor = NULL; } } QmitkStdMultiWidget* QmitkCorrespondingPointSetsModel::GetMultiWidget() { return this->m_MultiWidget; } void QmitkCorrespondingPointSetsModel::SetMultiWidget( QmitkStdMultiWidget* multiWidget ) { this->m_MultiWidget = multiWidget; this->m_TimeStepper = m_MultiWidget->GetTimeNavigationController()->GetTime(); } + diff --git a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.h b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.h index d0fc9a7d39..b82778f0da 100644 --- a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.h +++ b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsModel.h @@ -1,173 +1,175 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_CORRESPONDINGPOINTSETS_MODEL_H_INCLUDED #define QMITK_CORRESPONDINGPOINTSETS_MODEL_H_INCLUDED #include #include #include "MitkQtWidgetsExtExports.h" #include "mitkDataNode.h" #include "mitkPointSet.h" #include #include "QmitkStdMultiWidget.h" class MitkQtWidgetsExt_EXPORT QmitkCorrespondingPointSetsModel : public QAbstractTableModel { Q_OBJECT Q_PROPERTY(bool QTPropShowCoordinates READ QTPropCoordinatesEnabled WRITE QTPropSetCoordinatesEnabled) Q_PROPERTY(bool QTPropShowIds READ QTPropIdsEnabled WRITE QTPropSetIdsEnabled) public: QmitkCorrespondingPointSetsModel( int t = 0, QObject* parent = 0 ); ~QmitkCorrespondingPointSetsModel(); Qt::ItemFlags flags(const QModelIndex& index) const; void UpdateSelection(mitk::DataNode* selectedNode); void RemoveInteractor(); // returns PointIdentifier of selected point (-1 if no point is selected) mitk::PointSet::PointIdentifier SearchSelectedPoint(); /// interface of QAbstractTableModel int rowCount( const QModelIndex& parent = QModelIndex() ) const; /// interface of QAbstractTableModel int columnCount( const QModelIndex& parent = QModelIndex() ) const; /// interface of QAbstractTableModel QVariant data(const QModelIndex& index, int role) const; /// interface of QAbstractTableModel QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; /// which point set to work on void SetPointSetNodes( std::vector nodes ); /// which time step to display/model void SetTimeStep(int t); /// which time step to display/model int GetTimeStep() const; /** * \brief get point and point ID that correspond to a given QModelIndex * * The mitk::PointSet uses a map to store points in an ID<-->Point relation. * The IDs are not neccesarily continuously numbered, therefore, we can not * directly use the QModelIndex as point ID. This method returns the point and * the corresponding point id for a given QModelIndex. The point and the point ID * are returned in the outgoing parameters p and id. If a valid point and ID were * found, the method returns true, otherwise it returns false * \param[in] QModelIndex &index the index for which a point is requested. The row() part of the index is used to find a corresponding point * \param[out] mitk::Point3D& p If a valid point is found, it will be stored in the p parameter * \param[out] mitk::PointSet::PointIdentifier& id If a valid point is found, the corresponding ID will be stored in id * \return Returns true, if a valid point was found, false otherwise */ bool GetPointForModelIndex( const QModelIndex &index, mitk::PointSet::PointType& p, mitk::PointSet::PointIdentifier& id) const; bool GetPointForModelIndex( int row, int column, mitk::PointSet::PointType& p, mitk::PointSet::PointIdentifier& id) const; /**Documentation * \brief returns a QModelIndex for a given point ID * * The mitk::PointSet uses a map to store points in an ID<-->Point relation. * The IDs are not neccesarily continuously numbered, therefore, we can not * directly use the point ID as a QModelIndex. This method returns a QModelIndex * for a given point ID in the outgoing parameter index. * \param[in] mitk::PointSet::PointIdentifier id The point ID for which the QModelIndex will be created * \param[out] QModelIndex& index if a point with the ID id was found, index will contain a corresponding QModelIndex for that point * \return returns true, if a valid QModelIndex was created, false otherwise */ bool GetModelIndexForPointID(mitk::PointSet::PointIdentifier id, QModelIndex& index, int column) const; bool QTPropCoordinatesEnabled() const; void QTPropSetCoordinatesEnabled(bool qShowCoordinates); bool QTPropIdsEnabled() const; void QTPropSetIdsEnabled(bool qShowIds); std::vector GetPointSetNodes(); void SetSelectedPointSetIndex(int index); int GetSelectedPointSetIndex(); void ClearSelectedPointSet(); void MoveSelectedPointUp(); void MoveSelectedPointDown(); void RemoveSelectedPoint(); void ClearCurrentTimeStep(); void SetStepper(mitk::Stepper::Pointer stepper); mitk::Stepper::Pointer GetStepper(); Qt::DropActions supportedDropActions() const; bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); bool GetModelIndexForSelectedPoint(QModelIndex& index) const; void SetMultiWidget( QmitkStdMultiWidget* multiWidget ); ///< assign a QmitkStdMultiWidget for updating render window crosshair QmitkStdMultiWidget* GetMultiWidget(); ///< return the QmitkStdMultiWidget that is used for updating render window crosshair void OnPointSetChanged( const itk::EventObject & e ); private: public slots: signals: void SignalPointSetChanged(); protected: //initially checks if there is a PointSet as data in the DataNode. //returns PointSet if so and NULL if other data is set to node mitk::PointSet* CheckForPointSetInNode(mitk::DataNode* node) const; protected: bool QTPropShowIds; bool QTPropShowCoordinates; mitk::DataNode::Pointer m_PointSetNode; mitk::DataNode::Pointer m_ReferencePointSetNode; mitk::Stepper::Pointer m_TimeStepper; int m_SelectedPointSetIndex; mitk::PointSetInteractor::Pointer m_Interactor; QmitkStdMultiWidget* m_MultiWidget; unsigned long m_PointSetModifiedObserverTag; unsigned long m_ReferencePointSetModifiedObserverTag; void MoveSelectedPoint(mitk::PointSet::PointIdentifier targetID); void RemoveObservers(); void AddObservers(); }; + #endif + diff --git a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.cpp b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.cpp index 6a24c15707..758123396c 100644 --- a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.cpp +++ b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.cpp @@ -1,506 +1,524 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkCorrespondingPointSetsView.h" #include "QmitkCorrespondingPointSetsModel.h" #include "QmitkStdMultiWidget.h" #include "QmitkEditPointDialog.h" #include "mitkRenderingManager.h" #include #include #include #include #include #include #include #include #include #include QmitkCorrespondingPointSetsView::QmitkCorrespondingPointSetsView( QWidget* parent ) :QTableView( parent ), m_CorrespondingPointSetsModel( new QmitkCorrespondingPointSetsModel() ), m_SelfCall( false ), m_swapPointSets(false), m_addPointsMode(false), m_DataStorage( NULL ) { m_CorrespondingPointSetsModel->setProperty("QTPropShowCoordinates", true); m_CorrespondingPointSetsModel->setProperty("QTPropShowIds", true); this->setContextMenuPolicy(Qt::CustomContextMenu); this->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); this->setToolTip("Use right click to open context menu"); this->setDragEnabled(true); this->setAcceptDrops(true); this->setDropIndicatorShown(true); this->setDragDropMode(QAbstractItemView::InternalMove); QTableView::setAlternatingRowColors( false ); QTableView::setSelectionBehavior( QAbstractItemView::SelectItems ); QTableView::setSelectionMode( QAbstractItemView::SingleSelection ); QTableView::setModel( m_CorrespondingPointSetsModel ); QTableView::horizontalHeader()->resizeSection(0, (int)(this->width()/3.5)); QTableView::horizontalHeader()->setStretchLastSection(true); m_TimeStepFaderLabel = new QLabel(this); QFont font("Arial", 17); m_TimeStepFaderLabel->setFont(font); - //connect connect( QTableView::selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(OnPointSelectionChanged(const QItemSelection& , const QItemSelection&)) ); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ctxMenu(const QPoint &))); connect(this->m_CorrespondingPointSetsModel, SIGNAL(SignalPointSetChanged()), this, SLOT(UpdateSelectionHighlighting())); } QmitkCorrespondingPointSetsView::~QmitkCorrespondingPointSetsView() { delete m_CorrespondingPointSetsModel; } + void QmitkCorrespondingPointSetsView::SetPointSetNodes( std::vector nodes ) { if ( !this->m_swapPointSets || nodes.size()<2 ) m_CorrespondingPointSetsModel->SetPointSetNodes( nodes ); else { std::vector reverseNodes; reverseNodes.push_back(nodes.back()); reverseNodes.push_back(nodes.front()); m_CorrespondingPointSetsModel->SetPointSetNodes( reverseNodes ); } } + void QmitkCorrespondingPointSetsView::SetMultiWidget( QmitkStdMultiWidget* multiWidget ) { this->m_CorrespondingPointSetsModel->SetMultiWidget(multiWidget); } + QmitkStdMultiWidget* QmitkCorrespondingPointSetsView::GetMultiWidget() const { return this->m_CorrespondingPointSetsModel->GetMultiWidget(); } + void QmitkCorrespondingPointSetsView::SetDataStorage(mitk::DataStorage::Pointer dataStorage) { m_DataStorage = dataStorage; } -void QmitkCorrespondingPointSetsView::OnPointSelectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) +void QmitkCorrespondingPointSetsView::OnPointSelectionChanged(const QItemSelection& selected, const QItemSelection&) { if(m_SelfCall) return; std::vector pointSetNodes = this->GetPointSetNodes(); QModelIndexList selectedIndexes = selected.indexes(); m_CorrespondingPointSetsModel->SetSelectedPointSetIndex(-1); if (selectedIndexes.size() > 0) { QModelIndex index = selectedIndexes.front(); mitk::DataNode* pointSetNode = NULL; mitk::PointSet* pointSet = NULL; if (index.column() == 0) { pointSetNode = pointSetNodes.front(); } else { pointSetNode = pointSetNodes.back(); } if (pointSetNode) { this->m_CorrespondingPointSetsModel->UpdateSelection(pointSetNode); pointSet = dynamic_cast(pointSetNode->GetData()); if( pointSet->GetPointSet(m_CorrespondingPointSetsModel->GetTimeStep())) for (mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_CorrespondingPointSetsModel->GetTimeStep())->GetPoints()->Begin(); it != pointSet->GetPointSet(m_CorrespondingPointSetsModel->GetTimeStep())->GetPoints()->End(); ++it) { QModelIndex tempIndex; if (m_CorrespondingPointSetsModel->GetModelIndexForPointID(it->Index(), tempIndex, index.column())) { if (tempIndex == index) { pointSet->SetSelectInfo(it->Index(), true, m_CorrespondingPointSetsModel->GetTimeStep()); m_CorrespondingPointSetsModel->SetSelectedPointSetIndex(index.column()); if ( this->GetMultiWidget() != NULL) { this->GetMultiWidget()->MoveCrossToPosition(pointSet->GetPoint(it->Index(), m_CorrespondingPointSetsModel->GetTimeStep())); } } else { pointSet->SetSelectInfo(it->Index(), false, m_CorrespondingPointSetsModel->GetTimeStep()); } } } } } emit(SignalPointSelectionChanged()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); this->UpdateSelectionHighlighting(); m_SelfCall = false; } void QmitkCorrespondingPointSetsView::keyPressEvent( QKeyEvent * e ) { int key = e->key(); switch (key) { case Qt::Key_F2: m_CorrespondingPointSetsModel->MoveSelectedPointUp(); break; case Qt::Key_F3: m_CorrespondingPointSetsModel->MoveSelectedPointDown(); break; case Qt::Key_Delete: m_CorrespondingPointSetsModel->RemoveSelectedPoint(); break; default: break; } } void QmitkCorrespondingPointSetsView::wheelEvent(QWheelEvent *event) { if (!this->m_CorrespondingPointSetsModel->GetStepper()) return; int whe = event->delta(); int pos = this->m_CorrespondingPointSetsModel->GetStepper()->GetPos(); int currentTS = this->m_CorrespondingPointSetsModel->GetTimeStep(); if(whe > 0) { this->m_CorrespondingPointSetsModel->SetTimeStep(++currentTS); this->m_CorrespondingPointSetsModel->GetStepper()->SetPos(++pos); } else if( pos > 0 ) { this->m_CorrespondingPointSetsModel->SetTimeStep(--currentTS); this->m_CorrespondingPointSetsModel->GetStepper()->SetPos(--pos); } fadeTimeStepIn(); emit SignalPointSelectionChanged(); } void QmitkCorrespondingPointSetsView::fadeTimeStepIn() { if (!this->m_CorrespondingPointSetsModel->GetStepper()) return; QWidget *m_TimeStepFader = new QWidget(this); QHBoxLayout *layout = new QHBoxLayout(m_TimeStepFader); int x = (int)(this->geometry().x()+this->width()*0.75); int y = (int)(this->geometry().y()+this->height()*0.75); m_TimeStepFader->move(x,y); m_TimeStepFader->resize(60, 55); m_TimeStepFader->setLayout(layout); m_TimeStepFader->setAttribute(Qt::WA_DeleteOnClose); 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_CorrespondingPointSetsModel->GetStepper()->GetPos())); //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 QmitkCorrespondingPointSetsView::fadeTimeStepOut() { m_TimeStepFaderLabel->hide(); } + void QmitkCorrespondingPointSetsView::ctxMenu(const QPoint &pos) { QMenu *menu = new QMenu; int x = pos.x(); int y = pos.y(); int row = QTableView::rowAt(y); int col = QTableView::columnAt(x); int numNodes = this->GetPointSetNodes().size(); //add delete point action mitk::PointSet::PointsContainer::ElementIdentifier id; mitk::PointSet::PointType p; bool pointSelected = m_CorrespondingPointSetsModel->GetPointForModelIndex(row, col, p, id); QAction *movePointUp = new QAction(this); movePointUp->setText("Move point up"); connect(movePointUp, SIGNAL(triggered()), this, SLOT(MoveSelectedPointUp())); if(!pointSelected) movePointUp->setEnabled(false); menu->addAction(movePointUp); QAction *movePointDown = new QAction(this); movePointDown->setText("Move point down"); connect(movePointDown, SIGNAL(triggered()), this, SLOT(MoveSelectedPointDown())); if(!pointSelected) movePointDown->setEnabled(false); menu->addAction(movePointDown); QAction *delPoint = new QAction(this); delPoint->setText("Delete point"); connect(delPoint, SIGNAL(triggered()), this, SLOT(RemoveSelectedPoint())); if(!pointSelected) delPoint->setEnabled(false); menu->addAction(delPoint); QAction *separator = new QAction(this); separator->setSeparator(true); menu->addSeparator(); QAction *clearTS = new QAction(this); clearTS->setText("Clear time step"); connect(clearTS, SIGNAL(triggered()), this, SLOT(ClearCurrentTimeStep())); if(numNodes==0 || col!=0 && col!=1) clearTS->setEnabled(false); menu->addAction(clearTS); QAction *clearList = new QAction(this); clearList->setText("Clear point set"); connect(clearList, SIGNAL(triggered()), this, SLOT(ClearSelectedPointSet())); if(numNodes==0 || col!=0 && col!=1) clearList->setEnabled(false); menu->addAction(clearList); menu->addSeparator(); QAction *swapSets = new QAction(this); swapSets->setText("Swap point sets"); connect(swapSets, SIGNAL(triggered(bool)), this, SLOT(SwapPointSets(bool))); swapSets->setCheckable(true); swapSets->setChecked(m_swapPointSets); if (numNodes<2) swapSets->setEnabled(false); menu->addAction(swapSets); QAction *addPoints = new QAction(this); addPoints->setText("Check to add new points"); connect(addPoints, SIGNAL(triggered(bool)), this, SLOT(AddPointsMode(bool))); addPoints->setCheckable(true); addPoints->setChecked(m_addPointsMode); if (numNodes==0) addPoints->setEnabled(false); menu->addAction(addPoints); QAction *addPointSet = new QAction(this); addPointSet->setText("Create new point set"); connect(addPointSet, SIGNAL(triggered()), this, SLOT(AddPointSet())); if (!m_DataStorage) addPointSet->setEnabled(false); menu->addAction(addPointSet); menu->exec(this->mapToGlobal(pos)); } -std::vector QmitkCorrespondingPointSetsView::GetPointSetNodes(){ +std::vector QmitkCorrespondingPointSetsView::GetPointSetNodes() +{ return this->m_CorrespondingPointSetsModel->GetPointSetNodes(); } -std::vector QmitkCorrespondingPointSetsView::GetPointSets(){ + +std::vector QmitkCorrespondingPointSetsView::GetPointSets() +{ std::vector pointSetNodes = GetPointSetNodes(); std::vector pointSets; std::vector::iterator it; for ( it = pointSetNodes.begin(); it < pointSetNodes.end(); it++ ) { mitk::PointSet* pointSet = NULL; pointSet = dynamic_cast ( dynamic_cast(*it)->GetData() ); if ( pointSet != NULL ) pointSets.push_back(pointSet); } return pointSets; } + void QmitkCorrespondingPointSetsView::RemoveSelectedPoint() { this->m_CorrespondingPointSetsModel->RemoveSelectedPoint(); emit(SignalPointSelectionChanged()); } + void QmitkCorrespondingPointSetsView::MoveSelectedPointDown() { this->m_CorrespondingPointSetsModel->MoveSelectedPointDown(); } + void QmitkCorrespondingPointSetsView::MoveSelectedPointUp() { this->m_CorrespondingPointSetsModel->MoveSelectedPointUp(); } + void QmitkCorrespondingPointSetsView::ClearSelectedPointSet() { switch( QMessageBox::question( this, tr("Clear point set"), tr("Remove all points from the right clicked list?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { case QMessageBox::Yes: { this->m_CorrespondingPointSetsModel->ClearSelectedPointSet(); break; } case QMessageBox::No: break; default: break; } emit(SignalPointSelectionChanged()); } + void QmitkCorrespondingPointSetsView::ClearCurrentTimeStep() { switch( QMessageBox::question( this, tr("Clear time step"), tr("Remove points from current time step of the right clicked list?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { case QMessageBox::Yes: { this->m_CorrespondingPointSetsModel->ClearCurrentTimeStep(); break; } case QMessageBox::No: break; default: break; } emit(SignalPointSelectionChanged()); } void QmitkCorrespondingPointSetsView::SwapPointSets(bool checked) { m_swapPointSets = checked; if ( !checked ) { std::vector nodes = this->GetPointSetNodes(); std::vector reverseNodes; reverseNodes.push_back(nodes.back()); reverseNodes.push_back(nodes.front()); this->SetPointSetNodes( reverseNodes ); } else this->SetPointSetNodes(this->GetPointSetNodes()); m_CorrespondingPointSetsModel->SetSelectedPointSetIndex((m_CorrespondingPointSetsModel->GetSelectedPointSetIndex()+1)%2); this->UpdateSelectionHighlighting(); } + void QmitkCorrespondingPointSetsView::AddPointsMode(bool checked) { m_addPointsMode = checked; std::vector pointSetNodes = this->GetPointSetNodes(); std::vector::iterator it; bool selected = false; if (checked) { for ( it = pointSetNodes.begin(); it < pointSetNodes.end(); it++ ) { mitk::DataNode* dataNode = dynamic_cast(*it); dataNode->GetPropertyValue("selected", selected); if (selected) { this->UpdateSelection(dataNode); break; } } } else { this->m_CorrespondingPointSetsModel->RemoveInteractor(); } m_addPointsMode = selected; emit SignalAddPointsModeChanged(selected); } + void QmitkCorrespondingPointSetsView::UpdateSelection(mitk::DataNode* selectedNode) { this->m_CorrespondingPointSetsModel->UpdateSelection(selectedNode); } + void QmitkCorrespondingPointSetsView::AddPointSet() { //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->m_DataStorage->Add(pointSetNode); } bool QmitkCorrespondingPointSetsView::IsPointSelected() { if ( this->m_CorrespondingPointSetsModel->GetSelectedPointSetIndex()>=0 ) return true; return false; } QmitkCorrespondingPointSetsModel* QmitkCorrespondingPointSetsView::GetModel() { return this->m_CorrespondingPointSetsModel; } + void QmitkCorrespondingPointSetsView::UpdateSelectionHighlighting() { this->m_SelfCall = true; QModelIndex index; bool modelIndexOkay = this->m_CorrespondingPointSetsModel->GetModelIndexForSelectedPoint(index); if(!modelIndexOkay){ this->m_SelfCall = false; return; } QTableView::selectionModel()->select( index , QItemSelectionModel::ClearAndSelect ); this->setFocus(); this->m_SelfCall = false; } + diff --git a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.h b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.h index a4ce7fb923..fe336b0566 100644 --- a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.h +++ b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsView.h @@ -1,126 +1,128 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_POINTLIST_VIEW_H_INCLUDED #define QMITK_POINTLIST_VIEW_H_INCLUDED #include #include #include #include "MitkQtWidgetsExtExports.h" #include "QmitkCorrespondingPointSetsModel.h" class QmitkStdMultiWidget; /*! * \brief 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. * */ class MitkQtWidgetsExt_EXPORT QmitkCorrespondingPointSetsView : public QTableView { Q_OBJECT public: QmitkCorrespondingPointSetsView( QWidget* parent = 0 ); ~QmitkCorrespondingPointSetsView(); /// assign a point set for observation void SetPointSetNodes( std::vector nodes ); 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 SetDataStorage(mitk::DataStorage::Pointer dataStorage); std::vector GetPointSetNodes(); void UpdateSelection(mitk::DataNode* selectedNode); // return true if a point from one of the displayed point lists is selected bool IsPointSelected(); QmitkCorrespondingPointSetsModel* GetModel(); signals: void SignalPointSelectionChanged(); void SignalAddPointsModeChanged(bool); public slots: void AddPointSet(); void RemoveSelectedPoint(); void MoveSelectedPointDown(); void MoveSelectedPointUp(); void AddPointsMode(bool checked); void SwapPointSets(bool checked); protected slots: /// called when the selection of the view widget changes void OnPointSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); /// fade the shown timestep out void fadeTimeStepOut(); /// open ContextMenu void ctxMenu(const QPoint &pos); void ClearSelectedPointSet(); void ClearCurrentTimeStep(); void UpdateSelectionHighlighting(); protected: 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: std::vector GetPointSets(); QmitkCorrespondingPointSetsModel* m_CorrespondingPointSetsModel; bool m_SelfCall; bool m_swapPointSets; bool m_addPointsMode; QLabel* m_TimeStepFaderLabel; mitk::DataStorage::Pointer m_DataStorage; }; + #endif + diff --git a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.cpp b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.cpp index ca1269fd29..0bbcf1410e 100644 --- a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.cpp @@ -1,202 +1,213 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkCorrespondingPointSetsWidget.h" #include #include #include #include QmitkCorrespondingPointSetsWidget::QmitkCorrespondingPointSetsWidget(QWidget *parent): QWidget(parent), m_CorrespondingPointSetsView(NULL) { // create new QTableView m_CorrespondingPointSetsView = new QmitkCorrespondingPointSetsView(); // setup user interface SetupUi(); // setup connections connect( this->m_CorrespondingPointSetsView, SIGNAL(SignalPointSelectionChanged()), this, SLOT(OnPointSelectionChanged()) ); connect( this->m_CorrespondingPointSetsView, SIGNAL(SignalAddPointsModeChanged(bool)), this, SLOT(OnAddPointsModeChanged(bool)) ); } QmitkCorrespondingPointSetsWidget::~QmitkCorrespondingPointSetsWidget() { delete m_CorrespondingPointSetsView; } - void QmitkCorrespondingPointSetsWidget::SetupUi() { QBoxLayout* lay1 = new QVBoxLayout(this); // add status bar buttons if (QTPropShowButtonBar) { bool isPointSelected = this->m_CorrespondingPointSetsView->IsPointSelected(); QBoxLayout* lay2 = new QHBoxLayout(); lay1->addLayout(lay2); lay2->stretch(true); QStatusBar* statusBar = new QStatusBar(this); statusBar->setMaximumHeight(25); m_CreatePointSetBtn = new QToolButton(); m_CreatePointSetBtn->setAutoRaise(true); - m_CreatePointSetBtn->setIcon(QIcon(":/qmitk/btnAddPointSet.png")); + m_CreatePointSetBtn->setIcon(QIcon(":/QtWidgetsExt/btnAddPointSet.png")); m_CreatePointSetBtn->setToolTip(QString("Create new point set")); connect(this->m_CreatePointSetBtn, SIGNAL(clicked()), this, SLOT(AddPointSet())); statusBar->addWidget(m_CreatePointSetBtn); m_AddPointsBtn = new QToolButton(); m_AddPointsBtn->setAutoRaise(true); - m_AddPointsBtn->setIcon(QIcon(":/qmitk/btnSetPoints.png")); + m_AddPointsBtn->setIcon(QIcon(":/QtWidgetsExt/btnSetPoints.png")); m_AddPointsBtn->setToolTip(QString("Check to add new points (shift-click)")); m_AddPointsBtn->setCheckable(true); connect(this->m_AddPointsBtn, SIGNAL(clicked(bool)), this, SLOT(AddPointsMode(bool))); statusBar->addWidget(m_AddPointsBtn); m_MovePointUpBtn = new QToolButton(); m_MovePointUpBtn->setAutoRaise(true); - m_MovePointUpBtn->setIcon(QIcon(":/qmitk/btnMoveUp.png")); + m_MovePointUpBtn->setIcon(QIcon(":/QtWidgetsExt/btnMoveUp.png")); m_MovePointUpBtn->setToolTip(QString("Move selected point up")); connect(this->m_MovePointUpBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointUp())); statusBar->addWidget(m_MovePointUpBtn); m_MovePointDownBtn = new QToolButton(); m_MovePointDownBtn->setAutoRaise(true); - m_MovePointDownBtn->setIcon(QIcon(":/qmitk/btnMoveDown.png")); + m_MovePointDownBtn->setIcon(QIcon(":/QtWidgetsExt/btnMoveDown.png")); m_MovePointDownBtn->setToolTip(QString("Move selected point down")); connect(this->m_MovePointDownBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointDown())); statusBar->addWidget(m_MovePointDownBtn); m_RemovePointBtn = new QToolButton(); m_RemovePointBtn->setAutoRaise(true); - m_RemovePointBtn->setIcon(QIcon(":/qmitk/btnRemovePoint.png")); + m_RemovePointBtn->setIcon(QIcon(":/QtWidgetsExt/btnRemovePoint.png")); m_RemovePointBtn->setToolTip(QString("Remove selected point")); connect(this->m_RemovePointBtn, SIGNAL(clicked()), this, SLOT(RemoveSelectedPoint())); statusBar->addWidget(m_RemovePointBtn); m_SwapSetsBtn = new QToolButton(); m_SwapSetsBtn->setAutoRaise(true); - m_SwapSetsBtn->setIcon(QIcon(":/qmitk/btnSwapSets.png")); + m_SwapSetsBtn->setIcon(QIcon(":/QtWidgetsExt/btnSwapSets.png")); m_SwapSetsBtn->setToolTip(QString("Swap the two selected point sets")); m_SwapSetsBtn->setCheckable(true); connect(this->m_SwapSetsBtn, SIGNAL(clicked(bool)), this, SLOT(SwapPointSets(bool))); statusBar->addWidget(m_SwapSetsBtn); // disable buttons m_MovePointUpBtn->setEnabled(false); m_MovePointDownBtn->setEnabled(false); m_RemovePointBtn->setEnabled(false); m_SwapSetsBtn->setEnabled(false); m_AddPointsBtn->setEnabled(false); lay2->addWidget(statusBar); } lay1->insertWidget(0,m_CorrespondingPointSetsView); this->setLayout(lay1); } - - void QmitkCorrespondingPointSetsWidget::SetPointSetNodes(std::vector nodes) { this->m_CorrespondingPointSetsView->SetPointSetNodes(nodes); if (this->GetPointSetNodes().size()<2) m_SwapSetsBtn->setEnabled(false); else m_SwapSetsBtn->setEnabled(true); } + std::vector QmitkCorrespondingPointSetsWidget::GetPointSetNodes() { return this->m_CorrespondingPointSetsView->GetPointSetNodes(); } + void QmitkCorrespondingPointSetsWidget::SetMultiWidget(QmitkStdMultiWidget* multiWidget) { m_CorrespondingPointSetsView->SetMultiWidget(multiWidget); } + void QmitkCorrespondingPointSetsWidget::SetDataStorage(mitk::DataStorage::Pointer dataStorage) { m_CorrespondingPointSetsView->SetDataStorage(dataStorage); } + void QmitkCorrespondingPointSetsWidget::UpdateSelection(mitk::DataNode* selectedNode) { m_AddPointsBtn->setEnabled(false); if (!selectedNode || !(dynamic_cast(selectedNode->GetData()))) return; bool visible = false; selectedNode->GetPropertyValue("visible", visible); if (visible){ m_AddPointsBtn->setEnabled(true); m_CorrespondingPointSetsView->UpdateSelection(selectedNode); } } + bool QmitkCorrespondingPointSetsWidget::QTPropButtonBarEnabled() const { return this->QTPropShowButtonBar; } + void QmitkCorrespondingPointSetsWidget::QTPropSetButtonBarEnabled(bool showBB) { this->QTPropShowButtonBar = showBB; } void QmitkCorrespondingPointSetsWidget::AddPointSet() { m_CorrespondingPointSetsView->AddPointSet(); } + void QmitkCorrespondingPointSetsWidget::OnPointSelectionChanged() { if ( this->m_CorrespondingPointSetsView->IsPointSelected() ) { m_MovePointUpBtn->setEnabled(true); m_MovePointDownBtn->setEnabled(true); m_RemovePointBtn->setEnabled(true); } else { m_MovePointUpBtn->setEnabled(false); m_MovePointDownBtn->setEnabled(false); m_RemovePointBtn->setEnabled(false); } } + void QmitkCorrespondingPointSetsWidget::RemoveSelectedPoint() { this->m_CorrespondingPointSetsView->RemoveSelectedPoint(); } + void QmitkCorrespondingPointSetsWidget::MoveSelectedPointDown() { this->m_CorrespondingPointSetsView->MoveSelectedPointDown(); } + void QmitkCorrespondingPointSetsWidget::MoveSelectedPointUp() { this->m_CorrespondingPointSetsView->MoveSelectedPointUp(); } + void QmitkCorrespondingPointSetsWidget::AddPointsMode(bool checked) { this->m_CorrespondingPointSetsView->AddPointsMode(checked); } + void QmitkCorrespondingPointSetsWidget::OnAddPointsModeChanged(bool enabled) { this->m_AddPointsBtn->setChecked(enabled); } + void QmitkCorrespondingPointSetsWidget::SwapPointSets(bool checked) { this->m_CorrespondingPointSetsView->SwapPointSets(checked); } + diff --git a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.h b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.h index 02e081a4aa..fdadeaba04 100644 --- a/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.h +++ b/Modules/QtWidgetsExt/QmitkCorrespondingPointSetsWidget.h @@ -1,132 +1,130 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ + #ifndef QmitkCorrespondingPointSetsWidget_H #define QmitkCorrespondingPointSetsWidget_H #include #include #include "MitkQtWidgetsExtExports.h" #include #include #include #include #include #include /*! * \brief Widget for regular operations on two point sets * * Displays two sets of point coordinates, buttons and a context menu to enable modifications to the point sets * * \li creation of new point sets * \li adding/removing points * \li move points * \li clear all points from a set * \li clear all points in one time step of one set * * The user/application module of this widget needs to * assign two visible point sets to the widget * (via SetPointSetNodes(std::vector nodes)), * preferrably by passing all visible data nodes contained * in the data storage to the widget every time * DataStorageChanged() is called. * * The user/application module of this widget needs to * assign one selected point set to the widget * (via UpdateSelection(mitk::DataNode* selectedNode)), * preferrably by passing the selected data node contained * in the data storage to the widget every time * OnSelectionChanged() is called. * * The user/application module of this widget needs to * assign a QmitkStdMultiWidget and a mitk::DataStorage * to the widget (via SetMultiWidget and SetDataStorage). */ - - class MitkQtWidgetsExt_EXPORT QmitkCorrespondingPointSetsWidget : public QWidget { Q_OBJECT Q_PROPERTY(bool QTPropShowButtonBar READ QTPropButtonBarEnabled WRITE QTPropSetButtonBarEnabled) public: QmitkCorrespondingPointSetsWidget(QWidget *parent = 0); ~QmitkCorrespondingPointSetsWidget(); /// calls SetPointSetNodes of the according QmitkCorrespondingPointSetsView void SetPointSetNodes(std::vector nodes); /// returns the point set nodes contained in the table model /// calls GetPointSetNodes of the according QmitkCorrespondingPointSetsView std::vector GetPointSetNodes(); /// calls SetMultiWidget of the according QmitkCorrespondingPointSetsView void SetMultiWidget(QmitkStdMultiWidget* multiWidget); /// calls SetDataStorage of the according QmitkCorrespondingPointSetsView void SetDataStorage(mitk::DataStorage::Pointer dataStorage); /// calls UpdateSelection of the according QmitkCorrespondingPointSetsView void UpdateSelection(mitk::DataNode* selectedNode); /// returns the qt property which indicates an activated/deactivated button bar below the table bool QTPropButtonBarEnabled() const; /// sets the qt property which activates/deactivates the button bar below the table void QTPropSetButtonBarEnabled(bool showBB); -signals: - protected slots: /// enables/disables buttons if a/no point is selected void OnPointSelectionChanged(); /// add new point set to data manager void AddPointSet(); /// enable if new points should be a added void AddPointsMode(bool checked); void RemoveSelectedPoint(); void MoveSelectedPointDown(); void MoveSelectedPointUp(); /// toggles m_AddPointsBtn checked state void OnAddPointsModeChanged(bool enabled); /// swap the two table columns columns void SwapPointSets(bool checked); protected: void SetupUi(); bool QTPropShowButtonBar; QmitkCorrespondingPointSetsView* m_CorrespondingPointSetsView; QToolButton* m_CreatePointSetBtn; QToolButton* m_MovePointUpBtn; QToolButton* m_MovePointDownBtn; QToolButton* m_RemovePointBtn; QToolButton* m_AddPointsBtn; QToolButton* m_SwapSetsBtn; }; #endif + diff --git a/Modules/QtWidgetsExt/QmitkCrossWidget.cpp b/Modules/QtWidgetsExt/QmitkCrossWidget.cpp index ea5ddf9393..8652fe1215 100644 --- a/Modules/QtWidgetsExt/QmitkCrossWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkCrossWidget.cpp @@ -1,57 +1,58 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkCrossWidget.h" #include #include QmitkCrossWidget::QmitkCrossWidget(QWidget * parent, Qt::WindowFlags f) : QLabel(parent, f) { setEnabled(true); setVisible(true); setFocusPolicy(Qt::ClickFocus); } void QmitkCrossWidget::mousePressEvent(QMouseEvent * ) { QPoint p = QCursor::pos(); lastX = p.x(); lastY = p.y(); emit SignalDeltaMove( 0 , 0 ); } void QmitkCrossWidget::mouseMoveEvent(QMouseEvent * ) { QPoint p = QCursor::pos(); int newX = p.x(); int newY = p.y(); int deltaX = newX-lastX; int deltaY = newY-lastY; this->ResetMousePosition( lastX,lastY); emit SignalDeltaMove( deltaX , deltaY ); } void QmitkCrossWidget::mouseReleaseEvent(QMouseEvent*) { } + diff --git a/Modules/QtWidgetsExt/QmitkCrossWidget.h b/Modules/QtWidgetsExt/QmitkCrossWidget.h index b9910e712b..dac5b86738 100644 --- a/Modules/QtWidgetsExt/QmitkCrossWidget.h +++ b/Modules/QtWidgetsExt/QmitkCrossWidget.h @@ -1,58 +1,59 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTCROSSWIDGET_H_INCLUDED #define QMITKTCROSSWIDGET_H_INCLUDED #include #include "MitkQtWidgetsExtExports.h" #include class MitkQtWidgetsExt_EXPORT QmitkCrossWidget : public QLabel { Q_OBJECT public: QmitkCrossWidget( QWidget * parent=0, Qt::WindowFlags f = 0 ); void mousePressEvent( QMouseEvent* mouseEvent ); void mouseMoveEvent( QMouseEvent* mouseEvent ); void mouseReleaseEvent( QMouseEvent* mouseEvent ); signals: void SignalDeltaMove( int,int ); protected: // fix for bug 3378 - setPos() causes an app crash on MAC OS X #ifdef __APPLE__ void ResetMousePosition(int, int) {}; #else void ResetMousePosition(int xpos, int ypos) { QCursor::setPos(xpos, ypos); }; #endif int lastX,lastY; }; + #endif diff --git a/Modules/QtWidgetsExt/QmitkEditPointDialog.cpp b/Modules/QtWidgetsExt/QmitkEditPointDialog.cpp index 0f2202381a..783a8a48ff 100644 --- a/Modules/QtWidgetsExt/QmitkEditPointDialog.cpp +++ b/Modules/QtWidgetsExt/QmitkEditPointDialog.cpp @@ -1,92 +1,93 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkEditPointDialog.h" #include #include #include #include struct QmitkEditPointDialogData { mitk::PointSet* m_PointSet; mitk::PointSet::PointIdentifier m_PointId; QLineEdit* m_XCoord; QLineEdit* m_YCoord; QLineEdit* m_ZCoord; int m_Timestep; }; QmitkEditPointDialog::QmitkEditPointDialog( QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f) , d(new QmitkEditPointDialogData) { this->setWindowTitle("Edit Point Dialog"); d->m_PointSet = 0; d->m_Timestep = 0; d->m_XCoord = new QLineEdit; d->m_YCoord = new QLineEdit; d->m_ZCoord = new QLineEdit; QPushButton* _OKButton = new QPushButton("OK"); connect( _OKButton, SIGNAL(clicked(bool)), this, SLOT(OnOkButtonClicked(bool)) ); QGridLayout* layout = new QGridLayout; layout->addWidget(new QLabel("X: "), 0,0,1,1); layout->addWidget(d->m_XCoord, 0,1,1,1); layout->addWidget(new QLabel("Y: "), 1,0,1,1); layout->addWidget(d->m_YCoord, 1,1,1,1); layout->addWidget(new QLabel("Z: "), 2,0,1,1); layout->addWidget(d->m_ZCoord, 2,1,1,1); layout->addWidget(_OKButton, 3,0,2,1); this->setLayout(layout); } QmitkEditPointDialog::~QmitkEditPointDialog() { delete d; } void QmitkEditPointDialog::SetPoint( mitk::PointSet* _PointSet, mitk::PointSet::PointIdentifier _PointId , int timestep) { d->m_PointSet = _PointSet; d->m_PointId = _PointId; d->m_Timestep = timestep; mitk::PointSet::PointType p = d->m_PointSet->GetPoint(d->m_PointId, d->m_Timestep); d->m_XCoord->setText( QString::number( p.GetElement(0), 'f', 3 ) ); d->m_YCoord->setText( QString::number( p.GetElement(1), 'f', 3 ) ); d->m_ZCoord->setText( QString::number( p.GetElement(2), 'f', 3 ) ); } -void QmitkEditPointDialog::OnOkButtonClicked( bool /*triggered*/ ) +void QmitkEditPointDialog::OnOkButtonClicked(bool) { if(d->m_PointSet == 0) { MITK_WARN << "Pointset is 0."; this->reject(); } mitk::PointSet::PointType p = d->m_PointSet->GetPoint(d->m_PointId, d->m_Timestep); p.SetElement( 0, d->m_XCoord->text().toDouble() ); p.SetElement( 1, d->m_YCoord->text().toDouble() ); p.SetElement( 2, d->m_ZCoord->text().toDouble() ); d->m_PointSet->SetPoint(d->m_PointId, p); this->accept(); } + diff --git a/Modules/QtWidgetsExt/QmitkEditPointDialog.h b/Modules/QtWidgetsExt/QmitkEditPointDialog.h index a6c0dabdd7..961a6c3b8a 100644 --- a/Modules/QtWidgetsExt/QmitkEditPointDialog.h +++ b/Modules/QtWidgetsExt/QmitkEditPointDialog.h @@ -1,45 +1,49 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkEditPointDialog_h #define QmitkEditPointDialog_h #include "MitkQtWidgetsExtExports.h" #include #include struct QmitkEditPointDialogData; + /*! * \brief A dialog for editing points directly (coordinates) via TextEdits * */ class MitkQtWidgetsExt_EXPORT QmitkEditPointDialog : public QDialog { Q_OBJECT public: QmitkEditPointDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 ); virtual ~QmitkEditPointDialog(); void SetPoint( mitk::PointSet* _PointSet, mitk::PointSet::PointIdentifier _PointId, int timestep=0 ); + protected slots: - void OnOkButtonClicked( bool /*triggered = false*/ ); + void OnOkButtonClicked(bool); + protected: QmitkEditPointDialogData* d; }; -#endif // QmitkEditPointDialog_h +#endif + diff --git a/Modules/QtWidgetsExt/QmitkExt.qrc b/Modules/QtWidgetsExt/QmitkExt.qrc deleted file mode 100644 index 43d5367d03..0000000000 --- a/Modules/QtWidgetsExt/QmitkExt.qrc +++ /dev/null @@ -1,14 +0,0 @@ - - - PlanarAngle_48.png - PlanarFourPointAngle_48.png - PlanarLine_48.png - PlanarPath_48.png - PlanarPolygon_48.png - PlanarRectangle_48.png - PlanarCircle_48.png - PlanarDoubleEllipse_48.png - PlanarBezierCurve_48.png - icon_seedpoint.png - - diff --git a/Modules/QtWidgetsExt/QmitkExtRegisterClasses.cpp b/Modules/QtWidgetsExt/QmitkExtRegisterClasses.cpp deleted file mode 100644 index 804375bd20..0000000000 --- a/Modules/QtWidgetsExt/QmitkExtRegisterClasses.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "QmitkExtRegisterClasses.h" - -#include "QmitkRenderingManagerFactory.h" - -#include "QmitkCallbackFromGUIThread.h" -#include "QmitkNodeDescriptorManager.h" - -//#include "QmitkDrawPaintbrushToolGUI.h" - -#include "mitkNodePredicateDataType.h" -#include "mitkNodePredicateProperty.h" -#include "mitkNodePredicateAnd.h" -#include "mitkProperties.h" - -#include - -#include - -void QmitkExtRegisterClasses() -{ - static bool alreadyDone = false; - if (!alreadyDone) - { - MITK_DEBUG << "QmitkExtRegisterClasses()"; - - static QmitkCallbackFromGUIThread globalQmitkCallbackFromGUIThread; - - - alreadyDone = true; - } -} - diff --git a/Modules/QtWidgetsExt/QmitkExtRegisterClasses.h b/Modules/QtWidgetsExt/QmitkExtRegisterClasses.h deleted file mode 100644 index 14b1a61d8c..0000000000 --- a/Modules/QtWidgetsExt/QmitkExtRegisterClasses.h +++ /dev/null @@ -1,26 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef QmitkExtRegisterClassesHIncluded -#define QmitkExtRegisterClassesHIncluded - -#include "mitkCommon.h" -#include "MitkQtWidgetsExtExports.h" - -MitkQtWidgetsExt_EXPORT void QmitkExtRegisterClasses(); - -#endif - diff --git a/Modules/QtWidgetsExt/QmitkFileChooser.cpp b/Modules/QtWidgetsExt/QmitkFileChooser.cpp index d557afe007..7e601c2b42 100644 --- a/Modules/QtWidgetsExt/QmitkFileChooser.cpp +++ b/Modules/QtWidgetsExt/QmitkFileChooser.cpp @@ -1,122 +1,122 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkFileChooser.h" #include #include #include #include #include #include QmitkFileChooser::QmitkFileChooser(QWidget* parent, Qt::WindowFlags f ) : QWidget( parent, f ) , m_SelectDir( false ) , m_FileMustExist( true ) , m_SelectFile(new QPushButton("Select File")) , m_File( new QLineEdit ) { m_File->setReadOnly( true ); this->SetHorizotalLayout(false); connect( m_SelectFile, SIGNAL(clicked(bool)), this, SLOT( OnSelectFileClicked( bool ) ) ); connect( m_File, SIGNAL( editingFinished () ), this, SLOT( OnFileEditingFinished() ) ); } void QmitkFileChooser::SetHorizotalLayout(bool horizontalLayout) { QBoxLayout* layout = 0; if(horizontalLayout) layout = new QHBoxLayout; else layout = new QVBoxLayout; layout->setContentsMargins(0,0,0,0); layout->addWidget( m_File ); layout->addWidget( m_SelectFile ); this->setLayout( layout ); } void QmitkFileChooser::SetSelectDir( bool selectDir ) { m_SelectDir = selectDir; } void QmitkFileChooser::SetFileMustExist( bool fileMustExist ) { m_FileMustExist = fileMustExist; } void QmitkFileChooser::SetReadOnly( bool ReadOnly ) { m_File->setReadOnly( ReadOnly ); } void QmitkFileChooser::SetFile( const std::string& file ) { QFileInfo info( QString::fromStdString(file) ); if(info.exists() || m_FileMustExist == false) { m_File->setText( QString::fromStdString(file) ); emit NewFileSelected( file ); } } void QmitkFileChooser::SetFilePattern( const std::string& filepattern ) { m_FilePattern = QString::fromStdString(filepattern); } bool QmitkFileChooser::IsValidFile() const { QFileInfo info( m_File->text() ); return info.exists(); } std::string QmitkFileChooser::GetFile() const { return m_File->text().toStdString(); } -void QmitkFileChooser::OnSelectFileClicked( bool /*checked*/ ) +void QmitkFileChooser::OnSelectFileClicked(bool) { - QString filename; if( m_SelectDir ) filename = QFileDialog::getExistingDirectory( QApplication::activeWindow() , "Open directory", m_File->text() ); else { if (m_FileMustExist) filename = QFileDialog::getOpenFileName( QApplication::activeWindow() , "Open file", m_File->text(), m_FilePattern ); else filename = QFileDialog::getSaveFileName( QApplication::activeWindow() , "Open file", m_File->text(), m_FilePattern ); } if(!filename.isEmpty()) m_File->setText( filename ); emit NewFileSelected(filename.toStdString()); } void QmitkFileChooser::OnFileEditingFinished() { emit NewFileSelected( m_File->text().toStdString() ); } + diff --git a/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.cpp b/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.cpp index da14c1183d..9aac03cc38 100644 --- a/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.cpp +++ b/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.cpp @@ -1,253 +1,245 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkFloatingPointSpanSlider.h" #include -//#include - QmitkFloatingPointSpanSlider::QmitkFloatingPointSpanSlider(QWidget *parent) : QxtSpanSlider(parent), m_LowerValue(0), m_UpperValue(1000), m_Minimum(0), m_Maximum(1000), offset(0.0), factor(1.0), m_IntMode(false) { this->QxtSpanSlider::setMinimum(0); this->QxtSpanSlider::setMaximum(1000); connect(this, SIGNAL(spanChanged(int,int)), this, SLOT(IntSpanChanged(int,int))); } void QmitkFloatingPointSpanSlider::setIntegerMode(bool intMode) { m_IntMode = intMode; this->QxtSpanSlider::setMinimum(m_Minimum); this->QxtSpanSlider::setMaximum(m_Maximum); } double QmitkFloatingPointSpanSlider::lowerValue() const { if (m_IntMode) return this->QxtSpanSlider::lowerValue(); return m_LowerValue; } double QmitkFloatingPointSpanSlider::upperValue() const { if (m_IntMode) return this->QxtSpanSlider::upperValue(); return m_UpperValue; } void QmitkFloatingPointSpanSlider::setLowerValue(double lower) { m_LowerValue = lower; if (m_IntMode) { this->QxtSpanSlider::setLowerValue(lower); } else { this->QxtSpanSlider::setLowerValue(scaleValue(lower)); emit lowerValueChanged(lower); } } void QmitkFloatingPointSpanSlider::setUpperValue(double upper) { m_UpperValue = upper; if (m_IntMode) { this->QxtSpanSlider::setUpperValue(upper); } else { this->QxtSpanSlider::setUpperValue(scaleValue(upper)); emit upperValueChanged(upper); } } void QmitkFloatingPointSpanSlider::setSpan(double lower, double upper) { - //MITK_INFO << "QmitkFloatingPointSpanSlider new span: " << lower << " - " << upper; m_LowerValue = lower; m_UpperValue = upper; if (m_IntMode) { this->QxtSpanSlider::setLowerValue(lower); this->QxtSpanSlider::setUpperValue(upper); } else { this->QxtSpanSlider::setLowerValue(scaleValue(lower)); this->QxtSpanSlider::setUpperValue(scaleValue(upper)); emit spanChanged(lower, upper); } } double QmitkFloatingPointSpanSlider::maximum() const { if (m_IntMode) return this->QxtSpanSlider::maximum(); return m_Maximum; } double QmitkFloatingPointSpanSlider::minimum() const { if (m_IntMode) return this->QxtSpanSlider::minimum(); return m_Minimum; } void QmitkFloatingPointSpanSlider::setMaximum(double max) { - //MITK_INFO << "QmitkFloatingPointSpanSlider new max: " << max; if (m_IntMode) { this->QxtSpanSlider::setMaximum(max); return; } if (max < m_Minimum) { m_Minimum = max; } m_Maximum = max; scaleSliderToInt(); if (m_LowerValue > m_Maximum) { m_LowerValue = m_Maximum; this->QxtSpanSlider::setLowerValue(scaleValue(m_LowerValue)); } if (m_UpperValue > m_Maximum) { m_UpperValue = m_Maximum; this->QxtSpanSlider::setUpperValue(scaleValue(m_UpperValue)); } } void QmitkFloatingPointSpanSlider::setMinimum(double min) { - //MITK_INFO << "QmitkFloatingPointSpanSlider new min: " << min; if (m_IntMode) { this->QxtSpanSlider::setMinimum(min); return; } if (min > m_Maximum) { m_Maximum = min; } m_Minimum = min; scaleSliderToInt(); if (m_LowerValue < m_Minimum) { m_LowerValue = m_Minimum; this->QxtSpanSlider::setLowerValue(scaleValue(m_LowerValue)); } if (m_UpperValue < m_Minimum) { m_UpperValue = m_Minimum; this->QxtSpanSlider::setUpperValue(scaleValue(m_UpperValue)); } } void QmitkFloatingPointSpanSlider::setRange(double min, double max) { if (m_IntMode) { this->QxtSpanSlider::setRange(min, max); m_Minimum = minimum(); m_Maximum = maximum(); m_LowerValue = lowerValue(); m_UpperValue = upperValue(); return; } if (min > max) { min = max; } m_Minimum = min; m_Maximum = max; if (m_LowerValue > m_Maximum) { m_LowerValue = m_Maximum; this->QxtSpanSlider::setLowerValue(scaleValue(m_LowerValue)); } else if (m_LowerValue < m_Minimum) { m_LowerValue = m_Minimum; this->QxtSpanSlider::setLowerValue(scaleValue(m_LowerValue)); } if (m_UpperValue > m_Maximum) { m_UpperValue = m_Maximum; this->QxtSpanSlider::setUpperValue(scaleValue(m_UpperValue)); } else if (m_UpperValue < m_Minimum) { m_UpperValue = m_Minimum; this->QxtSpanSlider::setUpperValue(scaleValue(m_UpperValue)); } scaleSliderToInt(); } void QmitkFloatingPointSpanSlider::IntSpanChanged(int lower, int upper) { if (m_IntMode) { m_LowerValue = lower; m_UpperValue = upper; } else { m_LowerValue = unscaleValue(lower); m_UpperValue = unscaleValue(upper); } emit spanChanged(m_LowerValue, m_UpperValue); } void QmitkFloatingPointSpanSlider::scaleSliderToInt() { int tmpLower = unscaleValue(m_LowerValue); int tmpUpper = unscaleValue(m_UpperValue); double range = m_Maximum - m_Minimum; factor = range ? 1000.0 / range : 0; offset = -m_Minimum; - //MITK_INFO << "New offset: " << offset << ", scale: " << factor; - m_LowerValue = scaleValue(tmpLower); m_UpperValue = scaleValue(tmpUpper); } int QmitkFloatingPointSpanSlider::scaleValue(double val) { int scaled = factor ? (offset + val)*factor : 0; - //MITK_INFO << "Scaling " << val << " (double) ==> " << scaled << " (int)"; return scaled; } double QmitkFloatingPointSpanSlider::unscaleValue(int val) { double unscaled = factor ? static_cast(val)/factor - offset : 0; - //MITK_INFO << "Unscaling " << val << " (int) ==> " << unscaled << " (double)"; return unscaled; } + diff --git a/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.h b/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.h index 0f6a916721..c97de011a8 100644 --- a/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.h +++ b/Modules/QtWidgetsExt/QmitkFloatingPointSpanSlider.h @@ -1,86 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKFLOATINGPOINTSPANSLIDER_H #define QMITKFLOATINGPOINTSPANSLIDER_H #include #include #include class MitkQtWidgetsExt_EXPORT QmitkFloatingPointSpanSlider : public QxtSpanSlider { Q_OBJECT Q_PROPERTY(double loweralue READ lowerValue WRITE setLowerValue NOTIFY lowerValueChanged) Q_PROPERTY(double upperValue READ upperValue WRITE setUpperValue NOTIFY upperValueChanged) Q_PROPERTY(double maximum READ maximum WRITE setMaximum) Q_PROPERTY(double minimum READ minimum WRITE setMinimum) public: QmitkFloatingPointSpanSlider(QWidget *parent = 0); void setIntegerMode(bool intMode); double lowerValue() const; double upperValue() const; double maximum() const; double minimum() const; void setMaximum(double max); void setMinimum(double min); void setRange(double min, double max); signals: void lowerValueChanged(double lower); void upperValueChanged(double upper); void spanChanged(double lower, double upper); public slots: void setLowerValue(double lower); void setUpperValue(double upper); void setSpan(double lower, double upper); private slots: void IntSpanChanged(int lower, int upper); private: void scaleSliderToInt(); inline int scaleValue(double val); inline double unscaleValue(int val); double m_LowerValue; double m_UpperValue; double m_Minimum; double m_Maximum; double offset; double factor; bool m_IntMode; }; -#endif // QMITKFLOATINGPOINTSPANSLIDER_H +#endif + diff --git a/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.cpp b/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.cpp index 341daa3c4d..b4516f786e 100644 --- a/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.cpp +++ b/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.cpp @@ -1,588 +1,444 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ + #include "QmitkFunctionalityComponentContainer.h" -//#include "QmitkBaseFunctionalityComponent.h" #include "ui_QmitkFunctionalityComponentContainerControls.h" #include #include "mitkDataTreeFilterFunctions.h" #include #include #include "mitkProperties.h" -/*****Qt-Elements***/ #include #include #include -//#include #include #include #include -//#include #include #include #include const QSizePolicy preferred(QSizePolicy::Preferred, QSizePolicy::Preferred); -/*************** CONSTRUCTOR ***************/ QmitkFunctionalityComponentContainer::QmitkFunctionalityComponentContainer(QObject *parent, const char *parentName, bool updateSelector, bool showSelector) : QmitkBaseFunctionalityComponent(parent, parentName), m_UpdateSelector(updateSelector), m_ShowSelector(showSelector), m_GUI(NULL), -//m_ParentMitkImage(NULL), -//m_ParentMitkImageIterator(NULL), m_Active(false), m_SelectedItem(NULL), m_FunctionalityComponentContainerGUI(NULL), m_Parent(parent), -//m_ParentName(parentName), m_ComponentName("ComponentContainer"), -//m_MultiWidget(mitkStdMultiWidget), m_Spacer(NULL), -//m_MulitWidget(this->GetActiveStdMultiWidget()), m_BackButton(NULL), m_NextButton(NULL), m_MaximumWidgedStackSize(-1) { SetAvailability(true); } -/*************** DESTRUCTOR ***************/ QmitkFunctionalityComponentContainer::~QmitkFunctionalityComponentContainer() { } -/*************** SET COMPONENT NAME ***************/ void QmitkFunctionalityComponentContainer::SetComponentName(QString name) { m_ComponentName = name; } -/*************** GET COMPONENT NAME ***************/ QString QmitkFunctionalityComponentContainer::GetComponentName() { return m_ComponentName; } - -/************* SET SHOW TREE NODE SELECTOR ***********/ void QmitkFunctionalityComponentContainer::SetShowTreeNodeSelector(bool show) { GetImageContent()->setShown(show); } -/*************** GET IMAGE CONTENT ***************/ QGroupBox* QmitkFunctionalityComponentContainer::GetImageContent() { return (QGroupBox*) m_FunctionalityComponentContainerGUI->m_ImageContent; } -/*************** GET GUI ***************/ QWidget* QmitkFunctionalityComponentContainer::GetGUI() { return m_GUI; } -/*************** GET PARTENT MITK IMAGE ***************/ mitk::Image* QmitkFunctionalityComponentContainer::GetParentMitkImage() { return m_ParentMitkImage; } -/******** ******* GET TREE NODE SELECTOR ***************/ + QmitkDataStorageComboBox * QmitkFunctionalityComponentContainer::GetTreeNodeSelector() { if(m_FunctionalityComponentContainerGUI) { return m_FunctionalityComponentContainerGUI->m_TreeNodeSelector; } else return NULL; } -/******** ******* GET MULTI WIDGET ***************/ QmitkStdMultiWidget * QmitkFunctionalityComponentContainer::GetMultiWidget() { return m_MulitWidget; } -/*************** TREE CHANGED ( EVENT ) ***************/ -void QmitkFunctionalityComponentContainer::TreeChanged(const itk::EventObject & /*treeChangedEvent*/) +void QmitkFunctionalityComponentContainer::TreeChanged(const itk::EventObject&) { if(IsActivated()) { TreeChanged(); } else TreeChanged(); } -/*************** TREE CHANGED ( ) ***************/ void QmitkFunctionalityComponentContainer::TreeChanged() { UpdateDataTreeComboBoxes(); for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { m_AddedChildList[i]->TreeChanged(); } } -/************ Update DATATREECOMBOBOX(ES) *************/ void QmitkFunctionalityComponentContainer::UpdateDataTreeComboBoxes() { - //if(GetTreeNodeSelector() != NULL) - //{ - // m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->Update(); - //} } -/*************** CONNECTIONS ***************/ void QmitkFunctionalityComponentContainer::CreateConnections() { if ( m_FunctionalityComponentContainerGUI ) { connect( (QObject*)(m_FunctionalityComponentContainerGUI->m_TreeNodeSelector), SIGNAL(OnSelectionChanged (const mitk::DataNode *)), (QObject*) this, SLOT(ImageSelected(const mitk::DataNode *))); connect( (QObject*)(m_FunctionalityComponentContainerGUI->m_ContainerBorder), SIGNAL(toggled(bool)), (QObject*) this, SLOT(SetContentContainerVisibility(bool))); } } -/** \brief Method to set the DataStorage*/ void QmitkFunctionalityComponentContainer::SetDataStorage(mitk::DataStorage::Pointer dataStorage) { m_DataStorage = dataStorage; } -/** \brief Method to get the DataStorage*/ mitk::DataStorage::Pointer QmitkFunctionalityComponentContainer::GetDataStorage() { return m_DataStorage; } -/*************** DATA STORAGE CHANGED ***************/ void QmitkFunctionalityComponentContainer::DataStorageChanged(mitk::DataStorage::Pointer ds) { if(m_FunctionalityComponentContainerGUI != NULL) { for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { QmitkBaseFunctionalityComponent* functionalityComponent = dynamic_cast(m_AddedChildList[i]); if (functionalityComponent != NULL) { functionalityComponent->DataStorageChanged(ds); } } } if(m_FunctionalityComponentContainerGUI) { if(!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector) return; if(!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()) return; if(!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()) return; m_ParentMitkImage = static_cast (m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()); if(m_FunctionalityComponentContainerGUI != NULL) { for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { QmitkBaseFunctionalityComponent* functionalityComponent = dynamic_cast(m_AddedChildList[i]); if (functionalityComponent != NULL) { if(!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()) return; functionalityComponent->m_ParentMitkImage = static_cast (m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()); } } } } - //TreeChanged(;) } -/*************** IMAGE SELECTED ***************/ void QmitkFunctionalityComponentContainer::ImageSelected(const mitk::DataNode* item) { if(m_FunctionalityComponentContainerGUI != NULL) { mitk::DataNode::Pointer selectedItem = const_cast< mitk::DataNode*>(item); GetTreeNodeSelector()->SetSelectedNode(selectedItem); -// m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->changeItem(); for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { QmitkBaseFunctionalityComponent* functionalityComponent = dynamic_cast(m_AddedChildList[i]); if (functionalityComponent != NULL) - //functionalityComponent->GetTreeNodeSelector()->SetSelectedNode(selectedItem); functionalityComponent->ImageSelected(item); } } if(m_FunctionalityComponentContainerGUI) { m_ParentMitkImage = static_cast (item->GetData()); if(m_FunctionalityComponentContainerGUI != NULL) { for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { QmitkBaseFunctionalityComponent* functionalityComponent = dynamic_cast(m_AddedChildList[i]); if (functionalityComponent != NULL) { functionalityComponent->m_ParentMitkImage = static_cast (item->GetData()); } } } } TreeChanged(); } -/*************** CREATE CONTAINER WIDGET **************/ -void QmitkFunctionalityComponentContainer::CreateQtPartControl(QWidget * /*parent*/, mitk::DataStorage::Pointer dataStorage) +void QmitkFunctionalityComponentContainer::CreateQtPartControl(QWidget*, mitk::DataStorage::Pointer dataStorage) { if (m_FunctionalityComponentContainerGUI == NULL) { m_GUI = new QWidget; m_FunctionalityComponentContainerGUI = new Ui::QmitkFunctionalityComponentContainerGUI; m_FunctionalityComponentContainerGUI->setupUi(m_GUI); - //m_GUI = parent; - this->SetDataStorage(dataStorage); + this->SetDataStorage(dataStorage); m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->SetDataStorage(dataStorage); m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->SetPredicate(mitk::NodePredicateDataType::New("Image")); -m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(0); - - //m_FunctionalityComponentContainerGUI->m_TreeNodeSelector()->SetDataTree(GetDataTreeIterator()); - //m_FunctionalityComponentContainerGUI->GetContainerBorder()->setTitle("Select Image<\bold>"); - //m_FunctionalityComponentContainerGUI->GetContainerBorder()->setLineWidth(0); + m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(0); } this->CreateConnections(); - //m_MulitWidget = parent->GetActiveMultiWidget(); - //m_FunctionalityComponentContainerGUI->m_TreeNodeSelector()->GetFilter()->SetFilter(mitk::IsBaseDataTypeWithoutProperty("isComponentThresholdImage")); } -/*************** GET CONTENT CONTAINER ***************/ QGroupBox * QmitkFunctionalityComponentContainer::GetContentContainer() { return m_FunctionalityComponentContainerGUI->m_ImageContent; } -/************ GET MAIN CHECK BOX CONTAINER ************/ QGroupBox * QmitkFunctionalityComponentContainer::GetMainCheckBoxContainer() { return m_FunctionalityComponentContainerGUI->m_ContainerBorder; } -/*********** SET CONTENT CONTAINER VISIBLE ************/ void QmitkFunctionalityComponentContainer::SetContentContainerVisibility(bool) { if(GetMainCheckBoxContainer() != NULL) { if(GetMainCheckBoxContainer()->isChecked()) { Activated(); } else { Deactivated(); } } for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { if(m_AddedChildList[i]->GetContentContainer() != NULL) { m_AddedChildList[i]->GetContentContainer()->setShown(GetMainCheckBoxContainer()->isChecked()); } if(m_AddedChildList[i]->GetMainCheckBoxContainer() != NULL) { m_AddedChildList[i]->GetMainCheckBoxContainer()->setChecked(GetMainCheckBoxContainer()->isChecked()); } m_AddedChildList[i]->SetContentContainerVisibility(GetMainCheckBoxContainer()->isChecked()); } } -/************** SET SELECTOR VISIBILITY ***************/ void QmitkFunctionalityComponentContainer::SetSelectorVisibility(bool visibility) { if(m_GUI) { m_FunctionalityComponentContainerGUI->m_ImageContent->setShown(visibility); } m_ShowSelector = visibility; } -/*************** ACTIVATED ***************/ void QmitkFunctionalityComponentContainer::Activated() { TreeChanged(); QmitkBaseFunctionalityComponent::Activated(); m_Active = true; for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { m_AddedChildList[i]->Activated(); } } -/*************** DEACTIVATED ***************/ void QmitkFunctionalityComponentContainer::Deactivated() { QmitkBaseFunctionalityComponent::Deactivated(); m_Active = false; for(unsigned int i = 0; i < m_AddedChildList.size(); i++) { m_AddedChildList[i]->Deactivated(); } } -/*************** ADD COMPONENT ***************/ void QmitkFunctionalityComponentContainer::AddComponent(QmitkFunctionalityComponentContainer* component) { if(component!=NULL) { QWidget* componentWidget = component->CreateControlWidget(m_GUI); AddComponentListener(component); m_GUI->layout()->addWidget(componentWidget); component->CreateConnections(); if(m_Spacer != NULL) { m_GUI->layout()->removeItem(m_Spacer); } QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); m_Spacer = spacer; m_GUI->layout()->addItem( m_Spacer ); m_GUI->repaint(); } } -/** \brief Method to return the NextButton to switch to the next widgetStackPage*/ + QPushButton* QmitkFunctionalityComponentContainer::GetNextButton() { return m_NextButton; } -/** \brief Method to return the BackButton to switch to the last widgetStackPage*/ QPushButton* QmitkFunctionalityComponentContainer::GetBackButton() { return m_BackButton; } - -/*************** ADD COMPONENT ***************/ void QmitkFunctionalityComponentContainer::AddComponent(QmitkFunctionalityComponentContainer* component, QString label, int stackPage) { if(component!=NULL) { QWidget* visibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(); int idVisibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->indexOf(visibleWidget); if(idVisibleWidget > m_MaximumWidgedStackSize) { m_MaximumWidgedStackSize = idVisibleWidget; } if(m_MaximumWidgedStackSize < stackPage) { QWidget* w = new QWidget(m_FunctionalityComponentContainerGUI->m_WidgetStack); m_FunctionalityComponentContainerGUI->m_WidgetStack->insertTab(stackPage, w, label); m_MaximumWidgedStackSize++; m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(stackPage); visibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(); idVisibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->indexOf(visibleWidget); new QVBoxLayout(visibleWidget); - // QT3: new QVBoxLayout(visibleWidget, QBoxLayout::TopToBottom); } QLayout* layout; if(m_FunctionalityComponentContainerGUI->m_WidgetStack->layout() == 0) { layout = new QVBoxLayout( (QWidget*)(m_FunctionalityComponentContainerGUI->m_WidgetStack)); } else { layout = m_FunctionalityComponentContainerGUI->m_WidgetStack->layout(); } component->CreateQtPartControl(m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(), this->m_DataStorage); QWidget* componentWidget = component->GetGUI(); - //CreateControlWidget(m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget()); AddComponentListener(component); - //QTabWidget* myTabWidget = - //m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(stackPage); m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(stackPage); QWidget* theCurrentWidget=m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(); QLayout* theCurrentLayout = theCurrentWidget->layout(); theCurrentLayout->addWidget(componentWidget); - //m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget()->layout()->addWidget(componentWidget); -// QWidget* myWidget = myTabWidget->page(stackPage); - // QLayout* myLayout = myWidget->layout(); - // myWidget->layout()->add(componentWidget); - m_FunctionalityComponentContainerGUI->m_WidgetStack->setShown(true); m_FunctionalityComponentContainerGUI->m_WidgetStack->updateGeometry(); m_FunctionalityComponentContainerGUI->m_WidgetStack->layout()->activate(); componentWidget->setShown(true); component->CreateConnections(); m_GUI->repaint(); } } void QmitkFunctionalityComponentContainer::CreateNavigationButtons() { - //QBoxLayout * buttonLayout = new QHBoxLayout(GetImageContent()->layout()); QWidget* funcWidget = (QWidget*)m_FunctionalityComponentContainerGUI; QLayout *functionalityLayout = funcWidget->layout(); QBoxLayout * buttonLayout = new QHBoxLayout(funcWidget); if ( QBoxLayout* boxLayout = dynamic_cast(functionalityLayout) ) { boxLayout->addLayout( buttonLayout ); } - //if(m_BackButton==NULL) - //{ - // m_BackButton = new QPushButton("<<", GetImageContent()); - //} - //if(m_NextButton==NULL) - //{ - // m_NextButton = new QPushButton(">>", GetImageContent()); - //} if(m_BackButton==NULL) { m_BackButton = new QPushButton("<<", (QWidget*)(m_FunctionalityComponentContainerGUI)); } if(m_NextButton==NULL) { m_NextButton = new QPushButton(">>", (QWidget*)(m_FunctionalityComponentContainerGUI)); } buttonLayout->addWidget(m_BackButton); buttonLayout->addWidget(m_NextButton); - //m_GUI->layout()->addChildLayout(buttonLayout); m_BackButton->setShown(true); m_NextButton->setShown(true); - //m_GUI->layout()->AlignTop; m_GUI->layout()->activate(); m_GUI->repaint(); -// connect( (QObject*)(m_NextButton), SIGNAL(pressed()), (QObject*) this, SLOT(NextButtonPressed())); -// connect( (QObject*)(m_BackButton), SIGNAL(pressed()), (QObject*) this, SLOT(BackButtonPressed())); - m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(1); SetWizardText(""); GetImageContent()->updateGeometry(); if(m_Spacer != NULL) { m_GUI->layout()->removeItem(m_Spacer); } QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); m_Spacer = spacer; m_GUI->layout()->addItem( m_Spacer ); m_GUI->updateGeometry(); m_GUI->repaint(); } -void QmitkFunctionalityComponentContainer::SetWizardText(const QString& /*text*/) +void QmitkFunctionalityComponentContainer::SetWizardText(const QString&) { - //m_FunctionalityComponentContainerGUI->GetWizardTextLabel()->setText(text); - //m_FunctionalityComponentContainerGUI->GetWizardTextLabel()->setAlignment(Qt::WordBreak); GetImageContent()->updateGeometry(); GetImageContent()->repaint(); m_GUI->updateGeometry(); - //m_GUI->layout()->AlignTop; m_GUI->layout()->activate(); m_GUI->repaint(); } -//void QmitkFunctionalityComponentContainer::ChooseWizardText(int page) -//{ -// switch(page) -// { -// case 1: -// SetWizardText("Step 1 Minimize the dataset:
a) If you have a 4D-Dataset export one time step with the TimeStepExporter.
b) Crop the image by selecting a shape and placing it (STRG + Mouse) around the relevant areas. Everything around the shape will be cut off."); -// break; -// case 2: -// SetWizardText("Step 2 Create an STL-Model:
a) Choose a threshold with the Threshold Finder where all areas that shall be used for the model are marked (green).
b) If there are special areas that have to be manipulated use the PixelGreyValueManipulator and do not forget to select the new created image.>
c) Create a Surface with the SurfaceCreator."); -// break; -// case 3: -// SetWizardText("Step 3 Surface Finish:
a) If you have your surface you can use the connectivity filter where you can mark all connected areas in different colours or delete alle areas instead of the biggest."); -// break; -// default: -// SetWizardText("Step 1 Minimize the dataset:
a) If you have a 4D-Dataset export one time step with the TimeStepExporter.
b) Crop the image by selecting a shape and placing it (STRG + Mouse) around the relevant areas. Everything around the shape will be cut off."); -// break; -// }; -//} - -//void QmitkFunctionalityComponentContainer::NextButtonPressed() -//{ -// int actualPage = m_FunctionalityComponentContainerGUI->m_WidgetStack->id(m_FunctionalityComponentContainerGUI->m_WidgetStack->visibleWidget()); -// switch(actualPage) -// { -// case 1: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(2); -// ChooseWizardText(2); -// break; -// case 2: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(3); -// ChooseWizardText(3); -// break; -// case 3: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(1); -// ChooseWizardText(1); -// break; -// default: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(1); -// ChooseWizardText(1); -// break; -// }; -// -//} -//void QmitkFunctionalityComponentContainer::BackButtonPressed() -//{ -// int actualPage = m_FunctionalityComponentContainerGUI->m_WidgetStack->id(m_FunctionalityComponentContainerGUI->m_WidgetStack->visibleWidget()); -// switch(actualPage) -// { -// case 1: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(3); -// ChooseWizardText(3); -// break; -// case 2: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(1); -// ChooseWizardText(1); -// break; -// case 3: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(2); -// ChooseWizardText(2); -// break; -// default: -// m_FunctionalityComponentContainerGUI->m_WidgetStack->raiseWidget(1); -// ChooseWizardText(1); -// break; -// }; -//} - - Ui::QmitkFunctionalityComponentContainerGUI* QmitkFunctionalityComponentContainer::GetFunctionalityComponentContainerGUI() { return m_FunctionalityComponentContainerGUI; } + diff --git a/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.h b/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.h index 85dbae69fd..48c315a69b 100644 --- a/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.h +++ b/Modules/QtWidgetsExt/QmitkFunctionalityComponentContainer.h @@ -1,259 +1,182 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_FUNCTIONALITYCOMPONENTCONTAINER_H #define QMITK_FUNCTIONALITYCOMPONENTCONTAINER_H #include "QmitkBaseFunctionalityComponent.h" #include "MitkQtWidgetsExtExports.h" #include #include #include #include #include #include #include #include #include "ui_QmitkFunctionalityComponentContainerControls.h" #include - - /** * \brief ContainerClass for components * \ingroup QmitkFunctionalityComponent * * * - \ref QmitkBaseFunctionalityComponent * * \section QmitkFunctionalityComponentContainer Overview * * The FunctionalityComponentContainer is a containerclass for several components inherit from it. * All Components including to one FunctionalityComponentContainer can be used together as one applied * functionality. I.e. in particular that new functionalities can be combined with different components. * As common ground for all inherit classes the FunctionalityComponentContainer includes a selector for * marked data like image(s), segmentation(s) or model(s). */ class MitkQtWidgetsExt_EXPORT QmitkFunctionalityComponentContainer : public QmitkBaseFunctionalityComponent { Q_OBJECT public: - - - - /*************** CONSTRUCTOR ***************/ /** \brief Standard-Constructor. */ QmitkFunctionalityComponentContainer(QObject *parent=0, const char * parentName = 0, bool updateSelector = true, bool showSelector = true); - /*************** DESTRUCTOR ***************/ /** \brief Destructor. */ virtual ~QmitkFunctionalityComponentContainer(); - /*************** CREATE ***************/ /*! \brief Method to create all Signale-Slot-Connections */ virtual void CreateConnections(); /*! \brief Method to create the GUI-Object */ virtual void CreateQtPartControl(QWidget *parent, mitk::DataStorage::Pointer dataStorage); /** \brief Method to create the forward and backward -buttons to navigate through the wizard */ -void CreateNavigationButtons(); - -///** \brief Method to change the wizardText */ -//void CreateWizardTextLabel(); - -/** \brief Method to create a textLabel at the Top of the wizard where a description can be created */ -void SetWizardText(const QString & text); -// -///** \brief Method to choose the right wizard text, depending on the wizardpage*/ -//void ChooseWizardText(int page); - - /** \brief also the Graphical User Interface for the component, like m_GUI, but with its specific type */ -Ui::QmitkFunctionalityComponentContainerGUI* GetFunctionalityComponentContainerGUI(); - + void CreateNavigationButtons(); + /** \brief Method to create a textLabel at the Top of the wizard where a description can be created */ + void SetWizardText(const QString & text); + /** \brief also the Graphical User Interface for the component, like m_GUI, but with its specific type */ + Ui::QmitkFunctionalityComponentContainerGUI* GetFunctionalityComponentContainerGUI(); - /*************** SET AND GET ***************/ + /** \brief Method to set the DataStorage*/ + virtual void SetDataStorage(mitk::DataStorage::Pointer dataStorage); -/** \brief Method to set the DataStorage*/ -virtual void SetDataStorage(mitk::DataStorage::Pointer dataStorage); - -/** \brief Method to get the DataStorage*/ -virtual mitk::DataStorage::Pointer GetDataStorage(); + /** \brief Method to get the DataStorage*/ + virtual mitk::DataStorage::Pointer GetDataStorage(); /** \brief Method to set the Name of the FunctionalityComponent */ virtual void SetComponentName(QString name); /** \brief Method to get the Name of the FunctionalityComponent */ virtual QString GetComponentName(); /** \brief Method to get the GUI of this component.*/ QWidget* GetGUI(); virtual QmitkDataStorageComboBox * GetTreeNodeSelector(); /** \brief Method to set the Image Selector visible or invisible */ virtual void SetSelectorVisibility(bool visibility); QmitkStdMultiWidget * GetMultiWidget(); - /** \brief Method to return the ComboBox that includes all GUI-elements instead of the outermost checkable CheckBox and that can be set visible or not*/ + /** \brief Method to return the ComboBox that includes all GUI-elements instead of the outermost checkable CheckBox and that can be set visible or not*/ virtual QGroupBox * GetContentContainer(); - /** \brief Method to return the outermost checkable ComboBox that is to decide whether the content shall be shown or not */ + /** \brief Method to return the outermost checkable ComboBox that is to decide whether the content shall be shown or not */ virtual QGroupBox * GetMainCheckBoxContainer(); /** \brief Method to set the Tree-Node-Selector visible or not as his parent group-box is set shown or not. */ -virtual void SetShowTreeNodeSelector(bool show); - - -/** \brief Method to return the group-box that contains the tree-node-selector */ -virtual QGroupBox* GetImageContent(); + virtual void SetShowTreeNodeSelector(bool show); + /** \brief Method to return the group-box that contains the tree-node-selector */ + virtual QGroupBox* GetImageContent(); -/** \brief Method to return the Image Selected in the Container Combo Box */ -virtual mitk::Image* GetParentMitkImage(); + /** \brief Method to return the Image Selected in the Container Combo Box */ + virtual mitk::Image* GetParentMitkImage(); -/** \brief Method to return the NextButton to switch to the next widgetStackPage*/ -QPushButton* GetNextButton(); + /** \brief Method to return the NextButton to switch to the next widgetStackPage*/ + QPushButton* GetNextButton(); -/** \brief Method to return the BackButton to switch to the last widgetStackPage*/ -QPushButton* GetBackButton(); - -/*************** ADD COMPONENTS ***************/ + /** \brief Method to return the BackButton to switch to the last widgetStackPage*/ + QPushButton* GetBackButton(); /** \brief method to add components into this component. */ virtual void AddComponent(QmitkFunctionalityComponentContainer* componentContainer); - /** \brief method to add components into this component. */ + /** \brief method to add components into this component. */ virtual void AddComponent(QmitkFunctionalityComponentContainer* componentContainer, QString label, int stackPage); - /*************** TREE CHANGED ( ) ***************/ virtual void TreeChanged(const itk::EventObject & treeChangedEvent); - - /*************** (DE)ACTIVATED ***************/ - - ///** \brief Method to set m_Activated to true */ virtual void Activated(); - ///** \brief Method to set m_Activated to false */ virtual void Deactivated(); - /** \brief Attribute to decide whether the selector shall be updated when a parent-Selector is updatet or not */ + /** \brief Attribute to decide whether the selector shall be updated when a parent-Selector is updatet or not */ bool m_UpdateSelector; /** \brief Attribute to decide whether the selector shall be shown or not */ bool m_ShowSelector; /** \brief Slot method that will be called if TreeNodeSelector widget was activated. */ void ImageSelected(const mitk::DataNode* item); -protected slots: - - public slots: - /** \brief Method to set the "GetContentContainer"-visible or not, addicted to the visibility of a parent-component and the status of the checkable ComboBox from "GetMainCheckBoxContainer()" */ - virtual void SetContentContainerVisibility(bool); + /** \brief Method to set the "GetContentContainer"-visible or not, addicted to the visibility of a parent-component and the status of the checkable ComboBox from "GetMainCheckBoxContainer()" */ + virtual void SetContentContainerVisibility(bool); - /*************** TREE CHANGED ( ) ***************/ - // /** \brief The TreeChanged-slot-method updates the TreeNodeSelector if the datatree changes. */ virtual void TreeChanged(); - /*************** OHTER METHODS ***************/ - virtual void DataStorageChanged(mitk::DataStorage::Pointer ds); - - - - //void NextButtonPressed(); - //void BackButtonPressed(); + virtual void DataStorageChanged(mitk::DataStorage::Pointer ds); protected: - /** \brief Vector with all added components */ - //std::vector> m_WidgetStackAddedChildList; - /** \brief Method to update the content of all DataTreeComboBoxes. */ virtual void UpdateDataTreeComboBoxes(); - /*************** ATTRIBUTES ***************/ - /** \brief ObserverTag */ unsigned long m_ObserverTag; - - /** \brief Graphical User Interface for the component in general QWidget-Type */ QWidget* m_GUI; - - // /*! - //* image selected in MainSelector - //*/ - //mitk::Image* m_ParentMitkImage; - - - ///*! - //* iterator on current image - //*/ - //mitk::DataTreeIteratorClone m_ParentMitkImageIterator; - - /** \brief Attribute whether the component is active or not */ bool m_Active; - - /** \brief Item on the actual selected Image in the TreeNodeSelector */ QmitkDataStorageComboBox * m_SelectedItem; - - /** \brief Item on the actual selected Image in the TreeNodeSelector */ mitk::DataStorage::Pointer m_DataStorage; - private: - /*************** ATTRIBUTES ***************/ /** \brief also the Graphical User Interface for the component, like m_GUI, but with its specific type */ Ui::QmitkFunctionalityComponentContainerGUI * m_FunctionalityComponentContainerGUI; - - /** \brief parent of the component */ QObject *m_Parent; - - /** \brief name of this the component */ QString m_ComponentName; - -// QmitkStdMultiWidget * m_MultiWidget; -// QmitkFunctionalityComponentContainerGUI * m_GUI; - - /** \brief Spacer added at the end of the component */ QSpacerItem* m_Spacer; - - QmitkStdMultiWidget *m_MulitWidget; - + QmitkStdMultiWidget* m_MulitWidget; QPushButton* m_BackButton; QPushButton* m_NextButton; int m_MaximumWidgedStackSize; }; #endif diff --git a/Modules/QtWidgetsExt/QmitkHistogram.cpp b/Modules/QtWidgetsExt/QmitkHistogram.cpp index b809dff858..1d478770ad 100644 --- a/Modules/QtWidgetsExt/QmitkHistogram.cpp +++ b/Modules/QtWidgetsExt/QmitkHistogram.cpp @@ -1,224 +1,197 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include "QmitkHistogram.h" class QmitkHistogram::HistogramData { public: QwtIntervalSeriesData data; QColor color; double reference; }; QmitkHistogram::QmitkHistogram(const QwtText &title): QwtPlotItem(title) { init(); } QmitkHistogram::QmitkHistogram(const QString &title): QwtPlotItem(QwtText(title)) { init(); } QmitkHistogram::~QmitkHistogram() { delete m_Data; } void QmitkHistogram::init() { m_Data = new HistogramData(); m_Data->reference = 0.0; setItemAttribute(QwtPlotItem::AutoScale, true); setItemAttribute(QwtPlotItem::Legend, true); setZ(20.0); } void QmitkHistogram::setBaseline(double reference) { if ( m_Data->reference != reference ) { m_Data->reference = reference; itemChanged(); } } double QmitkHistogram::baseline() const { return m_Data->reference; } void QmitkHistogram::setData(const QwtIntervalSeriesData &data) { m_Data->data.setSamples(data.samples()); itemChanged(); } const QwtIntervalSeriesData &QmitkHistogram::data() const { return m_Data->data; } void QmitkHistogram::setColor(const QColor &color) { if ( m_Data->color != color ) { m_Data->color = color; itemChanged(); } } QColor QmitkHistogram::color() const { return m_Data->color; } QRectF QmitkHistogram::boundingRect() const { QRectF rect = m_Data->data.boundingRect(); if ( !rect.isValid() ) return rect; if ( rect.bottom() < m_Data->reference ) rect.setBottom( m_Data->reference ); else if ( rect.top() > m_Data->reference ) rect.setTop( m_Data->reference ); return rect; } void QmitkHistogram::draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &) const { const QwtIntervalSeriesData &iData = m_Data->data; painter->setPen(QPen(m_Data->color)); - //const int x0 = xMap.transform(baseline()); const int y0 = yMap.transform(baseline()); for ( int i = 0; i < (int)iData.size(); i++ ) { const int y2 = yMap.transform(iData.sample(i).value); if ( y2 == y0 ) continue; int x1 = xMap.transform(iData.sample(i).interval.minValue()); int x2 = xMap.transform(iData.sample(i).interval.maxValue()); if ( x1 > x2 ) qSwap(x1, x2); if ( i < (int)iData.size() - 2 ) { const int xx1 = xMap.transform(iData.sample(i+1).interval.minValue()); const int xx2 = xMap.transform(iData.sample(i+1).interval.maxValue()); if ( x2 == qMin(xx1, xx2) ) { const int yy2 = yMap.transform(iData.sample(i+1).value); if ( yy2 != y0 && ( (yy2 < y0 && y2 < y0) || (yy2 > y0 && y2 > y0) ) ) { // One pixel distance between neighbored bars x2--; } } } drawBar(painter, Qt::Vertical, QRect(x1, y0, x2 - x1, y2 - y0) ); } } void QmitkHistogram::drawBar(QPainter *painter, Qt::Orientation, const QRect& rect) const { painter->save(); const QColor color(painter->pen().color()); -#if QT_VERSION >= 0x040000 const QRect r = rect.normalized(); -#else - const QRect r = rect.normalize(); -#endif - const int factor = 125; const QColor light(color.light(factor)); const QColor dark(color.dark(factor)); painter->setBrush(color); painter->setPen(Qt::NoPen); QwtPainter::drawRect(painter, r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2); painter->setBrush(Qt::NoBrush); painter->setPen(QPen(light, 2)); -#if QT_VERSION >= 0x040000 + QwtPainter::drawLine(painter, r.left() + 1, r.top() + 2, r.right() + 1, r.top() + 2); -#else - QwtPainter::drawLine(painter, - r.left(), r.top() + 2, r.right() + 1, r.top() + 2); -#endif painter->setPen(QPen(dark, 2)); -#if QT_VERSION >= 0x040000 + QwtPainter::drawLine(painter, r.left() + 1, r.bottom(), r.right() + 1, r.bottom()); -#else - QwtPainter::drawLine(painter, - r.left(), r.bottom(), r.right() + 1, r.bottom()); -#endif painter->setPen(QPen(light, 1)); -#if QT_VERSION >= 0x040000 QwtPainter::drawLine(painter, r.left(), r.top() + 1, r.left(), r.bottom()); QwtPainter::drawLine(painter, r.left() + 1, r.top() + 2, r.left() + 1, r.bottom() - 1); -#else - QwtPainter::drawLine(painter, - r.left(), r.top() + 1, r.left(), r.bottom() + 1); - QwtPainter::drawLine(painter, - r.left() + 1, r.top() + 2, r.left() + 1, r.bottom()); -#endif painter->setPen(QPen(dark, 1)); -#if QT_VERSION >= 0x040000 QwtPainter::drawLine(painter, r.right() + 1, r.top() + 1, r.right() + 1, r.bottom()); QwtPainter::drawLine(painter, r.right(), r.top() + 2, r.right(), r.bottom() - 1); -#else - QwtPainter::drawLine(painter, - r.right() + 1, r.top() + 1, r.right() + 1, r.bottom() + 1); - QwtPainter::drawLine(painter, - r.right(), r.top() + 2, r.right(), r.bottom()); -#endif painter->restore(); } + diff --git a/Modules/QtWidgetsExt/QmitkHistogram.h b/Modules/QtWidgetsExt/QmitkHistogram.h index a8d7b3e66f..b44953d351 100644 --- a/Modules/QtWidgetsExt/QmitkHistogram.h +++ b/Modules/QtWidgetsExt/QmitkHistogram.h @@ -1,66 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKHISTOGRAM_H #define QMITKHISTOGRAM_H #include #include #include #include /** \brief Used to create a histogram that can be shown in a Qwt Plot. See QmitkHistogramWidget for an example of its usage. */ class QmitkHistogram: public QwtPlotItem { - -// Q_OBJECT - public: explicit QmitkHistogram(const QString &title = QString::null); explicit QmitkHistogram(const QwtText &title); virtual ~QmitkHistogram(); void setData(const QwtIntervalSeriesData &data); const QwtIntervalSeriesData &data() const; void setColor(const QColor &); QColor color() const; virtual QRectF boundingRect() const; virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &) const; void setBaseline(double reference); double baseline() const; protected: virtual void drawBar(QPainter *, Qt::Orientation o, const QRect &) const; private: void init(); class HistogramData; HistogramData *m_Data; }; #endif + diff --git a/Modules/QtWidgetsExt/QmitkHistogramJSWidget.cpp b/Modules/QtWidgetsExt/QmitkHistogramJSWidget.cpp index cf26a1d79b..7d95f44d54 100644 --- a/Modules/QtWidgetsExt/QmitkHistogramJSWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkHistogramJSWidget.cpp @@ -1,238 +1,239 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkHistogramJSWidget.h" #include "mitkPixelTypeMultiplex.h" #include #include #include "mitkRenderingManager.h" #include "mitkBaseRenderer.h" #include "mitkImageTimeSelector.h" #include "mitkExtractSliceFilter.h" QmitkHistogramJSWidget::QmitkHistogramJSWidget(QWidget *parent) : QWebView(parent) { // set histogram type to barchart in first instance m_UseLineGraph = false; m_Page = new QmitkJSWebPage(this); setPage(m_Page); // set html from source connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(AddJSObject())); - QUrl myUrl = QUrl("qrc:/qmitk/Histogram.html"); + QUrl myUrl = QUrl("qrc:///QtWidgetsExt/Histogram.html"); setUrl(myUrl); // set Scrollbars to be always disabled page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); m_ParametricPath = ParametricPathType::New(); } QmitkHistogramJSWidget::~QmitkHistogramJSWidget() { } // adds an Object of Type QmitkHistogramJSWidget to the JavaScript, using QtWebkitBridge void QmitkHistogramJSWidget::AddJSObject() { page()->mainFrame()->addToJavaScriptWindowObject(QString("histogramData"), this); } // reloads WebView, everytime its size has been changed, so the size of the Histogram fits to the size of the widget void QmitkHistogramJSWidget::resizeEvent(QResizeEvent* resizeEvent) { QWebView::resizeEvent(resizeEvent); // workaround for Qt Bug: https://bugs.webkit.org/show_bug.cgi?id=75984 page()->mainFrame()->evaluateJavaScript("disconnectSignals()"); this->reload(); } // method to expose data to JavaScript by using properties void QmitkHistogramJSWidget::ComputeHistogram(HistogramType* histogram) { m_Histogram = histogram; HistogramConstIteratorType startIt = m_Histogram->End(); HistogramConstIteratorType endIt = m_Histogram->End(); HistogramConstIteratorType it = m_Histogram->Begin(); ClearData(); unsigned int i = 0; bool firstValue = false; // removes frequencies of 0, which are outside the first and last bin for (; it != m_Histogram->End(); ++it) { if (it.GetFrequency() > 0.0) { endIt = it; if (!firstValue) { firstValue = true; startIt = it; } } } ++endIt; // generating Lists of measurement and frequencies for (it = startIt ; it != endIt; ++it, ++i) { QVariant frequency = QVariant::fromValue(it.GetFrequency()); QVariant measurement = it.GetMeasurementVector()[0]; m_Frequency.insert(i, frequency); m_Measurement.insert(i, measurement); } m_IntensityProfile = false; this->SignalDataChanged(); } void QmitkHistogramJSWidget::ClearData() { m_Frequency.clear(); m_Measurement.clear(); } void QmitkHistogramJSWidget::ClearHistogram() { this->ClearData(); this->SignalDataChanged(); } QList QmitkHistogramJSWidget::GetFrequency() { return m_Frequency; } QList QmitkHistogramJSWidget::GetMeasurement() { return m_Measurement; } bool QmitkHistogramJSWidget::GetUseLineGraph() { return m_UseLineGraph; } void QmitkHistogramJSWidget::OnBarRadioButtonSelected() { if (m_UseLineGraph) { m_UseLineGraph = false; this->SignalGraphChanged(); } } void QmitkHistogramJSWidget::OnLineRadioButtonSelected() { if (!m_UseLineGraph) { m_UseLineGraph = true; this->SignalGraphChanged(); } } void QmitkHistogramJSWidget::SetImage(mitk::Image* image) { m_Image = image; } void QmitkHistogramJSWidget::SetPlanarFigure(const mitk::PlanarFigure* planarFigure) { m_PlanarFigure = planarFigure; } template void ReadPixel(mitk::PixelType ptype, mitk::Image::Pointer image, mitk::Index3D indexPoint, double& value) { if (image->GetDimension() == 2) { mitk::ImagePixelReadAccessor readAccess(image, image->GetSliceData(0)); itk::Index<2> idx; idx[0] = indexPoint[0]; idx[1] = indexPoint[1]; value = readAccess.GetPixelByIndex(idx); } else if (image->GetDimension() == 3) { mitk::ImagePixelReadAccessor readAccess(image, image->GetVolumeData(0)); itk::Index<3> idx; idx[0] = indexPoint[0]; idx[1] = indexPoint[1]; idx[2] = indexPoint[2]; value = readAccess.GetPixelByIndex(idx); } else { //unhandled } } void QmitkHistogramJSWidget::ComputeIntensityProfile(unsigned int timeStep) { this->ClearData(); m_ParametricPath->Initialize(); if (m_PlanarFigure.IsNull()) { mitkThrow() << "PlanarFigure not set!"; } if (m_Image.IsNull()) { mitkThrow() << "Image not set!"; } mitk::Image::Pointer image; if (m_Image->GetDimension() == 4) { mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New(); timeSelector->SetInput(m_Image); timeSelector->SetTimeNr(timeStep); timeSelector->Update(); image = timeSelector->GetOutput(); } else { image = m_Image; } mitk::IntensityProfile::Pointer intensityProfile = mitk::ComputeIntensityProfile(image, const_cast(m_PlanarFigure.GetPointer())); m_Frequency.clear(); m_Measurement.clear(); int i = -1; mitk::IntensityProfile::ConstIterator end = intensityProfile->End(); for (mitk::IntensityProfile::ConstIterator it = intensityProfile->Begin(); it != end; ++it) { m_Frequency.push_back(it.GetMeasurementVector()[0]); m_Measurement.push_back(++i); } m_IntensityProfile = true; m_UseLineGraph = true; this->SignalDataChanged(); } bool QmitkHistogramJSWidget::GetIntensityProfile() { return m_IntensityProfile; } + diff --git a/Modules/QtWidgetsExt/QmitkHistogramJSWidget.h b/Modules/QtWidgetsExt/QmitkHistogramJSWidget.h index de832ebfb3..b0de9b52f5 100644 --- a/Modules/QtWidgetsExt/QmitkHistogramJSWidget.h +++ b/Modules/QtWidgetsExt/QmitkHistogramJSWidget.h @@ -1,277 +1,278 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKHISTOGRAMJSWIDGET_H #define QMITKHISTOGRAMJSWIDGET_H #include #include #include #include "MitkQtWidgetsExtExports.h" #include #include "mitkImage.h" #include "mitkPlanarFigure.h" #include #include /** * \brief Widget which shows a histogram using JavaScript. * * This class is a QWebView. It shows the histogram for a selected image * or segmentation. It also can display an intesity profile for * path elements, which lais over an image. */ class MitkQtWidgetsExt_EXPORT QmitkHistogramJSWidget : public QWebView { Q_OBJECT /** * \brief Measurement property. * * This property is used in JavaScript as member of the current object. * It holds a QList, containing the measurements of the current histogram. * @see GetMeasurement() */ Q_PROPERTY(QList measurement READ GetMeasurement) /** * \brief Frequency property. * * This property is used in JavaScript as member of the current object. * It holds a QList, containing the frequencies of the current histogram. * @see GetFrequency() */ Q_PROPERTY(QList frequency READ GetFrequency) /** * \brief Line graph property. * * This property is used in JavaScript as member of the current object. * It holds a boolean, which sais wether to use a line or not. * @see GetUseLineGraph() */ Q_PROPERTY(bool useLineGraph READ GetUseLineGraph) /** * @brief Intesity profile property. * * This property is used in JavaScript as member of the current object. * It holds a boolean, which sais wether to use an intesity profile or not. * @see GetIntensityProfile() */ Q_PROPERTY(bool intensityProfile READ GetIntensityProfile) public: typedef mitk::Image::HistogramType HistogramType; typedef mitk::Image::HistogramType::ConstIterator HistogramConstIteratorType; typedef itk::PolyLineParametricPath< 3 > ParametricPathType; typedef itk::ParametricPath< 3 >::Superclass PathType; typedef mitk::PlanarFigure::PolyLineType VertexContainerType; explicit QmitkHistogramJSWidget(QWidget *parent = 0); ~QmitkHistogramJSWidget(); /** * \brief Event which notifies a change of the widget size. * * Reimplemented from QWebView::resizeEvent(), * reloads the webframe */ void resizeEvent(QResizeEvent* resizeEvent); /** * \brief Calculates the histogram. * * This function removes all frequencies of 0 until the first bin and behind the last bin. * It writes the measurement and frequency, which are given from the HistogramType, into * m_Measurement and m_Frequency. * The SignalDataChanged is called, to update the information, which is displayed in the webframe. */ void ComputeHistogram(HistogramType* histogram); /** * \brief Calculates the intesityprofile. * * If an image and a pathelement are set, this function * calculates an intensity profile for a pathelement which lies over an image. * Sets m_IntensityProfile and m_UseLineGraph to true. * The SignalDataChanged is called, to update the information, which is displayed in the webframe. */ void ComputeIntensityProfile(unsigned int timeStep = 0); /** * \brief Clears the Histogram. * * This function clears the data and calls SignalDataChanged to update * the displayed information in the webframe. */ void ClearHistogram(); /** * \brief Getter for measurement. * * @return List of measurements. */ QList GetMeasurement(); /** * \brief Getter for frequency. * * @return List of frequencies. */ QList GetFrequency(); /** * \brief Getter for uselineGraph. * * @return True if a linegraph should be used. */ bool GetUseLineGraph(); /** * \brief Getter for intensity profile. * * @return True if current histogram is an intesityprofile */ bool GetIntensityProfile(); /** * \brief Setter for reference image. * * @param image The corresponding image for an intensity profile. */ void SetImage(mitk::Image* image); /** * \brief Setter for planarFigure. * * @param planarFigure The pathelement for an intensity profile. */ void SetPlanarFigure(const mitk::PlanarFigure* planarFigure); private: /** * \brief List of frequencies. * * A QList which holds the frequencies of the current histogram * or holds the intesities of current intensity profile. */ QList m_Frequency; /** * \brief List of measurements. * * A QList which holds the measurements of the current histogram * or holds the distances of current intensity profile. */ QList m_Measurement; /** * \brief Reference image. * * Holds the image to calculate an intesity profile. */ mitk::Image::Pointer m_Image; /** * \brief Pathelement. * * Holds a not closed planar figure to calculate an intesity profile. */ mitk::PlanarFigure::ConstPointer m_PlanarFigure; bool m_UseLineGraph; bool m_IntensityProfile; /** * Holds the current histogram */ HistogramType::ConstPointer m_Histogram; /** * Path derived either form user-specified path or from PlanarFigure-generated * path */ PathType::ConstPointer m_DerivedPath; /** * Parametric path as generated from PlanarFigure */ ParametricPathType::Pointer m_ParametricPath; /** * \brief Clears data. * * Clears the QLists m_Measurement and m_Frequency */ void ClearData(); QmitkJSWebPage* m_Page; private slots: /** * \brief Adds an object to JavaScript. * * Adds an object of the widget to JavaScript. * By using this object JavaScript can react to the signals of the widget * and can access the QProperties as members of the object. */ void AddJSObject(); public slots: /** * \brief Slot for radiobutton m_barRadioButton. * * Sets m_UseLineGraph to false. * Calls signal GraphChanged to update the graph in the webframe. */ void OnBarRadioButtonSelected(); /** * \brief Slot for radiobutton m_lineRadioButton. * * Sets m_UseLineGraph to true. * Calls signal GraphChanged to update the graph in the webframe. */ void OnLineRadioButtonSelected(); signals: /** * \brief Signal data has changed. * * It has to be called when the data of the histogram or intesity profile has changed. */ void SignalDataChanged(); /** * \brief Signal graph has changed. * * It has to be called when the graph changed from barchart to linegraph. Vice versa. */ void SignalGraphChanged(); }; -#endif // QMITKHISTOGRAMJSWIDGET_H +#endif + diff --git a/Modules/QtWidgetsExt/QmitkHistogramWidget.cpp b/Modules/QtWidgetsExt/QmitkHistogramWidget.cpp index b395bc525d..407598537c 100644 --- a/Modules/QtWidgetsExt/QmitkHistogramWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkHistogramWidget.cpp @@ -1,194 +1,193 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkHistogramWidget.h" #include #include "mitkImageStatisticsHolder.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include QmitkHistogramWidget::QmitkHistogramWidget(QWidget * parent, bool showreport) : QDialog(parent) , m_Plot(NULL) , m_Textedit(NULL) , m_Marker(NULL) , m_Picker(NULL) , m_Zoomer(NULL) , m_Histogram(NULL) { QBoxLayout *layout = new QVBoxLayout(this); //***histogram*** QGroupBox *hgroupbox = new QGroupBox("", this); hgroupbox->setMinimumSize(900, 400); m_Plot = new QwtPlot(hgroupbox); m_Plot->setCanvasBackground(QColor(Qt::white)); m_Plot->setTitle("Histogram"); QwtText text = m_Plot->titleLabel()->text(); text.setFont(QFont("Helvetica", 12, QFont::Normal)); QwtPlotGrid *grid = new QwtPlotGrid; grid->enableXMin(true); grid->enableYMin(true); grid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine)); grid->setMinorPen(QPen(Qt::gray, 0 , Qt::DotLine)); grid->attach(m_Plot); layout->addWidget(hgroupbox); layout->setSpacing(20); if (showreport == true) { //***report*** QGroupBox *rgroupbox = new QGroupBox("", this); rgroupbox->setMinimumSize(900, 400); QLabel *label = new QLabel("Gray Value Analysis", rgroupbox); label->setAlignment(Qt::AlignHCenter); label->setFont(QFont("Helvetica", 14, QFont::Bold)); m_Textedit = new QTextEdit(rgroupbox); m_Textedit->setFont(QFont("Helvetica", 12, QFont::Normal)); m_Textedit->setReadOnly(true); layout->addWidget(rgroupbox); } m_Picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::NoRubberBand, QwtPicker::AlwaysOn, m_Plot->canvas()); // the m_PickerMachine pointer is managed by the m_Picker instance m_Picker->setStateMachine(new QwtPickerClickPointMachine()); connect(m_Picker, SIGNAL(selected(const QwtDoublePoint &)), SLOT(OnSelect(const QwtDoublePoint &))); } QmitkHistogramWidget::~QmitkHistogramWidget() { } void QmitkHistogramWidget::SetHistogram(HistogramType::ConstPointer itkHistogram) { HistogramType::SizeType size = itkHistogram->GetSize(); HistogramType::IndexType index; HistogramType::MeasurementVectorType currentMeasurementVector; QVector intervalSeries(size[0]); for (unsigned int i = 0; i < size[0]; ++i) { index[0] = static_cast (i); currentMeasurementVector = itkHistogram->GetMeasurementVector(index); if (currentMeasurementVector[0] != 0.0) { intervalSeries[i] = QwtIntervalSample(static_cast (itkHistogram->GetFrequency(index)), Round(currentMeasurementVector[0]-1), Round(currentMeasurementVector[0])); } } // rebuild the plot m_Plot->detachItems(); m_Histogram = new QmitkHistogram(); m_Histogram->setColor(Qt::darkCyan); m_Histogram->setData(QwtIntervalSeriesData(intervalSeries)); m_Histogram->attach(m_Plot); this->InitializeMarker(); this->InitializeZoomer(); m_Plot->replot(); } void QmitkHistogramWidget::SetHistogram( mitk::Image* mitkImage ) { this->SetHistogram(mitkImage->GetStatistics()->GetScalarHistogram()); } void QmitkHistogramWidget::SetReport(std::string report) { m_Textedit->setText(report.c_str()); } void QmitkHistogramWidget::InitializeMarker() { m_Marker = new QwtPlotMarker(); m_Marker->setXValue(0.); m_Marker->setLineStyle(QwtPlotMarker::VLine); m_Marker->setLabelAlignment(Qt::AlignHCenter | Qt::AlignRight); m_Marker->setLinePen(QPen(QColor(200,150,0), 3, Qt::SolidLine)); m_Marker->setSymbol(new QwtSymbol(QwtSymbol::Diamond, QColor(Qt::red), QColor(Qt::red), QSize(10,10))); m_Marker->attach(m_Plot); } void QmitkHistogramWidget::InitializeZoomer() { m_Zoomer = new QwtPlotZoomer(m_Plot->xBottom, m_Plot->yLeft, m_Plot->canvas()); m_Zoomer->setRubberBandPen(QPen(Qt::red, 2, Qt::DotLine)); m_Zoomer->setTrackerPen(QPen(Qt::red)); - //m_Zoomer->setSelectionFlags(QwtPlotZoomer::RectSelection); } void QmitkHistogramWidget::OnSelect( const QPointF& pos ) { m_Marker->setXValue( this->Round(pos.x()) ); - //unsigned int count = (unsigned int)(m_Histogram->data().value(pos.x())); QString str = QString( "%1" ) .arg( (int)(this->Round(pos.x())), 0, 10 ); QwtText text(str); text.setBackgroundBrush(QColor(200,150,0)); text.setFont(QFont("Helvetica", 14, QFont::Bold)); m_Marker->setLabel(text); m_Plot->replot(); } double QmitkHistogramWidget::GetMarkerPosition() { return m_Marker->xValue(); } double QmitkHistogramWidget::Round(double val) { double ival = (double)(int)val; if( (val - ival) > 0.5) return ival+1; else return ival; } + diff --git a/Modules/QtWidgetsExt/QmitkHistogramWidget.h b/Modules/QtWidgetsExt/QmitkHistogramWidget.h index daa39e62fe..4830a42d64 100644 --- a/Modules/QtWidgetsExt/QmitkHistogramWidget.h +++ b/Modules/QtWidgetsExt/QmitkHistogramWidget.h @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKHistogramWidget_H_ #define QMITKHistogramWidget_H_ #include "MitkQtWidgetsExtExports.h" #include #include "mitkImage.h" class QTextEdit; class QwtPlot; class QwtPlotMarker; class QwtPlotPicker; class QwtPlotZoomer; class QmitkHistogram; /** \brief Shows a histogram in a Qwt_Plot and a report (selectable) in a QTextEdit Makes the data Values from a itk::histogram suitable for a Qwt_Plot. Offers zoom possibility. A marker can be set and shows the frequency at his position. */ class MitkQtWidgetsExt_EXPORT QmitkHistogramWidget: public QDialog { Q_OBJECT public: //overloaded constructor to choose between showing only the histogram or the histogram and the report QmitkHistogramWidget(QWidget *parent = 0, bool showreport = false); virtual ~QmitkHistogramWidget(); typedef mitk::Image::HistogramType HistogramType; /** - gets the data values from either a itk histogram or a mitk image - copies them into data arrays suitable for qwt - creates a plot dialog, fill it with the data and shows it */ void SetHistogram(HistogramType::ConstPointer histogram); void SetHistogram(mitk::Image* mitkImage); void SetReport(std::string report); double GetMarkerPosition(); protected slots: void OnSelect( const QPointF &pos ); protected: // convenience fct. for rounding doubles to integral numbers double Round(double val); void InitializeMarker(); void InitializeZoomer(); QwtPlot* m_Plot; QTextEdit* m_Textedit; QwtPlotMarker* m_Marker; QwtPlotPicker* m_Picker; QwtPlotZoomer* m_Zoomer; QmitkHistogram* m_Histogram; }; -#endif /* QMITKHistogramWidget_H_ */ +#endif diff --git a/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.cpp b/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.cpp index c2c9c937e4..ad9aa9d8c6 100644 --- a/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.cpp +++ b/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.cpp @@ -1,108 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkHotkeyLineEdit.h" #include #include #include #include const std::string QmitkHotkeyLineEdit::TOOLTIP = "Press any key (combination)"; QmitkHotkeyLineEdit::QmitkHotkeyLineEdit( QWidget* parent ) : QLineEdit(parent) { this->Init(); - //this->setReadOnly(true); } QmitkHotkeyLineEdit::QmitkHotkeyLineEdit( const QKeySequence& _QKeySequence, QWidget* parent) : QLineEdit(parent) { this->Init(); - //this->setReadOnly(true); this->SetKeySequence(_QKeySequence); } QmitkHotkeyLineEdit::QmitkHotkeyLineEdit( const QString& _QKeySequenceAsString, QWidget* parent) : QLineEdit(parent) { this->Init(); - //this->setReadOnly(true); this->SetKeySequence(_QKeySequenceAsString); } void QmitkHotkeyLineEdit::Init() { this->setToolTip(QString::fromStdString(QmitkHotkeyLineEdit::TOOLTIP)); this->setReadOnly(true); connect( this, SIGNAL( textChanged(const QString &) ), this, SLOT( LineEditTextChanged(const QString &) ) ); } void QmitkHotkeyLineEdit::keyPressEvent( QKeyEvent * event ) { if(event->key() == Qt::Key_unknown) return; else if(event->key() == Qt::Key_Escape) m_KeySequence = QKeySequence(); else { m_KeySequence = QKeySequence(event->modifiers(), event->key()); // if no modifier was pressed the sequence is now empty if(event->modifiers() == Qt::NoModifier) m_KeySequence = QKeySequence(event->key()); } this->SetKeySequence(m_KeySequence); } void QmitkHotkeyLineEdit::SetKeySequence( const QKeySequence& _QKeySequence) { this->setText(_QKeySequence.toString()); } void QmitkHotkeyLineEdit::SetKeySequence( const QString& _QKeySequenceAsString ) { this->SetKeySequence(QKeySequence(_QKeySequenceAsString)); } QKeySequence QmitkHotkeyLineEdit::GetKeySequence() { return m_KeySequence; } QString QmitkHotkeyLineEdit::GetKeySequenceAsString() { return m_KeySequence.toString(); } bool QmitkHotkeyLineEdit::Matches( QKeyEvent * event ) { QKeySequence _KeySequence = QKeySequence(event->modifiers(), event->key()); // if no modifier was pressed the sequence is now empty if(event->modifiers() == Qt::NoModifier) _KeySequence = QKeySequence(event->key()); return _KeySequence == m_KeySequence; } void QmitkHotkeyLineEdit::LineEditTextChanged(const QString & text) { m_KeySequence = QKeySequence(text.toUpper()); } + diff --git a/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.h b/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.h index 211e5b0a57..16f96e5fd1 100644 --- a/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.h +++ b/Modules/QtWidgetsExt/QmitkHotkeyLineEdit.h @@ -1,52 +1,53 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKHOTKEYLINEEDIT_H_ #define QMITKHOTKEYLINEEDIT_H_ #include #include #include "MitkQtWidgetsExtExports.h" class MitkQtWidgetsExt_EXPORT QmitkHotkeyLineEdit : public QLineEdit { Q_OBJECT public: static const std::string TOOLTIP; QmitkHotkeyLineEdit(QWidget* parent = 0); QmitkHotkeyLineEdit(const QKeySequence& _QKeySequence, QWidget* parent = 0); QmitkHotkeyLineEdit(const QString& _QString, QWidget* parent = 0); virtual void SetKeySequence(const QKeySequence& _QKeySequence); virtual void SetKeySequence(const QString& _QKeySequenceAsString); virtual QKeySequence GetKeySequence(); virtual QString GetKeySequenceAsString(); bool Matches( QKeyEvent * event ); protected slots: void LineEditTextChanged(const QString &); protected: virtual void keyPressEvent ( QKeyEvent * event ); void Init(); protected: QKeySequence m_KeySequence; }; -#endif /* QMITKHOTKEYLINEEDIT_H_ */ +#endif + diff --git a/Modules/QtWidgetsExt/QmitkLineEdit.cpp b/Modules/QtWidgetsExt/QmitkLineEdit.cpp index c3a667d038..e9e3618908 100644 --- a/Modules/QtWidgetsExt/QmitkLineEdit.cpp +++ b/Modules/QtWidgetsExt/QmitkLineEdit.cpp @@ -1,105 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkLineEdit.h" #include QmitkLineEdit::QmitkLineEdit(QWidget* parent) : QLineEdit(parent) { this->Initialize(); } QmitkLineEdit::QmitkLineEdit(const QString& defaultText, QWidget* parent) : QLineEdit(parent), m_DefaultText(defaultText) { this->Initialize(); } QmitkLineEdit::~QmitkLineEdit() { } void QmitkLineEdit::focusInEvent(QFocusEvent* event) { QLineEdit::focusInEvent(event); emit this->FocusChanged(true); } void QmitkLineEdit::focusOutEvent(QFocusEvent* event) { QLineEdit::focusOutEvent(event); emit this->FocusChanged(false); } QString QmitkLineEdit::GetDefaultText() const { return m_DefaultText; } void QmitkLineEdit::Initialize() { m_DefaultPalette.setColor(QPalette::Text, QApplication::palette().color(QPalette::Disabled, QPalette::Text)); this->ShowDefaultText(true); connect(this, SIGNAL(FocusChanged(bool)), this, SLOT(OnFocusChanged(bool))); connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(OnTextChanged(const QString&))); } void QmitkLineEdit::OnFocusChanged(bool hasFocus) { if (hasFocus) { if (this->text() == m_DefaultText && this->palette() == m_DefaultPalette) this->ShowDefaultText(false); } else { if (this->text().isEmpty()) this->ShowDefaultText(true); } } void QmitkLineEdit::OnTextChanged(const QString& text) { if (this->palette() == m_DefaultPalette) this->setPalette(QPalette()); } void QmitkLineEdit::SetDefaultText(const QString& defaultText) { m_DefaultText = defaultText; } void QmitkLineEdit::ShowDefaultText(bool show) { this->blockSignals(true); if (show) { this->setPalette(m_DefaultPalette); this->setText(m_DefaultText); } else { this->setPalette(QPalette()); this->clear(); } this->blockSignals(false); } + diff --git a/Modules/QtWidgetsExt/QmitkLineEdit.h b/Modules/QtWidgetsExt/QmitkLineEdit.h index 053ce4d1dd..286ccacd35 100644 --- a/Modules/QtWidgetsExt/QmitkLineEdit.h +++ b/Modules/QtWidgetsExt/QmitkLineEdit.h @@ -1,67 +1,68 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkLineEdit_h #define QmitkLineEdit_h #include #include #include /** * \deprecatedSince{2014_03} Use QLineEdit instead */ class MitkQtWidgetsExt_EXPORT QmitkLineEdit : public QLineEdit { Q_OBJECT Q_PROPERTY(QString DefaultText READ GetDefaultText WRITE SetDefaultText FINAL) public: /** * \deprecatedSince{2014_03} Use QLineEdit instead */ DEPRECATED(explicit QmitkLineEdit(QWidget* parent = NULL)); /** * \deprecatedSince{2014_03} Use QLineEdit instead */ DEPRECATED(explicit QmitkLineEdit(const QString& defaultText, QWidget* parent = NULL)); ~QmitkLineEdit(); QString GetDefaultText() const; void SetDefaultText(const QString& defaultText); protected: void focusInEvent(QFocusEvent* event); void focusOutEvent(QFocusEvent* event); private: void Initialize(); void ShowDefaultText(bool show); signals: void FocusChanged(bool hasFocus); private slots: void OnFocusChanged(bool hasFocus); void OnTextChanged(const QString& text); private: QString m_DefaultText; QPalette m_DefaultPalette; }; #endif + diff --git a/Modules/QtWidgetsExt/QmitkModuleTableModel.h b/Modules/QtWidgetsExt/QmitkModuleTableModel.h index 722f71962c..3dbf8ccadd 100644 --- a/Modules/QtWidgetsExt/QmitkModuleTableModel.h +++ b/Modules/QtWidgetsExt/QmitkModuleTableModel.h @@ -1,59 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKMODULETABLEMODEL_H #define QMITKMODULETABLEMODEL_H #include #include #include namespace us { class ModuleContext; class Module; } class QmitkModuleTableModelPrivate; class MitkQtWidgetsExt_EXPORT QmitkModuleTableModel : public QAbstractTableModel { public: QmitkModuleTableModel(QObject* parent = 0, us::ModuleContext* mc = 0); ~QmitkModuleTableModel(); protected: int rowCount(const QModelIndex& parent = QModelIndex()) const; int columnCount(const QModelIndex& parent = QModelIndex()) const; QVariant data(const QModelIndex& index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; private: friend class QmitkModuleTableModelPrivate; void insertModule(us::Module* module); QmitkModuleTableModelPrivate* const d; }; -#endif // QMITKMODULETABLEMODEL_H +#endif + diff --git a/Modules/QtWidgetsExt/QmitkModulesDialog.cpp b/Modules/QtWidgetsExt/QmitkModulesDialog.cpp index 0f17313628..3c3f339a3a 100644 --- a/Modules/QtWidgetsExt/QmitkModulesDialog.cpp +++ b/Modules/QtWidgetsExt/QmitkModulesDialog.cpp @@ -1,65 +1,66 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkModulesDialog.h" #include #include #include #include #include #include "QmitkModuleTableModel.h" QmitkModulesDialog::QmitkModulesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { this->setWindowTitle("MITK Modules"); QVBoxLayout* layout = new QVBoxLayout(); this->setLayout(layout); QTableView* tableView = new QTableView(this); QmitkModuleTableModel* tableModel = new QmitkModuleTableModel(tableView); QSortFilterProxyModel* sortProxyModel = new QSortFilterProxyModel(tableView); sortProxyModel->setSourceModel(tableModel); sortProxyModel->setDynamicSortFilter(true); tableView->setModel(sortProxyModel); tableView->verticalHeader()->hide(); tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::ExtendedSelection); tableView->setTextElideMode(Qt::ElideMiddle); tableView->setSortingEnabled(true); tableView->sortByColumn(0, Qt::AscendingOrder); tableView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setStretchLastSection(true); tableView->horizontalHeader()->setCascadingSectionResizes(true); layout->addWidget(tableView); QDialogButtonBox* btnBox = new QDialogButtonBox(QDialogButtonBox::Close); layout->addWidget(btnBox); this->resize(800, 600); connect(btnBox, SIGNAL(rejected()), this, SLOT(reject())); } + diff --git a/Modules/QtWidgetsExt/QmitkModulesDialog.h b/Modules/QtWidgetsExt/QmitkModulesDialog.h index 7cd5c8e94e..fd649dd88d 100644 --- a/Modules/QtWidgetsExt/QmitkModulesDialog.h +++ b/Modules/QtWidgetsExt/QmitkModulesDialog.h @@ -1,34 +1,35 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKMODULESDIALOG_H #define QMITKMODULESDIALOG_H #include #include class MitkQtWidgetsExt_EXPORT QmitkModulesDialog : public QDialog { public: explicit QmitkModulesDialog(QWidget *parent = 0, Qt::WindowFlags f = Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); }; -#endif // QMITKMODULESDIALOG_H +#endif + diff --git a/Modules/QtWidgetsExt/QmitkPiecewiseFunctionCanvas.cpp b/Modules/QtWidgetsExt/QmitkPiecewiseFunctionCanvas.cpp index 38e053b221..e9d5615088 100755 --- a/Modules/QtWidgetsExt/QmitkPiecewiseFunctionCanvas.cpp +++ b/Modules/QtWidgetsExt/QmitkPiecewiseFunctionCanvas.cpp @@ -1,158 +1,158 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPiecewiseFunctionCanvas.h" #include #include QmitkPiecewiseFunctionCanvas::QmitkPiecewiseFunctionCanvas(QWidget * parent, Qt::WindowFlags f) : QmitkTransferFunctionCanvas(parent, f), m_PiecewiseFunction(0) { // used for drawing a border setContentsMargins(1,1,1,1); } void QmitkPiecewiseFunctionCanvas::SetTitle(const QString& title) { m_Title=title; } void QmitkPiecewiseFunctionCanvas::paintEvent(QPaintEvent*) { QPainter painter(this); PaintHistogram(painter); if (m_Title.size()>0) { painter.setPen(Qt::black); painter.drawText(QPoint(11,21),m_Title); painter.setPen(Qt::white); painter.drawText(QPoint(10,20),m_Title); } { QString qs_min = QString::number( m_Min ); QString qs_max = QString::number( m_Max ); QRect qr_min = painter.fontMetrics().boundingRect( qs_min ); QRect qr_max = painter.fontMetrics().boundingRect( qs_max ); int y,x; y=this->contentsRect().height()-qr_min.height()+5; x=10; // Fill the tf presets in the generator widget painter.setPen(Qt::black); painter.drawText(QPoint(x+1,y+1),qs_min); painter.setPen(Qt::white); painter.drawText(QPoint(x ,y ),qs_min); y=this->contentsRect().height()-qr_max.height()+5; x=this->contentsRect().width()-qr_max.width()-6; painter.setPen(Qt::black); painter.drawText(QPoint(x,y+1),qs_max); painter.setPen(Qt::white); painter.drawText(QPoint(x,y ),qs_max); } painter.setPen(Qt::gray); QRect contentsRect = this->contentsRect(); painter.drawRect(0, 0, contentsRect.width()+1, contentsRect.height()+1); if (m_PiecewiseFunction && this->isEnabled()) { double* dp = m_PiecewiseFunction->GetDataPointer(); // Render lines painter.setPen(Qt::black); for (int i = -1; i < m_PiecewiseFunction->GetSize(); i++) { std::pair left; std::pair right; if(i < 0) left = this->FunctionToCanvas(std::make_pair(-32768, dp[0 * 2 + 1])); else left = this->FunctionToCanvas(std::make_pair(dp[i * 2], dp[i * 2 + 1])); if(i+1 >= m_PiecewiseFunction->GetSize()) right = this->FunctionToCanvas(std::make_pair(32768, dp[(i ) * 2 + 1])); else right = this->FunctionToCanvas(std::make_pair(dp[(i+1) * 2], dp[(i+1) * 2 + 1])); painter.drawLine(left.first, left.second, right.first, right.second); } // Render Points for (int i = 0; i < m_PiecewiseFunction->GetSize(); i++) { std::pair point = this->FunctionToCanvas(std::make_pair( dp[i * 2], dp[i * 2 + 1])); if (i == m_GrabbedHandle) { painter.setBrush(QBrush(Qt::red)); if (m_LineEditAvailable) { m_XEdit->setText(QString::number(GetFunctionX(m_GrabbedHandle))); m_YEdit->setText(QString::number(GetFunctionY(m_GrabbedHandle))); } } else { painter.setBrush(QBrush(Qt::green)); } painter.drawEllipse(point.first - 4, point.second - 4, 8, 8); } painter.setBrush(Qt::NoBrush); } } int QmitkPiecewiseFunctionCanvas::GetNearHandle(int x, int y, unsigned int maxSquaredDistance) { double* dp = m_PiecewiseFunction->GetDataPointer(); for (int i = 0; i < m_PiecewiseFunction->GetSize(); i++) { std::pair point = this->FunctionToCanvas(std::make_pair(dp[i * 2], dp[i * 2 + 1])); if ((unsigned int) ((point.first - x) * (point.first - x) + (point.second - y) * (point.second - y)) <= maxSquaredDistance) { return i; } } return -1; } void QmitkPiecewiseFunctionCanvas::MoveFunctionPoint(int index, std::pair pos) { RemoveFunctionPoint(GetFunctionX(index)); AddFunctionPoint(pos.first, pos.second); - //std::cout<<" AddFunctionPoint x: "< class MitkQtWidgetsExt_EXPORT QmitkPiecewiseFunctionCanvas: public QmitkTransferFunctionCanvas { Q_OBJECT public: QmitkPiecewiseFunctionCanvas( QWidget * parent=0, Qt::WindowFlags f = 0 ); virtual void paintEvent( QPaintEvent* e ); void SetTitle(const QString& title); int GetNearHandle(int x,int y,unsigned int maxSquaredDistance = 32); void SetPiecewiseFunction(vtkPiecewiseFunction* piecewiseFunction) { this->m_PiecewiseFunction = piecewiseFunction; this->SetMin(m_PiecewiseFunction->GetRange()[0]); this->SetMax(m_PiecewiseFunction->GetRange()[1]); setEnabled(true); update(); } void AddFunctionPoint(double x,double val) { m_PiecewiseFunction->AddPoint(x,val); } void RemoveFunctionPoint(double x) { int old_size = GetFunctionSize(); m_PiecewiseFunction->RemovePoint(x); if (GetFunctionSize() + 1 != old_size) { std::cout << "old/new size" << old_size << "/" << GetFunctionSize() << std::endl; std::cout << "called with x=" << x << std::endl; } } double GetFunctionX(int index) { return m_PiecewiseFunction->GetDataPointer()[index*2]; } float GetFunctionY(int index) { return m_PiecewiseFunction->GetValue(m_PiecewiseFunction->GetDataPointer()[index*2]); } int GetFunctionSize() { return m_PiecewiseFunction->GetSize(); } - void DoubleClickOnHandle(int /*handle*/) - {} + void DoubleClickOnHandle(int) + { + } void MoveFunctionPoint(int index, std::pair pos); double GetFunctionMax() { return m_PiecewiseFunction->GetRange()[1]; } double GetFunctionMin() { return m_PiecewiseFunction->GetRange()[0]; } double GetFunctionRange() { double range; if((m_PiecewiseFunction->GetRange()[0])<0) { range = (m_PiecewiseFunction->GetRange()[1])-(m_PiecewiseFunction->GetRange()[0]); return range; } else { range = m_PiecewiseFunction->GetRange()[1]; return range; } } void RemoveAllFunctionPoints() { m_PiecewiseFunction->AddSegment(this->GetFunctionMin(),0,this->GetFunctionMax(),1); m_PiecewiseFunction->AddPoint(0.0,0.0); } void ResetGO() { //Gradient Opacity m_PiecewiseFunction->AddSegment(this->GetFunctionMin(),0,0,1); m_PiecewiseFunction->AddSegment(0,1,((this->GetFunctionRange())*0.125),1); m_PiecewiseFunction->AddSegment(((this->GetFunctionRange())*0.125),1,((this->GetFunctionRange())*0.2),1); m_PiecewiseFunction->AddSegment(((this->GetFunctionRange())*0.2),1,((this->GetFunctionRange())*0.25),1); } protected: vtkPiecewiseFunction* m_PiecewiseFunction; QString m_Title; }; + #endif diff --git a/Modules/QtWidgetsExt/QmitkPlotDialog.cpp b/Modules/QtWidgetsExt/QmitkPlotDialog.cpp index f94a171310..19ca0deb72 100644 --- a/Modules/QtWidgetsExt/QmitkPlotDialog.cpp +++ b/Modules/QtWidgetsExt/QmitkPlotDialog.cpp @@ -1,45 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include "QmitkPlotDialog.h" -QmitkPlotDialog::QmitkPlotDialog(const char* title, QWidget* parent, const char* /*name*/): QDialog(parent) +QmitkPlotDialog::QmitkPlotDialog(const char* title, QWidget* parent, const char*): QDialog(parent) { QVBoxLayout* boxLayout = new QVBoxLayout(this); m_Plot = new QmitkPlotWidget( this, title ) ; m_CloseDialogButton = new QPushButton("close plot window", this); boxLayout->addWidget( m_Plot ); boxLayout->addWidget( m_CloseDialogButton ); connect( m_CloseDialogButton, SIGNAL( clicked( ) ), this, SLOT( accept() ) ); } QmitkPlotDialog::~QmitkPlotDialog() { delete m_Plot; } QmitkPlotWidget* QmitkPlotDialog::GetPlot() { return m_Plot; } QwtPlot* QmitkPlotDialog::GetQwtPlot() { return m_Plot->GetPlot(); } + diff --git a/Modules/QtWidgetsExt/QmitkPlotWidget.cpp b/Modules/QtWidgetsExt/QmitkPlotWidget.cpp index 1578eabddb..c387d8fd51 100644 --- a/Modules/QtWidgetsExt/QmitkPlotWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkPlotWidget.cpp @@ -1,164 +1,165 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include "QmitkPlotWidget.h" -QmitkPlotWidget::QmitkPlotWidget(QWidget* parent, const char* title, const char* /*name*/, Qt::WindowFlags f) +QmitkPlotWidget::QmitkPlotWidget(QWidget* parent, const char* title, const char*, Qt::WindowFlags f) : QWidget(parent, f) { QVBoxLayout* boxLayout = new QVBoxLayout(this); m_Plot = new QwtPlot( QwtText(title), this ) ; m_Plot->setCanvasBackground(Qt::white); boxLayout->addWidget( m_Plot ); } QmitkPlotWidget::~QmitkPlotWidget() { this->Clear(); delete m_Plot; } QwtPlot* QmitkPlotWidget::GetPlot() { return m_Plot; } void QmitkPlotWidget::SetLegend(QwtLegend* legend, QwtPlot::LegendPosition pos, double ratio) { m_Plot->insertLegend(legend, pos, ratio); } unsigned int QmitkPlotWidget::InsertCurve(const char* title) { QwtPlotCurve* curve = new QwtPlotCurve(QwtText(title)); m_PlotCurveVector.push_back(curve); curve->attach(m_Plot); return static_cast (m_PlotCurveVector.size() - 1); } void QmitkPlotWidget::SetPlotTitle(const char* title) { m_Plot->setTitle(title); } void QmitkPlotWidget::SetAxisTitle(int axis, const char* title) { m_Plot->setAxisTitle(axis, title); } bool QmitkPlotWidget::SetCurveData( unsigned int curveId, const QmitkPlotWidget::DataVector& xValues, const QmitkPlotWidget::DataVector& yValues ) { if ( xValues.size() != yValues.size() ) { std::cerr << "Sizes of data arrays don't match." << std::endl; return false; } double* rawDataX = ConvertToRawArray( xValues ); double* rawDataY = ConvertToRawArray( yValues ); m_PlotCurveVector[curveId]->setSamples(new QwtPointArrayData(rawDataX, rawDataY, static_cast(xValues.size()))); delete[] rawDataX; delete[] rawDataY; return true; } bool QmitkPlotWidget::SetCurveData(unsigned int curveId, const XYDataVector& data ) { double* rawDataX = ConvertToRawArray( data, 0 ); double* rawDataY = ConvertToRawArray( data, 1 ); m_PlotCurveVector[curveId]->setData(new QwtPointArrayData(rawDataX, rawDataY, static_cast(data.size()))); delete[] rawDataX; delete[] rawDataY; return true; } void QmitkPlotWidget::SetCurvePen( unsigned int curveId, const QPen& pen ) { m_PlotCurveVector[curveId]->setPen( pen ); } void QmitkPlotWidget::SetCurveBrush( unsigned int curveId, const QBrush& brush ) { m_PlotCurveVector[curveId]->setBrush( brush ); } -void QmitkPlotWidget::SetCurveTitle( unsigned int /*curveId*/, const char* title ) +void QmitkPlotWidget::SetCurveTitle( unsigned int, const char* title ) { m_Plot->setTitle( title ); } void QmitkPlotWidget::SetCurveStyle( unsigned int curveId, const QwtPlotCurve::CurveStyle style ) { m_PlotCurveVector[curveId]->setStyle(style); } void QmitkPlotWidget::SetCurveSymbol( unsigned int curveId, QwtSymbol* symbol ) { m_PlotCurveVector[curveId]->setSymbol(symbol); } void QmitkPlotWidget::Replot() { m_Plot->replot(); } void QmitkPlotWidget::Clear() { m_Plot->detachItems(); m_PlotCurveVector.clear(); m_PlotCurveVector.resize(0); } double* QmitkPlotWidget::ConvertToRawArray( const QmitkPlotWidget::DataVector& values ) { double* raw = new double[ values.size() ]; for( unsigned int i = 0; i < values.size(); ++i ) raw[i] = values[i]; return raw; } double* QmitkPlotWidget::ConvertToRawArray( const QmitkPlotWidget::XYDataVector& values, unsigned int component ) { double* raw = new double[ values.size() ]; for( unsigned int i = 0; i < values.size(); ++i ) { switch (component) { case (0): raw[i] = values[i].first; break; case (1): raw[i] = values[i].second; break; default: std::cout << "Component must be either 0 or 1."<< std::endl; } } return raw; } + diff --git a/Modules/QtWidgetsExt/QmitkPointListModel.cpp b/Modules/QtWidgetsExt/QmitkPointListModel.cpp index 9197476c35..4e447c3e49 100644 --- a/Modules/QtWidgetsExt/QmitkPointListModel.cpp +++ b/Modules/QtWidgetsExt/QmitkPointListModel.cpp @@ -1,335 +1,334 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPointListModel.h" #include #include "mitkInteractionConst.h" #include "mitkPointOperation.h" #include "mitkRenderingManager.h" #include #include #include #include QmitkPointListModel::QmitkPointListModel( mitk::DataNode* pointSetNode, int t, QObject* parent ) :QAbstractListModel(parent), m_PointSetNode(NULL), m_PointSetModifiedObserverTag(0), m_PointSetDeletedObserverTag(0), m_TimeStep(t) { ObserveNewPointSet( pointSetNode ); } Qt::ItemFlags QmitkPointListModel::flags(const QModelIndex& /*index*/) const { // no editing so far, return default (enabled, selectable) return Qt::ItemIsSelectable | Qt::ItemIsEnabled; } QmitkPointListModel::~QmitkPointListModel() { this->ObserveNewPointSet( NULL ); } void QmitkPointListModel::SetPointSetNode( mitk::DataNode* pointSetNode ) { this->ObserveNewPointSet( pointSetNode ); QAbstractListModel::reset(); emit SignalUpdateSelection(); } mitk::PointSet* QmitkPointListModel::GetPointSet() const { return this->CheckForPointSetInNode(m_PointSetNode); } void QmitkPointListModel::SetTimeStep(int t) { m_TimeStep = t; QAbstractListModel::reset(); emit SignalUpdateSelection(); } int QmitkPointListModel::GetTimeStep() const { return m_TimeStep; } void QmitkPointListModel::ObserveNewPointSet( mitk::DataNode* pointSetNode ) { //remove old observers if (m_PointSetNode != NULL) { mitk::PointSet::Pointer oldPointSet = dynamic_cast(m_PointSetNode->GetData()); if (oldPointSet.IsNotNull()) { oldPointSet->RemoveObserver(m_PointSetModifiedObserverTag); oldPointSet->RemoveObserver(m_PointSetDeletedObserverTag); } } //get the new pointset mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(pointSetNode); m_PointSetNode = pointSetNode; if ( pointSet.IsNotNull()) { // add new observer for modified if necessary itk::ReceptorMemberCommand::Pointer modCommand = itk::ReceptorMemberCommand::New(); modCommand->SetCallbackFunction( this, &QmitkPointListModel::OnPointSetChanged ); m_PointSetModifiedObserverTag = pointSet->AddObserver( itk::ModifiedEvent(), modCommand ); // add new observer for detele if necessary itk::ReceptorMemberCommand::Pointer delCommand = itk::ReceptorMemberCommand::New(); delCommand->SetCallbackFunction( this, &QmitkPointListModel::OnPointSetDeleted ); m_PointSetDeletedObserverTag = pointSet->AddObserver( itk::DeleteEvent(), delCommand ); } else { m_PointSetModifiedObserverTag = 0; m_PointSetDeletedObserverTag = 0; } } -void QmitkPointListModel::OnPointSetChanged( const itk::EventObject & /*e*/ ) +void QmitkPointListModel::OnPointSetChanged(const itk::EventObject&) { QAbstractListModel::reset(); emit SignalUpdateSelection(); } -void QmitkPointListModel::OnPointSetDeleted( const itk::EventObject & /*e*/ ) +void QmitkPointListModel::OnPointSetDeleted(const itk::EventObject&) { -// m_PointSetNode = NULL; mitk::PointSet::Pointer ps = CheckForPointSetInNode(m_PointSetNode); if (ps) { ps->RemoveObserver(m_PointSetModifiedObserverTag); ps->RemoveObserver(m_PointSetDeletedObserverTag); } m_PointSetModifiedObserverTag = 0; m_PointSetDeletedObserverTag = 0; QAbstractListModel::reset(); } -int QmitkPointListModel::rowCount( const QModelIndex& /*parent*/ ) const +int QmitkPointListModel::rowCount(const QModelIndex&) const { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if ( pointSet.IsNotNull() ) { return pointSet->GetSize(m_TimeStep); } else { return 0; } } QVariant QmitkPointListModel::data(const QModelIndex& index, int role) const { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if ( pointSet.IsNull() ) { return QVariant(); } if ( !index.isValid() ) { return QVariant(); } if ( index.row() >= pointSet->GetSize(m_TimeStep) ) { return QVariant(); } if (role == Qt::DisplayRole) { mitk::PointSet::PointsContainer::ElementIdentifier id; mitk::PointSet::PointType p; bool pointFound = this->GetPointForModelIndex(index, p, id); if (pointFound == false) return QVariant(); QString s = QString("%0: (%1, %2, %3)") .arg( id, 3) .arg( p[0], 0, 'f', 3 ) .arg( p[1], 0, 'f', 3 ) .arg( p[2], 0, 'f', 3 ); return QVariant(s); } else { return QVariant(); } } QVariant QmitkPointListModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) { return QVariant(); } if (orientation == Qt::Horizontal) { return QString("Coordinates").arg(section); } else { return QString("Row %1").arg(section); } } bool QmitkPointListModel::GetPointForModelIndex( const QModelIndex &index, mitk::PointSet::PointType& p, mitk::PointSet::PointIdentifier& id) const { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if (pointSet.IsNull()) return false; if ((index.row() < 0) || (index.row() >= (int)pointSet->GetPointSet(m_TimeStep)->GetPoints()->Size())) return false; // get the nth. element, if it exists. // we can not use the index directly, because PointSet uses a map container, // where the index is not necessarily the same as the key. // Therefore we have to count the elements mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_TimeStep)->GetPoints()->Begin(); for (int i = 0; i < index.row(); ++i) { ++it; if (it == pointSet->GetPointSet(m_TimeStep)->GetPoints()->End()) return false; } if (it != pointSet->GetPointSet(m_TimeStep)->GetPoints()->End()) // not at the end, { p = it->Value(); id = it->Index(); return true; } return false; } bool QmitkPointListModel::GetModelIndexForPointID(mitk::PointSet::PointIdentifier id, QModelIndex& index) const { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if (pointSet.IsNull()) return false; mitk::PointSet::PointsContainer::Pointer points = pointSet->GetPointSet(m_TimeStep)->GetPoints(); if (points->IndexExists(id) == false) return false; unsigned int idx = 0; for (mitk::PointSet::PointsContainer::Iterator it = points->Begin(); it != points->End(); ++it) { if (it->Index() == id) // we found the correct element { index = this->index(idx); return true; } idx++; } return false; // nothing found } void QmitkPointListModel::MoveSelectedPointUp() { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if (pointSet.IsNull()) return; mitk::PointSet::PointIdentifier selectedID; selectedID = pointSet->SearchSelectedPoint(m_TimeStep); mitk::PointSet::PointType point = pointSet->GetPoint(selectedID, m_TimeStep); mitk::ScalarType tsInMS = pointSet->GetTimeGeometry()->TimeStepToTimePoint(m_TimeStep); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP,tsInMS, pointSet->GetPoint(selectedID, m_TimeStep), selectedID, true); pointSet->ExecuteOperation(doOp); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // Workaround for update problem in Pointset/Mapper } void QmitkPointListModel::MoveSelectedPointDown() { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if (pointSet.IsNull()) return; mitk::PointSet::PointIdentifier selectedID; selectedID = pointSet->SearchSelectedPoint(m_TimeStep); mitk::ScalarType tsInMS = pointSet->GetTimeGeometry()->TimeStepToTimePoint(m_TimeStep); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, tsInMS, pointSet->GetPoint(selectedID, m_TimeStep), selectedID, true); pointSet->ExecuteOperation(doOp); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // Workaround for update problem in Pointset/Mapper } void QmitkPointListModel::RemoveSelectedPoint() { mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode); if (pointSet.IsNull()) return; //get corresponding interactor to PointSet mitk::PointSetInteractor::Pointer interactor = dynamic_cast(m_PointSetNode->GetInteractor()); if (interactor.IsNull()) { if (m_PointSetNode->GetInteractor()==NULL && m_PointSetNode != NULL) //no Interactor set to node { interactor = mitk::PointSetInteractor::New("pointsetinteractor",m_PointSetNode); m_PointSetNode->SetInteractor(interactor); } else { MITK_WARN<<"Unexpected interactor found!\n"; return; } } //send a DEL event to pointsetinteractor const mitk::Event* delEvent = new mitk::Event(NULL, mitk::Type_KeyPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_Delete); mitk::StateEvent* delStateEvent = new mitk::StateEvent(mitk::EIDDELETE, delEvent); interactor->HandleEvent(delStateEvent); delete delEvent; delete delStateEvent; mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // Workaround for update problem in PointSet/Mapper } mitk::PointSet* QmitkPointListModel::CheckForPointSetInNode(mitk::DataNode* node) const { if (node != NULL) { mitk::PointSet::Pointer pointSet = dynamic_cast(node->GetData()); if (pointSet.IsNotNull()) return pointSet; } return NULL; } diff --git a/Modules/QtWidgetsExt/QmitkPointListModel.h b/Modules/QtWidgetsExt/QmitkPointListModel.h index 2ba657f8c1..4bc5fea898 100644 --- a/Modules/QtWidgetsExt/QmitkPointListModel.h +++ b/Modules/QtWidgetsExt/QmitkPointListModel.h @@ -1,131 +1,133 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_POINTLIST_MODEL_H_INCLUDED #define QMITK_POINTLIST_MODEL_H_INCLUDED #include #include "MitkQtWidgetsExtExports.h" #include "mitkDataNode.h" #include "mitkPointSet.h" class MitkQtWidgetsExt_EXPORT QmitkPointListModel : public QAbstractListModel { Q_OBJECT public: QmitkPointListModel( mitk::DataNode* = NULL, int t = 0, QObject* parent = 0 ); ~QmitkPointListModel(); - Qt::ItemFlags flags(const QModelIndex& /*index*/) const; + Qt::ItemFlags flags(const QModelIndex&) const; /// interface of QAbstractListModel int rowCount( const QModelIndex& parent = QModelIndex() ) const; /// interface of QAbstractListModel QVariant data(const QModelIndex& index, int role) const; /// interface of QAbstractListModel QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; /// which point set to work on void SetPointSetNode( mitk::DataNode* pointSetNode ); /// which point set to work on mitk::PointSet* GetPointSet() const; // which point set to work on mitk::DataNode* GetPointSetNode() const; /// which time step to display/model void SetTimeStep(int t); /// which time step to display/model int GetTimeStep() const; /// itk observer for point set "modified" events void OnPointSetChanged( const itk::EventObject & e ); /// itk observer for point set "delete" events void OnPointSetDeleted( const itk::EventObject & e ); /** * \brief get point and point ID that correspond to a given QModelIndex * * The mitk::PointSet uses a map to store points in an ID<-->Point relation. * The IDs are not neccesarily continuously numbered, therefore, we can not * directly use the QModelIndex as point ID. This method returns the point and * the corresponding point id for a given QModelIndex. The point and the point ID * are returned in the outgoing parameters p and id. If a valid point and ID were * found, the method returns true, otherwise it returns false * \param[in] QModelIndex &index the index for which a point is requested. The row() part of the index is used to find a corresponding point * \param[out] mitk::Point3D& p If a valid point is found, it will be stored in the p parameter * \param[out] mitk::PointSet::PointIdentifier& id If a valid point is found, the corresponding ID will be stored in id * \return Returns true, if a valid point was found, false otherwise */ bool GetPointForModelIndex( const QModelIndex &index, mitk::PointSet::PointType& p, mitk::PointSet::PointIdentifier& id) const; /**Documentation * \brief returns a QModelIndex for a given point ID * * The mitk::PointSet uses a map to store points in an ID<-->Point relation. * The IDs are not neccesarily continuously numbered, therefore, we can not * directly use the point ID as a QModelIndex. This method returns a QModelIndex * for a given point ID in the outgoing parameter index. * \param[in] mitk::PointSet::PointIdentifier id The point ID for which the QModelIndex will be created * \param[out] QModelIndex& index if a point with the ID id was found, index will contain a corresponding QModelIndex for that point * \return returns true, if a valid QModelIndex was created, false otherwise */ bool GetModelIndexForPointID(mitk::PointSet::PointIdentifier id, QModelIndex& index) const; public slots: void MoveSelectedPointUp(); void MoveSelectedPointDown(); void RemoveSelectedPoint(); signals: /// emitted, when views should update their selection status /// (because mouse interactions in render windows can change /// the selection status of points) void SignalUpdateSelection(); protected: /// internally observe different point set void ObserveNewPointSet( mitk::DataNode* pointSetNode ); //initially checks if there is a PointSet as data in the DataNode. //returns PointSet if so and NULL if other data is set to node mitk::PointSet* CheckForPointSetInNode(mitk::DataNode* node) const; protected: mitk::DataNode* m_PointSetNode; unsigned int m_PointSetModifiedObserverTag; unsigned int m_PointSetDeletedObserverTag; int m_TimeStep; }; + #endif + diff --git a/Modules/QtWidgetsExt/QmitkPointListView.cpp b/Modules/QtWidgetsExt/QmitkPointListView.cpp index 6085eb1b95..0fb63cb7b1 100644 --- a/Modules/QtWidgetsExt/QmitkPointListView.cpp +++ b/Modules/QtWidgetsExt/QmitkPointListView.cpp @@ -1,470 +1,414 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPointListView.h" #include "QmitkPointListModel.h" #include "QmitkStdMultiWidget.h" #include "QmitkEditPointDialog.h" #include "mitkRenderingManager.h" #include #include #include #include #include QmitkPointListView::QmitkPointListView( QWidget* parent ) : QListView( parent ), m_Snc1(NULL), m_Snc2(NULL), m_Snc3(NULL), 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() { delete m_PointListModel; } void QmitkPointListView::SetPointSetNode( mitk::DataNode* pointSetNode ) { m_PointListModel->SetPointSetNode( pointSetNode); } const mitk::PointSet* QmitkPointListView::GetPointSet() const { return m_PointListModel->GetPointSet(); } void QmitkPointListView::SetMultiWidget( QmitkStdMultiWidget* multiWidget ) { m_MultiWidget = multiWidget; } QmitkStdMultiWidget* QmitkPointListView::GetMultiWidget() const { return m_MultiWidget; } void QmitkPointListView::OnPointDoubleClicked(const QModelIndex & index) { 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() { 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::OnListViewSelectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) { if (m_SelfCall) return; mitk::PointSet* pointSet = const_cast( 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()); // Use Multiwidget or SliceNavigationControllers to set crosshair to selected point if ( m_MultiWidget != NULL) { m_MultiWidget->MoveCrossToPosition(pointSet->GetPoint(it->Index(), m_PointListModel->GetTimeStep())); } mitk::Point3D p = pointSet->GetPoint(it->Index(), m_PointListModel->GetTimeStep()); // remove the three ifs below after the SetSnc* methods have been removed if (m_Snc1 != NULL) { m_Snc1->SelectSliceByPoint(p); } if (m_Snc2 != NULL) { m_Snc2->SelectSliceByPoint(p); } if (m_Snc3 != NULL) { m_Snc3->SelectSliceByPoint(p); } for (std::set::const_iterator i = m_Sncs.begin(); i != m_Sncs.end(); ++i) { (*i)->SelectSliceByPoint(p); } } else { pointSet->SetSelectInfo(it->Index(), false, m_PointListModel->GetTimeStep()); } } } m_SelfCall = false; emit SignalPointSelectionChanged(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkPointListView::keyPressEvent( QKeyEvent * e ) { 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::wheelEvent(QWheelEvent *event) { - if (!m_PointListModel || !m_PointListModel->GetPointSet() || (int)(m_PointListModel->GetPointSet()->GetTimeSteps()) == 1 /*|| !m_4DPointSet*/) + if (!m_PointListModel || !m_PointListModel->GetPointSet() || (int)(m_PointListModel->GetPointSet()->GetTimeSteps()) == 1) return; int whe = event->delta(); mitk::PointSet::Pointer ps = dynamic_cast(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(); } void QmitkPointListView::fadeTimeStepIn() { //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() { m_TimeStepFaderLabel->hide(); } void QmitkPointListView::ctxMenu(const QPoint &pos) { 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::SetFading(bool onOff) { m_showFading = onOff; } void QmitkPointListView::ClearPointList() { 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->IsEmptyTimeStep(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() { - // 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::SetSnc1(mitk::SliceNavigationController* snc) { m_Snc1 = snc; } void QmitkPointListView::SetSnc2(mitk::SliceNavigationController* snc) { m_Snc2 = snc; } void QmitkPointListView::SetSnc3(mitk::SliceNavigationController* snc) { m_Snc3 = snc; } void QmitkPointListView::AddSliceNavigationController(mitk::SliceNavigationController* snc) { if (snc == NULL) return; m_Sncs.insert(snc); } void QmitkPointListView::RemoveSliceNavigationController(mitk::SliceNavigationController* snc) { if (snc == NULL) return; m_Sncs.erase(snc); } + diff --git a/Modules/QtWidgetsExt/QmitkPointListView.h b/Modules/QtWidgetsExt/QmitkPointListView.h index ded3902728..21ec573ae9 100644 --- a/Modules/QtWidgetsExt/QmitkPointListView.h +++ b/Modules/QtWidgetsExt/QmitkPointListView.h @@ -1,153 +1,155 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_POINTLIST_VIEW_H_INCLUDED #define QMITK_POINTLIST_VIEW_H_INCLUDED #include #include #include "MitkQtWidgetsExtExports.h" #include #include "QmitkPointListModel.h" class QmitkStdMultiWidget; /*! * \brief 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. * */ class MitkQtWidgetsExt_EXPORT QmitkPointListView : public QListView { Q_OBJECT public: QmitkPointListView( QWidget* parent = 0 ); ~QmitkPointListView(); /// assign a point set for observation void SetPointSetNode( mitk::DataNode* pointSetNode ); /// which point set to work on const mitk::PointSet* GetPointSet() const; /** * \brief If Multiwidget is set, the crosshair is automatically centering to the selected point * As an alternative, if you dont have a multiwidget, you can call SetSnc1, SetSnc2, SetSnc3 to set the * SliceNavigationControllers directly to enable the focussing feature. */ void SetMultiWidget( QmitkStdMultiWidget* multiWidget ); QmitkStdMultiWidget* GetMultiWidget() const; ///< return the QmitkStdMultiWidget that is used for updating render window crosshair void SetTimesStep(int i); ///< which time step to display/model ///@{ /** * \brief Sets the SliceNavigationController of the three 2D Renderwindows. * If they are defined, they can be used to automatically set the crosshair to the selected point * * \deprecatedSince{2013_03} Use AddSliceNavigationController and RemoveSliceNavigationController instead. */ DEPRECATED( void SetSnc1(mitk::SliceNavigationController* snc) ); DEPRECATED( void SetSnc2(mitk::SliceNavigationController* snc) ); DEPRECATED( void SetSnc3(mitk::SliceNavigationController* snc) ); ///@} /** * @brief Add a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method adds \c snc to the set of slice navigation controllers which are * used to navigate to the selected point. */ void AddSliceNavigationController(mitk::SliceNavigationController* snc); /** * @brief Remove a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method removes \c snc from the set of slice navigation controllers which are * used to navigate to the selected point. */ void RemoveSliceNavigationController(mitk::SliceNavigationController* snc); signals: void SignalPointSelectionChanged(); ///< this signal is emmitted, if the selection of a point in the pointset is changed protected slots: /// Filtering double click event for editing point coordinates via a dialog void OnPointDoubleClicked(const QModelIndex & index); /// called when the point set data structure changes void OnPointSetSelectionChanged(); /// called when the selection of the view widget changes void OnListViewSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); /// fade the shown timestep out void fadeTimeStepOut(); /// open ContextMenu void ctxMenu(const QPoint &pos); /// Turn TimeStep Fading On/Off void SetFading(bool onOff); /// Delete all points in the list void ClearPointList(); /// delete all points in the list in the current timestep void ClearPointListTS(); protected: 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 mitk::SliceNavigationController* m_Snc1; mitk::SliceNavigationController* m_Snc2; mitk::SliceNavigationController* m_Snc3; std::set m_Sncs; QmitkPointListModel* m_PointListModel; bool m_SelfCall; bool m_showFading; /// used to position the planes on a selected point QmitkStdMultiWidget* m_MultiWidget; QLabel* m_TimeStepFaderLabel; }; + #endif + diff --git a/Modules/QtWidgetsExt/QmitkPointListViewWidget.cpp b/Modules/QtWidgetsExt/QmitkPointListViewWidget.cpp index 2474a20545..2bb99dac60 100644 --- a/Modules/QtWidgetsExt/QmitkPointListViewWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkPointListViewWidget.cpp @@ -1,325 +1,256 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPointListViewWidget.h" #include "QmitkPointListModel.h" #include "QmitkStdMultiWidget.h" #include "QmitkEditPointDialog.h" #include "mitkInteractionConst.h" #include "mitkPointOperation.h" #include "mitkRenderingManager.h" #include QmitkPointListViewWidget::QmitkPointListViewWidget( QWidget* parent ) :QListWidget( parent ), m_TimeStep( 0 ), m_SelfCall( false ), m_MultiWidget( NULL) { QListWidget::setAlternatingRowColors( true ); // logic QListWidget::setSelectionBehavior( QAbstractItemView::SelectRows ); QListWidget::setSelectionMode( QAbstractItemView::SingleSelection ); connect( this, SIGNAL(itemDoubleClicked ( QListWidgetItem * )), this, SLOT(OnItemDoubleClicked( QListWidgetItem *)) ); connect( this, SIGNAL( currentRowChanged( int ) ), this, SLOT( OnCurrentRowChanged( int ) ) ); } QmitkPointListViewWidget::~QmitkPointListViewWidget() { this->SetPointSet(0); // remove listener } void QmitkPointListViewWidget::SetPointSet( mitk::PointSet* pointSet ) { if(m_PointSet.IsNotNull()) { m_PointSet.ObjectModified.RemoveListener (mitk::MessageDelegate1( this, &QmitkPointListViewWidget::OnPointSetChanged )); m_PointSet.ObjectDelete.RemoveListener (mitk::MessageDelegate1( this, &QmitkPointListViewWidget::OnPointSetDeleted )); } m_PointSet = pointSet; if(m_PointSet.IsNotNull()) { m_PointSet.ObjectModified.AddListener (mitk::MessageDelegate1( this, &QmitkPointListViewWidget::OnPointSetChanged )); m_PointSet.ObjectDelete.AddListener (mitk::MessageDelegate1( this, &QmitkPointListViewWidget::OnPointSetDeleted )); } this->Update(); } const mitk::PointSet* QmitkPointListViewWidget::GetPointSet() const { return m_PointSet; } void QmitkPointListViewWidget::SetTimeStep(int t) { m_TimeStep = t; this->Update(); } int QmitkPointListViewWidget::GetTimeStep() const { return m_TimeStep; } void QmitkPointListViewWidget::SetMultiWidget( QmitkStdMultiWidget* multiWidget ) { m_MultiWidget = multiWidget; } QmitkStdMultiWidget* QmitkPointListViewWidget::GetMultiWidget() const { return m_MultiWidget; } -void QmitkPointListViewWidget::OnPointSetChanged( const itk::Object* /*obj*/ ) +void QmitkPointListViewWidget::OnPointSetChanged(const itk::Object*) { if(!m_SelfCall) this->Update(); } -void QmitkPointListViewWidget::OnPointSetDeleted( const itk::Object* /*obj*/ ) +void QmitkPointListViewWidget::OnPointSetDeleted(const itk::Object*) { this->SetPointSet(0); this->Update(); } void QmitkPointListViewWidget::OnItemDoubleClicked(QListWidgetItem * item) { QmitkEditPointDialog _EditPointDialog(this); _EditPointDialog.SetPoint(m_PointSet, this->row(item), m_TimeStep); _EditPointDialog.exec(); } -void QmitkPointListViewWidget::OnCurrentRowChanged( int /*currentRow*/ ) +void QmitkPointListViewWidget::OnCurrentRowChanged(int) { this->Update(true); } -/* -void QmitkPointListViewWidget::OnPointSetSelectionChanged() -{ - if (m_SelfCall) - return; - - - 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 ) - { - /// @TODO use logging as soon as available - std::cerr << "Point set has multiple selected points. This view is not designed for more than one selected point." << std::endl; - } - - 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) - QListWidget::selectionModel()->select( m_PointListModel->index( selectedIndex ), QItemSelectionModel::SelectCurrent ); - - emit PointSelectionChanged(); - m_SelfCall = false; -} - - -void QmitkPointListViewWidget::OnListViewSelectionChanged(const QItemSelection& selected, const QItemSelection& *deselected*) -{ - if (m_SelfCall || m_PointSet.IsNull()) - 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 = m_PointSet->GetPointSet(m_TimeStep)->GetPoints()->Begin() - ; it != m_PointSet->GetPointSet(m_TimeStep)->GetPoints()->End() - ; ++it) - { - QModelIndex index; - m_PointListModel->GetModelIndexForPointID(it->Index(), index); - if (selectedIndexes.indexOf(index) != -1) // index is found in the selected indices list - { - m_PointSet->SetSelectInfo(it->Index(), true, m_PointListModel->GetTimeStep()); - if ( m_MultiWidget != NULL) - m_MultiWidget->MoveCrossToPosition(m_PointSet->GetPoint(it->Index(), m_PointListModel->GetTimeStep())); - - } - else - pointSet->SetSelectInfo(it->Index(), false, m_PointListModel->GetTimeStep()); - } - m_SelfCall = false; - emit PointSelectionChanged(); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} -*/ - void QmitkPointListViewWidget::keyPressEvent( QKeyEvent * e ) { if (m_PointSet.IsNull()) return; int key = e->key(); switch (key) { case Qt::Key_F2: this->MoveSelectedPointUp(); break; case Qt::Key_F3: this->MoveSelectedPointDown(); break; case Qt::Key_Delete: this->RemoveSelectedPoint(); break; default: break; } } void QmitkPointListViewWidget::MoveSelectedPointUp() { if (m_PointSet == NULL) return; mitk::PointSet::PointIdentifier selectedID; selectedID = m_PointSet->SearchSelectedPoint(m_TimeStep); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, m_PointSet->GetPoint(selectedID, m_TimeStep), selectedID, true); m_PointSet->ExecuteOperation(doOp); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // Workaround for update problem in Pointset/Mapper } void QmitkPointListViewWidget::MoveSelectedPointDown() { if (m_PointSet == NULL) return; mitk::PointSet::PointIdentifier selectedID; selectedID = m_PointSet->SearchSelectedPoint(m_TimeStep); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, m_PointSet->GetPoint(selectedID, m_TimeStep), selectedID, true); m_PointSet->ExecuteOperation(doOp); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // Workaround for update problem in Pointset/Mapper } void QmitkPointListViewWidget::RemoveSelectedPoint() { if (m_PointSet == NULL) return; mitk::PointSet::PointIdentifier selectedID; selectedID = m_PointSet->SearchSelectedPoint(m_TimeStep); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpREMOVE, m_PointSet->GetPoint(selectedID, m_TimeStep), selectedID, true); m_PointSet->ExecuteOperation(doOp); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // Workaround for update problem in Pointset/Mapper } void QmitkPointListViewWidget::Update(bool currentRowChanged) { if(m_SelfCall) return; if(m_PointSet.IsNull()) { this->clear(); return; } m_SelfCall = true; QString text; int i = 0; mitk::PointSet::DataType::Pointer pointset = m_PointSet->GetPointSet(m_TimeStep); for (mitk::PointSet::PointsContainer::Iterator it = pointset->GetPoints()->Begin(); it != pointset->GetPoints()->End(); ++it) { text = QString("%0: (%1, %2, %3)") .arg( i, 3) .arg( it.Value().GetElement(0), 0, 'f', 3 ) .arg( it.Value().GetElement(1), 0, 'f', 3 ) .arg( it.Value().GetElement(2), 0, 'f', 3 ); if(i==this->count()) this->addItem(text); // insert text else this->item(i)->setText(text); // update text if(currentRowChanged) { if(i == this->currentRow()) m_PointSet->SetSelectInfo(this->currentRow(), true, m_TimeStep); else m_PointSet->SetSelectInfo(it->Index(), false, m_TimeStep); // select nothing now } ++i; } // remove unnecessary listwidgetitems while (m_PointSet->GetPointSet(m_TimeStep)->GetPoints()->Size() < (unsigned int)this->count() ) { QListWidgetItem * item = this->takeItem(this->count()-1); delete item; } // update selection in pointset or in the list widget if(!currentRowChanged) { if ( m_PointSet->GetNumberOfSelected( m_TimeStep ) > 1 ) { /// @TODO use logging as soon as available std::cerr << "Point set has multiple selected points. This view is not designed for more than one selected point." << std::endl; } int selectedIndex = m_PointSet->SearchSelectedPoint( m_TimeStep ); if (selectedIndex != -1) // no selected point is found { this->setCurrentRow ( selectedIndex ); } } m_SelfCall = false; } + diff --git a/Modules/QtWidgetsExt/QmitkPointListViewWidget.h b/Modules/QtWidgetsExt/QmitkPointListViewWidget.h index 6ea7857598..fd7d4ba411 100644 --- a/Modules/QtWidgetsExt/QmitkPointListViewWidget.h +++ b/Modules/QtWidgetsExt/QmitkPointListViewWidget.h @@ -1,98 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPointListViewWidget_h #define QmitkPointListViewWidget_h #include #include "MitkQtWidgetsExtExports.h" #include #include class QmitkStdMultiWidget; /*! * \brief 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. * */ class MitkQtWidgetsExt_EXPORT QmitkPointListViewWidget : public QListWidget { Q_OBJECT signals: void PointSelectionChanged(); ///< this signal is emmitted, if the selection of a point in the pointset is changed public: QmitkPointListViewWidget( QWidget* parent = 0 ); ~QmitkPointListViewWidget(); /// assign a point set for observation void SetPointSet( mitk::PointSet* pointSet ); /// which point set to work on const mitk::PointSet* GetPointSet() const; 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 /// which time step to display/model void SetTimeStep(int t); /// which time step to display/model int GetTimeStep() const; /// observer for point set "modified" events void OnPointSetChanged( const itk::Object* /*obj*/ ); /// observer for point set "delete" events void OnPointSetDeleted( const itk::Object* /*obj*/ ); protected slots: /// /// Filtering double click event for editing point coordinates via a dialog /// void OnItemDoubleClicked( QListWidgetItem * item ); /// called when the selection of the view widget changes void OnCurrentRowChanged( int /*currentRow*/ ); protected: void keyPressEvent( QKeyEvent * e ); ///< react to F2, F3 and DEL keys void MoveSelectedPointUp(); void MoveSelectedPointDown(); void RemoveSelectedPoint(); void Update(bool currentRowChanged=false); protected: mitk::WeakPointer m_PointSet; int m_TimeStep; bool m_SelfCall; /// used to position the planes on a selected point QmitkStdMultiWidget* m_MultiWidget; }; -#endif // QmitkPointListViewWidget_h + +#endif + diff --git a/Modules/QtWidgetsExt/QmitkPointListWidget.cpp b/Modules/QtWidgetsExt/QmitkPointListWidget.cpp index a01958af1f..563ed19573 100644 --- a/Modules/QtWidgetsExt/QmitkPointListWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkPointListWidget.cpp @@ -1,526 +1,496 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPointListWidget.h" #include #include #include #include #include #include #include #include #include -#include "btnLoad.xpm" -#include "btnSave.xpm" -#include "btnClear.xpm" -#include "btnSetPoints.xpm" -#include "btnSetPointsManually.xpm" -#include "btnUp.xpm" -#include "btnDown.xpm" - - #include QmitkPointListWidget::QmitkPointListWidget(QWidget *parent, int orientation): QWidget(parent), m_PointListView(NULL), m_MultiWidget(NULL), m_PointSetNode(NULL), m_Orientation(0), m_MovePointUpBtn(NULL), m_MovePointDownBtn(NULL), m_RemovePointBtn(NULL), m_SavePointsBtn(NULL), m_LoadPointsBtn(NULL), m_ToggleAddPoint(NULL), m_AddPoint(NULL), m_Snc1(NULL), m_Snc2(NULL), m_Snc3(NULL), m_DataInteractor(NULL), m_TimeStep(0), m_EditAllowed(true), m_NodeObserverTag(0) { m_PointListView = new QmitkPointListView(); if(orientation != 0) m_Orientation = orientation; SetupUi(); SetupConnections(); ObserveNewNode(NULL); } QmitkPointListWidget::~QmitkPointListWidget() { m_DataInteractor = NULL; if(m_PointSetNode && m_NodeObserverTag) { m_PointSetNode->RemoveObserver(m_NodeObserverTag); m_NodeObserverTag = 0; } m_MultiWidget = NULL; delete m_PointListView; } void QmitkPointListWidget::SetupConnections() { - //m_PointListView->setModel(m_PointListModel); - connect(this->m_LoadPointsBtn, SIGNAL(clicked()), this, SLOT(OnBtnLoadPoints())); connect(this->m_SavePointsBtn, SIGNAL(clicked()), this, SLOT(OnBtnSavePoints())); connect(this->m_MovePointUpBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointUp())); connect(this->m_MovePointDownBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointDown())); connect(this->m_RemovePointBtn, SIGNAL(clicked()), this, SLOT(RemoveSelectedPoint())); connect(this->m_ToggleAddPoint, SIGNAL(toggled(bool)), this, SLOT(OnBtnAddPoint(bool))); connect(this->m_AddPoint, SIGNAL(clicked()), this, SLOT(OnBtnAddPointManually())); connect(this->m_PointListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnListDoubleClick())); connect(this->m_PointListView, SIGNAL(SignalPointSelectionChanged()), this, SLOT(OnPointSelectionChanged())); } void QmitkPointListWidget::SetupUi() { //Setup the buttons - m_ToggleAddPoint = new QPushButton();//iconSetPoints, "", this); + m_ToggleAddPoint = new QPushButton(); m_ToggleAddPoint->setMaximumSize(25,25); m_ToggleAddPoint->setCheckable(true); m_ToggleAddPoint->setToolTip("Toggle point editing (use SHIFT + Left Mouse Button to add Points)"); - QIcon iconAdd(btnSetPoints_xpm); + QIcon iconAdd(":/QtWidgetsExt/btnSetPoints.xpm"); m_ToggleAddPoint->setIcon(iconAdd); - m_AddPoint = new QPushButton();//iconSetPoints, "", this); + m_AddPoint = new QPushButton(); m_AddPoint->setMaximumSize(25,25); m_AddPoint->setToolTip("Manually add point"); - QIcon iconAddManually(btnSetPointsManually_xpm); + QIcon iconAddManually(":/QtWidgetsExt/btnSetPointsManually.xpm"); m_AddPoint->setIcon(iconAddManually); m_RemovePointBtn = new QPushButton(); m_RemovePointBtn->setMaximumSize(25, 25); - const QIcon iconDel(btnClear_xpm); + const QIcon iconDel(":/QtWidgetsExt/btnClear.xpm"); m_RemovePointBtn->setIcon(iconDel); m_RemovePointBtn->setToolTip("Erase one point from list (Hotkey: DEL)"); m_MovePointUpBtn = new QPushButton(); m_MovePointUpBtn->setMaximumSize(25, 25); - const QIcon iconUp(btnUp_xpm); + const QIcon iconUp(":/QtWidgetsExt/btnUp.xpm"); m_MovePointUpBtn->setIcon(iconUp); m_MovePointUpBtn->setToolTip("Swap selected point upwards (Hotkey: F2)"); m_MovePointDownBtn = new QPushButton(); m_MovePointDownBtn->setMaximumSize(25, 25); - const QIcon iconDown(btnDown_xpm); + const QIcon iconDown(":/QtWidgetsExt/btnDown.xpm"); m_MovePointDownBtn->setIcon(iconDown); m_MovePointDownBtn->setToolTip("Swap selected point downwards (Hotkey: F3)"); m_SavePointsBtn = new QPushButton(); m_SavePointsBtn->setMaximumSize(25, 25); - QIcon iconSave(btnSave_xpm); + QIcon iconSave(":/QtWidgetsExt/btnSave.xpm"); m_SavePointsBtn->setIcon(iconSave); m_SavePointsBtn->setToolTip("Save points to file"); m_LoadPointsBtn = new QPushButton(); m_LoadPointsBtn->setMaximumSize(25, 25); - QIcon iconLoad(btnLoad_xpm); + QIcon iconLoad(":/QtWidgetsExt/btnLoad.xpm"); m_LoadPointsBtn->setIcon(iconLoad); m_LoadPointsBtn->setToolTip("Load list of points from file (REPLACES current content)"); int i; QBoxLayout* lay1; QBoxLayout* lay2; switch (m_Orientation) { case 0: lay1 = new QVBoxLayout(this); lay2 = new QHBoxLayout(); i = 0; break; case 1: lay1 = new QHBoxLayout(this); lay2 = new QVBoxLayout(); i=-1; break; case 2: lay1 = new QHBoxLayout(this); lay2 = new QVBoxLayout(); i=0; break; default: lay1 = new QVBoxLayout(this); lay2 = new QHBoxLayout(); i=-1; break; } //setup Layouts this->setLayout(lay1); lay1->addLayout(lay2); lay2->stretch(true); lay2->addWidget(m_ToggleAddPoint); lay2->addWidget(m_AddPoint); lay2->addWidget(m_RemovePointBtn); lay2->addWidget(m_MovePointUpBtn); lay2->addWidget(m_MovePointDownBtn); lay2->addWidget(m_SavePointsBtn); lay2->addWidget(m_LoadPointsBtn); - - //lay2->addSpacing();; - lay1->insertWidget(i,m_PointListView); this->setLayout(lay1); } void QmitkPointListWidget::SetPointSet(mitk::PointSet* newPs) { if(newPs == NULL) return; this->m_PointSetNode->SetData(newPs); dynamic_cast(this->m_PointListView->model())->SetPointSetNode(m_PointSetNode); ObserveNewNode(m_PointSetNode); } void QmitkPointListWidget::SetPointSetNode(mitk::DataNode *newNode) { if (m_DataInteractor.IsNotNull()) m_DataInteractor->SetDataNode(newNode); ObserveNewNode(newNode); dynamic_cast(this->m_PointListView->model())->SetPointSetNode(newNode); } void QmitkPointListWidget::OnBtnSavePoints() { if ((dynamic_cast(m_PointSetNode->GetData())) == NULL) return; // don't write empty point sets. If application logic requires something else then do something else. if ((dynamic_cast(m_PointSetNode->GetData()))->GetSize() == 0) return; // let the user choose a file std::string name(""); - QString fileNameProposal = QString("/PointSet.mps");//.arg(m_PointSetNode->GetName().c_str()); //"PointSet.mps"; + QString fileNameProposal = QString("/PointSet.mps"); QString aFilename = QFileDialog::getSaveFileName( NULL, "Save point set", QDir::currentPath() + fileNameProposal, "MITK Pointset (*.mps)" ); if ( aFilename.isEmpty() ) return; try { // instantiate the writer and add the point-sets to write mitk::PointSetWriter::Pointer writer = mitk::PointSetWriter::New(); writer->SetInput( dynamic_cast(m_PointSetNode->GetData()) ); writer->SetFileName( aFilename.toLatin1() ); writer->Update(); } catch(...) { QMessageBox::warning( this, "Save point set", QString("File writer reported problems writing %1\n\n" "PLEASE CHECK output file!").arg(aFilename) ); } } void QmitkPointListWidget::OnBtnLoadPoints() { // get the name of the file to load QString filename = QFileDialog::getOpenFileName( NULL, "Open MITK Pointset", "", "MITK Point Sets (*.mps)"); if ( filename.isEmpty() ) return; // attempt to load file try { mitk::PointSetReader::Pointer reader = mitk::PointSetReader::New(); reader->SetFileName( filename.toLatin1() ); reader->Update(); mitk::PointSet::Pointer pointSet = reader->GetOutput(); if ( pointSet.IsNull() ) { QMessageBox::warning( this, "Load point set", QString("File reader could not read %1").arg(filename) ); return; } // loading successful - // bool interactionOn( m_Interactor.IsNotNull() ); - // if (interactionOn) - // { - // OnEditPointSetButtonToggled(false); - // } - // this->SetPointSet(pointSet); - // if (interactionOn) - // { - // OnEditPointSetButtonToggled(true); - // } } catch(...) { QMessageBox::warning( this, "Load point set", QString("File reader collapsed while reading %1").arg(filename) ); } emit PointListChanged(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } mitk::PointSet* QmitkPointListWidget::GetPointSet() { return dynamic_cast(m_PointSetNode->GetData()); } mitk::DataNode* QmitkPointListWidget::GetPointSetNode() { return m_PointSetNode; } void QmitkPointListWidget::SetMultiWidget(QmitkStdMultiWidget *multiWidget) { this->m_MultiWidget = multiWidget; m_PointListView->SetMultiWidget(multiWidget); } void QmitkPointListWidget::RemoveSelectedPoint() { if (!m_PointSetNode) return; mitk::PointSet* pointSet = dynamic_cast( m_PointSetNode->GetData() ); if (!pointSet) return; if (pointSet->GetSize() == 0) return; QmitkPointListModel* pointListModel = dynamic_cast( m_PointListView->model() ); pointListModel->RemoveSelectedPoint(); emit PointListChanged(); } void QmitkPointListWidget::MoveSelectedPointDown() { if (!m_PointSetNode) return; mitk::PointSet* pointSet = dynamic_cast( m_PointSetNode->GetData() ); if (!pointSet) return; if (pointSet->GetSize() == 0) return; QmitkPointListModel* pointListModel = dynamic_cast( m_PointListView->model() ); pointListModel->MoveSelectedPointDown(); emit PointListChanged(); } void QmitkPointListWidget::MoveSelectedPointUp() { if (!m_PointSetNode) return; mitk::PointSet* pointSet = dynamic_cast( m_PointSetNode->GetData() ); if (!pointSet) return; if (pointSet->GetSize() == 0) return; QmitkPointListModel* pointListModel = dynamic_cast( m_PointListView->model() ); pointListModel->MoveSelectedPointUp(); emit PointListChanged(); } void QmitkPointListWidget::OnBtnAddPoint(bool checked) { if (m_PointSetNode.IsNotNull()) { if (checked) { m_DataInteractor = m_PointSetNode->GetDataInteractor(); // If no data Interactor is present create a new one if (m_DataInteractor.IsNull()) { // Create PointSetData Interactor m_DataInteractor = mitk::PointSetDataInteractor::New(); // Load the according state machine for regular point set interaction m_DataInteractor->LoadStateMachine("PointSet.xml"); // Set the configuration file that defines the triggers for the transitions m_DataInteractor->SetEventConfig("PointSetConfig.xml"); // set the DataNode (which already is added to the DataStorage m_DataInteractor->SetDataNode(m_PointSetNode); } } else { m_PointSetNode->SetDataInteractor(NULL); m_DataInteractor=NULL; } emit EditPointSets(checked); } } void QmitkPointListWidget::OnBtnAddPointManually() { mitk::PointSet* pointSet = this->GetPointSet(); int currentPosition = pointSet->GetSize(); QmitkEditPointDialog editPointDialog(this); editPointDialog.SetPoint(pointSet, currentPosition, m_TimeStep); editPointDialog.exec(); } void QmitkPointListWidget::OnListDoubleClick() { - ; } void QmitkPointListWidget::OnPointSelectionChanged() { emit this->PointSelectionChanged(); } -void QmitkPointListWidget::DeactivateInteractor(bool /*deactivate*/) +void QmitkPointListWidget::DeactivateInteractor(bool) { - ; } -void QmitkPointListWidget::EnableEditButton( bool enabled ) +void QmitkPointListWidget::EnableEditButton(bool enabled) { m_EditAllowed = enabled; if (enabled == false) m_ToggleAddPoint->setEnabled(false); else m_ToggleAddPoint->setEnabled(true); OnBtnAddPoint(enabled); } -void QmitkPointListWidget::ObserveNewNode( mitk::DataNode* node ) +void QmitkPointListWidget::ObserveNewNode(mitk::DataNode* node) { if (m_DataInteractor.IsNotNull()) m_DataInteractor->SetDataNode(node); // remove old observer if ( m_PointSetNode ) { if (m_DataInteractor) { m_DataInteractor = NULL; m_ToggleAddPoint->setChecked( false ); } m_PointSetNode->RemoveObserver(m_NodeObserverTag); m_NodeObserverTag = 0; } m_PointSetNode = node; // add new observer if necessary if ( m_PointSetNode ) { itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction( this, &QmitkPointListWidget::OnNodeDeleted ); m_NodeObserverTag = m_PointSetNode->AddObserver( itk::DeleteEvent(), command ); - - - } else { m_NodeObserverTag = 0; } - - if (m_EditAllowed == true) m_ToggleAddPoint->setEnabled( m_PointSetNode ); else m_ToggleAddPoint->setEnabled( false ); m_RemovePointBtn->setEnabled( m_PointSetNode ); m_LoadPointsBtn->setEnabled( m_PointSetNode ); m_SavePointsBtn->setEnabled(m_PointSetNode); m_AddPoint->setEnabled(m_PointSetNode); } -void QmitkPointListWidget::OnNodeDeleted( const itk::EventObject & /*e*/ ) +void QmitkPointListWidget::OnNodeDeleted(const itk::EventObject&) { if(m_PointSetNode.IsNotNull() && ! m_NodeObserverTag) m_PointSetNode->RemoveObserver( m_NodeObserverTag ); m_NodeObserverTag = 0; m_PointSetNode = NULL; m_PointListView->SetPointSetNode(NULL); m_ToggleAddPoint->setEnabled(false); m_RemovePointBtn->setEnabled( false ); m_LoadPointsBtn->setEnabled( false ); m_SavePointsBtn->setEnabled(false); m_AddPoint->setEnabled(false); } void QmitkPointListWidget::SetSnc1(mitk::SliceNavigationController* snc) { if (snc == NULL) { m_PointListView->RemoveSliceNavigationController(m_Snc1); } else { m_PointListView->AddSliceNavigationController(snc); } m_Snc1 = snc; } void QmitkPointListWidget::SetSnc2(mitk::SliceNavigationController* snc) { if (snc == NULL) { m_PointListView->RemoveSliceNavigationController(m_Snc2); } else { m_PointListView->AddSliceNavigationController(snc); } m_Snc2 = snc; } void QmitkPointListWidget::SetSnc3(mitk::SliceNavigationController* snc) { if (snc == NULL) { m_PointListView->RemoveSliceNavigationController(m_Snc3); } else { m_PointListView->AddSliceNavigationController(snc); } m_Snc3 = snc; } void QmitkPointListWidget::AddSliceNavigationController(mitk::SliceNavigationController* snc) { m_PointListView->AddSliceNavigationController(snc); } void QmitkPointListWidget::RemoveSliceNavigationController(mitk::SliceNavigationController* snc) { m_PointListView->RemoveSliceNavigationController(snc); } void QmitkPointListWidget::UnselectEditButton() { m_ToggleAddPoint->setChecked(false); } + diff --git a/Modules/QtWidgetsExt/QmitkPointListWidget.h b/Modules/QtWidgetsExt/QmitkPointListWidget.h index f9cd005dc6..87740ae948 100644 --- a/Modules/QtWidgetsExt/QmitkPointListWidget.h +++ b/Modules/QtWidgetsExt/QmitkPointListWidget.h @@ -1,171 +1,172 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPointListWidget_H #define QmitkPointListWidget_H #include #include #include "MitkQtWidgetsExtExports.h" #include #include #include #include #include #include #include /*! * \brief Widget for regular operations on point sets * * Displays a list of point coordinates and a couple of * buttons which * * \li enable point set interaction * \li clear all points from a set * \li load points from file * \li save points to file * * The user/application module of this widget needs to * assign a mitk::PointSet object to this widget. The user * also has to decide whether it wants to put the point set * into (a) DataStorage. This widget will not add/remove * point sets to DataStorage. * * If the render window crosshair should be moved to the * currently selected point, the widget user has to provide * a QmitkStdMultiWidget object. */ class MitkQtWidgetsExt_EXPORT QmitkPointListWidget : public QWidget { Q_OBJECT public: QmitkPointListWidget(QWidget *parent = 0, int orientation = 0); ~QmitkPointListWidget(); void SetupConnections(); ///@{ /** * \brief Sets the SliceNavigationController of the three 2D Renderwindows. * If they are defined, they can be used to automatically set the crosshair to the selected point * \deprecatedSince{2013_03} Use AddSliceNavigationController and RemoveSliceNavigationController instead. */ DEPRECATED( void SetSnc1(mitk::SliceNavigationController* snc) ); DEPRECATED( void SetSnc2(mitk::SliceNavigationController* snc) ); DEPRECATED( void SetSnc3(mitk::SliceNavigationController* snc) ); ///@} /** * @brief Add a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method adds \c snc to the set of slice navigation controllers which are * used to navigate to the selected point. */ void AddSliceNavigationController(mitk::SliceNavigationController* snc); /** * @brief Remove a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method removes \c snc from the set of slice navigation controllers which are * used to navigate to the selected point. */ void RemoveSliceNavigationController(mitk::SliceNavigationController* snc); /** @brief assign a point set (contained in a node of DataStorage) for observation */ void SetPointSet(mitk::PointSet* newPs); mitk::PointSet* GetPointSet(); /** @brief assign a point set (contained in a node of DataStorage) for observation */ void SetPointSetNode(mitk::DataNode* newNode); mitk::DataNode* GetPointSetNode(); /** @brief assign a QmitkStdMultiWidget for updating render window crosshair */ void SetMultiWidget(QmitkStdMultiWidget* multiWidget); /** @brief itk observer for node "delete" events */ void OnNodeDeleted( const itk::EventObject & e ); /** @brief Unselects the edit button if it is selected. */ void UnselectEditButton(); public slots: void DeactivateInteractor(bool deactivate); void EnableEditButton(bool enabled); signals: /** @brief signal to inform about the state of the EditPointSetButton, whether an interactor for setting points is active or not */ void EditPointSets(bool active); /// signal to inform that the selection of a point in the pointset has changed void PointSelectionChanged(); /// signal to inform about cleared or loaded point sets void PointListChanged(); protected slots: void OnBtnSavePoints(); void OnBtnLoadPoints(); void RemoveSelectedPoint(); void MoveSelectedPointDown(); void MoveSelectedPointUp(); void OnBtnAddPoint(bool checked); void OnBtnAddPointManually(); - //void OnBtnSetPointsMode(bool checked); + /*! \brief pass through signal from PointListView that point selection has changed */ void OnPointSelectionChanged(); void OnListDoubleClick(); protected: void SetupUi(); void ObserveNewNode(mitk::DataNode* node); QmitkPointListView* m_PointListView; QmitkStdMultiWidget* m_MultiWidget; mitk::DataNode::Pointer m_PointSetNode; int m_Orientation; QPushButton* m_MovePointUpBtn; QPushButton* m_MovePointDownBtn; QPushButton* m_RemovePointBtn; QPushButton* m_SavePointsBtn; QPushButton* m_LoadPointsBtn; QPushButton* m_ToggleAddPoint; QPushButton* m_AddPoint; mitk::SliceNavigationController* m_Snc1; mitk::SliceNavigationController* m_Snc2; mitk::SliceNavigationController* m_Snc3; mitk::DataInteractor::Pointer m_DataInteractor; int m_TimeStep; bool m_EditAllowed; unsigned long m_NodeObserverTag; }; #endif + diff --git a/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.cpp b/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.cpp index 790d8b25a0..3a002c9e48 100755 --- a/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.cpp @@ -1,118 +1,118 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPrimitiveMovieNavigatorWidget.h" QmitkPrimitiveMovieNavigatorWidget::QmitkPrimitiveMovieNavigatorWidget( QWidget* parent, Qt::WindowFlags fl ) : QWidget( parent, fl ) { m_Controls.setupUi(this); // signals and slots connections connect( m_Controls.m_SpinBox, SIGNAL( valueChanged(int) ), this, SLOT( spinBoxValueChanged(int) ) ); connect( m_Controls.m_StopButton, SIGNAL( clicked() ), this, SLOT( stopButton_clicked() ) ); connect( m_Controls.m_GoButton, SIGNAL( clicked() ), this, SLOT( goButton_clicked() ) ); connect( m_Controls.m_TimerInterval, SIGNAL( valueChanged(int) ), this, SLOT( setTimerInterval(int) ) ); - //this->setupUi(parent); m_InRefetch = true; // this avoids trying to use m_Stepper until it is set to something != NULL (additionally to the avoiding recursions during refetching) m_Timer = new QTimer(this); m_TimerIntervalInMS = 120; connect(m_Timer, SIGNAL(timeout()), SLOT(next()) ); } /* * Destroys the object and frees any allocated resources */ QmitkPrimitiveMovieNavigatorWidget::~QmitkPrimitiveMovieNavigatorWidget() { // no need to delete child widgets, Qt does it all for us } void QmitkPrimitiveMovieNavigatorWidget::Refetch() { if(!m_InRefetch) { m_InRefetch=true; m_Controls.m_SpinBox->setMinimum( 0 ); m_Controls.m_SpinBox->setMaximum( m_Stepper->GetSteps()-1 ); m_Controls.m_SpinBox->setValue( m_Stepper->GetPos() ); m_InRefetch=false; } } void QmitkPrimitiveMovieNavigatorWidget::SetStepper( mitk::Stepper * stepper) { m_Stepper = stepper; m_InRefetch = (stepper==NULL); // this avoids trying to use m_Stepper until it is set to something != NULL (additionally to the avoiding recursions during refetching) } void QmitkPrimitiveMovieNavigatorWidget::goButton_clicked() { if(!m_InRefetch && m_Stepper->GetSteps() > 0) // this step shall only be used if the dataset is 3D+t. If it is not, nothing happens :-) { if(m_Timer->isActive()==false) { m_Timer->start(m_TimerIntervalInMS); } } } void QmitkPrimitiveMovieNavigatorWidget::stopButton_clicked() { m_Timer->stop(); } void QmitkPrimitiveMovieNavigatorWidget::next() { if(!m_InRefetch) { if(m_Stepper->GetPos()==m_Stepper->GetSteps()-1) m_Stepper->First(); else m_Stepper->Next(); } } void QmitkPrimitiveMovieNavigatorWidget::spinBoxValueChanged(int) { if(!m_InRefetch) { m_Stepper->SetPos( m_Controls.m_SpinBox->value() ); } } int QmitkPrimitiveMovieNavigatorWidget::getTimerInterval() { return m_TimerIntervalInMS; } void QmitkPrimitiveMovieNavigatorWidget::setTimerInterval( int timerIntervalInMS ) { if(timerIntervalInMS!=m_TimerIntervalInMS) { m_TimerIntervalInMS = timerIntervalInMS; if(m_Timer->isActive()) { m_Timer->setInterval(m_TimerIntervalInMS); } } } + diff --git a/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.h b/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.h index d123f63ed6..3519ab57ba 100755 --- a/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.h +++ b/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.h @@ -1,55 +1,56 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKPRIMITIVEMOVIENAVIGATORWIDGET_H_ #define QMITKPRIMITIVEMOVIENAVIGATORWIDGET_H_ #include #include "MitkQtWidgetsExtExports.h" #include #include -class MitkQtWidgetsExt_EXPORT QmitkPrimitiveMovieNavigatorWidget : public QWidget//, public Ui::QmitkPrimitiveMovieNavigator +class MitkQtWidgetsExt_EXPORT QmitkPrimitiveMovieNavigatorWidget : public QWidget { Q_OBJECT public: QmitkPrimitiveMovieNavigatorWidget( QWidget* parent = 0, Qt::WindowFlags fl = 0 ); ~QmitkPrimitiveMovieNavigatorWidget(); virtual int getTimerInterval(); public slots: virtual void Refetch(); virtual void SetStepper( mitk::Stepper * stepper ); virtual void goButton_clicked(); virtual void stopButton_clicked(); virtual void spinBoxValueChanged(int value); virtual void setTimerInterval( int timerIntervalInMS ); protected: Ui::QmitkPrimitiveMovieNavigator m_Controls; mitk::Stepper::Pointer m_Stepper; bool m_InRefetch; QTimer* m_Timer; int m_TimerIntervalInMS; private slots: virtual void next(); }; -#endif /* QMITKPRIMITIVEMOVIENAVIGATORWIDGET_H_ */ +#endif + diff --git a/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.ui b/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.ui index 0aaae03148..897262c16d 100755 --- a/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.ui +++ b/Modules/QtWidgetsExt/QmitkPrimitiveMovieNavigatorWidget.ui @@ -1,112 +1,112 @@ QmitkPrimitiveMovieNavigator 0 0 252 47 0 0 QmitkPrimitiveMovieNavigator 50 0 - :/qmitk/play.xpm:/qmitk/play.xpm + :/QtWidgetsExt/play.xpm:/QtWidgetsExt/play.xpm 50 0 - :/qmitk/stop.xpm:/qmitk/stop.xpm + :/QtWidgetsExt/stop.xpm:/QtWidgetsExt/stop.xpm 0 0 0 60 0 10 1000 250 Qt::Horizontal QSlider::TicksBelow 100 mitkStepper.h diff --git a/Modules/QtWidgetsExt/QmitkPropertyListPopup.cpp b/Modules/QtWidgetsExt/QmitkPropertyListPopup.cpp index 1090f7afb4..cab2ebff4a 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyListPopup.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyListPopup.cpp @@ -1,532 +1,394 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPropertyListPopup.h" #include "QmitkMaterialEditor.h" #include "QmitkNumberPropertySlider.h" #include "mitkRenderingManager.h" #include "mitkStringProperty.h" #include "mitkColorProperty.h" #include #include #include #include #include #include -/*! - Auxiliary class to provide fancy menu items with different fonts. - - Copied from the Qt example program menu/menu.cpp: - "This example program may be used, distributed and modified without limitation." - */ -//!mm,deleted: Qt4 no longer supports QCustomMenuItem -//!instead you have QAction with a lot of possibilities for fancy menu items -/* -class QFontMenuItem : public QCustomMenuItem -{ - public: - QFontMenuItem( const QString& s, const QFont& f ) - : string( s ), font( f ), color ( Qt::black ) {}; - QFontMenuItem( const QString& s, const QFont& f, const QColor& c ) - : string( s ), font( f ), color( c ) {}; - ~QFontMenuItem(){} - - void paint( QPainter* p, const QColorGroup& cg, bool act, bool enabled, int x, int y, int w, int h ) - { - p->setBackgroundMode ( Qt::OpaqueMode ); - int ha,es,vau; - color.getHsv(ha,es,vau); - if ( es < 60 && vau > 200 ) - p->setBackgroundColor ( Qt::black ); - else - p->setBackgroundColor ( Qt::white ); - p->setPen ( color ); - p->setFont ( font ); - p->drawText( x, y, w, h, AlignLeft | AlignVCenter | DontClip | ShowPrefix, string ); - } - - QSize sizeHint() - { - return QFontMetrics( font ).size( AlignLeft | AlignVCenter | ShowPrefix | DontClip, string ); - } - private: - QString string; - QFont font; - QColor color; -}; -*/ -//! - QmitkPropertyListPopup::QmitkPropertyListPopup( mitk::PropertyList* list, QObject* parent, bool disableBoolProperties, bool fillMenuImmediatelty, const char* name ) :QObject(parent, name), -//!mm -//m_PopupMenu( new Q3PopupMenu( dynamic_cast(parent), name ) ), m_PopupMenu( new QMenu( name, dynamic_cast(parent) ) ), -//! m_PropertyList(list), m_MaterialEditor(NULL), -//!mm,init QAction ptrs with 0 m_NameMenuAction(0), m_VisibleMenuAction(0), m_ColorMenuAction(0), m_MaterialMenuAction(0), m_OpacityMenuAction(0), m_AcceptOnHide(false), m_DisableBoolProperties(disableBoolProperties) -//! { if (!parent) { std::cerr << "In " __FILE__ ", l." << __LINE__ << ": popup menu without parent. This tends to crash (click 'Choose color' in the material editor)." << std::endl; } if (fillMenuImmediatelty) { fillPopup(); } connect( m_PopupMenu, SIGNAL(aboutToHide()), this, SLOT(popupAboutToHide()) ); - //!mm - //connect( m_PopupMenu, SIGNAL(highlighted(int)), this, SLOT(popupMenuItemHighlighted(int)) ); connect( m_PopupMenu, SIGNAL(hovered(int)), this, SLOT(popupMenuItemHovered(int)) ); - //! } -//!mm QIcon QmitkPropertyListPopup::createColorIcon(QColor color) { QPixmap pixmap(20, 20); QPainter painter(&pixmap); painter.setPen(Qt::NoPen); painter.fillRect(QRect(0, 0, 20, 20), color); return QIcon(pixmap); } -//! void QmitkPropertyListPopup::fillPopup() { if (m_PropertyList.IsNotNull()) { - //!mm - //m_PopupMenu->setCheckable(true); // in general, there could are some checkable items in this menu - //! - // color mitk::ColorProperty* colorProperty = dynamic_cast( m_PropertyList->GetProperty("color")); if (colorProperty) { mitk::Color col = colorProperty->GetColor(); QColor currentColor((int)(col.GetRed() * 255), (int)(col.GetGreen() * 255), (int)(col.GetBlue() * 255)); QFont normalFont; normalFont.setBold(true); - //!mm - //m_ColorMenuID = m_PopupMenu->insertItem( new QFontMenuItem("Color...", normalFont, currentColor ) ); - //m_PopupMenu->connectItem( m_ColorMenuID, this, SLOT(onColorClicked()) ); - //m_PopupMenu->setItemEnabled( m_ColorMenuID, true ); m_ColorMenuAction = new QAction(this->createColorIcon(currentColor), QString("Color..."), this); m_ColorMenuAction->setFont(normalFont); m_PopupMenu->addAction(m_ColorMenuAction); m_ColorMenuAction->setEnabled(true); connect( m_ColorMenuAction, SIGNAL(triggered()), this, SLOT(onColorClicked()) ); - //! } else { - //!mm - //m_ColorMenuAction = m_PopupMenu->insertItem( "Color..." ); - //m_PopupMenu->setItemEnabled( m_ColorMenuAction, false ); m_ColorMenuAction = new QAction(QString("Color..."), this); m_PopupMenu->addAction(m_ColorMenuAction); m_ColorMenuAction->setEnabled(true); - //! } if ( !AddMaterialPopup() ) { - //!mm - //m_MaterialMenuAction = m_PopupMenu->insertItem("Material"); - //m_PopupMenu->setItemEnabled( m_MaterialMenuAction, false ); m_MaterialMenuAction = new QAction(QString("Material"), this); m_PopupMenu->addAction(m_MaterialMenuAction); m_MaterialMenuAction->setEnabled(false); - //! } // opacity if ( mitk::FloatProperty* opacityProperty = dynamic_cast( m_PropertyList->GetProperty("opacity"))) { m_OriginalOpacity = mitk::FloatProperty::New( opacityProperty->GetValue() ); - //!mm - //Q3PopupMenu* opacityPopup = new Q3PopupMenu( m_PopupMenu ); QMenu* opacityPopup = m_PopupMenu->addMenu("Opacity"); - //! QmitkNumberPropertySlider* npe = new QmitkNumberPropertySlider( opacityProperty, opacityPopup ); npe->setShowPercent(true); npe->setMinValue(0); npe->setMaxValue(1); - //!mm - //opacityPopup->insertItem( npe ); - //m_OpacityMenuAction = m_PopupMenu->insertItem("Opacity", opacityPopup); - //m_PopupMenu->setItemEnabled( m_OpacityMenuAction, true ); QWidgetAction* opacityMenuAction = new QWidgetAction(opacityPopup); opacityMenuAction->setDefaultWidget(npe); m_OpacityMenuAction = opacityMenuAction; opacityPopup->addAction(m_OpacityMenuAction); m_OpacityMenuAction->setEnabled(true); - //! } else { - //!mm - //m_OpacityMenuAction = m_PopupMenu->insertItem("Opacity"); - //m_PopupMenu->setItemEnabled( m_OpacityMenuAction, false ); m_OpacityMenuAction = new QAction(QString("Opacity"), this); m_PopupMenu->addAction(m_OpacityMenuAction); m_OpacityMenuAction->setEnabled(true); - //! } - // Build up a "name" entry. On click, call onNameChangeClicked. - //!mm - //m_NameMenuAction = m_PopupMenu->insertItem("Name..."); - //mitk::StringProperty* nameProperty = dynamic_cast( m_PropertyList->GetProperty("name")); - //m_PopupMenu->setItemEnabled( m_NameMenuAction, nameProperty != NULL ); - //if (nameProperty) - //{ - //m_PopupMenu->connectItem( m_NameMenuAction, this, SLOT(onNameClicked()) ); - //} m_NameMenuAction = new QAction(QString("Name..."), this); m_PopupMenu->addAction(m_NameMenuAction); mitk::StringProperty* nameProperty = dynamic_cast( m_PropertyList->GetProperty("name")); m_NameMenuAction->setEnabled(nameProperty != NULL); if (nameProperty) { connect( m_NameMenuAction, SIGNAL(triggered()), this, SLOT(onNameClicked()) ); } - //! - - - // Build up a checkable "visible" entry. On click, call onVisibleChanged. - //!m - //m_VisibleMenuAction = m_PopupMenu->insertItem("Visibility"); - //mitk::BoolProperty* visibleProperty = dynamic_cast( m_PropertyList->GetProperty("visible")); - //m_PopupMenu->setItemEnabled( m_VisibleMenuAction, visibleProperty != NULL ); - //if (visibleProperty) - //{ - //m_PopupMenu->setItemChecked( m_VisibleMenuAction, visibleProperty->GetValue() ); - //m_PopupMenu->connectItem( m_VisibleMenuAction, this, SLOT(onVisibleClicked()) ); - //} + m_VisibleMenuAction = new QAction(QString("Visibility"), this); m_VisibleMenuAction->setCheckable(true); m_PopupMenu->addAction(m_VisibleMenuAction); mitk::BoolProperty* visibleProperty = dynamic_cast( m_PropertyList->GetProperty("visible")); m_VisibleMenuAction->setEnabled( visibleProperty != NULL ); if (visibleProperty) { m_VisibleMenuAction->setChecked( visibleProperty->GetValue() ); connect( m_VisibleMenuAction, SIGNAL(triggered()), this, SLOT(onVisibleClicked()) ); } - //! // other properties, "information" const mitk::PropertyList::PropertyMap* map = m_PropertyList->GetMap(); if (map) { - // build a sub-menu with all properties shown - //!mm - //m_InfoPopup = new Q3PopupMenu( m_PopupMenu ); - //m_InfoPopup->setCheckable(true); // bool properties are checked - //m_PopupMenu->insertItem("Information", m_InfoPopup); - - //m_PopupMenu->insertSeparator(); m_InfoPopup = m_PopupMenu->addMenu("Information"); - //m_InfoPopup->setCheckable(true); // bool properties are checked m_PopupMenu->addSeparator(); - //! QFont boldFont = m_PopupMenu->font(); boldFont.setBold( true ); // first all bool properties for ( mitk::PropertyList::PropertyMap::const_iterator propertyIter = map->begin(); propertyIter != map->end(); ++propertyIter ) { std::string name = propertyIter->first; if (name == "visible") continue; // we already display that above if ( mitk::BoolProperty* boolProperty = dynamic_cast(propertyIter->second.first.GetPointer()) ) { // fill a vector (int -> smartpointer(boolprop)) for reacting to clicks on checked items m_BoolProperties.push_back( boolProperty ); int newID = m_PopupMenu->insertItem( QString("%1").arg( name.c_str()) ); m_PopupMenu->setItemChecked( newID, boolProperty->GetValue() ); m_PopupMenu->setItemParameter( newID, m_BoolProperties.size() ); m_PopupMenu->connectItem( newID, this, SLOT(onBoolPropertyClicked(int)) ); if (m_DisableBoolProperties ) { m_PopupMenu->setItemEnabled( newID, false ); } } } boldFont = m_InfoPopup->font(); // then all non-bool properties for ( mitk::PropertyList::PropertyMap::const_iterator propertyIter = map->begin(); propertyIter != map->end(); ++propertyIter ) { std::string name = propertyIter->first; if ( !dynamic_cast(propertyIter->second.first.GetPointer()) ) { std::string value("no value"); mitk::BaseProperty::Pointer bp = propertyIter->second.first; if ( bp.IsNotNull() ) { value = bp->GetValueAsString(); } m_InfoPopup->insertItem( QString("%1: %2").arg( name.c_str()).arg(value.c_str()) ); } } } } } bool QmitkPropertyListPopup::AddMaterialPopup() { // normal material if ( mitk::MaterialProperty* materialProperty = dynamic_cast( m_PropertyList->GetProperty("material"))) // normal "material" { m_OriginalMaterial = mitk::MaterialProperty::New( *materialProperty ); - //!mm - //Q3PopupMenu* materialPopup = new Q3PopupMenu( m_PopupMenu ); QMenu* materialPopup = new QMenu( m_PopupMenu ); - //! m_MaterialEditor = new QmitkMaterialEditor( m_PopupMenu ); m_MaterialEditor->setInline(true); // important to call this first :( m_MaterialEditor->Initialize( materialProperty ); - //!mm - //materialPopup->insertItem( m_MaterialEditor ); // setting QDialog as menu item with Qt4 QWidgetAction QWidgetAction* materialEditorMenuItem = new QWidgetAction(materialPopup); materialEditorMenuItem->setDefaultWidget(m_MaterialEditor); materialPopup->addAction(materialEditorMenuItem); - //! connect( m_MaterialEditor, SIGNAL(ChangesAccepted(QmitkMaterialEditor*)), this, SLOT(MaterialEditorChangesAccepted(QmitkMaterialEditor*)) ); - //!mm - //m_MaterialMenuAction = m_PopupMenu->insertItem("Material", materialPopup); - //m_PopupMenu->setItemEnabled( m_MaterialMenuAction, true ); m_MaterialMenuAction = new QAction(QString("Material"), materialPopup); materialPopup->addAction(m_OpacityMenuAction); m_OpacityMenuAction->setEnabled(true); - //! return true; } return false; } QmitkPropertyListPopup::~QmitkPropertyListPopup() { delete m_MaterialEditor; } -//!mm -//void QmitkPropertyListPopup::popup( const QPoint& pos, int indexAtPoint ) -//{ -// m_PopupMenu->exec(pos, indexAtPoint); -//} -void QmitkPropertyListPopup::popup( const QPoint& pos, QAction* action /*= 0 */ ) +void QmitkPropertyListPopup::popup( const QPoint& pos, QAction* action) { m_PopupMenu->exec(pos, action); } -//! void QmitkPropertyListPopup::onNameClicked() { mitk::StringProperty* nameProperty = dynamic_cast( m_PropertyList->GetProperty("name")); if (nameProperty) { bool ok; QString newName = QInputDialog::getText( tr("Change object name"), QString(tr("Enter a new name for \"%1\"")).arg(nameProperty->GetValue()), QLineEdit::Normal, QString(nameProperty->GetValue()), &ok, m_PopupMenu ); if ( ok && !newName.isEmpty() ) { // user entered something and pressed OK nameProperty->SetValue( newName.ascii() ); nameProperty->Modified(); emit propertyListChangesDone(); } else if (ok) { // user entered nothing or pressed Cancel if ( QMessageBox::question( m_PopupMenu, tr("Change object name"), tr("Do you really want to assign an empty name to '%1'?").arg( nameProperty->GetValue() ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { // ok, this user is sure, we assign "" as a name nameProperty->SetValue( newName.ascii() ); nameProperty->Modified(); emit propertyListChangesDone(); } } } } void QmitkPropertyListPopup::onVisibleClicked() { - //!mm - //m_PopupMenu->setItemChecked( m_VisibleMenuAction, !m_PopupMenu->isItemChecked(m_VisibleMenuAction) ); m_VisibleMenuAction->setChecked(m_VisibleMenuAction->isChecked()); - //! mitk::BoolProperty* visibleProperty = dynamic_cast( m_PropertyList->GetProperty("visible")); if (visibleProperty) { - //!mm - //visibleProperty->SetValue( m_PopupMenu->isItemChecked( m_VisibleMenuAction ) ); visibleProperty->SetValue( m_VisibleMenuAction->isChecked() ); - //! visibleProperty->Modified(); // quite stupid that this is not done in SetValue() to inform observers mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit propertyListChangesDone(); } } void QmitkPropertyListPopup::onColorClicked() { mitk::ColorProperty* colorProperty = dynamic_cast( m_PropertyList->GetProperty("color")); if (colorProperty) { mitk::Color col = colorProperty->GetColor(); QColor result = QColorDialog::getColor(QColor((int)(col.GetRed() * 255), (int)(col.GetGreen() * 255), (int)(col.GetBlue() * 255))); if (result.isValid()) { col.SetRed(result.red() / 255.0); col.SetGreen(result.green() / 255.0); col.SetBlue(result.blue() / 255.0); colorProperty->SetColor(col); colorProperty->Modified(); // quite stupid that this is not done in SetColor() to inform observers } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit propertyListChangesDone(); } } void QmitkPropertyListPopup::onBoolPropertyClicked(int param) { int item = m_PopupMenu->idAt(param+6); // plus number of items before all the boolean properties (excluding separator) bool on( !m_PopupMenu->isItemChecked(item) ); m_PopupMenu->setItemChecked( item, on ); // toggle try { mitk::BoolProperty* boolProperty = m_BoolProperties.at( param-1 ); if (boolProperty) { boolProperty->SetValue( on ); boolProperty->Modified(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit propertyListChangesDone(); } } catch(...) { // strange } } -void QmitkPropertyListPopup::MaterialEditorChangesAccepted(QmitkMaterialEditor* /*ed*/) +void QmitkPropertyListPopup::MaterialEditorChangesAccepted(QmitkMaterialEditor*) { } void QmitkPropertyListPopup::popupAboutToHide() { if (!m_AcceptOnHide) return; bool changes(false); UpdateNodeMaterialOnPopupHiding( changes ); mitk::FloatProperty* opacity = dynamic_cast( m_PropertyList->GetProperty("opacity")); if (opacity) { if ( !(*opacity == *m_OriginalOpacity) ) { changes = true; } } if (changes) { emit propertyListChangesDone(); } } -//!mm -//void QmitkPropertyListPopup::popupMenuItemHighlighted(int id) void QmitkPropertyListPopup::popupMenuItemHovered( QAction* action ) { if ( action == m_OpacityMenuAction || action == m_MaterialMenuAction ) { m_AcceptOnHide = true; } else { m_AcceptOnHide = false; } } void QmitkPropertyListPopup::UpdateNodeMaterialOnPopupHiding( bool& changes ) { mitk::MaterialProperty* material = dynamic_cast( m_PropertyList->GetProperty("material")); if (material) { mitk::DataNode* node = material->GetDataNode(); material->SetDataNode(NULL); m_OriginalMaterial->SetDataNode(NULL); if ( !(*material == *m_OriginalMaterial) ) { changes = true; } material->SetDataNode(node); } } diff --git a/Modules/QtWidgetsExt/QmitkPropertyListPopup.h b/Modules/QtWidgetsExt/QmitkPropertyListPopup.h index c5ed2039ab..d2ed70296a 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyListPopup.h +++ b/Modules/QtWidgetsExt/QmitkPropertyListPopup.h @@ -1,125 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPropertyListPopuph_included_dingeling #define QmitkPropertyListPopuph_included_dingeling -//!mm,update: QPopupMenu is deprecated, use QtMenu in Qt4 -//#include #include "MitkQtWidgetsExtExports.h" #include -//! - -//#include "QmitkMaterialEditor.h" // by Max -//#include "mitkMaterialProperty.h" #include "mitkPropertyList.h" #include "mitkProperties.h" class QmitkMaterialEditor; /*! \class QmitkPropertyListPopUp @ingroup Widgets @ingroup ToolManagerEtAl @ingroup Visualization \brief Displays the properties from a mitk::PropertyList. This widget gets a mitk::PropertyList in its constructor, changes its elements like "color", "visible", "material" etc. When all changes are done successfully, clients are notified by the signal propertyListChangesDone. */ class MitkQtWidgetsExt_EXPORT QmitkPropertyListPopup : public QObject { Q_OBJECT public: QmitkPropertyListPopup( mitk::PropertyList*, QObject* parent = 0, bool disableBoolProperties = false, bool fillMenuImmediatelty = true, const char* name = 0 ); virtual ~QmitkPropertyListPopup(); - //!mm - //void popup( const QPoint& pos, int indexAtPoint = -1 ); void popup( const QPoint& pos, QAction* action = 0 ); - //! void fillPopup(); signals: void propertyListChangesDone(); protected slots: void onNameClicked(); void onVisibleClicked(); void onColorClicked(); void onBoolPropertyClicked(int); virtual void MaterialEditorChangesAccepted(QmitkMaterialEditor* ed); virtual void popupAboutToHide(); - //!mm - //void popupMenuItemHighlighted(int id); void popupMenuItemHovered(QAction* action); - //! protected: virtual bool AddMaterialPopup(); virtual void UpdateNodeMaterialOnPopupHiding( bool& changes ); - //!mm QIcon createColorIcon(QColor color); - //! - //!mm,update: QPopupMenu is deprecated, use QtMenu in Qt4 - //Q3PopupMenu* m_PopupMenu; QMenu* m_PopupMenu; - //! mitk::PropertyList::Pointer m_PropertyList; std::vector m_BoolProperties; - - //!mm,update: QPopupMenu is deprecated, use QtMenu in Qt4 - //Q3PopupMenu* m_PopupMenu; QMenu* m_InfoPopup; - //! - - // QmitkMaterialEditor* m_MaterialEditor; - //!mm - //int m_NameMenuID; - //int m_VisibleMenuID; - //int m_ColorMenuID; - //int m_MaterialMenuID; - //int m_OpacityMenuID; QAction* m_NameMenuAction; QAction* m_VisibleMenuAction; QAction* m_ColorMenuAction; QAction* m_MaterialMenuAction; QAction* m_OpacityMenuAction; - //! bool m_AcceptOnHide; -// mitk::MaterialProperty::Pointer m_OriginalMaterial; mitk::FloatProperty::Pointer m_OriginalOpacity; bool m_DisableBoolProperties; }; #endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkBoolPropertyWidget.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkBoolPropertyWidget.cpp index eb167940a7..1f0f6ed07e 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkBoolPropertyWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkBoolPropertyWidget.cpp @@ -1,112 +1,111 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkBoolPropertyWidget.h" #include class _BoolPropertyWidgetImpl : public mitk::PropertyEditor { public: _BoolPropertyWidgetImpl(mitk::BoolProperty* property, QCheckBox* checkBox) : PropertyEditor(property), m_BoolProperty(property), m_CheckBox(checkBox) { } virtual void PropertyChanged() { if ( m_Property ) m_CheckBox->setChecked( m_BoolProperty->GetValue() ); } virtual void PropertyRemoved() { m_Property = NULL; m_BoolProperty = NULL; // display "no certain value" m_CheckBox->blockSignals(true); m_CheckBox->setTristate(true); m_CheckBox->setCheckState(Qt::PartiallyChecked); m_CheckBox->setEnabled(false); m_CheckBox->blockSignals(false); } void ValueChanged(bool value) { this->BeginModifyProperty(); // deregister from events m_BoolProperty->SetValue(value); this->EndModifyProperty(); // again register for events } protected: mitk::BoolProperty* m_BoolProperty; QCheckBox* m_CheckBox; }; QmitkBoolPropertyWidget::QmitkBoolPropertyWidget(QWidget* parent ) : QCheckBox(parent), m_PropEditorImpl(0) { setEnabled(false); connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggle(bool))); } QmitkBoolPropertyWidget::QmitkBoolPropertyWidget(const QString& text, QWidget* parent ) : QCheckBox(text, parent ), m_PropEditorImpl(0) { setEnabled( false ); connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggle(bool))); } QmitkBoolPropertyWidget::~QmitkBoolPropertyWidget() { delete m_PropEditorImpl; } void QmitkBoolPropertyWidget::SetProperty(mitk::BoolProperty* property) { if (m_PropEditorImpl) { delete m_PropEditorImpl; m_PropEditorImpl = 0; } if (!property) { setTristate(true); setCheckState(Qt::PartiallyChecked); setEnabled(false); return; } setEnabled(true); m_PropEditorImpl = new _BoolPropertyWidgetImpl(property, this); m_PropEditorImpl->PropertyChanged(); } void QmitkBoolPropertyWidget::onToggle(bool on) { if (m_PropEditorImpl) { m_PropEditorImpl->ValueChanged(on); } } - diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyEditor.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyEditor.cpp index 1e430ccdbe..27da658354 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyEditor.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyEditor.cpp @@ -1,299 +1,296 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkColorPropertyEditor.h" #include #include #include #include #include #include #include //----- QmitkPopupColorChooser --------------------------------------------------------- QmitkPopupColorChooser::QmitkPopupColorChooser(QWidget* parent, unsigned int steps, unsigned int size) : QFrame (parent, Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool | Qt::X11BypassWindowManagerHint), my_parent(parent) { setSteps(steps); setLineWidth(2); setMouseTracking ( TRUE ); - //setMargin(0); - //setAutoMask( FALSE ); setFrameStyle ( QFrame::Panel | QFrame::Raised ); setLineWidth( 1 ); ensurePolished(); resize(size, size); hide(); } QmitkPopupColorChooser::~QmitkPopupColorChooser() { } void QmitkPopupColorChooser::setSteps(int steps) { m_Steps = steps; m_Steps2 = m_Steps / 2; m_HStep = 360 / m_Steps; m_SStep = 512 / m_Steps; m_VStep = 512 / m_Steps; } void QmitkPopupColorChooser::keyReleaseEvent(QKeyEvent*) { emit colorSelected( m_OriginalColor ); close(); } void QmitkPopupColorChooser::mouseMoveEvent (QMouseEvent* e) { double x(e->pos().x()); double y(e->pos().y()); x /= width(); if ( x >= 0.0 ) { - //x = (int)(x / (1.0/m_Steps)) * (1.0/m_Steps); // div stepsize * stepsize - x = (int)(x * (float)(m_Steps-1)) / (float)(m_Steps-1); // same as above + x = (int)(x * (float)(m_Steps-1)) / (float)(m_Steps-1); if (x > 1.0) x = 1.0; if (x < 0.0) x = 0.0; } y /= height(); if (y >= 1.0) y = 0.9; if (y < 0.0) y = 0.0; y = (int)(y * (float)m_Steps) / (float)m_Steps; m_H = static_cast( y * 359.0 ); if ( x >= 0.5 ) { m_S = static_cast( (1.0 - x) * 511.0 ); if ( m_S > 255 ) m_S = 255; m_V = 255; } else { m_S = 255; if ( x < 0.0 ) m_V = 0; else { m_V = static_cast( x * 511.0 + 511.0 / (float)(m_Steps-1) ); if ( m_V > 255 ) m_V = 255; } } QColor color; color.setHsv(m_H, m_S, m_V); emit colorSelected( color ); } void QmitkPopupColorChooser::mouseReleaseEvent (QMouseEvent*) { close (); } void QmitkPopupColorChooser::closeEvent (QCloseEvent*e) { e->accept (); releaseKeyboard(); releaseMouse(); if (!m_popupParent) return; // remember that we (as a popup) might recieve the mouse release // event instead of the popupParent. This is due to the fact that // the popupParent popped us up in its mousePressEvent handler. To // avoid the button remaining in pressed state we simply send a // faked mouse button release event to it. // Maleike: parent should not pop us on MouseRelease! QMouseEvent me( QEvent::MouseButtonRelease, QPoint(0,0), QPoint(0,0), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); QApplication::sendEvent ( m_popupParent, &me ); } void QmitkPopupColorChooser::popup(QWidget* parent, const QPoint& point, const mitk::Color* color) { m_popupParent = parent; if (m_popupParent) { QPoint newPos; if (color) { QColor qcolor( (int)((*color)[0] * 255.0) , (int)((*color)[1] * 255.0) , (int)((*color)[2] * 255.0) ); int h,s,v; qcolor.getHsv(&h, &s, &v); if ( h == -1 ) // set by Qt if color is achromatic ( but this widget does not display grays ) h = 10; // red int x, y; float cellwidth = (float)width() / (float)(m_Steps); if ( s > v ) // restrict to the colors we can display { // left side, ramp from v = 255/m_Steps to v = 255 s = 255; x = (int)( ( ((float)v / 255.0) * ((float)m_Steps2) - 1.0 ) * cellwidth + cellwidth/2 ); } else { v = 255; x = (int)( ( (1.0 - ((float)s / 255.0)) * ((float)m_Steps2) ) * cellwidth + cellwidth/2 + width() / 2 ); } y = (int)( (float)h/360.0 * (float)m_Steps * cellwidth ); m_OriginalColor.setHsv(h,s,v); // move to color newPos.setX( point.x() - x ); newPos.setY( point.y() - y ); } else { // center widget m_OriginalColor.setHsv(-1, 0, 0); newPos.setX( point.x() - width() / 2 ); newPos.setY( point.y() - height() / 2 ); } move ( m_popupParent->mapToGlobal( newPos ) ); } show(); raise(); grabMouse(); grabKeyboard(); } void QmitkPopupColorChooser::paintEvent(QPaintEvent*) { QPainter painter(this); drawGradient( &painter ); } void QmitkPopupColorChooser::drawGradient( QPainter* p) { p->setWindow( 0, 0, m_Steps-1, m_Steps ); // defines coordinate system p->setPen( Qt::NoPen ); QColor c; for ( unsigned int h = 0; h < m_Steps; ++h ) { for ( unsigned int v = 1; v < m_Steps2; ++v ) { c.setHsv( h*m_HStep, 255, v*m_VStep ); // rainbow effect p->setBrush( c ); // solid fill with color c p->drawRect( v-1, h, m_Steps2, m_Steps ); // draw the rectangle } for ( unsigned int s = 0; s < m_Steps2; ++s ) { c.setHsv( h*m_HStep, 255 - s*m_SStep, 255 ); // rainbow effect p->setBrush( c ); // solid fill with color c p->drawRect( m_Steps2+s-1, h, m_Steps2, m_Steps ); // draw the rectangle } } } //----- QmitkColorPropertyEditor -------------------------------------------------- // initialization of static pointer to color picker widget QmitkPopupColorChooser* QmitkColorPropertyEditor::colorChooser = NULL; int QmitkColorPropertyEditor::colorChooserRefCount = 0; QmitkColorPropertyEditor::QmitkColorPropertyEditor( const mitk::ColorProperty* property, QWidget* parent ) : QmitkColorPropertyView( property, parent ) { // our popup belongs to the whole screen, so it could be drawn outside the toplevel window's borders int scr; if ( QApplication::desktop()->isVirtualDesktop() ) scr = QApplication::desktop()->screenNumber( parent->mapToGlobal( pos() ) ); else scr = QApplication::desktop()->screenNumber( parent ); if ( colorChooserRefCount == 0 ) { colorChooser = new QmitkPopupColorChooser( QApplication::desktop()->screen( scr ), 50 ); } ++colorChooserRefCount; } QmitkColorPropertyEditor::~QmitkColorPropertyEditor() { --colorChooserRefCount; if (!colorChooserRefCount) { delete colorChooser; colorChooser = NULL; } } void QmitkColorPropertyEditor::mousePressEvent(QMouseEvent* e) { connect( colorChooser, SIGNAL(colorSelected(QColor)), this, SLOT(onColorSelected(QColor)) ); if (m_ColorProperty) { colorChooser->popup( this, e->pos(), &(m_ColorProperty->GetColor()) ); } } void QmitkColorPropertyEditor::mouseReleaseEvent(QMouseEvent*) { disconnect( colorChooser, SIGNAL(colorSelected(QColor)), this, SLOT(onColorSelected(QColor)) ); } void QmitkColorPropertyEditor::onColorSelected(QColor c) { if (m_ColorProperty) { int r,g,b; c.getRgb( &r, &g, &b ); const_cast(m_ColorProperty)->SetColor( r / 255.0, g / 255.0, b / 255.0 ); const_cast(m_ColorProperty)->Modified(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.cpp index a007149be7..0e461ffcf8 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.cpp @@ -1,85 +1,58 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkColorPropertyView.h" #include #define ROUND_P(x) ((int)((x)+0.5)) QmitkColorPropertyView::QmitkColorPropertyView( const mitk::ColorProperty* property, QWidget* parent ) : QLabel( parent ), PropertyView( property ), m_ColorProperty(property) - //m_SelfCall(false) { setText(" "); // two spaces for some minimun height setMinimumSize(15,15); PropertyChanged(); m_WidgetPalette = QWidget::palette(); QWidget::setPalette(m_WidgetPalette); QWidget::setAutoFillBackground(true); } QmitkColorPropertyView::~QmitkColorPropertyView() { } -//void QmitkColorPropertyView::unsetPalette() -//{ -// // just ignore calls... this widget is the only one to change its background color -//} - -//void QmitkColorPropertyView::setPalette( const QPalette& p) -//{ -// // just ignore calls... this widget is the only one to change its background color -// if (m_SelfCall) QWidget::setPalette(p); -//} - -//void QmitkColorPropertyView::setBackgroundMode( QWidget::BackgroundMode ) -//{ -// // just ignore calls... this widget is the only one to change its background color -//} - -//void QmitkColorPropertyView::setPaletteBackgroundColor( const QColor & ) -//{ -// // just ignore calls... this widget is the only one to change its background color -//} - void QmitkColorPropertyView::PropertyChanged() { if ( m_Property ) DisplayColor(); } void QmitkColorPropertyView::PropertyRemoved() { m_Property = NULL; m_ColorProperty = NULL; - //QLabel::setPaletteBackgroundPixmap( QPixmap(no_color_icon_xpm) ); } void QmitkColorPropertyView::DisplayColor() { const mitk::Color& tmp_col(m_ColorProperty->GetColor()); QColor color( ROUND_P(tmp_col[0] * 255.0), ROUND_P(tmp_col[1] * 255.0) , ROUND_P(tmp_col[2] * 255.0) ); - //m_SelfCall = true; - //QWidget::setPaletteBackgroundColor( color ); - //m_SelfCall = false; m_WidgetPalette.setColor(QPalette::Background, color); } - diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.h index 39a549ffbb..2a4ce88a03 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkColorPropertyView.h @@ -1,55 +1,47 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_COLORPROPERTYVIEW_H_INCLUDED #define QMITK_COLORPROPERTYVIEW_H_INCLUDED #include #include "MitkQtWidgetsExtExports.h" #include #include /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkColorPropertyView : public QLabel, public mitk::PropertyView { Q_OBJECT public: QmitkColorPropertyView( const mitk::ColorProperty*, QWidget* parent ); virtual ~QmitkColorPropertyView(); - //virtual void unsetPalette(); - //virtual void setPalette( const QPalette & ); - //virtual void setBackgroundMode( QWidget::BackgroundMode ); - //virtual void setPaletteBackgroundColor( const QColor & ); protected: virtual void PropertyChanged(); virtual void PropertyRemoved(); void DisplayColor(); const mitk::ColorProperty* m_ColorProperty; QPalette m_WidgetPalette; - - private: - - //bool m_SelfCall; }; #endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.cpp index c40c27827e..e25437dd17 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.cpp @@ -1,122 +1,121 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkEnumerationPropertyWidget.h" #include #include class _EnumPropEditorImpl : public mitk::PropertyEditor { public: _EnumPropEditorImpl(mitk::EnumerationProperty* property, QComboBox* combo, const QHash& enumIdToItemIndex) : PropertyEditor(property), m_EnumerationProperty(property), m_ComboBox(combo), m_EnumIdToItemIndex(enumIdToItemIndex) { } ~_EnumPropEditorImpl() { m_EnumerationProperty = 0; } void IndexChanged(int enumId) { this->BeginModifyProperty(); m_EnumerationProperty->SetValue(enumId); this->EndModifyProperty(); } virtual void PropertyChanged() { if (m_EnumerationProperty) { m_ComboBox->setCurrentIndex(m_EnumIdToItemIndex[m_EnumerationProperty->GetValueAsId()]); } } virtual void PropertyRemoved() { m_Property = 0; m_EnumerationProperty = 0; m_ComboBox->setEnabled(false); } protected: mitk::EnumerationProperty* m_EnumerationProperty; QComboBox* m_ComboBox; QHash m_EnumIdToItemIndex; }; QmitkEnumerationPropertyWidget::QmitkEnumerationPropertyWidget(QWidget* parent) : QComboBox(parent), propView(0) { connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(OnIndexChanged(int))); } QmitkEnumerationPropertyWidget::~QmitkEnumerationPropertyWidget() { delete propView; } void QmitkEnumerationPropertyWidget::SetProperty(mitk::EnumerationProperty* property) { if(propView) { delete propView; propView = 0; } this->clear(); if(!property) { return; } this->setEnabled(true); QHash enumIdToItemIndex; const mitk::EnumerationProperty::EnumStringsContainerType& strings = property->GetEnumStrings(); int index = 0; for (mitk::EnumerationProperty::EnumStringsContainerType::const_iterator it = strings.begin(); it != strings.end(); ++it, ++index) { enumIdToItemIndex.insert(it->second, index); this->addItem(QString::fromStdString(it->first), it->second); } propView = new _EnumPropEditorImpl(property, this, enumIdToItemIndex); propView->PropertyChanged(); } void QmitkEnumerationPropertyWidget::OnIndexChanged(int index) { if (propView) { int enumIndex = this->itemData(index, Qt::UserRole).toInt(); propView->IndexChanged(enumIndex); } } - diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.h index 8cff8a77c2..e14506f59c 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkEnumerationPropertyWidget.h @@ -1,56 +1,56 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_ENUMERATIONPROPERTYWIDGET_H_INCLUDED #define QMITK_ENUMERATIONPROPERTYWIDGET_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include namespace mitk { class EnumerationProperty; } class _EnumPropEditorImpl; /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkEnumerationPropertyWidget : public QComboBox { Q_OBJECT public: QmitkEnumerationPropertyWidget(QWidget* parent = 0); ~QmitkEnumerationPropertyWidget(); void SetProperty(mitk::EnumerationProperty* property); protected slots: void OnIndexChanged(int index); protected: _EnumPropEditorImpl* propView; }; -#endif // QMITK_ENUMERATIONPROPERTYWIDGET_H_INCLUDED +#endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.cpp index c7ad2fa4f2..7d292a0946 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.cpp @@ -1,319 +1,287 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkNumberPropertyEditor.h" #include #include #define DT_SHORT 1 #define DT_INT 2 #define DT_FLOAT 3 #define DT_DOUBLE 4 #define ROUND(x) (((x) > 0) ? int((x) + 0.5) : int((x) - 0.5)) #define ROUND_SHORT(x) (((x) > 0) ? short((x) + 0.5) : short((x) - 0.5)) -/* -QmitkNumberPropertyEditor::QmitkNumberPropertyEditor( mitk::GenericProperty* property, QWidget* parent, const char* name ) -: QSpinBox( parent, name ), - PropertyEditor( property ), - m_ShortProperty(property), - m_DataType(DT_SHORT) -{ - initialize(); -} -*/ + QmitkNumberPropertyEditor::QmitkNumberPropertyEditor( mitk::IntProperty* property, QWidget* parent ) : QSpinBox( parent ), PropertyEditor( property ), m_IntProperty(property), m_DataType(DT_INT) { initialize(); } QmitkNumberPropertyEditor::QmitkNumberPropertyEditor( mitk::FloatProperty* property, QWidget* parent ) : QSpinBox( parent ), PropertyEditor( property ), m_FloatProperty(property), m_DataType(DT_FLOAT) { initialize(); } QmitkNumberPropertyEditor::QmitkNumberPropertyEditor( mitk::DoubleProperty* property, QWidget* parent ) : QSpinBox( parent ), PropertyEditor( property ), m_DoubleProperty(property), m_DataType(DT_DOUBLE) { initialize(); } QmitkNumberPropertyEditor::~QmitkNumberPropertyEditor() { } void QmitkNumberPropertyEditor::initialize() { // only to be called from constructors // spinbox settings - //setValidator(0); setSuffix(""); // protected m_DecimalPlaces = 0; m_FactorPropertyToSpinbox = 1.0; m_FactorSpinboxToDisplay = 1.0; m_ShowPercents = false; // private m_SelfChangeLock = false; connect( this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)) ); // display current value of our property DisplayNumber(); } void QmitkNumberPropertyEditor::adjustFactors(short newDecimalPlaces, bool newShowPercents) { int oldMax = maxValue(); int oldMin = minValue(); m_DecimalPlaces = newDecimalPlaces; m_ShowPercents = newShowPercents; m_FactorPropertyToSpinbox = pow(10.0,m_DecimalPlaces); m_FactorSpinboxToDisplay = 1.0 / m_FactorPropertyToSpinbox; - // commented line would set the default increase/decrease to 1.0, no matter how many decimal places are available - //setLineStep( ROUND(m_FactorPropertyToSpinbox) ); - if ( m_ShowPercents ) { m_FactorPropertyToSpinbox *= 100.0; - //setLineStep( ROUND(0.01 *m_FactorPropertyToSpinbox) ); setSuffix("%"); } else { setSuffix(""); } setMinValue(oldMin); setMaxValue(oldMax); } short QmitkNumberPropertyEditor::getDecimalPlaces() const { return m_DecimalPlaces; } void QmitkNumberPropertyEditor::setDecimalPlaces(short places) { switch (m_DataType) { case DT_FLOAT: case DT_DOUBLE: { adjustFactors( places, m_ShowPercents ); DisplayNumber(); break; } default: break; } } bool QmitkNumberPropertyEditor::getShowPercent() const { return m_ShowPercents; } void QmitkNumberPropertyEditor::setShowPercent(bool showPercent) { if ( showPercent == m_ShowPercents ) return; // nothing to change switch (m_DataType) { case DT_FLOAT: case DT_DOUBLE: { adjustFactors( m_DecimalPlaces, showPercent ); break; } default: { break; } } DisplayNumber(); } int QmitkNumberPropertyEditor::minValue() const { return ROUND( QSpinBox::minimum() / m_FactorPropertyToSpinbox ); } void QmitkNumberPropertyEditor::setMinValue(int value) { QSpinBox::setMinimum( ROUND(value * m_FactorPropertyToSpinbox ) ); } int QmitkNumberPropertyEditor::maxValue() const { return ROUND( QSpinBox::maximum() / m_FactorPropertyToSpinbox ); } void QmitkNumberPropertyEditor::setMaxValue(int value) { QSpinBox::setMaximum( ROUND( value * m_FactorPropertyToSpinbox ) ); } double QmitkNumberPropertyEditor::doubleValue() const { return static_cast((QSpinBox::value()) / m_FactorPropertyToSpinbox ); } void QmitkNumberPropertyEditor::setDoubleValue(double value) { QSpinBox::setValue( ROUND( value * m_FactorPropertyToSpinbox ) ); - //QSpinBox::updateDisplay(); } QString QmitkNumberPropertyEditor::textFromValue(int value) const { QString displayedText; QTextStream stream(&displayedText); double d( value * m_FactorSpinboxToDisplay ); if ( m_DecimalPlaces > 0 ) { -// QString formatString; -// formatString.sprintf("%%.%if", m_DecimalPlaces); // do copy before sprintf -// displayedText.sprintf( formatString , d ); stream.setRealNumberPrecision(m_DecimalPlaces); stream << d; } else - //displayedText.sprintf( "%i" , ROUND(d) ); + { stream << ROUND(d); + } return displayedText; } int QmitkNumberPropertyEditor::valueFromText(const QString& text) const { return ROUND( text.toDouble() / m_FactorSpinboxToDisplay ); } void QmitkNumberPropertyEditor::onValueChanged(int value) { if (m_SelfChangeLock) return; // valueChanged is even emitted, when this widget initiates a change to its value // this may be useful some times, but in this use, it would be wrong: // (A) is an editor with 3 decimal places // (B) is an editor with 2 decimal places // User changes A's displayed value to 4.002 // A's onValueChanged gets called, sets the associated Property to 4.002 // B's onPropertyChanged gets called, sets its display to 4.00 // B's onValueChanged gets called and sets the associated Property to 4.00 // A's onPropertyChanged gets called, sets its display to 4.000 BeginModifyProperty(); double newValue( value / m_FactorPropertyToSpinbox ); switch (m_DataType) { - /* - case DT_SHORT: - { - m_ShortProperty->SetValue(ROUND_SHORT(newValue)); - break; - } - */ case DT_INT: { m_IntProperty->SetValue(ROUND(newValue)); break; } case DT_FLOAT: { m_FloatProperty->SetValue(newValue); break; } case DT_DOUBLE: { m_DoubleProperty->SetValue(newValue); break; } } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); EndModifyProperty(); } void QmitkNumberPropertyEditor::PropertyChanged() { DisplayNumber(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkNumberPropertyEditor::PropertyRemoved() { m_Property = NULL; } void QmitkNumberPropertyEditor::DisplayNumber() { if (! m_Property ) return; m_SelfChangeLock = true; switch (m_DataType) { - /* - case DT_SHORT: - { - short s = m_ShortProperty->GetValue(); - QSpinBox::setValue( s ); - break; - } - */ case DT_INT: { int i = m_IntProperty->GetValue(); QSpinBox::setValue( i ); break; } case DT_FLOAT: { float f = m_FloatProperty->GetValue(); setDoubleValue( f ); break; } case DT_DOUBLE: { double d = m_DoubleProperty->GetValue(); setDoubleValue( d ); break; } default: break; } m_SelfChangeLock = false; } diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.h index 61b01fda89..0d4944fdf6 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyEditor.h @@ -1,93 +1,91 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_NUMBERPROPERTYEDITOR_H_INCLUDED #define QMITK_NUMBERPROPERTYEDITOR_H_INCLUDED #include #include "MitkQtWidgetsExtExports.h" #include #include /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkNumberPropertyEditor : public QSpinBox, public mitk::PropertyEditor { Q_OBJECT Q_PROPERTY( short decimalPlaces READ getDecimalPlaces WRITE setDecimalPlaces ) Q_PROPERTY( bool showPercent READ getShowPercent WRITE setShowPercent ) Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) public: - //QmitkNumberPropertyEditor( mitk::GenericProperty*, QWidget* parent, const char* name = 0 ); QmitkNumberPropertyEditor( mitk::IntProperty*, QWidget* parent ); QmitkNumberPropertyEditor( mitk::FloatProperty*, QWidget* parent ); QmitkNumberPropertyEditor( mitk::DoubleProperty*, QWidget* parent ); virtual ~QmitkNumberPropertyEditor(); short getDecimalPlaces() const; void setDecimalPlaces(short); bool getShowPercent() const; void setShowPercent(bool); int minValue() const; void setMinValue(int); int maxValue() const; void setMaxValue(int); double doubleValue() const; void setDoubleValue(double); protected: void initialize(); virtual QString textFromValue(int) const; virtual int valueFromText(const QString&) const; virtual void PropertyChanged(); virtual void PropertyRemoved(); void DisplayNumber(); union { - //mitk::GenericProperty* m_ShortProperty; mitk::GenericProperty* m_IntProperty; mitk::GenericProperty* m_FloatProperty; mitk::GenericProperty* m_DoubleProperty; }; const int m_DataType; short m_DecimalPlaces; // how many decimal places are shown double m_FactorPropertyToSpinbox; // internal conversion factor. neccessary because spinbox ranges work only with ints double m_FactorSpinboxToDisplay; // internal conversion factor. neccessary because spinbox ranges work only with ints bool m_ShowPercents; // whether values are given in percent (0.5 -> 50%) protected slots: void onValueChanged(int); private: void adjustFactors(short, bool); bool m_SelfChangeLock; }; #endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.cpp index d4fb57f7c3..8e2e0f78d3 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.cpp @@ -1,283 +1,254 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #define DT_SHORT 1 #define DT_INT 2 #define DT_FLOAT 3 #define DT_DOUBLE 4 #define ROUND(x) (((x) > 0) ? int((x) + 0.5) : int((x) - 0.5)) #define ROUND_SHORT(x) (((x) > 0) ? short((x) + 0.5) : short((x) - 0.5)) -QmitkNumberPropertySlider::QmitkNumberPropertySlider( mitk::IntProperty* property, QWidget* parent, const char* /*name*/ ) +QmitkNumberPropertySlider::QmitkNumberPropertySlider( mitk::IntProperty* property, QWidget* parent, const char*) : QSlider( parent ), PropertyEditor( property ), m_IntProperty(property), m_DataType(DT_INT) { initialize(); } -QmitkNumberPropertySlider::QmitkNumberPropertySlider( mitk::FloatProperty* property, QWidget* parent, const char* /*name*/ ) +QmitkNumberPropertySlider::QmitkNumberPropertySlider( mitk::FloatProperty* property, QWidget* parent, const char*) : QSlider( parent ), PropertyEditor( property ), m_FloatProperty(property), m_DataType(DT_FLOAT) { initialize(); } -QmitkNumberPropertySlider::QmitkNumberPropertySlider( mitk::DoubleProperty* property, QWidget* parent, const char* /*name*/ ) +QmitkNumberPropertySlider::QmitkNumberPropertySlider( mitk::DoubleProperty* property, QWidget* parent, const char* ) : QSlider( parent ), PropertyEditor( property ), m_DoubleProperty(property), m_DataType(DT_DOUBLE) { initialize(); } QmitkNumberPropertySlider::~QmitkNumberPropertySlider() { } void QmitkNumberPropertySlider::initialize() { // only to be called from constructors // spinbox settings - //setValidator(0); - //setSuffix(""); setOrientation( Qt::Horizontal ); // protected m_DecimalPlaces = 0; m_FactorPropertyToSlider = 1.0; m_FactorSliderToDisplay = 1.0; m_ShowPercents = false; // private m_SelfChangeLock = false; connect( this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)) ); // display current value of our property DisplayNumber(); } void QmitkNumberPropertySlider::adjustFactors(short newDecimalPlaces, bool newShowPercents) { int oldMax = maxValue(); int oldMin = minValue(); m_DecimalPlaces = newDecimalPlaces; m_ShowPercents = newShowPercents; m_FactorPropertyToSlider = pow(10.0,m_DecimalPlaces); m_FactorSliderToDisplay = 1.0 / m_FactorPropertyToSlider; - // commented line would set the default increase/decrease to 1.0, no matter how many decimal places are available - //setLineStep( ROUND(m_FactorPropertyToSlider) ); - if ( m_ShowPercents ) - { m_FactorPropertyToSlider *= 100.0; - //setLineStep( ROUND(0.01 *m_FactorPropertyToSlider) ); - //setSuffix("%"); - } - else - { - //setSuffix(""); - } setMinimum(oldMin); setMaximum(oldMax); } short QmitkNumberPropertySlider::getDecimalPlaces() const { return m_DecimalPlaces; } void QmitkNumberPropertySlider::setDecimalPlaces(short places) { switch (m_DataType) { case DT_FLOAT: case DT_DOUBLE: { adjustFactors( places, m_ShowPercents ); DisplayNumber(); break; } default: break; } } bool QmitkNumberPropertySlider::getShowPercent() const { return m_ShowPercents; } void QmitkNumberPropertySlider::setShowPercent(bool showPercent) { if ( showPercent == m_ShowPercents ) return; // nothing to change switch (m_DataType) { case DT_FLOAT: case DT_DOUBLE: { adjustFactors( m_DecimalPlaces, showPercent ); break; } default: { break; } } DisplayNumber(); } int QmitkNumberPropertySlider::minValue() const { return ROUND( QSlider::minimum() / m_FactorPropertyToSlider ); } void QmitkNumberPropertySlider::setMinValue(int value) { QSlider::setMinimum( ROUND(value * m_FactorPropertyToSlider ) ); } int QmitkNumberPropertySlider::maxValue() const { return ROUND( QSlider::maximum() / m_FactorPropertyToSlider ); } void QmitkNumberPropertySlider::setMaxValue(int value) { QSlider::setMaximum( ROUND( value * m_FactorPropertyToSlider ) ); } double QmitkNumberPropertySlider::doubleValue() const { return static_cast((QSlider::value()) / m_FactorPropertyToSlider ); } void QmitkNumberPropertySlider::setDoubleValue(double value) { QSlider::setValue( ROUND( value * m_FactorPropertyToSlider ) ); - //QSlider::updateDisplay(); } void QmitkNumberPropertySlider::onValueChanged(int value) { if (m_SelfChangeLock) return; // valueChanged is even emitted, when this widget initiates a change to its value // this may be useful some times, but in this use, it would be wrong: // (A) is an editor with 3 decimal places // (B) is an editor with 2 decimal places // User changes A's displayed value to 4.002 // A's onValueChanged gets called, sets the associated Property to 4.002 // B's onPropertyChanged gets called, sets its display to 4.00 // B's onValueChanged gets called and sets the associated Property to 4.00 // A's onPropertyChanged gets called, sets its display to 4.000 BeginModifyProperty(); double newValue( value / m_FactorPropertyToSlider ); switch (m_DataType) { - /* - case DT_SHORT: - { - m_ShortProperty->SetValue(ROUND_SHORT(newValue)); - break; - } - */ case DT_INT: { m_IntProperty->SetValue(ROUND(newValue)); break; } case DT_FLOAT: { m_FloatProperty->SetValue(newValue); break; } case DT_DOUBLE: { m_DoubleProperty->SetValue(newValue); break; } } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); EndModifyProperty(); } void QmitkNumberPropertySlider::PropertyChanged() { DisplayNumber(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkNumberPropertySlider::PropertyRemoved() { m_Property = NULL; } void QmitkNumberPropertySlider::DisplayNumber() { if (! m_Property ) return; m_SelfChangeLock = true; switch (m_DataType) { - /* - case DT_SHORT: - { - short s = m_ShortProperty->GetValue(); - QSlider::setValue( s ); - break; - } - */ case DT_INT: { int i = m_IntProperty->GetValue(); QSlider::setValue( i ); break; } case DT_FLOAT: { float f = m_FloatProperty->GetValue(); setDoubleValue( f ); break; } case DT_DOUBLE: { double d = m_DoubleProperty->GetValue(); setDoubleValue( d ); break; } default: break; } m_SelfChangeLock = false; } diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.h index e3ac20ac9a..591833a7e8 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertySlider.h @@ -1,90 +1,88 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNumberPropertySliderhincludecd #define QmitkNumberPropertySliderhincludecd #include #include "MitkQtWidgetsExtExports.h" #include #include /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkNumberPropertySlider : public QSlider, public mitk::PropertyEditor { Q_OBJECT Q_PROPERTY( short decimalPlaces READ getDecimalPlaces WRITE setDecimalPlaces ) Q_PROPERTY( bool showPercent READ getShowPercent WRITE setShowPercent ) Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) public: - //QmitkNumberPropertySlider( mitk::GenericProperty*, QWidget* parent, const char* name = 0 ); QmitkNumberPropertySlider( mitk::IntProperty*, QWidget* parent, const char* name = 0 ); QmitkNumberPropertySlider( mitk::FloatProperty*, QWidget* parent, const char* name = 0 ); QmitkNumberPropertySlider( mitk::DoubleProperty*, QWidget* parent, const char* name = 0 ); virtual ~QmitkNumberPropertySlider(); short getDecimalPlaces() const; void setDecimalPlaces(short); bool getShowPercent() const; void setShowPercent(bool); int minValue() const; void setMinValue(int); int maxValue() const; void setMaxValue(int); double doubleValue() const; void setDoubleValue(double); protected: void initialize(); virtual void PropertyChanged(); virtual void PropertyRemoved(); void DisplayNumber(); union { - //mitk::GenericProperty* m_ShortProperty; mitk::GenericProperty* m_IntProperty; mitk::GenericProperty* m_FloatProperty; mitk::GenericProperty* m_DoubleProperty; }; const int m_DataType; short m_DecimalPlaces; // how many decimal places are shown double m_FactorPropertyToSlider; // internal conversion factor. neccessary because slider ranges work only with ints double m_FactorSliderToDisplay; // internal conversion factor. neccessary because slider ranges work only with ints bool m_ShowPercents; // whether values are given in percent (0.5 -> 50%) protected slots: void onValueChanged(int); private: void adjustFactors(short, bool); bool m_SelfChangeLock; }; #endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.cpp index 588d075c5e..ce7198816a 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.cpp @@ -1,183 +1,152 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkNumberPropertyView.h" #include #define DT_SHORT 1 #define DT_INT 2 #define DT_FLOAT 3 #define DT_DOUBLE 4 -/* -QmitkNumberPropertyView::QmitkNumberPropertyView( const mitk::GenericProperty* property, QWidget* parent, const char* name ) -: QLabel( parent, name ), - PropertyView( property ), - m_ShortProperty(property), - m_DataType(DT_SHORT) -{ - initialize(); -} -*/ + QmitkNumberPropertyView::QmitkNumberPropertyView( const mitk::IntProperty* property, QWidget* parent ) : QLabel( parent ), PropertyView( property ), m_IntProperty(property), m_DataType(DT_INT) { initialize(); } QmitkNumberPropertyView::QmitkNumberPropertyView( const mitk::FloatProperty* property, QWidget* parent ) : QLabel( parent ), PropertyView( property ), m_FloatProperty(property), m_DataType(DT_FLOAT) { initialize(); } QmitkNumberPropertyView::QmitkNumberPropertyView( const mitk::DoubleProperty* property, QWidget* parent ) : QLabel( parent ), PropertyView( property ), m_DoubleProperty(property), m_DataType(DT_DOUBLE) { initialize(); } QmitkNumberPropertyView::~QmitkNumberPropertyView() { } void QmitkNumberPropertyView::initialize() { // only to be called from constructors m_Suffix = ""; m_DisplayFactor = 1.0; - //setDecimalPlaces(-1); // unlimited setDecimalPlaces(2); } short QmitkNumberPropertyView::decimalPlaces() const { return m_DecimalPlaces; } void QmitkNumberPropertyView::setDecimalPlaces(short places) { m_DecimalPlaces = places; - -// if (m_DecimalPlaces >= 0) -// { -// m_FormatString = "%%.%if"; -// m_FormatString.sprintf(QString(m_FormatString), m_DecimalPlaces); // do copy before sprintf -// } -// else -// { -// m_FormatString = "%g"; -// } - DisplayNumber(); } QString QmitkNumberPropertyView::suffix() const { if (m_Suffix =="") return QString::null; else return m_Suffix; } void QmitkNumberPropertyView::setSuffix(const QString& suffix) { m_Suffix = suffix; DisplayNumber(); } bool QmitkNumberPropertyView::showPercent() const { return m_DisplayFactor == 100.0; } void QmitkNumberPropertyView::setShowPercent(bool show) { if (show) { m_DisplayFactor = 100.0; setSuffix("%"); } else { m_DisplayFactor = 1.0; setSuffix(""); } - - //DisplayNumber(); // gets called in setSuffix } void QmitkNumberPropertyView::PropertyChanged() { if ( m_Property ) DisplayNumber(); } void QmitkNumberPropertyView::PropertyRemoved() { m_Property = NULL; setText("n/a"); } void QmitkNumberPropertyView::DisplayNumber() { QString displayedText; QTextStream stream(&displayedText); stream.setRealNumberPrecision(m_DecimalPlaces); switch (m_DataType) { - /* - case DT_SHORT: - { - short s = m_ShortProperty->GetValue(); - displayedText.sprintf(m_FormatString, s * m_DisplayFactor); - break; - } - */ case DT_INT: { int i = m_IntProperty->GetValue(); stream << (i * m_DisplayFactor); break; } case DT_FLOAT: { float f = m_FloatProperty->GetValue(); stream << (f * m_DisplayFactor); break; } case DT_DOUBLE: { double d = m_DoubleProperty->GetValue(); stream << (d * m_DisplayFactor); break; } default: break; } setText( displayedText ); } diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.h index ee4baca2aa..b3b925e3d9 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkNumberPropertyView.h @@ -1,79 +1,72 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_NUMBERPROPERTYVIEW_H_INCLUDED #define QMITK_NUMBERPROPERTYVIEW_H_INCLUDED #include #include "MitkQtWidgetsExtExports.h" #include #include /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkNumberPropertyView : public QLabel, public mitk::PropertyView { Q_OBJECT Q_PROPERTY( short decimalPlaces READ decimalPlaces WRITE setDecimalPlaces ) Q_PROPERTY( QString suffix READ suffix WRITE setSuffix ) Q_PROPERTY( bool showPercent READ showPercent WRITE setShowPercent ) public: - //QmitkNumberPropertyView( const mitk::GenericProperty*, QWidget* parent, const char* name = 0 ); QmitkNumberPropertyView( const mitk::IntProperty*, QWidget* parent ); QmitkNumberPropertyView( const mitk::FloatProperty*, QWidget* parent ); QmitkNumberPropertyView( const mitk::DoubleProperty*, QWidget* parent ); virtual ~QmitkNumberPropertyView(); short decimalPlaces() const; void setDecimalPlaces(short); QString suffix() const; void setSuffix(const QString&); bool showPercent() const; void setShowPercent(bool); protected: void initialize(); virtual void PropertyChanged(); virtual void PropertyRemoved(); void DisplayNumber(); union { - //const mitk::GenericProperty* m_ShortProperty; const mitk::GenericProperty* m_IntProperty; const mitk::GenericProperty* m_FloatProperty; const mitk::GenericProperty* m_DoubleProperty; }; const int m_DataType; short m_DecimalPlaces; /// -1 indicates "no limit to decimal places" QString m_Suffix; double m_DisplayFactor; - - //QString m_FormatString; - - private: - }; #endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.cpp index e4fab69370..29138d72c2 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.cpp @@ -1,165 +1,151 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkPropertyViewFactory.h" // the different view and editor classes #include "QmitkBasePropertyView.h" #include "QmitkBoolPropertyWidget.h" #include "QmitkStringPropertyView.h" #include "QmitkStringPropertyEditor.h" #include "QmitkStringPropertyOnDemandEdit.h" #include "QmitkColorPropertyView.h" #include "QmitkColorPropertyEditor.h" #include "QmitkNumberPropertyView.h" #include "QmitkNumberPropertyEditor.h" #include "QmitkEnumerationPropertyWidget.h" #include QmitkPropertyViewFactory* QmitkPropertyViewFactory::GetInstance() { static QmitkPropertyViewFactory instance; return &instance; } QmitkPropertyViewFactory::QmitkPropertyViewFactory() { } QmitkPropertyViewFactory::~QmitkPropertyViewFactory() { } -QWidget* QmitkPropertyViewFactory::CreateView(const mitk::BaseProperty* property, unsigned int /*type*/, QWidget* parent) +QWidget* QmitkPropertyViewFactory::CreateView(const mitk::BaseProperty* property, unsigned int, QWidget* parent) { if ( const mitk::StringProperty* prop = dynamic_cast(property) ) { // a string property return new QmitkStringPropertyView(prop, parent); } else if ( const mitk::ColorProperty* prop = dynamic_cast(property) ) { // a color property return new QmitkColorPropertyView(prop, parent); } else if ( const mitk::BoolProperty* prop = dynamic_cast(property) ) { // a bool property // TODO fix after refactoring QmitkBoolPropertyWidget* widget = new QmitkBoolPropertyWidget(parent); widget->SetProperty(const_cast(prop)); return widget; } - /* - else if ( const mitk::GenericProperty* prop = dynamic_cast*>(property) ) - { - // a number property - return new QmitkNumberPropertyView(prop, parent, name); - } - */ else if ( const mitk::IntProperty* prop = dynamic_cast(property) ) { // a number property return new QmitkNumberPropertyView(prop, parent); } else if ( const mitk::FloatProperty* prop = dynamic_cast(property) ) { // a number property return new QmitkNumberPropertyView(prop, parent); } else if ( const mitk::DoubleProperty* prop = dynamic_cast(property) ) { // a number property return new QmitkNumberPropertyView(prop, parent); } else if ( property != NULL ) { // some unknown property --> use the GetValueAsString() method to return new QmitkBasePropertyView(prop, parent); } return NULL; } QWidget* QmitkPropertyViewFactory::CreateEditor(mitk::BaseProperty* property, unsigned int type, QWidget* parent) { if (!property) return NULL; if ( mitk::StringProperty* prop = dynamic_cast(property) ) { switch (type) { case etON_DEMAND_EDIT: // a string property return new QmitkStringPropertyOnDemandEdit(prop, parent); default: // a string property return new QmitkStringPropertyEditor(prop, parent); } } else if ( mitk::ColorProperty* prop = dynamic_cast(property) ) { // a color property return new QmitkColorPropertyEditor(prop, parent); } else if ( mitk::BoolProperty* prop = dynamic_cast(property) ) { // a bool property // TODO fix after refactoring QmitkBoolPropertyWidget* widget = new QmitkBoolPropertyWidget(parent); widget->SetProperty(prop); return widget; } - /* - else if ( mitk::GenericProperty* prop = dynamic_cast*>(property) ) - { - // a number property - return new QmitkNumberPropertyEditor(prop, parent, name); - } - */ else if ( mitk::IntProperty* prop = dynamic_cast(property) ) { // a number property return new QmitkNumberPropertyEditor(prop, parent); } else if ( mitk::FloatProperty* prop = dynamic_cast(property) ) { // a number property QmitkNumberPropertyEditor* pe = new QmitkNumberPropertyEditor(prop, parent); pe->setDecimalPlaces(2); return pe; } else if ( mitk::DoubleProperty* prop = dynamic_cast(property) ) { // a number property QmitkNumberPropertyEditor* pe = new QmitkNumberPropertyEditor(prop, parent); pe->setDecimalPlaces(2); return pe; } else if ( mitk::EnumerationProperty* prop = dynamic_cast(property) ) { // a enumeration property QmitkEnumerationPropertyWidget* pe = new QmitkEnumerationPropertyWidget(parent); pe->SetProperty(prop); return pe; } else { // some unknown property --> no editor possible return NULL; } } diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.h index e7cd4b0095..16b70adbb8 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkPropertyViewFactory.h @@ -1,44 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ +#ifndef QmitkPropertyViewFactory_h +#define QmitkPropertyViewFactory_h + #include #include "MitkQtWidgetsExtExports.h" class QWidget; class MitkQtWidgetsExt_EXPORT QmitkPropertyViewFactory { public: enum ViewTypes { vtDEFAULT = 0 }; enum EditorTypes { etDEFAULT = 0, etALWAYS_EDIT = 1, etON_DEMAND_EDIT = 2 }; static QmitkPropertyViewFactory* GetInstance(); // singleton /// Views and editors are created via operator new. After creation they belong to the caller of CreateView()/CreateEditor(), /// i.e. the caller has to ensure, that the objects are properly deleted! QWidget* CreateView (const mitk::BaseProperty* property, unsigned int type = 0, QWidget* parent = 0); QWidget* CreateEditor(mitk::BaseProperty* property, unsigned int type = 0, QWidget* parent = 0); protected: QmitkPropertyViewFactory(); // hidden, access through GetInstance() ~QmitkPropertyViewFactory(); - - private: - }; +#endif + diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.cpp index 90e49651b4..633347a9f2 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.cpp @@ -1,98 +1,85 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkStringPropertyOnDemandEdit.h" #include QmitkStringPropertyOnDemandEdit::QmitkStringPropertyOnDemandEdit( mitk::StringProperty* property, QWidget* parent ) : QFrame( parent ), PropertyEditor( property ), m_StringProperty(property) { setFrameStyle( QFrame::NoFrame ); setLineWidth(0); // create HBoxLayout with two buttons m_layout = new QHBoxLayout(this); m_layout->setMargin(0); m_label = new QLabel(this); m_layout->addWidget(m_label); m_toolbutton = new QClickableLabel2(this); m_toolbutton->setText("..."); m_layout->addWidget(m_toolbutton); m_layout->addStretch(10); connect( m_toolbutton, SIGNAL( clicked() ) , this, SLOT(onToolButtonClicked()) ); ensurePolished(); adjustSize(); PropertyChanged(); } QmitkStringPropertyOnDemandEdit::~QmitkStringPropertyOnDemandEdit() { } void QmitkStringPropertyOnDemandEdit::PropertyChanged() { if ( m_Property ) m_label->setText( m_StringProperty->GetValue() ); } void QmitkStringPropertyOnDemandEdit::PropertyRemoved() { m_Property = NULL; m_StringProperty = NULL; m_label->setText("n/a"); } void QmitkStringPropertyOnDemandEdit::onToolButtonClicked() { bool ok(false); QString newText = QInputDialog::getText(this, "Change text", "You can change the displayed text here", QLineEdit::Normal, m_label->text(), &ok); if (ok) { BeginModifyProperty(); // deregister from events m_StringProperty->SetValue(newText.toStdString()); m_label->setText(newText); EndModifyProperty(); // again register for events } } -//void QmitkStringPropertyOnDemandEdit::setPalette( const QPalette& p ) -//{ -// m_label->setPalette(p); -// m_toolbutton->setPalette(p); -// QFrame::setPalette(p); -//} - -//void QmitkStringPropertyOnDemandEdit::setBackgroundMode (BackgroundMode m) -//{ -// m_label->setBackgroundMode(m); -// m_toolbutton->setBackgroundMode(m); -// QFrame::setBackgroundMode(m); -//} diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.h index a1ff451569..00fd43a961 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.h @@ -1,78 +1,73 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_STRINGPROPERTYONDEMANDDEDITOR_H_INCLUDED #define QMITK_STRINGPROPERTYONDEMANDDEDITOR_H_INCLUDED #include #include "MitkQtWidgetsExtExports.h" #include #include #include class MitkQtWidgetsExt_EXPORT QClickableLabel2 : public QLabel { Q_OBJECT signals: void clicked(); public: QClickableLabel2( QWidget * parent, Qt::WindowFlags f = 0 ) :QLabel(parent, f) { } virtual void mouseReleaseEvent( QMouseEvent* ) { emit clicked(); } }; /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkStringPropertyOnDemandEdit : public QFrame, public mitk::PropertyEditor { Q_OBJECT public: QmitkStringPropertyOnDemandEdit( mitk::StringProperty*, QWidget* parent ); virtual ~QmitkStringPropertyOnDemandEdit(); - //virtual void setPalette ( const QPalette & ); - //virtual void setBackgroundMode ( BackgroundMode ); protected: virtual void PropertyChanged(); virtual void PropertyRemoved(); mitk::StringProperty* m_StringProperty; QHBoxLayout* m_layout; QLabel* m_label; QClickableLabel2* m_toolbutton; protected slots: void onToolButtonClicked(); - - private: - }; #endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyView.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyView.h index ced4986755..435826c6da 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyView.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkStringPropertyView.h @@ -1,47 +1,43 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_STRINGPROPERTYVIEW_H_INCLUDED #define QMITK_STRINGPROPERTYVIEW_H_INCLUDED #include #include "MitkQtWidgetsExtExports.h" #include #include /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkStringPropertyView : public QLabel, public mitk::PropertyView { Q_OBJECT public: QmitkStringPropertyView( const mitk::StringProperty*, QWidget* parent ); virtual ~QmitkStringPropertyView(); protected: virtual void PropertyChanged(); virtual void PropertyRemoved(); const mitk::StringProperty* m_StringProperty; - - private: - - }; #endif diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.cpp b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.cpp index 7c5d1d8eba..6589d759b4 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.cpp @@ -1,288 +1,289 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkUGCombinedRepresentationPropertyWidget.h" #include #include #include #include class _UGCombinedBoolPropEditor : public mitk::PropertyEditor { public: _UGCombinedBoolPropEditor(mitk::BoolProperty* boolProp, QmitkUGCombinedRepresentationPropertyWidget* combo) : PropertyEditor(boolProp), m_BoolProperty(boolProp), m_ComboBox(combo) { PropertyChanged(); } virtual ~_UGCombinedBoolPropEditor() {} bool IsEnabled() const { return enabled; } void SetEnabled(bool enable) { this->BeginModifyProperty(); m_BoolProperty->SetValue(enable); this->EndModifyProperty(); } protected: virtual void PropertyChanged() { if (m_BoolProperty) enabled = m_BoolProperty->GetValue(); else enabled = false; m_ComboBox->IsVolumeChanged(enabled); } virtual void PropertyRemoved() { m_Property = 0; m_BoolProperty = 0; enabled = false; } mitk::BoolProperty* m_BoolProperty; QmitkUGCombinedRepresentationPropertyWidget* m_ComboBox; bool enabled; }; class _UGCombinedEnumPropEditor : public mitk::PropertyEditor { public: _UGCombinedEnumPropEditor(mitk::EnumerationProperty* property, QmitkUGCombinedRepresentationPropertyWidget* combo, bool isVolumeProp) : PropertyEditor(property), m_EnumerationProperty(property), m_ComboBox(combo), m_IsVolumeProp(isVolumeProp) { } ~_UGCombinedEnumPropEditor() { m_EnumerationProperty = 0; } void IndexChanged(int enumId) { this->BeginModifyProperty(); m_EnumerationProperty->SetValue(enumId); this->EndModifyProperty(); } virtual void PropertyChanged() { if (m_EnumerationProperty) { if (m_IsVolumeProp) { m_ComboBox->SetGridVolumeId(m_EnumerationProperty->GetValueAsId()); } else { m_ComboBox->SetGridRepresentationId(m_EnumerationProperty->GetValueAsId()); } } } virtual void PropertyRemoved() { m_Property = 0; m_EnumerationProperty = 0; } protected: mitk::EnumerationProperty* m_EnumerationProperty; QmitkUGCombinedRepresentationPropertyWidget* m_ComboBox; QHash m_EnumIdToItemIndex; bool m_IsVolumeProp; }; QmitkUGCombinedRepresentationPropertyWidget::QmitkUGCombinedRepresentationPropertyWidget(QWidget *parent) : QComboBox(parent), gridRepPropEditor(0), volumeMapperPropEditor(0), volumePropEditor(0), m_GridRepIndex(0), m_GridVolIndex(0), m_FirstVolumeRepId(0) { connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(OnIndexChanged(int))); } QmitkUGCombinedRepresentationPropertyWidget::~QmitkUGCombinedRepresentationPropertyWidget() { delete gridRepPropEditor; delete volumeMapperPropEditor; delete volumePropEditor; } void QmitkUGCombinedRepresentationPropertyWidget::SetProperty( mitk::GridRepresentationProperty* gridRepProp, mitk::GridVolumeMapperProperty* gridVolProp, mitk::BoolProperty* volumeProp) { if (gridRepPropEditor) { delete gridRepPropEditor; gridRepPropEditor = 0; } if (volumeMapperPropEditor) { delete volumeMapperPropEditor; volumeMapperPropEditor = 0; } if (volumePropEditor) { delete volumePropEditor; volumePropEditor = 0; } this->clear(); this->setEnabled(true); m_FirstVolumeRepId = 0; m_MapRepEnumToIndex.clear(); m_MapVolEnumToIndex.clear(); if (!gridRepProp && !gridVolProp) return; int i = 0; if (gridRepProp) { const mitk::EnumerationProperty::EnumStringsContainerType& repStrings = gridRepProp->GetEnumStrings(); for (mitk::EnumerationProperty::EnumStringsContainerType::const_iterator it = repStrings.begin(); it != repStrings.end(); ++it, ++i) { m_MapRepEnumToIndex.insert(it->second, i); this->addItem(QString::fromStdString(it->first), it->second); } m_FirstVolumeRepId = i; } if (gridVolProp) { const mitk::EnumerationProperty::EnumStringsContainerType& volStrings = gridVolProp->GetEnumStrings(); for (mitk::EnumerationProperty::EnumStringsContainerType::const_iterator it = volStrings.begin(); it != volStrings.end(); ++it, ++i) { m_MapVolEnumToIndex.insert(it->second, i); this->addItem(QString("Volume (") + QString::fromStdString(it->first) + ")", it->second); } } if (gridRepProp) { gridRepPropEditor = new _UGCombinedEnumPropEditor(gridRepProp, this, false); } if (gridVolProp) { volumeMapperPropEditor = new _UGCombinedEnumPropEditor(gridVolProp, this, true); } if (volumeProp) { volumePropEditor = new _UGCombinedBoolPropEditor(volumeProp, this); } if (gridRepProp) { this->SetGridRepresentationId(gridRepProp->GetValueAsId()); } if (gridVolProp) { this->SetGridVolumeId(gridVolProp->GetValueAsId()); } } void QmitkUGCombinedRepresentationPropertyWidget::OnIndexChanged(int index) { int enumIndex = this->itemData(index, Qt::UserRole).toInt(); if (index < m_FirstVolumeRepId && gridRepPropEditor) { gridRepPropEditor->IndexChanged(enumIndex); if (volumePropEditor) { volumePropEditor->SetEnabled(false); } } else if (volumeMapperPropEditor) { volumeMapperPropEditor->IndexChanged(enumIndex); if (volumePropEditor) { volumePropEditor->SetEnabled(true); } } } void QmitkUGCombinedRepresentationPropertyWidget::SetGridRepresentationId(int enumId) { m_GridRepIndex = enumId; if (volumePropEditor && volumePropEditor->IsEnabled()) { return; } else { this->setCurrentIndex(m_MapRepEnumToIndex[enumId]); } } void QmitkUGCombinedRepresentationPropertyWidget::SetGridVolumeId(int enumId) { m_GridVolIndex = enumId; if (volumePropEditor && volumePropEditor->IsEnabled()) { this->setCurrentIndex(m_MapVolEnumToIndex[enumId]); } else { return; } } void QmitkUGCombinedRepresentationPropertyWidget::IsVolumeChanged(bool volume) { if (volume) { this->SetGridVolumeId(m_GridVolIndex); } else { this->SetGridRepresentationId(m_GridRepIndex); } } + diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.h b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.h index 4a916f344e..6d0bad238b 100644 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.h +++ b/Modules/QtWidgetsExt/QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.h @@ -1,76 +1,77 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKUGCOMBINEDREPRESENTATIONPROPERTYWIDGET_H #define QMITKUGCOMBINEDREPRESENTATIONPROPERTYWIDGET_H #include "MitkQtWidgetsExtExports.h" #include namespace mitk { class GridVolumeMapperProperty; class GridRepresentationProperty; class BoolProperty; } class _UGCombinedEnumPropEditor; class _UGCombinedBoolPropEditor; /// @ingroup Widgets class MitkQtWidgetsExt_EXPORT QmitkUGCombinedRepresentationPropertyWidget : public QComboBox { Q_OBJECT public: QmitkUGCombinedRepresentationPropertyWidget(QWidget *parent = 0); ~QmitkUGCombinedRepresentationPropertyWidget(); void SetProperty(mitk::GridRepresentationProperty* gridRepresentation, mitk::GridVolumeMapperProperty* volumeMapper, mitk::BoolProperty* volumeProp); protected slots: void OnIndexChanged(int index); protected: friend class _UGCombinedEnumPropEditor; friend class _UGCombinedBoolPropEditor; void SetGridRepresentationId(int enumId); void SetGridVolumeId(int enumId); void IsVolumeChanged(bool volume); _UGCombinedEnumPropEditor* gridRepPropEditor; _UGCombinedEnumPropEditor* volumeMapperPropEditor; _UGCombinedBoolPropEditor* volumePropEditor; int m_GridRepIndex; int m_GridVolIndex; int m_FirstVolumeRepId; QHash m_MapRepEnumToIndex; QHash m_MapVolEnumToIndex; }; -#endif // QMITKUGCOMBINEDREPRESENTATIONPROPERTYWIDGET_H +#endif + diff --git a/Modules/QtWidgetsExt/QmitkPropertyObservers/no_color_icon.xpm b/Modules/QtWidgetsExt/QmitkPropertyObservers/no_color_icon.xpm deleted file mode 100644 index 56a0958925..0000000000 --- a/Modules/QtWidgetsExt/QmitkPropertyObservers/no_color_icon.xpm +++ /dev/null @@ -1,14 +0,0 @@ -/* XPM */ -static const char * no_color_icon_xpm[] = { -"8 8 3 1", -" c None", -". c #a0a0a0", -"+ c #FFFFFF", -"....++++", -"....++++", -"....++++", -"....++++", -"++++....", -"++++....", -"++++....", -"++++...."}; diff --git a/Modules/QtWidgetsExt/QmitkSelectableGLWidget.cpp b/Modules/QtWidgetsExt/QmitkSelectableGLWidget.cpp index 6583c3bea0..04b9915e69 100644 --- a/Modules/QtWidgetsExt/QmitkSelectableGLWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkSelectableGLWidget.cpp @@ -1,107 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkSelectableGLWidget.h" #include "QmitkRenderWindow.h" #include QmitkSelectableGLWidget::QmitkSelectableGLWidget(QWidget* parent) : QWidget(parent) { setupUi(this); QLayout *hlayout; hlayout=layout(); hlayout->setMargin(3); - //hlayout->setAutoAdd(true); QString rendererName("Renderer::"); rendererName += objectName(); // create Renderer m_Renderer= mitk::VtkPropRenderer::New( qPrintable(rendererName), NULL, mitk::RenderingManager::GetInstance(),mitk::BaseRenderer::RenderingMode::Standard ); // create widget QString composedName("QSGLWt::"); if(!objectName().isEmpty()) composedName+=objectName(); else composedName+="QmitkGLWidget"; /* * here is the place to define QT-Flags to enable and disable certain OpenGL elements, like StencilBuffer, RGBA and so on. * See QGLFormat for futher informations * QGL::AlphaChannel: Enable Alpha in Framebuffer * QGL::Rgba enable use of rgba rather than color_index * QGL::StencilBuffer for use of stencilbuffer in OpenGL */ m_RenderWindow = new QmitkRenderWindow(this, composedName,m_Renderer); hlayout->addWidget(m_RenderWindow); } mitk::VtkPropRenderer* QmitkSelectableGLWidget::GetRenderer() { return m_Renderer.GetPointer(); } QmitkRenderWindow* QmitkSelectableGLWidget::GetRenderWindow() const { return m_RenderWindow; } void QmitkSelectableGLWidget::wheelEvent( QWheelEvent * e ) { if ( m_RenderWindow->GetSliceNavigationController()->GetSliceLocked() ) return; mitk::Stepper* stepper = m_RenderWindow ->GetSliceNavigationController()->GetSlice(); if (stepper->GetSteps() <= 1) { stepper = m_RenderWindow->GetSliceNavigationController()->GetTime(); } if (e->orientation() * e->delta() > 0) { stepper->Next(); } else { stepper->Previous(); } } mitk::SliceNavigationController* QmitkSelectableGLWidget ::GetSliceNavigationController() const { return m_RenderWindow->GetSliceNavigationController(); } mitk::CameraRotationController* QmitkSelectableGLWidget ::GetCameraRotationController() const { return m_RenderWindow->GetCameraRotationController(); } mitk::BaseController* QmitkSelectableGLWidget ::GetController() const { return m_RenderWindow->GetController(); -} \ No newline at end of file +} diff --git a/Modules/QtWidgetsExt/QmitkSelectableGLWidget.h b/Modules/QtWidgetsExt/QmitkSelectableGLWidget.h index 843ea4686f..d1cc1f8826 100644 --- a/Modules/QtWidgetsExt/QmitkSelectableGLWidget.h +++ b/Modules/QtWidgetsExt/QmitkSelectableGLWidget.h @@ -1,47 +1,48 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKSELECTABLEGLWIDGET_H #define QMITKSELECTABLEGLWIDGET_H #include "ui_QmitkSelectableGLWidget.h" #include "mitkCameraRotationController.h" #include "mitkCommon.h" #include "mitkSliceNavigationController.h" #include "mitkVtkPropRenderer.h" #include #include class QmitkRenderWindow; class QmitkSelectableGLWidget : public QWidget, public Ui::QmitkSelectableGLWidget { public: QmitkSelectableGLWidget(QWidget* parent=0); mitk::VtkPropRenderer* GetRenderer(); QmitkRenderWindow* GetRenderWindow() const; mitk::SliceNavigationController* GetSliceNavigationController() const; mitk::CameraRotationController* GetCameraRotationController() const; mitk::BaseController* GetController() const; protected: void wheelEvent( QWheelEvent * e ); QmitkRenderWindow *m_RenderWindow; mitk::VtkPropRenderer::Pointer m_Renderer; }; #endif + diff --git a/Modules/QtWidgetsExt/QmitkSliceWidget.cpp b/Modules/QtWidgetsExt/QmitkSliceWidget.cpp index dc18e6000b..0ceee93a23 100644 --- a/Modules/QtWidgetsExt/QmitkSliceWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkSliceWidget.cpp @@ -1,334 +1,302 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkSliceWidget.h" #include "QmitkStepperAdapter.h" #include "mitkNodePredicateDataType.h" #include - - -//#include "QmitkRenderWindow.h" -// -//#include "mitkSliceNavigationController.h" -//#include "QmitkLevelWindowWidget.h" -// -//#include -//#include "mitkRenderingManager.h" - #include #include QmitkSliceWidget::QmitkSliceWidget(QWidget* parent, const char* name, Qt::WindowFlags f) : QWidget(parent, f) { this->setupUi(this); if (name != 0) this->setObjectName(name); popUp = new QMenu(this); popUp->addAction("Axial"); popUp->addAction("Frontal"); popUp->addAction("Sagittal"); QObject::connect(popUp, SIGNAL(triggered(QAction*)), this, SLOT(ChangeView(QAction*)) ); setPopUpEnabled(false); m_SlicedGeometry = 0; m_View = mitk::SliceNavigationController::Axial; QHBoxLayout *hlayout = new QHBoxLayout(container); hlayout->setMargin(0); // create widget QString composedName("QmitkSliceWidget::"); if (!this->objectName().isEmpty()) composedName += this->objectName(); else composedName += "QmitkGLWidget"; m_RenderWindow = new QmitkRenderWindow(container, composedName); m_Renderer = m_RenderWindow->GetRenderer(); hlayout->addWidget(m_RenderWindow); new QmitkStepperAdapter(m_NavigatorWidget, m_RenderWindow->GetSliceNavigationController()->GetSlice(), "navigation"); SetLevelWindowEnabled(true); } mitk::VtkPropRenderer* QmitkSliceWidget::GetRenderer() { return m_Renderer; } QFrame* QmitkSliceWidget::GetSelectionFrame() { return SelectionFrame; } void QmitkSliceWidget::SetDataStorage( mitk::StandaloneDataStorage::Pointer storage) { m_DataStorage = storage; m_Renderer->SetDataStorage(m_DataStorage); } mitk::StandaloneDataStorage* QmitkSliceWidget::GetDataStorage() { return m_DataStorage; } void QmitkSliceWidget::SetData( mitk::DataStorage::SetOfObjects::ConstIterator it) { SetData(it->Value(), m_View); } void QmitkSliceWidget::SetData( mitk::DataStorage::SetOfObjects::ConstIterator it, mitk::SliceNavigationController::ViewDirection view) { SetData(it->Value(), view); } void QmitkSliceWidget::SetData(mitk::DataNode::Pointer node) { try { if (m_DataStorage.IsNotNull()) { m_DataStorage->Add(node); } } catch (...) { } SetData(node, m_View); } -//void QmitkSliceWidget::AddData( mitk::DataNode::Pointer node) -//{ -// if ( m_DataTree.IsNull() ) -// { -// m_DataTree = mitk::DataTree::New(); -// } -// mitk::DataTreePreOrderIterator it(m_DataTree); -// it.Add( node ); -// SetData(&it, m_View); -//} - - void QmitkSliceWidget::SetData(mitk::DataNode::Pointer node, mitk::SliceNavigationController::ViewDirection view) { mitk::Image::Pointer image = dynamic_cast(node->GetData()); if (image.IsNull()) { MITK_WARN << "QmitkSliceWidget data is not an image!"; return; } m_SlicedGeometry = image->GetSlicedGeometry(); this->InitWidget(view); } void QmitkSliceWidget::InitWidget( mitk::SliceNavigationController::ViewDirection viewDirection) { m_View = viewDirection; mitk::SliceNavigationController* controller = m_RenderWindow->GetSliceNavigationController(); if (viewDirection == mitk::SliceNavigationController::Axial) { controller->SetViewDirection( mitk::SliceNavigationController::Axial); } else if (viewDirection == mitk::SliceNavigationController::Frontal) { controller->SetViewDirection(mitk::SliceNavigationController::Frontal); } // init sagittal view else { controller->SetViewDirection(mitk::SliceNavigationController::Sagittal); } int currentPos = 0; if (m_RenderWindow->GetSliceNavigationController()) { currentPos = controller->GetSlice()->GetPos(); } if (m_SlicedGeometry.IsNull()) { return; } // compute bounding box with respect to first images geometry const mitk::BoundingBox::BoundsArrayType imageBounds = m_SlicedGeometry->GetBoundingBox()->GetBounds(); - // mitk::SlicedGeometry3D::Pointer correctGeometry = m_SlicedGeometry.GetPointer(); mitk::Geometry3D::Pointer geometry = static_cast (m_SlicedGeometry->Clone().GetPointer()); const mitk::BoundingBox::Pointer boundingbox = m_DataStorage->ComputeVisibleBoundingBox(GetRenderer(), NULL); if (boundingbox->GetPoints()->Size() > 0) { - ////geometry = mitk::Geometry3D::New(); - ////geometry->Initialize(); - //geometry->SetBounds(boundingbox->GetBounds()); - //geometry->SetSpacing(correctGeometry->GetSpacing()); - //let's see if we have data with a limited live-span ... mitk::TimeBounds timebounds = m_DataStorage->ComputeTimeBounds( GetRenderer(), NULL); if (timebounds[1] < mitk::ScalarTypeNumericTraits::max()) { mitk::ScalarType duration = timebounds[1] - timebounds[0]; timebounds[1] = timebounds[0] + 1.0f; geometry->SetTimeBounds(timebounds); } mitk::ProportionalTimeGeometry::Pointer timeGeometry = mitk::ProportionalTimeGeometry::New(); timeGeometry->Initialize(geometry,1); if (const_cast (timeGeometry->GetBoundingBoxInWorld())->GetDiagonalLength2() >= mitk::eps) { controller->SetInputWorldTimeGeometry(timeGeometry); controller->Update(); } } GetRenderer()->GetDisplayGeometry()->Fit(); mitk::RenderingManager::GetInstance()->RequestUpdate( GetRenderer()->GetRenderWindow()); - //int w=vtkObject::GetGlobalWarningDisplay(); - //vtkObject::GlobalWarningDisplayOff(); - //vtkRenderer * vtkrenderer = ((mitk::OpenGLRenderer*)(GetRenderer()))->GetVtkRenderer(); - //if(vtkrenderer!=NULL) vtkrenderer->ResetCamera(); - //vtkObject::SetGlobalWarningDisplay(w); } void QmitkSliceWidget::UpdateGL() { GetRenderer()->GetDisplayGeometry()->Fit(); mitk::RenderingManager::GetInstance()->RequestUpdate( GetRenderer()->GetRenderWindow()); } void QmitkSliceWidget::mousePressEvent(QMouseEvent * e) { if (e->button() == Qt::RightButton && popUpEnabled) { popUp->popup(QCursor::pos()); } } void QmitkSliceWidget::wheelEvent(QWheelEvent * e) { int val = m_NavigatorWidget->GetPos(); if (e->orientation() * e->delta() > 0) { m_NavigatorWidget->SetPos(val + 1); } else { if (val > 0) m_NavigatorWidget->SetPos(val - 1); } } void QmitkSliceWidget::ChangeView(QAction* val) { if (val->text() == "Axial") { InitWidget(mitk::SliceNavigationController::Axial); } else if (val->text() == "Frontal") { InitWidget(mitk::SliceNavigationController::Frontal); } else if (val->text() == "Sagittal") { InitWidget(mitk::SliceNavigationController::Sagittal); } } void QmitkSliceWidget::setPopUpEnabled(bool b) { popUpEnabled = b; } QmitkSliderNavigatorWidget* QmitkSliceWidget::GetNavigatorWidget() { return m_NavigatorWidget; } void QmitkSliceWidget::SetLevelWindowEnabled(bool enable) { levelWindow->setEnabled(enable); if (!enable) { levelWindow->setMinimumWidth(0); levelWindow->setMaximumWidth(0); } else { levelWindow->setMinimumWidth(28); levelWindow->setMaximumWidth(28); } } bool QmitkSliceWidget::IsLevelWindowEnabled() { return levelWindow->isEnabled(); } QmitkRenderWindow* QmitkSliceWidget::GetRenderWindow() { return m_RenderWindow; } mitk::SliceNavigationController* QmitkSliceWidget::GetSliceNavigationController() const { return m_RenderWindow->GetSliceNavigationController(); } mitk::CameraRotationController* QmitkSliceWidget::GetCameraRotationController() const { return m_RenderWindow->GetCameraRotationController(); } mitk::BaseController* QmitkSliceWidget::GetController() const { return m_RenderWindow->GetController(); } + diff --git a/Modules/QtWidgetsExt/QmitkSliceWidget.h b/Modules/QtWidgetsExt/QmitkSliceWidget.h index e71c35d9c3..f02a70d11f 100644 --- a/Modules/QtWidgetsExt/QmitkSliceWidget.h +++ b/Modules/QtWidgetsExt/QmitkSliceWidget.h @@ -1,104 +1,102 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKSLICEWIDGET_H_ #define QMITKSLICEWIDGET_H_ #include "ui_QmitkSliceWidget.h" #include "MitkQtWidgetsExtExports.h" #include "QmitkRenderWindow.h" #include "mitkSliceNavigationController.h" #include "mitkDataStorage.h" #include "mitkStandaloneDataStorage.h" #include class MitkQtWidgetsExt_EXPORT QmitkSliceWidget : public QWidget, public Ui::QmitkSliceWidgetUi { Q_OBJECT public: QmitkSliceWidget(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags f = 0); mitk::VtkPropRenderer* GetRenderer(); QFrame* GetSelectionFrame(); void UpdateGL(); void mousePressEvent( QMouseEvent * e ); void setPopUpEnabled( bool b ); void SetDataStorage( mitk::StandaloneDataStorage::Pointer storage ); mitk::StandaloneDataStorage* GetDataStorage(); QmitkSliderNavigatorWidget* GetNavigatorWidget(); bool IsLevelWindowEnabled(); QmitkRenderWindow* GetRenderWindow(); mitk::SliceNavigationController* GetSliceNavigationController() const; mitk::CameraRotationController* GetCameraRotationController() const; mitk::BaseController* GetController() const; public slots: void SetData(mitk::DataStorage::SetOfObjects::ConstIterator it); void SetData(mitk::DataStorage::SetOfObjects::ConstIterator it, mitk::SliceNavigationController::ViewDirection view); void SetData( mitk::DataNode::Pointer node ); - // void AddData( mitk::DataNode::Pointer node); - void SetData( mitk::DataNode::Pointer node, mitk::SliceNavigationController::ViewDirection view ); void InitWidget( mitk::SliceNavigationController::ViewDirection viewDirection ); void wheelEvent( QWheelEvent * e ); void ChangeView(QAction* val); void SetLevelWindowEnabled( bool enable ); protected: QmitkRenderWindow* m_RenderWindow; mitk::SliceNavigationController::ViewDirection m_View; - //int newVariable; private: bool popUpEnabled; mitk::VtkPropRenderer::Pointer m_Renderer; mitk::SlicedGeometry3D::Pointer m_SlicedGeometry; mitk::StandaloneDataStorage::Pointer m_DataStorage; QMenu* popUp; }; -#endif /*QMITKSLICEWIDGET_H_*/ +#endif + diff --git a/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.cpp b/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.cpp index 573efbd920..5a11468f1a 100644 --- a/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.cpp @@ -1,267 +1,268 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkSliderNavigatorWidget.h" QmitkSliderNavigatorWidget::QmitkSliderNavigatorWidget(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f) { this->setupUi(this); // this avoids trying to use m_Stepper until it is set to something != NULL // (additionally to the avoiding recursions during refetching) m_InRefetch = true; // Hide slider labeling -- until it is explicitly activated this->ShowLabels( false ); // Set label values as invalid (N/A) this->SetLabelValuesValid( false, false ); m_HasLabels = false; m_HasLabelUnit = true; m_InverseDirection = false; } void QmitkSliderNavigatorWidget::Refetch() { if ( !m_InRefetch ) { m_InRefetch = true; m_Slider->setMinimum( 0 ); m_Slider->setMaximum( m_Stepper->GetSteps() - 1 ); if (m_InverseDirection) { m_Slider->setValue( m_Stepper->GetSteps()-1-m_Stepper->GetPos() ); } else { m_Slider->setValue( m_Stepper->GetPos() ); } m_SpinBox->setMinimum( 0 ); m_SpinBox->setMaximum( m_Stepper->GetSteps() - 1 ); if (m_InverseDirection) { m_SpinBox->setValue( m_Stepper->GetSteps()-1-m_Stepper->GetPos() ); } else { m_SpinBox->setValue( m_Stepper->GetPos() ); } if ( m_Stepper->HasRange() && m_HasLabels ) { // Show slider with labels according to below settings m_SliderLabelLeft->setHidden( false ); m_SliderLabelRight->setHidden( false ); if ( m_Stepper->HasValidRange() ) { this->SetLabelValuesValid( true, true ); this->SetLabelValues( m_Stepper->GetRangeMin(), m_Stepper->GetRangeMax() ); } else { this->SetLabelValuesValid( false, false ); } if ( m_Stepper->HasUnitName() ) { this->SetLabelUnit( m_Stepper->GetUnitName() ); } } else { // Show slider without any labels m_SliderLabelLeft->setHidden( true ); m_SliderLabelRight->setHidden( true ); } // Update GUI according to above settings this->SetLabels(); m_InRefetch=false; } } void QmitkSliderNavigatorWidget::SetStepper( mitk::Stepper * stepper) { m_Stepper = stepper; // this avoids trying to use m_Stepper until it is set to something != NULL // (additionally to the avoiding recursions during refetching) m_InRefetch = (stepper==NULL); } void QmitkSliderNavigatorWidget::slider_valueChanged( int ) { if (!m_InRefetch) { if (m_InverseDirection) { m_Stepper->SetPos(m_Stepper->GetSteps()-1-m_Slider->value()); } else { m_Stepper->SetPos(m_Slider->value()); } this->Refetch(); } } void QmitkSliderNavigatorWidget::ShowLabels( bool show ) { m_HasLabels = show; } void QmitkSliderNavigatorWidget::ShowLabelUnit( bool show ) { m_HasLabelUnit = show; } void QmitkSliderNavigatorWidget::SetLabelValues( float min, float max ) { m_MinValue = min; m_MaxValue = max; } void QmitkSliderNavigatorWidget::SetLabelValuesValid( bool minValid, bool maxValid ) { m_MinValueValid = minValid; m_MaxValueValid = maxValid; } void QmitkSliderNavigatorWidget::SetLabelUnit( const char *unit ) { m_LabelUnit = unit; } QString QmitkSliderNavigatorWidget::GetLabelUnit() { return m_LabelUnit; } QString QmitkSliderNavigatorWidget::ClippedValueToString( float value ) { if ( value < -10000000.0 ) { return "-INF"; } else if ( value > 10000000.0 ) { return "+INF"; } else { return QString::number( value, 'f', 2 ); } } QString QmitkSliderNavigatorWidget::GetMinValueLabel() { if ( m_MinValueValid ) { return this->ClippedValueToString( m_MinValue ); } else { return "N/A"; } } QString QmitkSliderNavigatorWidget::GetMaxValueLabel() { if ( m_MaxValueValid ) { return this->ClippedValueToString( m_MaxValue ); } else { return "N/A"; } } void QmitkSliderNavigatorWidget::SetLabels() { QString minText = "

" + this->GetMinValueLabel(); QString maxText = "

" + this->GetMaxValueLabel(); if ( m_HasLabelUnit ) { minText += " " + this->GetLabelUnit(); maxText += " " + this->GetLabelUnit(); } if ( m_MinValueValid ) { minText += "
(pos 0)"; } if ( m_MaxValueValid ) { maxText += "
(pos " + QString::number( m_Stepper->GetSteps() - 1 ) + ")"; } minText += "

"; maxText += "

"; m_SliderLabelLeft->setText( minText ); m_SliderLabelRight->setText( maxText ); } void QmitkSliderNavigatorWidget::spinBox_valueChanged( int ) { if(!m_InRefetch) { if (m_InverseDirection) { m_Stepper->SetPos( m_Stepper->GetSteps()-1-m_SpinBox->value() ); } else { m_Stepper->SetPos( m_SpinBox->value() ); } this->Refetch(); } } int QmitkSliderNavigatorWidget::GetPos() { return m_Stepper->GetPos(); } void QmitkSliderNavigatorWidget::SetPos(int val) { if (!m_InRefetch) { m_Stepper->SetPos( val ); } } void QmitkSliderNavigatorWidget::SetInverseDirection(bool inverseDirection) { m_InverseDirection = inverseDirection; } + diff --git a/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.h b/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.h index b5fff2a797..5d900efe4a 100644 --- a/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.h +++ b/Modules/QtWidgetsExt/QmitkSliderNavigatorWidget.h @@ -1,121 +1,122 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKSLIDERNAVIGATORWIDGET_H_ #define QMITKSLIDERNAVIGATORWIDGET_H_ #include "ui_QmitkSliderNavigator.h" #include "MitkQtWidgetsExtExports.h" #include #include #include class MitkQtWidgetsExt_EXPORT QmitkSliderNavigatorWidget : public QWidget, public Ui::QmitkSliderNavigator { Q_OBJECT public: QmitkSliderNavigatorWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); QString GetLabelUnit(); /** * \brief Converts the passed value to a QString representation. * * If the value exceeds a certain maximum, "INF" (for "infinity") is displayed * instead. */ QString ClippedValueToString( float value ); /** * \brief Returns range-minimum (displayed as label left of slider if enabled) */ QString GetMinValueLabel(); QString GetMaxValueLabel(); int GetPos(); public slots: /** * \brief Updates the slider with the recent changes applied to the navigator. * * Intended to be called via event mechanism, e.g. if the connected * mitk::Stepper is modified. */ void Refetch(); void SetStepper( mitk::Stepper * stepper); void ShowLabels( bool show ); /** * \brief En-/disables displaying of the unit label (range will be displayed * without unit if enabled). */ void ShowLabelUnit( bool show ); void SetPos(int val); void SetInverseDirection (bool inverseDirection); protected slots: void slider_valueChanged( int ); /** * \brief Set range minimum and maximum (displayed as labels left and right * of slider if enabled) */ void SetLabelValues( float min, float max ); void SetLabelValuesValid( bool minValid, bool maxValid ); /** * \brief Set range unit (e.g. mm or ms) which will be displayed below range * labels if enabled. */ void SetLabelUnit( const char *unit ); /** * \brief Configure slider with labels according to range and unit settings */ void SetLabels(); void spinBox_valueChanged( int ); protected: bool m_HasLabelUnit; bool m_MaxValueValid; bool m_MinValueValid; QString m_LabelUnit; mitk::Stepper::Pointer m_Stepper; bool m_InRefetch; bool m_HasLabels; float m_MinValue; float m_MaxValue; bool m_InverseDirection; }; -#endif /*QMITKSLIDERNAVIGATORWIDGET_H_*/ +#endif + diff --git a/Modules/QtWidgetsExt/QmitkStandardViews.cpp b/Modules/QtWidgetsExt/QmitkStandardViews.cpp index f2f77711df..c308cf952f 100644 --- a/Modules/QtWidgetsExt/QmitkStandardViews.cpp +++ b/Modules/QtWidgetsExt/QmitkStandardViews.cpp @@ -1,131 +1,129 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkStandardViews.h" #include "mitkBaseRenderer.h" #include #include #include #include QmitkStandardViews::QmitkStandardViews( QWidget* parent, Qt::WindowFlags f ) :QWidget(parent, f) { QVBoxLayout *vlayout = new QVBoxLayout(this); QWidget *labelContainer = new QWidget(this); vlayout->addStretch(1); vlayout->addWidget(labelContainer); vlayout->addStretch(1); QHBoxLayout *hlayout = new QHBoxLayout(labelContainer); // find embedded picture QPixmap pixmap(":QmitkStandardViews.png"); // set picture for label m_ClickablePicture = new QClickableLabel(labelContainer); // set hotspots specific for this image m_ClickablePicture->setPixmap( pixmap ); m_ClickablePicture->AddHotspot( "Left", QRect(QPoint(0,64), QPoint(21, 83)) ); m_ClickablePicture->AddHotspot( "Right", QRect(QPoint(128, 64), QPoint(149, 83)) ); m_ClickablePicture->AddHotspot( "Top", QRect(QPoint(66, 0), QPoint(83, 75)) ); m_ClickablePicture->AddHotspot( "Bottom", QRect(QPoint(66, 128), QPoint(83, 149)) ); m_ClickablePicture->AddHotspot( "Front", QRect(QPoint(10, 102), QPoint(29, 119)) ); m_ClickablePicture->AddHotspot( "Back", QRect(QPoint(119, 30), QPoint(138, 48)) ); connect( m_ClickablePicture, SIGNAL( mouseReleased(const QString&)), this, SLOT(hotspotClicked(const QString&)) ); hlayout->addStretch(1); hlayout->addWidget( m_ClickablePicture ); hlayout->addStretch(1); } QmitkStandardViews::~QmitkStandardViews() { } void QmitkStandardViews::SetCameraController( mitk::CameraController* controller ) { m_CameraController = controller; } void QmitkStandardViews::SetCameraControllerFromRenderWindow( vtkRenderWindow* window ) { if ( window != NULL ) { if ( mitk::BaseRenderer::GetInstance(window) != NULL ) if ( mitk::BaseRenderer::GetInstance(window)->GetCameraController() != NULL ) m_CameraController = mitk::BaseRenderer::GetInstance(window)->GetCameraController(); } else { std::cerr << "Warning in "<<__FILE__<<", "<<__LINE__<<": render window is NULL!" << std::endl; } } void QmitkStandardViews::hotspotClicked(const QString& s) { mitk::CameraController::StandardView view; bool good(true); if ( s == "Left" ) view = mitk::CameraController::DEXTER; else if ( s == "Right" ) view = mitk::CameraController::SINISTER; else if ( s == "Top" ) view = mitk::CameraController::CRANIAL; else if ( s == "Bottom" ) view = mitk::CameraController::CAUDAL; else if ( s == "Front" ) view = mitk::CameraController::ANTERIOR; else if ( s == "Back" ) view = mitk::CameraController::POSTERIOR; else { std::cerr << "Warning in "<<__FILE__<<", "<<__LINE__<<": unknown standard view '" << s.toStdString() << "'" << std::endl; view = mitk::CameraController::ANTERIOR; good = false; } if (good) { if ( m_CameraController.IsNotNull() ) { m_CameraController->SetStandardView( view ); } emit StandardViewDefined( view ); } } - - diff --git a/Modules/QtWidgetsExt/QmitkStandardViews.h b/Modules/QtWidgetsExt/QmitkStandardViews.h index a297babee3..a6d076fd60 100644 --- a/Modules/QtWidgetsExt/QmitkStandardViews.h +++ b/Modules/QtWidgetsExt/QmitkStandardViews.h @@ -1,59 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkStandardViews_h_included #define QmitkStandardViews_h_included #include "mitkCommon.h" #include "MitkQtWidgetsExtExports.h" #include "mitkCameraController.h" #include class QClickableLabel; class vtkRenderWindow; class MitkQtWidgetsExt_EXPORT QmitkStandardViews : public QWidget { Q_OBJECT public: QmitkStandardViews( QWidget * parent = 0, Qt::WindowFlags f = 0 ); virtual ~QmitkStandardViews(); void SetCameraController( mitk::CameraController* controller ); void SetCameraControllerFromRenderWindow( vtkRenderWindow* window ); signals: void StandardViewDefined(mitk::CameraController::StandardView view); protected slots: void hotspotClicked(const QString& s); protected: QClickableLabel* m_ClickablePicture; mitk::CameraController::Pointer m_CameraController; }; #endif + diff --git a/Modules/QtWidgetsExt/QmitkStepperAdapter.cpp b/Modules/QtWidgetsExt/QmitkStepperAdapter.cpp index bd22943fd5..b653689edd 100644 --- a/Modules/QtWidgetsExt/QmitkStepperAdapter.cpp +++ b/Modules/QtWidgetsExt/QmitkStepperAdapter.cpp @@ -1,38 +1,38 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkStepperAdapter.h" -QmitkStepperAdapter::QmitkStepperAdapter( QObject * navigator, mitk::Stepper * stepper, const char * /*name*/ ) +QmitkStepperAdapter::QmitkStepperAdapter( QObject * navigator, mitk::Stepper * stepper, const char *) : QObject( navigator ), m_Stepper(stepper) { connect(this, SIGNAL(SendStepper(mitk::Stepper *)), navigator, SLOT(SetStepper(mitk::Stepper *))); connect(this, SIGNAL(Refetch()), navigator, SLOT(Refetch())); emit SendStepper(stepper); m_ItkEventListener = new ItkEventListener(this); m_ObserverTag = m_Stepper->AddObserver(itk::ModifiedEvent(), m_ItkEventListener); emit Refetch(); } QmitkStepperAdapter::~QmitkStepperAdapter() { m_ItkEventListener->Delete(); m_Stepper->RemoveObserver(m_ObserverTag); } diff --git a/Modules/QtWidgetsExt/QmitkStepperAdapter.h b/Modules/QtWidgetsExt/QmitkStepperAdapter.h index 627f717e62..afa80ea697 100644 --- a/Modules/QtWidgetsExt/QmitkStepperAdapter.h +++ b/Modules/QtWidgetsExt/QmitkStepperAdapter.h @@ -1,86 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 #define QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 #include "qobject.h" #include "MitkQtWidgetsExtExports.h" #include "mitkStepper.h" #include "itkObject.h" #include "itkCommand.h" //##Documentation //## @brief Helper class to connect Qt-based navigators to instances of Stepper //## //## The constructor has to be provided with the \a Navigator //## that wants to use the \a Stepper. The \a Navigator has to define the //## slots \a Refetch() and \a SetStepper(mitk::Stepper *). \a SetStepper will be //## called only once to pass the \a Stepper to the \a Navigator. When the values of //## the \a Stepper changes, \a Refetch() will be called. The \a Navigator can than //## ask the \a Stepper for its new values. //## \warning The \a Navigator has to be aware that it might have caused the changes //## of the \a Stepper itself. So take care that no infinite recursion is created! //## @ingroup NavigationControl class MitkQtWidgetsExt_EXPORT QmitkStepperAdapter : public QObject { Q_OBJECT public: QmitkStepperAdapter( QObject * navigator, mitk::Stepper * stepper, const char * name ); virtual ~QmitkStepperAdapter(); void SetStepper( mitk::Stepper* stepper ) { this->SendStepper( stepper ); this->Refetch(); } class MitkQtWidgetsExt_EXPORT ItkEventListener : public itk::Command { public: mitkClassMacro(ItkEventListener, itk::Command); ItkEventListener(QmitkStepperAdapter* receiver) : m_Receiver(receiver) { }; - virtual void Execute (itk::Object * /* caller */, const itk::EventObject & /* event */) + virtual void Execute (itk::Object*, const itk::EventObject&) { emit m_Receiver->Refetch(); }; - virtual void Execute (const itk::Object * /* caller */, const itk::EventObject & /* event */) + virtual void Execute (const itk::Object*, const itk::EventObject&) { emit m_Receiver->Refetch(); }; protected: QmitkStepperAdapter* m_Receiver; }; signals: void signal_dummy(); void Refetch(); void SendStepper(mitk::Stepper *); protected: mitk::Stepper::Pointer m_Stepper; long m_ObserverTag; friend class QmitkStepperAdapter::ItkEventListener; ItkEventListener::Pointer m_ItkEventListener; }; -#endif /* QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 */ +#endif + diff --git a/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.cpp b/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.cpp index 24a29c209d..ffd5f17359 100755 --- a/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.cpp +++ b/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.cpp @@ -1,258 +1,237 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkTransferFunctionCanvas.h" #include #include #include #include QmitkTransferFunctionCanvas::QmitkTransferFunctionCanvas(QWidget * parent, Qt::WindowFlags f) : QWidget(parent, f), m_GrabbedHandle(-1), m_Lower(0.0), m_Upper(1.0), m_Min(0.0), m_Max(1.0), m_Histogram(0), m_ImmediateUpdate(false), m_Range(0.0f), m_LineEditAvailable(false), m_XEdit(0), m_YEdit(0) { setEnabled(false); setFocusPolicy(Qt::ClickFocus); } void QmitkTransferFunctionCanvas::paintEvent(QPaintEvent* ev) { QWidget::paintEvent(ev); } std::pair QmitkTransferFunctionCanvas::FunctionToCanvas( std::pair functionPoint) { - //std::cout<<"F2C.first: "<<(int)((functionPoint.first - m_Lower) / (m_Upper - m_Lower) * width())<<" F2C.second: "<<(int)(height() * (1 - functionPoint.second))< QmitkTransferFunctionCanvas::CanvasToFunction( std::pair canvasPoint) { - //std::cout<<"C2F.first: "<<(canvasPoint.first * (m_Upper - m_Lower) / width() + m_Lower)<<" C2F.second: "<<(1.0 - (double)canvasPoint.second / height())<pos().x(), mouseEvent->pos().y()); if (nearHandle != -1) { this->DoubleClickOnHandle(nearHandle); } } /** returns index of a near handle or -1 if none is near */ -int QmitkTransferFunctionCanvas::GetNearHandle(int /*x*/, int /*y*/, - unsigned int /*maxSquaredDistance*/) +int QmitkTransferFunctionCanvas::GetNearHandle(int, int, unsigned int) { return -1; } void QmitkTransferFunctionCanvas::mousePressEvent(QMouseEvent* mouseEvent) { if (m_LineEditAvailable) { m_XEdit->clear(); if(m_YEdit) m_YEdit->clear(); } m_GrabbedHandle = GetNearHandle(mouseEvent->pos().x(), mouseEvent->pos().y()); if ( (mouseEvent->button() & Qt::LeftButton) && m_GrabbedHandle == -1) { this->AddFunctionPoint( this->CanvasToFunction(std::make_pair(mouseEvent->pos().x(), mouseEvent->pos().y())).first, this->CanvasToFunction(std::make_pair(mouseEvent->x(), mouseEvent->y())).second); m_GrabbedHandle = GetNearHandle(mouseEvent->pos().x(), mouseEvent->pos().y()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } else if ((mouseEvent->button() & Qt::RightButton) && m_GrabbedHandle != -1 && this->GetFunctionSize() > 1) { this->RemoveFunctionPoint(this->GetFunctionX(m_GrabbedHandle)); m_GrabbedHandle = -1; mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } update(); - - // m_TransferFunction->UpdateVtkFunctions(); } void QmitkTransferFunctionCanvas::mouseMoveEvent(QMouseEvent* mouseEvent) { if (m_GrabbedHandle != -1) { std::pair newPos = this->CanvasToFunction(std::make_pair(mouseEvent->x(), mouseEvent->y())); // X Clamping { // Check with predecessor if( m_GrabbedHandle > 0 ) if (newPos.first <= this->GetFunctionX(m_GrabbedHandle - 1)) newPos.first = this->GetFunctionX(m_GrabbedHandle); // Check with sucessor if( m_GrabbedHandle < this->GetFunctionSize()-1 ) if (newPos.first >= this->GetFunctionX(m_GrabbedHandle + 1)) newPos.first = this->GetFunctionX(m_GrabbedHandle); // Clamping to histogramm if (newPos.first < m_Min) newPos.first = m_Min; else if (newPos.first > m_Max) newPos.first = m_Max; } // Y Clamping { if (newPos.second < 0.0) newPos.second = 0.0; else if (newPos.second > 1.0) newPos.second = 1.0; } // Move selected point this->MoveFunctionPoint(m_GrabbedHandle, newPos); - /* - // Search again selected point ??????? should not be required, seems like a legacy workaround/bugfix - // and no longer required - m_GrabbedHandle = -1; - for (int i = 0; i < this->GetFunctionSize(); i++) - { - if (this->GetFunctionX(i) == newPos.first) - { - m_GrabbedHandle = i; - break; - } - } - */ - update(); - //if (m_ImmediateUpdate) - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void QmitkTransferFunctionCanvas::mouseReleaseEvent(QMouseEvent*) { - // m_GrabbedHandle = -1; update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkTransferFunctionCanvas::PaintHistogram(QPainter &p) { if(m_Histogram) { p.save(); p.setPen(Qt::gray); int displayWidth = contentsRect().width(); int displayHeight = contentsRect().height(); double windowLeft = m_Lower; double windowRight = m_Upper; double step = (windowRight-windowLeft)/double(displayWidth); double pos = windowLeft; for (int x = 0; x < displayWidth; x++) { double left = pos; double right = pos + step; float height = m_Histogram->GetRelativeBin( left , right ); if (height >= 0) p.drawLine(x, displayHeight*(1-height), x, displayHeight); pos += step; } p.restore(); } } void QmitkTransferFunctionCanvas::keyPressEvent(QKeyEvent * e) { if( m_GrabbedHandle == -1) return; switch(e->key()) { case Qt::Key_Delete: if(this->GetFunctionSize() > 1) { this->RemoveFunctionPoint(GetFunctionX(m_GrabbedHandle)); m_GrabbedHandle = -1; } break; case Qt::Key_Left: this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle)-1 , GetFunctionY(m_GrabbedHandle)))); break; case Qt::Key_Right: this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle)+1 , GetFunctionY(m_GrabbedHandle)))); break; case Qt::Key_Up: this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle) , GetFunctionY(m_GrabbedHandle)+0.001))); break; case Qt::Key_Down: this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair( GetFunctionX(m_GrabbedHandle) , GetFunctionY(m_GrabbedHandle)-0.001))); break; } update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } // Update immediatly while changing the transfer function void QmitkTransferFunctionCanvas::SetImmediateUpdate(bool state) { m_ImmediateUpdate = state; } + diff --git a/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.h b/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.h index bdcc2b403c..fc3d4888fb 100755 --- a/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.h +++ b/Modules/QtWidgetsExt/QmitkTransferFunctionCanvas.h @@ -1,167 +1,166 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTRANSFERFUNCTIONCANVAS_H_INCLUDED #define QMITKTRANSFERFUNCTIONCANVAS_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include #include class MitkQtWidgetsExt_EXPORT QmitkTransferFunctionCanvas : public QWidget { Q_OBJECT public: QmitkTransferFunctionCanvas( QWidget * parent=0, Qt::WindowFlags f = 0 ); mitk::SimpleHistogram* GetHistogram() { return m_Histogram; } void SetHistogram(mitk::SimpleHistogram *histogram) { m_Histogram = histogram; } double GetMin() { return m_Min; } void SetMin(double min) { this->m_Min = min; SetLower(min); } double GetMax() { return m_Max; } void SetMax(double max) { this->m_Max = max; SetUpper(max); } double GetLower() { return m_Lower; } void SetLower(double lower) { this->m_Lower = lower; } double GetUpper() { return m_Upper; } void SetUpper(double upper) { this->m_Upper = upper; } - // itkGetConstObjectMacro(Histogram,mitk::HistogramGenerator::HistogramType); - // itkSetObjectMacro(Histogram,mitk::HistogramGenerator::HistogramType); void mousePressEvent( QMouseEvent* mouseEvent ); virtual void paintEvent( QPaintEvent* e ); virtual void DoubleClickOnHandle(int handle) = 0; void mouseMoveEvent( QMouseEvent* mouseEvent ); void mouseReleaseEvent( QMouseEvent* mouseEvent ); void mouseDoubleClickEvent( QMouseEvent* mouseEvent ); void PaintHistogram(QPainter &p); virtual int GetNearHandle(int x,int y,unsigned int maxSquaredDistance = 32) = 0; virtual void AddFunctionPoint(double x,double val) = 0; virtual void RemoveFunctionPoint(double x) = 0; virtual void MoveFunctionPoint(int index, std::pair pos) = 0; virtual double GetFunctionX(int index) = 0; virtual float GetFunctionY(int index) = 0; virtual int GetFunctionSize() = 0; int m_GrabbedHandle; double m_Lower, m_Upper, m_Min, m_Max; std::pair FunctionToCanvas(std::pair); std::pair CanvasToFunction(std::pair); mitk::SimpleHistogram *m_Histogram; void keyPressEvent ( QKeyEvent * e ); void SetImmediateUpdate(bool state); static std::pair ValidateCoord( std::pair x ) { if( x.first < -2048 ) x.first = -2048; if( x.first > 2048 ) x.first = 2048; if( x.second < 0 ) x.second = 0; if( x.second > 1 ) x.second = 1; return x; } void SetX(float x) { if (m_GrabbedHandle != -1) { this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(x,GetFunctionY(m_GrabbedHandle)))); update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void SetY(float y) { if (m_GrabbedHandle != -1) { this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(GetFunctionX(m_GrabbedHandle),y))); update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void SetQLineEdits(QLineEdit* xEdit, QLineEdit* yEdit) { m_XEdit = xEdit; m_YEdit = yEdit; m_LineEditAvailable = true; } protected: bool m_ImmediateUpdate; float m_Range; bool m_LineEditAvailable; QLineEdit* m_XEdit; QLineEdit* m_YEdit; }; + #endif diff --git a/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.cpp b/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.cpp index a5d3fdcad1..f14c958f1e 100644 --- a/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.cpp @@ -1,508 +1,414 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkTransferFunctionGeneratorWidget.h" #include #include #include #include #include #include #include #include QmitkTransferFunctionGeneratorWidget::QmitkTransferFunctionGeneratorWidget(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f), deltaScale(1.0), deltaMax(1024), deltaMin(1) { histoGramm = NULL; this->setupUi(this); // LevelWindow Tab { connect( m_CrossLevelWindow, SIGNAL( SignalDeltaMove( int, int ) ), this, SLOT( OnDeltaLevelWindow( int, int ) ) ); } // Threshold Tab { connect( m_CrossThreshold, SIGNAL( SignalDeltaMove( int, int ) ), this, SLOT( OnDeltaThreshold( int, int ) ) ); thDelta = 100; } // Presets Tab { m_TransferFunctionComboBox->setVisible(false); connect( m_TransferFunctionComboBox, SIGNAL( activated( int ) ), this, SIGNAL(SignalTransferFunctionModeChanged(int)) ); connect( m_TransferFunctionComboBox, SIGNAL( activated( int ) ), this, SLOT(OnPreset(int)) ); connect( m_SavePreset, SIGNAL( clicked() ), this, SLOT( OnSavePreset() ) ); connect( m_LoadPreset, SIGNAL( clicked() ), this, SLOT( OnLoadPreset() ) ); } presetFileName = "."; } int QmitkTransferFunctionGeneratorWidget::AddPreset(const QString &presetName) { m_TransferFunctionComboBox->setVisible(true); m_TransferFunctionComboBox->addItem( presetName); return m_TransferFunctionComboBox->count()-1; } void QmitkTransferFunctionGeneratorWidget::SetPresetsTabEnabled(bool enable) { m_PresetTab->setEnabled(enable); } void QmitkTransferFunctionGeneratorWidget::SetThresholdTabEnabled(bool enable) { m_ThresholdTab->setEnabled(enable); } void QmitkTransferFunctionGeneratorWidget::SetBellTabEnabled(bool enable) { m_BellTab->setEnabled(enable); } void QmitkTransferFunctionGeneratorWidget::OnSavePreset( ) { if(tfpToChange.IsNull()) return; mitk::TransferFunction::Pointer tf = tfpToChange->GetValue(); std::string fileName; std::string fileNameOutput; presetFileName = QFileDialog::getSaveFileName( this,"Choose a filename to save the transferfunction",presetFileName, "Transferfunction (*.xml)" ); fileName=presetFileName.toLocal8Bit().constData(); MITK_INFO << "Saving Transferfunction under path: " << fileName; fileNameOutput= ReduceFileName(fileName); if ( mitk::TransferFunctionPropertySerializer::SerializeTransferFunction( fileName.c_str(), tf )) m_InfoPreset->setText( QString( (std::string("saved ")+ fileNameOutput).c_str() ) ); else m_InfoPreset->setText( QString( std::string("saving failed").c_str() ) ); - /* - FILE *f=fopen("c:\\temp.txt","w"); - - - // grayvalue -> opacity - { - mitk::TransferFunction::ControlPoints scalarOpacityPoints = tf->GetScalarOpacityPoints(); - fprintf(f,"// grayvalue->opacity \n" - "{\n" - " vtkPiecewiseFunction *f=tf->GetScalarOpacityFunction();\n" - " f->RemoveAllPoints();\n"); - for ( mitk::TransferFunction::ControlPoints::iterator iter = scalarOpacityPoints.begin(); iter != scalarOpacityPoints.end(); ++iter ) - fprintf(f," f->AddPoint(%f,%f);\n",iter->first, iter->second); - fprintf(f," f->Modified();\n" - "}\n"); - } - - // gradient - { - mitk::TransferFunction::ControlPoints gradientOpacityPoints = tf->GetGradientOpacityPoints(); - fprintf(f,"// gradient at grayvalue->opacity \n" - "{\n" - " vtkPiecewiseFunction *f=tf->GetGradientOpacityFunction();\n" - " f->RemoveAllPoints();\n"); - for ( mitk::TransferFunction::ControlPoints::iterator iter = gradientOpacityPoints.begin(); iter != gradientOpacityPoints.end(); ++iter ) - fprintf(f," f->AddPoint(%f,%f);\n",iter->first, iter->second); - fprintf(f," f->Modified();\n" - "}\n"); - } - - // color - { - mitk::TransferFunction::RGBControlPoints points = tf->GetRGBPoints(); - - fprintf(f,"// grayvalue->color \n" - "{\n" - " vtkColorTransferFunction *f=tf->GetColorTransferFunction();\n" - " f->RemoveAllPoints();\n"); - for ( mitk::TransferFunction::RGBControlPoints::iterator iter = points.begin(); iter != points.end(); ++iter ) - fprintf(f," f->AddRGBPoint(%f,%f,%f,%f);\n",iter->first, iter->second[0], iter->second[1], iter->second[2]); - fprintf(f," f->Modified();\n" - "}\n"); - } - - fclose(f); - - MITK_INFO << "saved under C:\\temp.txt"; - */ } void QmitkTransferFunctionGeneratorWidget::OnLoadPreset( ) { if(tfpToChange.IsNull()) return; std::string fileName; std::string fileNameOutput; presetFileName = QFileDialog::getOpenFileName( this,"Choose a file to open the transferfunction from",presetFileName, "Transferfunction (*.xml)" ); fileName=presetFileName.toLocal8Bit().constData(); MITK_INFO << "Loading Transferfunction from path: " << fileName; fileNameOutput= ReduceFileName(fileName); mitk::TransferFunction::Pointer tf = mitk::TransferFunctionPropertySerializer::DeserializeTransferFunction(fileName.c_str()); if(tf.IsNotNull()) { - /* - if( histoGramm ) - tf->InitializeByItkHistogram( histoGramm ); - */ - tfpToChange->SetValue( tf ); m_InfoPreset->setText( QString( (std::string("loaded ")+ fileNameOutput).c_str() ) ); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalUpdateCanvas(); - - /* - double* dp = tf->GetScalarOpacityFunction()->GetDataPointer(); - for (int i = 0; i < tf->GetScalarOpacityFunction()->GetSize(); i++) - { - MITK_INFO << "x: " << dp[i * 2] << " y: " << dp[i * 2 + 1]; - } - */ } } void QmitkTransferFunctionGeneratorWidget::OnPreset(int mode) { //first item is only information if( --mode == -1 ) return; m_InfoPreset->setText(QString("selected ") + m_TransferFunctionComboBox->currentText()); //revert to first item m_TransferFunctionComboBox->setCurrentIndex( 0 ); } static double transformationGlocke ( double x ) { double z = 0.1; double a = 2 - 2 * z; double b = 2 * z - 1; x = a * x + b; return x; } static double stepFunctionGlocke ( double x ) { x = 1-(2*x -1.0); // map [0.5;1] to [0,1] x = x * ( 3*x - 2*x*x ); // apply smoothing function x = x * x; return x; } double QmitkTransferFunctionGeneratorWidget::ScaleDelta(int d) const { - //MITK_INFO << "Scaling (int) " << d << "to (double) " << deltaScale*(double)d; return deltaScale*(double)d; } -void QmitkTransferFunctionGeneratorWidget::OnDeltaLevelWindow(int dx, int dy) // bell +void QmitkTransferFunctionGeneratorWidget::OnDeltaLevelWindow(int dx, int dy) // bell { - //std::string infoText; - -// m_InfoThreshold->setText( QString( x.c_str() ) ); - if(tfpToChange.IsNull()) return; thPos += ScaleDelta(dx); thDelta -= ScaleDelta(dy); if(thDelta < deltaMin) thDelta = deltaMin; if(thDelta > deltaMax) thDelta = deltaMax; if(thPos < histoMinimum) thPos = histoMinimum; if(thPos > histoMaximum) thPos = histoMaximum; std::stringstream ss; ss << "Click on the cross and move the mouse"<<"\n" <<"\n" << "center at " << thPos << "\n" << "width " << thDelta * 2; m_InfoLevelWindow->setText( QString( ss.str().c_str() ) ); mitk::TransferFunction::Pointer tf = tfpToChange->GetValue(); // grayvalue->opacity { vtkPiecewiseFunction *f=tf->GetScalarOpacityFunction(); f->RemoveAllPoints(); for( int r = 0; r<= 6; r++) { double relPos = (r / 6.0) * 0.5 + 0.5; f->AddPoint(thPos+thDelta*(-transformationGlocke(relPos)),stepFunctionGlocke(relPos)); f->AddPoint(thPos+thDelta*( transformationGlocke(relPos)),stepFunctionGlocke(relPos)); } f->Modified(); } // gradient at grayvalue->opacity { vtkPiecewiseFunction *f=tf->GetGradientOpacityFunction(); f->RemoveAllPoints(); f->AddPoint( 0, 1.0 ); f->Modified(); } -/* - // grayvalue->color - { - vtkColorTransferFunction *ctf=tf->GetColorTransferFunction(); - ctf->RemoveAllPoints(); - ctf->AddRGBPoint( 0, 1.0, 1.0, 1.0 ); - ctf->Modified(); - } - */ + tf->Modified(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalUpdateCanvas(); } static double stepFunctionThreshold ( double x ) { x = 0.5*x + 0.5; // map [-1;1] to [0,1] x = x * ( 3*x - 2*x*x ); // apply smoothing function x = x * x; return x; } -void QmitkTransferFunctionGeneratorWidget::OnDeltaThreshold(int dx, int dy) // LEVELWINDOW +void QmitkTransferFunctionGeneratorWidget::OnDeltaThreshold(int dx, int dy) // LEVELWINDOW { if(tfpToChange.IsNull()) return; thPos += ScaleDelta(dx); thDelta += ScaleDelta(dy); if(thDelta < deltaMin) thDelta = deltaMin; if(thDelta > deltaMax) thDelta = deltaMax; if(thPos < histoMinimum) thPos = histoMinimum; if(thPos > histoMaximum) thPos = histoMaximum; - //MITK_INFO << "threshold pos: " << thPos << " delta: " << thDelta; - //MITK_INFO << "histoMinimum: " << histoMinimum << " max: " << histoMaximum; - - - std::stringstream ss; ss << "Click on the cross and move the mouse"<<"\n" <<"\n" << "threshold at " << thPos << "\n" << "width " << thDelta * 2; m_InfoThreshold->setText( QString( ss.str().c_str() ) ); mitk::TransferFunction::Pointer tf = tfpToChange->GetValue(); // grayvalue->opacity { vtkPiecewiseFunction *f=tf->GetScalarOpacityFunction(); f->RemoveAllPoints(); for( int r = 1; r<= 4; r++) { double relPos = r / 4.0; f->AddPoint(thPos+thDelta*(-relPos),stepFunctionThreshold(-relPos)); f->AddPoint(thPos+thDelta*( relPos),stepFunctionThreshold( relPos)); } f->Modified(); } // gradient at grayvalue->opacity { vtkPiecewiseFunction *f=tf->GetGradientOpacityFunction(); f->RemoveAllPoints(); f->AddPoint( 0, 1.0 ); f->Modified(); } -/* - // grayvalue->color - { - vtkColorTransferFunction *ctf=tf->GetColorTransferFunction(); - ctf->RemoveAllPoints(); - ctf->AddRGBPoint( 0, 1.0, 1.0, 1.0 ); - ctf->Modified(); - } - */ tf->Modified(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); emit SignalUpdateCanvas(); } std::string QmitkTransferFunctionGeneratorWidget::ReduceFileName(std::string fileNameLong ) { if (fileNameLong.length()< 40) return fileNameLong; - //MITK_INFO <<" fileName > 20 "; - std::string fileNameShort; std::string fileNameRevert; for(unsigned int i=0; i< fileNameLong.length(); i++) { if(i<3) { char x= fileNameLong[i]; fileNameShort= fileNameShort+x; } if(i==3) { fileNameShort= fileNameShort+"..."; break; } } - //MITK_INFO <<" fileNameShort: " << fileNameShort.c_str(); + unsigned int len( fileNameLong.length() ); for(unsigned int i=len-1; i <= len; i--) { std::string x=std::string("")+fileNameLong[i]; if ( x.compare("/")==0 || x.compare("\\")==0) { fileNameRevert= "/" + fileNameRevert; break; } if (i>=fileNameLong.length()-24) { fileNameRevert= x+ fileNameRevert; - //MITK_INFO <<" fileNameRevert: " << fileNameRevert.c_str(); } else { fileNameRevert= "/..." + fileNameRevert; break; } } return fileNameShort+fileNameRevert; } QmitkTransferFunctionGeneratorWidget::~QmitkTransferFunctionGeneratorWidget() { } void QmitkTransferFunctionGeneratorWidget::SetDataNode(mitk::DataNode* node) { histoGramm = NULL; if (node) { tfpToChange = dynamic_cast(node->GetProperty("TransferFunction")); if(!tfpToChange) { node->SetProperty("TransferFunction", tfpToChange = mitk::TransferFunctionProperty::New() ); dynamic_cast(node->GetProperty("TransferFunction")); } mitk::TransferFunction::Pointer tf = tfpToChange->GetValue(); if( mitk::Image* image = dynamic_cast( node->GetData() ) ) { -// tf->InitializeByItkHistogram( histoGramm = image->GetScalarHistogram() ); histoMinimum= image->GetScalarValueMin(); histoMaximum= image->GetScalarValueMax(); } else if (mitk::UnstructuredGrid* grid = dynamic_cast( node->GetData() ) ) { double* range = grid->GetVtkUnstructuredGrid()->GetScalarRange(); histoMinimum = range[0]; histoMaximum = range[1]; double histoRange = histoMaximum - histoMinimum; deltaMax = histoRange/4.0; deltaMin = histoRange/400.0; deltaScale = histoRange/1024.0; } else { MITK_WARN << "QmitkTransferFunctonGeneratorWidget does not support " << node->GetData()->GetNameOfClass() << " instances"; } thPos = ( histoMinimum + histoMaximum ) / 2.0; } else { tfpToChange = 0; m_InfoPreset->setText( QString( "" ) ); } } - - diff --git a/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.h b/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.h index fb5a56f664..d215d33fc4 100644 --- a/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.h +++ b/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.h @@ -1,88 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTRANSFERFUNCTIONGENERATORWIDGET_H #define QMITKTRANSFERFUNCTIONGENERATORWIDGET_H #include "ui_QmitkTransferFunctionGeneratorWidget.h" #include "MitkQtWidgetsExtExports.h" #include #include #include #include class MitkQtWidgetsExt_EXPORT QmitkTransferFunctionGeneratorWidget : public QWidget, public Ui::QmitkTransferFunctionGeneratorWidget { Q_OBJECT public: QmitkTransferFunctionGeneratorWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); ~QmitkTransferFunctionGeneratorWidget () ; void SetDataNode(mitk::DataNode* node); int AddPreset(const QString& presetName); void SetPresetsTabEnabled(bool enable); void SetThresholdTabEnabled(bool enable); void SetBellTabEnabled(bool enable); public slots: void OnSavePreset( ); void OnLoadPreset( ); void OnDeltaLevelWindow( int dx, int dy ); void OnDeltaThreshold( int dx, int dy ); signals: void SignalTransferFunctionModeChanged( int ); void SignalUpdateCanvas(); protected slots: void OnPreset( int mode ); protected: mitk::TransferFunctionProperty::Pointer tfpToChange; double histoMinimum; double histoMaximum; double thPos; double thDelta; double deltaScale; double deltaMax; double deltaMin; const mitk::Image::HistogramType *histoGramm; QString presetFileName; std::string ReduceFileName(std::string fileNameLong ); double ScaleDelta(int d) const; }; + #endif + diff --git a/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.ui b/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.ui index a71c38d19d..92c187bfea 100644 --- a/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.ui +++ b/Modules/QtWidgetsExt/QmitkTransferFunctionGeneratorWidget.ui @@ -1,416 +1,416 @@ QmitkTransferFunctionGeneratorWidget 0 0 349 316 1 1 16777215 16777215 Form 0 0 0 0 0 16777215 120 0 0 0 Presets Apply internal MITK transferfunction presets. Or save and load your own created transferfunctions in a folder in XML format. Qt::Vertical 20 0 true 0 0 0 0 Choose one of generic MITK internal presets to apply on standard CT data or MR data. Load a MITK internal preset -1 16 16 false true 0 1 0 0 16777215 25 Qt::AutoText Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop true 0 0 0 64 16777215 Load a transferfunction in xml-format from the filesystem. The load includes all transferfunctions: grayvalue, color and gradient. Load 0 0 64 16777215 Save a transferfunction in xml-format in the filesystem. The save includes all transferfunctions: grayvalue, color and gradient. Save 0 0 Threshold Generate a threshold transfer function interactively. 0 0 0 0 48 48 Click and hold left mouse button on the cross. Move the mouse to the top and the function will be flatter. Move the mouse to the bottom and the function will be steeper. Move the mouse to the left and the function moves to the left. Move the mouse to the right and the function moves to the right. Qt::LeftToRight - :/qmitk/cross.png + :/QtWidgetsExt/cross.png true Qt::AlignCenter -1 Qt::NoTextInteraction 0 0 0 0 7 Click and hold left mouse button on the cross to interactively generate a threshold transferfunction Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop true 0 0 Bell Generate a bell transfer function interactively. 0 0 0 0 48 48 Click and hold left mouse button on the cross. Move the mouse to the top and the bell will be wider. Move the mouse to the bottom and the bell will be flattened. Move the mouse to the left and the center of the bell moves to the left. Move the mouse to the right and the center of the bell moves to the right. - :/qmitk/cross.png + :/QtWidgetsExt/cross.png true Qt::AlignCenter Qt::NoTextInteraction 0 0 0 0 7 Click and hold left mouse button on the cross to interactively generate a bell transferfunction Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop true QmitkCrossWidget QLabel
QmitkCrossWidget.h
diff --git a/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.cpp b/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.cpp index 4a0b4f7466..c714e1914e 100755 --- a/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.cpp +++ b/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.cpp @@ -1,260 +1,251 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkTransferFunctionWidget.h" #include #include QmitkTransferFunctionWidget::QmitkTransferFunctionWidget(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f) { this->setupUi(this); // signals and slots connections connect(m_XEditScalarOpacity, SIGNAL(returnPressed()), this, SLOT(SetXValueScalar())); connect(m_YEditScalarOpacity, SIGNAL(returnPressed()), this, SLOT(SetYValueScalar())); connect(m_XEditGradientOpacity, SIGNAL(returnPressed()), this, SLOT(SetXValueGradient())); connect(m_YEditGradientOpacity, SIGNAL(returnPressed()), this, SLOT(SetYValueGradient())); connect(m_XEditColor, SIGNAL(returnPressed()), this, SLOT(SetXValueColor())); QPlastiqueStyle *sliderStyle = new QPlastiqueStyle(); m_RangeSlider->setMaximum(2048); m_RangeSlider->setMinimum(-2048); m_RangeSlider->setHandleMovementMode(QxtSpanSlider::NoOverlapping); m_RangeSlider->setStyle(sliderStyle); connect(m_RangeSlider, SIGNAL(spanChanged(double,double)),this, SLOT(OnSpanChanged(double,double))); //reset button connect(m_RangeSliderReset, SIGNAL(pressed()), this, SLOT(OnResetSlider())); m_ScalarOpacityFunctionCanvas->SetQLineEdits(m_XEditScalarOpacity, m_YEditScalarOpacity); m_GradientOpacityCanvas->SetQLineEdits(m_XEditGradientOpacity, m_YEditGradientOpacity); m_ColorTransferFunctionCanvas->SetQLineEdits(m_XEditColor, 0); m_ScalarOpacityFunctionCanvas->SetTitle("Grayvalue -> Opacity"); m_GradientOpacityCanvas->SetTitle("Grayvalue/Gradient -> Opacity"); m_ColorTransferFunctionCanvas->SetTitle("Grayvalue -> Color"); } QmitkTransferFunctionWidget::~QmitkTransferFunctionWidget() { } void QmitkTransferFunctionWidget::SetIntegerMode(bool intMode) { m_RangeSlider->setIntegerMode(intMode); } void QmitkTransferFunctionWidget::SetScalarLabel(const QString& scalarLabel) { m_textLabelX->setText(scalarLabel); m_textLabelX_2->setText(scalarLabel); m_textLabelX_3->setText(scalarLabel); m_ScalarOpacityFunctionCanvas->SetTitle(scalarLabel + " -> Opacity"); m_GradientOpacityCanvas->SetTitle(scalarLabel + "/Gradient -> Opacity"); m_ColorTransferFunctionCanvas->SetTitle(scalarLabel + " -> Color"); } void QmitkTransferFunctionWidget::ShowScalarOpacityFunction(bool show) { m_ScalarOpacityWidget->setVisible(show); } void QmitkTransferFunctionWidget::ShowColorFunction(bool show) { m_ColorWidget->setVisible(show); } void QmitkTransferFunctionWidget::ShowGradientOpacityFunction(bool show) { m_GradientOpacityWidget->setVisible(show); } void QmitkTransferFunctionWidget::SetScalarOpacityFunctionEnabled(bool enable) { m_ScalarOpacityWidget->setEnabled(enable); } void QmitkTransferFunctionWidget::SetColorFunctionEnabled(bool enable) { m_ColorWidget->setEnabled(enable); } void QmitkTransferFunctionWidget::SetGradientOpacityFunctionEnabled(bool enable) { m_GradientOpacityWidget->setEnabled(enable); } void QmitkTransferFunctionWidget::SetDataNode(mitk::DataNode* node) { - - //MITK_INFO << "TransW called with" << (1&&node); - - if (node) { tfpToChange = dynamic_cast(node->GetProperty("TransferFunction")); if(!tfpToChange) { if (! dynamic_cast(node->GetData())) { MITK_WARN << "QmitkTransferFunctionWidget::SetDataNode called with non-image node"; goto turnOff; } node->SetProperty("TransferFunction", tfpToChange = mitk::TransferFunctionProperty::New() ); } mitk::TransferFunction::Pointer tf = tfpToChange->GetValue(); if( mitk::BaseData* data = node->GetData() ) { mitk::SimpleHistogram *h = histogramCache[data]; m_RangeSliderMin= h->GetMin(); m_RangeSliderMax= h->GetMax(); m_RangeSlider->blockSignals(true); m_RangeSlider->setMinimum(m_RangeSliderMin); m_RangeSlider->setMaximum(m_RangeSliderMax); m_RangeSlider->setSpan( m_RangeSliderMin, m_RangeSliderMax); m_RangeSlider->blockSignals(false); m_ScalarOpacityFunctionCanvas->SetHistogram( h ); m_GradientOpacityCanvas->SetHistogram( h ); } - //UpdateRanges(); OnUpdateCanvas(); return; } turnOff: m_ScalarOpacityFunctionCanvas->setEnabled(false); m_ScalarOpacityFunctionCanvas->SetHistogram(0); m_GradientOpacityCanvas->setEnabled(false); m_GradientOpacityCanvas->SetHistogram(0); m_ColorTransferFunctionCanvas->setEnabled(false); tfpToChange = 0; } - void QmitkTransferFunctionWidget::OnUpdateCanvas() { if(tfpToChange.IsNull()) return; mitk::TransferFunction::Pointer tf = tfpToChange->GetValue(); if(tf.IsNull()) return; m_ScalarOpacityFunctionCanvas->SetPiecewiseFunction( tf->GetScalarOpacityFunction() ); m_GradientOpacityCanvas->SetPiecewiseFunction( tf->GetGradientOpacityFunction() ); m_ColorTransferFunctionCanvas->SetColorTransferFunction( tf->GetColorTransferFunction() ); UpdateRanges(); m_ScalarOpacityFunctionCanvas->update(); m_GradientOpacityCanvas->update(); m_ColorTransferFunctionCanvas->update(); } void QmitkTransferFunctionWidget::SetXValueScalar() { m_ScalarOpacityFunctionCanvas->SetX(m_XEditScalarOpacity->text().toFloat()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkTransferFunctionWidget::SetYValueScalar() { m_ScalarOpacityFunctionCanvas->SetY(m_YEditScalarOpacity->text().toFloat()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkTransferFunctionWidget::SetXValueGradient() { m_GradientOpacityCanvas->SetX(m_XEditGradientOpacity->text().toFloat()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkTransferFunctionWidget::SetYValueGradient() { m_GradientOpacityCanvas->SetY(m_YEditGradientOpacity->text().toFloat()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkTransferFunctionWidget::SetXValueColor() { m_ColorTransferFunctionCanvas->SetX(m_XEditColor->text().toFloat()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkTransferFunctionWidget::UpdateRanges() { double lower = m_RangeSlider->lowerValue(); double upper = m_RangeSlider->upperValue(); - //MITK_INFO << "UpdateRanges: lower: " << lower << " upper: " << upper; - m_ScalarOpacityFunctionCanvas->SetMin(lower); m_ScalarOpacityFunctionCanvas->SetMax(upper); m_GradientOpacityCanvas->SetMin(lower); m_GradientOpacityCanvas->SetMax(upper); m_ColorTransferFunctionCanvas->SetMin(lower); m_ColorTransferFunctionCanvas->SetMax(upper); } -void QmitkTransferFunctionWidget::OnSpanChanged(double /*lower*/, double /*upper*/) +void QmitkTransferFunctionWidget::OnSpanChanged(double, double) { - //MITK_INFO << "OnSpanChanged, m_RangeSlider: lowerValue: " << lower << "upperValue: " << upper; - UpdateRanges(); m_GradientOpacityCanvas->update(); m_ColorTransferFunctionCanvas->update(); m_ScalarOpacityFunctionCanvas->update(); } void QmitkTransferFunctionWidget::OnResetSlider() { m_RangeSlider->blockSignals(true); m_RangeSlider->setUpperValue(m_RangeSliderMax); m_RangeSlider->setLowerValue(m_RangeSliderMin); m_RangeSlider->blockSignals(false); UpdateRanges(); m_GradientOpacityCanvas->update(); m_ColorTransferFunctionCanvas->update(); m_ScalarOpacityFunctionCanvas->update(); } + diff --git a/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.h b/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.h index 4172cb838c..317cf66c29 100755 --- a/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.h +++ b/Modules/QtWidgetsExt/QmitkTransferFunctionWidget.h @@ -1,85 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTRANSFERFUNCTIONWIDGET_H #define QMITKTRANSFERFUNCTIONWIDGET_H #include "ui_QmitkTransferFunctionWidget.h" #include "MitkQtWidgetsExtExports.h" #include #include #include #include #include #include #include class MitkQtWidgetsExt_EXPORT QmitkTransferFunctionWidget : public QWidget, public Ui::QmitkTransferFunctionWidget { Q_OBJECT public: QmitkTransferFunctionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); ~QmitkTransferFunctionWidget () ; void SetDataNode(mitk::DataNode* node); void SetIntegerMode(bool intMode); void SetScalarLabel(const QString& scalarLabel); void ShowScalarOpacityFunction(bool show); void ShowColorFunction(bool show); void ShowGradientOpacityFunction(bool show); void SetScalarOpacityFunctionEnabled(bool enable); void SetColorFunctionEnabled(bool enable); void SetGradientOpacityFunctionEnabled(bool enable); public slots: void SetXValueScalar(); void SetYValueScalar(); void SetXValueGradient(); void SetYValueGradient(); void SetXValueColor(); void OnUpdateCanvas(); void UpdateRanges(); void OnResetSlider(); void OnSpanChanged (double lower, double upper); protected: mitk::TransferFunctionProperty::Pointer tfpToChange; double m_RangeSliderMin; double m_RangeSliderMax; mitk::SimpleHistogramCache histogramCache; }; + #endif + diff --git a/Modules/QtWidgetsExt/QmitkVideoBackground.cpp b/Modules/QtWidgetsExt/QmitkVideoBackground.cpp index 5cffe9166e..968c8234d3 100644 --- a/Modules/QtWidgetsExt/QmitkVideoBackground.cpp +++ b/Modules/QtWidgetsExt/QmitkVideoBackground.cpp @@ -1,303 +1,303 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkVideoBackground.h" // MITK includes #include "mitkVtkLayerController.h" #include "mitkRenderingManager.h" // QT includes #include // itk includes #include // VTK includes #include #include #include #include #include #include #include #include #include #include #include #include QmitkVideoBackground::QmitkVideoBackground( QObject *parent ) : QObject(parent) , m_QTimer(new QTimer(this)) , m_VideoSource(0) , m_VideoSourceObserverTag(0) { this->ResetVideoBackground(); } QmitkVideoBackground::QmitkVideoBackground(mitk::VideoSource* v, int TimerDelay) : QObject(0) , m_QTimer(new QTimer(this)) , m_VideoSource(0) , m_VideoSourceObserverTag(0) { this->SetVideoSource( v ); this->ResetVideoBackground(); } void QmitkVideoBackground::ResetVideoBackground() { m_QTimer->setInterval(25); connect( m_QTimer, SIGNAL(timeout()), SLOT(UpdateVideo()) ); m_renderWindowVectorInfo.clear(); } QmitkVideoBackground::~QmitkVideoBackground() { this->Disable(); } void QmitkVideoBackground::AddRenderWindow(vtkRenderWindow* renderWindow ) { if(!renderWindow || !m_VideoSource) { MITK_WARN << "No Renderwindow or VideoSource set!"; return; } this->RemoveRenderWindow(renderWindow); vtkRenderer* videoRenderer = vtkRenderer::New(); vtkImageActor* videoActor = vtkImageActor::New(); vtkImageImport* videoImport = vtkImageImport::New(); videoImport->SetDataScalarTypeToUnsignedChar(); videoImport->SetNumberOfScalarComponents(3); if(m_VideoSource->GetImageWidth() == 0) m_VideoSource->FetchFrame(); videoImport->SetWholeExtent(0, m_VideoSource->GetImageWidth()-1, 0, m_VideoSource->GetImageHeight()-1, 0, 1-1); videoImport->SetDataExtentToWholeExtent(); VideoBackgroundVectorInfo v; v.renWin = renderWindow; v.videoRenderer = videoRenderer; v.videoActor = videoActor; v.videoImport = videoImport; // callback for the deletion of the renderwindow vtkSmartPointer deleteCallback = vtkSmartPointer::New(); deleteCallback->SetCallback ( QmitkVideoBackground::OnRenderWindowDelete ); deleteCallback->SetClientData(this); v.renderWindowObserverTag = renderWindow->AddObserver( vtkCommand::DeleteEvent, deleteCallback ); m_renderWindowVectorInfo.push_back(v); // completes the initialization this->Modified(); } void QmitkVideoBackground::RemoveRenderWindow( vtkRenderWindow* renderWindow ) { this->RemoveRenderWindow(renderWindow, true); } void QmitkVideoBackground::RemoveRenderWindow( vtkRenderWindow* renderWindow, bool removeObserver ) { // search for renderwindow and remove it for(RenderWindowVectorInfoType::iterator it = m_renderWindowVectorInfo.begin(); it != m_renderWindowVectorInfo.end(); it++) { if((*it).renWin == renderWindow) { mitk::VtkLayerController* layerController = mitk::VtkLayerController::GetInstance((*it).renWin); // unregister video backround renderer from renderwindow if( layerController ) layerController->RemoveRenderer((*it).videoRenderer); (*it).videoRenderer->Delete(); (*it).videoActor->Delete(); (*it).videoImport->Delete(); // remove listener if(removeObserver) renderWindow->RemoveObserver( (*it).renderWindowObserverTag ); m_renderWindowVectorInfo.erase(it); break; } } } bool QmitkVideoBackground::IsRenderWindowIncluded(vtkRenderWindow* renderWindow ) { for(RenderWindowVectorInfoType::iterator it = m_renderWindowVectorInfo.begin(); it != m_renderWindowVectorInfo.end(); it++) { if((*it).renWin == renderWindow) return true; } return false; } void QmitkVideoBackground::Pause() { m_QTimer->stop(); } void QmitkVideoBackground::Resume() { m_QTimer->start(); } /** * Enables drawing of the color Video background. * If you want to disable it, call the Disable() function. */ void QmitkVideoBackground::Enable() { UpdateVideo(); Modified(); m_QTimer->start(); } /** * Disables drawing of the color Video background. * If you want to enable it, call the Enable() function. */ void QmitkVideoBackground::Disable() { if ( this->IsEnabled() ) { mitk::VtkLayerController* layerController = 0; for(RenderWindowVectorInfoType::iterator it = m_renderWindowVectorInfo.begin(); it != m_renderWindowVectorInfo.end(); it++) { layerController = mitk::VtkLayerController::GetInstance((*it).renWin); if(layerController) layerController->RemoveRenderer((*it).videoRenderer); } m_QTimer->stop(); } } bool QmitkVideoBackground::IsEnabled() { return m_QTimer->isActive(); } void QmitkVideoBackground::UpdateVideo() { if( m_renderWindowVectorInfo.size() > 0 ) { unsigned char *src = 0; src = m_VideoSource->GetVideoTexture(); if(src) { for(RenderWindowVectorInfoType::iterator it = m_renderWindowVectorInfo.begin(); it != m_renderWindowVectorInfo.end(); it++) { (*it).videoImport->SetImportVoidPointer(src); (*it).videoImport->Modified(); (*it).videoImport->Update(); mitk::RenderingManager::GetInstance()->RequestUpdate((*it).renWin); } emit NewFrameAvailable ( m_VideoSource ); } else MITK_WARN << "No video texture available"; } } void QmitkVideoBackground::Modified() { // ensures registration of video backrounds in each renderwindow for(RenderWindowVectorInfoType::iterator it = m_renderWindowVectorInfo.begin(); it != m_renderWindowVectorInfo.end(); it++) { (*it).videoImport->Update(); (*it).videoActor->SetInputData((*it).videoImport->GetOutput()); (*it).videoRenderer->AddActor2D((*it).videoActor); (*it).videoRenderer->ResetCamera(); (*it).videoRenderer->InteractiveOff(); (*it).videoRenderer->GetActiveCamera()->ParallelProjectionOn(); (*it).videoRenderer->GetActiveCamera()->SetParallelScale(m_VideoSource->GetImageHeight()/2); mitk::VtkLayerController* layerController = mitk::VtkLayerController::GetInstance((*it).renWin); if( layerController && !layerController->IsRendererInserted((*it).videoRenderer) ) layerController->InsertBackgroundRenderer((*it).videoRenderer,true); } } void QmitkVideoBackground::SetVideoSource( mitk::VideoSource* videoSource ) { if( m_VideoSource == videoSource ) return; if( m_VideoSource ) m_VideoSource->RemoveObserver( m_VideoSourceObserverTag ); m_VideoSource = videoSource; if( m_VideoSource ) { itk::MemberCommand::Pointer _ModifiedCommand = itk::MemberCommand::New(); _ModifiedCommand->SetCallbackFunction(this, &QmitkVideoBackground::OnVideoSourceDelete); m_VideoSourceObserverTag = m_VideoSource->AddObserver(itk::DeleteEvent(), _ModifiedCommand); } } void QmitkVideoBackground::SetTimerDelay( int ms ) { m_QTimer->setInterval( ms ); - //ResetVideoBackground(); } mitk::VideoSource* QmitkVideoBackground::GetVideoSource() { return m_VideoSource; } int QmitkVideoBackground::GetTimerDelay() { return m_QTimer->interval(); } void QmitkVideoBackground::OnVideoSourceDelete( const itk::Object* caller, const itk::EventObject &event ) { this->Disable(); // will only disable if enabled m_VideoSource = 0; } void QmitkVideoBackground::OnRenderWindowDelete( vtkObject * object, unsigned long eid, void* clientdata, - void * /*calldata*/ ) + void*) { QmitkVideoBackground* instance = static_cast( clientdata ); instance->RemoveRenderWindow( static_cast(object), false ); } + diff --git a/Modules/QtWidgetsExt/QmitkWebPage.cpp b/Modules/QtWidgetsExt/QmitkWebPage.cpp index cac3e28e69..563c29019d 100644 --- a/Modules/QtWidgetsExt/QmitkWebPage.cpp +++ b/Modules/QtWidgetsExt/QmitkWebPage.cpp @@ -1,29 +1,31 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include QmitkJSWebPage::QmitkJSWebPage(QObject *parent) : QWebPage(parent) { } + QmitkJSWebPage::~QmitkJSWebPage() { } bool QmitkJSWebPage::shouldInterruptJavaScript() { return false; } + diff --git a/Modules/QtWidgetsExt/QmitkWebPage.h b/Modules/QtWidgetsExt/QmitkWebPage.h index ccb270d163..c7a6c33ca8 100644 --- a/Modules/QtWidgetsExt/QmitkWebPage.h +++ b/Modules/QtWidgetsExt/QmitkWebPage.h @@ -1,56 +1,54 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -//#include -//#include #include #ifndef QMITK_WEBPAGE_H #define QMITK_WEBPAGE_H /** * @brief The QmitkWebPage class * * This class reimplements QWebPage as a fix for bug 16158. */ class QmitkJSWebPage : public QWebPage { Q_OBJECT public: /** * @brief Constructor */ QmitkJSWebPage(QObject *parent=0); /** * @brief Destructor */ virtual ~QmitkJSWebPage(); public slots: /** * @brief shouldInterruptJavaScript * * Overwritten from QWebView, to stop asking Qt to stop the JavaScript. * @return false so JavaScript is not stopped */ bool shouldInterruptJavaScript(); }; #endif diff --git a/Modules/QtWidgetsExt/btnClearOne.xpm b/Modules/QtWidgetsExt/btnClearOne.xpm deleted file mode 100644 index d71939e4e9..0000000000 --- a/Modules/QtWidgetsExt/btnClearOne.xpm +++ /dev/null @@ -1,18 +0,0 @@ -/* XPM */ -static const char * btnClearOne_xpm[] = { -"12 10 5 1", -" g None", -". g #000000", -"+ g #FFFFFF", -"@ g #C3C3C3", -"# g #7F7F7F", -" .....", -" .++@..", -" .++@.#.", -" .....#. ", -" .++@.. ", -" . ..... ", -" . ", -"..... ", -" . ", -" . "}; diff --git a/Modules/QtWidgetsExt/files.cmake b/Modules/QtWidgetsExt/files.cmake index 7a30a88c11..8f5c5c9251 100644 --- a/Modules/QtWidgetsExt/files.cmake +++ b/Modules/QtWidgetsExt/files.cmake @@ -1,134 +1,118 @@ set(CPP_FILES - - QmitkApplicationBase/QmitkIOUtil.cpp - - QmitkAboutDialog/QmitkAboutDialog.cpp - - QmitkPropertyObservers/QmitkBasePropertyView.cpp - QmitkPropertyObservers/QmitkBoolPropertyWidget.cpp - QmitkPropertyObservers/QmitkColorPropertyEditor.cpp - QmitkPropertyObservers/QmitkColorPropertyView.cpp - QmitkPropertyObservers/QmitkEnumerationPropertyWidget.cpp - QmitkPropertyObservers/QmitkNumberPropertyEditor.cpp - QmitkPropertyObservers/QmitkNumberPropertyView.cpp - QmitkPropertyObservers/QmitkPropertyViewFactory.cpp - QmitkPropertyObservers/QmitkStringPropertyEditor.cpp - QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.cpp - QmitkPropertyObservers/QmitkStringPropertyView.cpp - QmitkPropertyObservers/QmitkNumberPropertySlider.cpp - QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.cpp - - qclickablelabel.cpp - - QmitkCallbackFromGUIThread.cpp - QmitkEditPointDialog.cpp - QmitkExtRegisterClasses.cpp - QmitkFileChooser.cpp - - QmitkFloatingPointSpanSlider.cpp - QmitkColorTransferFunctionCanvas.cpp - QmitkStandardViews.cpp - QmitkStepperAdapter.cpp - QmitkPiecewiseFunctionCanvas.cpp - QmitkSliderNavigatorWidget.cpp - QmitkTransferFunctionCanvas.cpp - QmitkCrossWidget.cpp - QmitkSliceWidget.cpp - QmitkTransferFunctionWidget.cpp - QmitkTransferFunctionGeneratorWidget.cpp - QmitkSelectableGLWidget.cpp - QmitkPrimitiveMovieNavigatorWidget.cpp - - QmitkHistogram.cpp - QmitkHistogramWidget.cpp - - QmitkPlotWidget.cpp - QmitkPlotDialog.cpp - QmitkPointListModel.cpp - QmitkPointListView.cpp - QmitkPointListWidget.cpp - QmitkPointListViewWidget.cpp - QmitkCorrespondingPointSetsView.cpp - QmitkCorrespondingPointSetsModel.cpp - QmitkCorrespondingPointSetsWidget.cpp - QmitkVideoBackground.cpp - QmitkHotkeyLineEdit.cpp - QmitkBoundingObjectWidget.cpp - - QmitkModuleTableModel.cpp - QmitkModulesDialog.cpp - - QmitkHistogramJSWidget.cpp - QmitkWebPage.cpp - - QmitkLineEdit.cpp - QmitkGnuplotWidget.cpp + QmitkAboutDialog/QmitkAboutDialog.cpp + QmitkApplicationBase/QmitkIOUtil.cpp + QmitkPropertyObservers/QmitkBasePropertyView.cpp + QmitkPropertyObservers/QmitkBoolPropertyWidget.cpp + QmitkPropertyObservers/QmitkColorPropertyEditor.cpp + QmitkPropertyObservers/QmitkColorPropertyView.cpp + QmitkPropertyObservers/QmitkEnumerationPropertyWidget.cpp + QmitkPropertyObservers/QmitkNumberPropertyEditor.cpp + QmitkPropertyObservers/QmitkNumberPropertySlider.cpp + QmitkPropertyObservers/QmitkNumberPropertyView.cpp + QmitkPropertyObservers/QmitkPropertyViewFactory.cpp + QmitkPropertyObservers/QmitkStringPropertyEditor.cpp + QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.cpp + QmitkPropertyObservers/QmitkStringPropertyView.cpp + QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.cpp + qclickablelabel.cpp + QmitkBoundingObjectWidget.cpp + QmitkCallbackFromGUIThread.cpp + QmitkColorTransferFunctionCanvas.cpp + QmitkCorrespondingPointSetsModel.cpp + QmitkCorrespondingPointSetsView.cpp + QmitkCorrespondingPointSetsWidget.cpp + QmitkCrossWidget.cpp + QmitkEditPointDialog.cpp + QmitkFileChooser.cpp + QmitkFloatingPointSpanSlider.cpp + QmitkGnuplotWidget.cpp + QmitkHistogram.cpp + QmitkHistogramJSWidget.cpp + QmitkHistogramWidget.cpp + QmitkHotkeyLineEdit.cpp + QmitkLineEdit.cpp + QmitkModulesDialog.cpp + QmitkModuleTableModel.cpp + QmitkPiecewiseFunctionCanvas.cpp + QmitkPlotWidget.cpp + QmitkPlotDialog.cpp + QmitkPointListModel.cpp + QmitkPointListView.cpp + QmitkPointListViewWidget.cpp + QmitkPointListWidget.cpp + QmitkPrimitiveMovieNavigatorWidget.cpp + QmitkSelectableGLWidget.cpp + QmitkSliceWidget.cpp + QmitkSliderNavigatorWidget.cpp + QmitkStandardViews.cpp + QmitkStepperAdapter.cpp + QmitkTransferFunctionCanvas.cpp + QmitkTransferFunctionGeneratorWidget.cpp + QmitkTransferFunctionWidget.cpp + QmitkVideoBackground.cpp + QmitkWebPage.cpp ) set(MOC_H_FILES - QmitkPropertyObservers/QmitkBasePropertyView.h - QmitkPropertyObservers/QmitkBoolPropertyWidget.h - QmitkPropertyObservers/QmitkColorPropertyEditor.h - QmitkPropertyObservers/QmitkColorPropertyView.h - QmitkPropertyObservers/QmitkEnumerationPropertyWidget.h - QmitkPropertyObservers/QmitkNumberPropertyEditor.h - QmitkPropertyObservers/QmitkNumberPropertyView.h - QmitkPropertyObservers/QmitkStringPropertyEditor.h - QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.h - QmitkPropertyObservers/QmitkStringPropertyView.h - QmitkPropertyObservers/QmitkNumberPropertySlider.h - QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.h - - qclickablelabel.h - QmitkCallbackFromGUIThread.h - QmitkEditPointDialog.h - QmitkStandardViews.h - QmitkStepperAdapter.h - QmitkSliderNavigatorWidget.h - QmitkSliceWidget.h - QmitkColorTransferFunctionCanvas.h - QmitkPiecewiseFunctionCanvas.h - QmitkTransferFunctionCanvas.h - QmitkFloatingPointSpanSlider.h - QmitkCrossWidget.h - QmitkTransferFunctionWidget.h - QmitkTransferFunctionGeneratorWidget.h - QmitkPrimitiveMovieNavigatorWidget.h - QmitkPlotWidget.h - QmitkPointListModel.h - QmitkPointListView.h - QmitkPointListWidget.h - QmitkPointListViewWidget.h - QmitkCorrespondingPointSetsView.h - QmitkCorrespondingPointSetsModel.h - QmitkCorrespondingPointSetsWidget.h - QmitkHistogramWidget.h - QmitkVideoBackground.h - QmitkFileChooser.h - QmitkHotkeyLineEdit.h - QmitkAboutDialog/QmitkAboutDialog.h - QmitkBoundingObjectWidget.h - QmitkPlotWidget.h - - QmitkHistogramJSWidget.h - QmitkWebPage.h - - QmitkLineEdit.h - QmitkGnuplotWidget.h + QmitkAboutDialog/QmitkAboutDialog.h + QmitkPropertyObservers/QmitkBasePropertyView.h + QmitkPropertyObservers/QmitkBoolPropertyWidget.h + QmitkPropertyObservers/QmitkColorPropertyEditor.h + QmitkPropertyObservers/QmitkColorPropertyView.h + QmitkPropertyObservers/QmitkEnumerationPropertyWidget.h + QmitkPropertyObservers/QmitkNumberPropertyEditor.h + QmitkPropertyObservers/QmitkNumberPropertySlider.h + QmitkPropertyObservers/QmitkNumberPropertyView.h + QmitkPropertyObservers/QmitkStringPropertyEditor.h + QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.h + QmitkPropertyObservers/QmitkStringPropertyView.h + QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.h + qclickablelabel.h + QmitkBoundingObjectWidget.h + QmitkCallbackFromGUIThread.h + QmitkColorTransferFunctionCanvas.h + QmitkCorrespondingPointSetsModel.h + QmitkCorrespondingPointSetsView.h + QmitkCorrespondingPointSetsWidget.h + QmitkCrossWidget.h + QmitkEditPointDialog.h + QmitkFileChooser.h + QmitkFloatingPointSpanSlider.h + QmitkGnuplotWidget.h + QmitkHistogramJSWidget.h + QmitkHistogramWidget.h + QmitkHotkeyLineEdit.h + QmitkLineEdit.h + QmitkPiecewiseFunctionCanvas.h + QmitkPlotWidget.h + QmitkPointListModel.h + QmitkPointListView.h + QmitkPointListViewWidget.h + QmitkPointListWidget.h + QmitkPrimitiveMovieNavigatorWidget.h + QmitkSelectableGLWidget.h + QmitkSliceWidget.h + QmitkSliderNavigatorWidget.h + QmitkStandardViews.h + QmitkStepperAdapter.h + QmitkTransferFunctionCanvas.h + QmitkTransferFunctionGeneratorWidget.h + QmitkTransferFunctionWidget.h + QmitkVideoBackground.h + QmitkWebPage.h ) set(UI_FILES - QmitkSliderNavigator.ui - QmitkSliceWidget.ui - QmitkTransferFunctionWidget.ui - QmitkTransferFunctionGeneratorWidget.ui - QmitkSelectableGLWidget.ui - QmitkPrimitiveMovieNavigatorWidget.ui QmitkAboutDialog/QmitkAboutDialogGUI.ui QmitkGnuplotWidget.ui + QmitkPrimitiveMovieNavigatorWidget.ui + QmitkSelectableGLWidget.ui + QmitkSliceWidget.ui + QmitkSliderNavigator.ui + QmitkTransferFunctionGeneratorWidget.ui + QmitkTransferFunctionWidget.ui ) set(QRC_FILES - QmitkExt.qrc - resources/QmitkResources.qrc + resources/QtWidgetsExt.qrc ) diff --git a/Modules/QtWidgetsExt/lblWarning.xpm b/Modules/QtWidgetsExt/lblWarning.xpm deleted file mode 100644 index b0ed619e87..0000000000 --- a/Modules/QtWidgetsExt/lblWarning.xpm +++ /dev/null @@ -1,405 +0,0 @@ -/* XPM */ -static const char * Warning_xpm[] = { -"400 400 2 1", -" c None", -". c #FF0000", -" ....... ", -" ........... ", -" ............. ", -" ............... ", -" ................. ", -" .................. ", -" ................... ", -" .................... ", -" ..................... ", -" ...................... ", -" ....................... ", -" ........................ ", -" ......................... ", -" .......................... ", -" ........................... ", -" ............................ ", -" ............................. ", -" .............................. ", -" ............................... ", -" ................................ ", -" ................................. ", -" .................................. ", -" ................................... ", -" .................................... ", -" ..................................... ", -" ...................................... ", -" ....................................... ", -" ........................................ ", -" ......................................... ", -" .......................................... ", -" ........................................... ", -" ............................................ ", -" ............................................. ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ....................... ...................... ", -" ...................... ................................................................ ....................... ", -" ....................... .................................................................... ...................... ", -" ...................... .................................................................... ....................... ", -" ....................... ...................................................................... ...................... ", -" ...................... ...................................................................... ....................... ", -" ....................... ...................................................................... ...................... ", -" ...................... ...................................................................... ....................... ", -" ....................... ...................................................................... ...................... ", -" ...................... ...................................................................... ....................... ", -" ....................... ...................................................................... ...................... ", -" ...................... ..................................................................... ....................... ", -" ....................... ..................................................................... ...................... ", -" ...................... .................................................................... ....................... ", -" ....................... .................................................................... ...................... ", -" ...................... .................................................................... ....................... ", -" ....................... .................................................................... ...................... ", -" ...................... ................................................................... ....................... ", -" ....................... ................................................................... ...................... ", -" ...................... .................................................................. ....................... ", -" ....................... .................................................................. ...................... ", -" ...................... .................................................................. ....................... ", -" ....................... .................................................................. ...................... ", -" ...................... ................................................................. ....................... ", -" ....................... ................................................................. ...................... ", -" ...................... ................................................................ ....................... ", -" ....................... ................................................................ ...................... ", -" ...................... ................................................................ ....................... ", -" ....................... ................................................................ ...................... ", -" ...................... ............................................................... ....................... ", -" ....................... ............................................................... ...................... ", -" ...................... .............................................................. ....................... ", -" ....................... .............................................................. ...................... ", -" ...................... .............................................................. ....................... ", -" ....................... .............................................................. ...................... ", -" ...................... ............................................................. ....................... ", -" ....................... ............................................................. ...................... ", -" ...................... ............................................................ ....................... ", -" ....................... ............................................................ ...................... ", -" ...................... ............................................................ ....................... ", -" ....................... ............................................................ ...................... ", -" ...................... ........................................................... ....................... ", -" ....................... ........................................................... ...................... ", -" ...................... ........................................................... ....................... ", -" ....................... .......................................................... ...................... ", -" ...................... .......................................................... ....................... ", -" ....................... .......................................................... ...................... ", -" ...................... ......................................................... ....................... ", -" ....................... ......................................................... ...................... ", -" ...................... ......................................................... ....................... ", -" ....................... ........................................................ ...................... ", -" ...................... ........................................................ ....................... ", -" ....................... ........................................................ ...................... ", -" ...................... ....................................................... ....................... ", -" ....................... ....................................................... ...................... ", -" ...................... ....................................................... ....................... ", -" ....................... ...................................................... ...................... ", -" ...................... ...................................................... ....................... ", -" ....................... ...................................................... ...................... ", -" ...................... ..................................................... ....................... ", -" ....................... ..................................................... ...................... ", -" ...................... ..................................................... ....................... ", -" ....................... .................................................... ...................... ", -" ...................... .................................................... ....................... ", -" ....................... .................................................... ...................... ", -" ...................... ................................................... ....................... ", -" ....................... ................................................... ...................... ", -" ...................... ................................................... ....................... ", -" ....................... .................................................. ...................... ", -" ...................... .................................................. ....................... ", -" ....................... .................................................. ...................... ", -" ...................... ................................................. ....................... ", -" ....................... ................................................. ...................... ", -" ...................... ................................................. ....................... ", -" ....................... ................................................ ...................... ", -" ...................... ................................................ ....................... ", -" ....................... ................................................ ...................... ", -" ...................... ............................................... ....................... ", -" ....................... ............................................... ...................... ", -" ...................... ............................................... ....................... ", -" ....................... .............................................. ...................... ", -" ...................... .............................................. ....................... ", -" ....................... .............................................. ...................... ", -" ...................... ............................................. ....................... ", -" ....................... ............................................. ...................... ", -" ...................... ............................................. ....................... ", -" ....................... ............................................ ...................... ", -" ...................... ............................................ ....................... ", -" ....................... ............................................ ...................... ", -" ...................... ........................................... ....................... ", -" ....................... ........................................... ...................... ", -" ...................... ........................................... ....................... ", -" ....................... .......................................... ...................... ", -" ...................... .......................................... ....................... ", -" ....................... .......................................... ...................... ", -" ...................... ......................................... ....................... ", -" ....................... ......................................... ...................... ", -" ...................... ......................................... ....................... ", -" ....................... ........................................ ...................... ", -" ...................... ........................................ ....................... ", -" ....................... ........................................ ...................... ", -" ...................... ....................................... ....................... ", -" ....................... ....................................... ...................... ", -" ...................... ....................................... ....................... ", -" ....................... ...................................... ...................... ", -" ...................... ...................................... ....................... ", -" ....................... ...................................... ...................... ", -" ...................... ..................................... ....................... ", -" ....................... ..................................... ...................... ", -" ...................... ..................................... ....................... ", -" ....................... ..................................... ...................... ", -" ...................... .................................... ....................... ", -" ....................... .................................... ...................... ", -" ...................... ................................... ....................... ", -" ....................... ................................... ...................... ", -" ...................... ................................... ....................... ", -" ....................... ................................... ...................... ", -" ...................... .................................. ....................... ", -" ....................... .................................. ...................... ", -" ...................... ................................. ....................... ", -" ....................... ................................. ...................... ", -" ...................... ................................. ....................... ", -" ....................... ................................. ...................... ", -" ...................... ................................ ....................... ", -" ....................... ................................ ...................... ", -" ...................... ............................... ....................... ", -" ....................... ............................... ...................... ", -" ...................... ............................... ....................... ", -" ...................... ............................... ...................... ", -" ...................... .............................. ....................... ", -" ...................... .............................. ...................... ", -" ...................... ............................. ....................... ", -" ...................... ............................. ...................... ", -" ...................... ............................. ....................... ", -" ...................... ............................. ...................... ", -" ...................... ............................ ....................... ", -" ...................... ............................ ...................... ", -" ...................... ........................... ....................... ", -" ...................... ........................... ...................... ", -" ...................... ........................... ....................... ", -" ...................... ........................... ...................... ", -" ...................... .......................... ....................... ", -" ...................... .......................... ...................... ", -" ...................... ......................... ....................... ", -" ...................... ......................... ...................... ", -" ...................... ......................... ...................... ", -" ...................... ......................... ...................... ", -" ...................... ........................ ...................... ", -" ...................... ........................ ...................... ", -" ...................... ........................ ...................... ", -" ...................... ....................... ...................... ", -" ...................... ....................... ...................... ", -" ...................... ....................... ...................... ", -" ...................... ...................... ...................... ", -" ...................... ...................... ...................... ", -" ...................... ...................... ...................... ", -" ...................... ..................... ...................... ", -" ...................... ..................... ...................... ", -" ...................... ..................... ...................... ", -" ...................... .................... ...................... ", -" ...................... .................... ...................... ", -" ...................... .................... ...................... ", -" ...................... ................... ...................... ", -" ...................... ................... ...................... ", -" ...................... ................... ...................... ", -" ...................... .................. ...................... ", -" ...................... .................. ...................... ", -" ...................... .................. ...................... ", -" ...................... ................. ...................... ", -" ...................... ................. ...................... ", -" ...................... ................. ...................... ", -" ...................... ................ ...................... ", -" ...................... ................ ...................... ", -" ...................... ................ ...................... ", -" ...................... ............... ...................... ", -" ...................... ............... ...................... ", -" ...................... ............... ...................... ", -" ...................... ............... ...................... ", -" ...................... .............. ...................... ", -" ...................... .............. ...................... ", -" ...................... ............. ...................... ", -" ...................... ............. ...................... ", -" ...................... ............. ...................... ", -" ...................... ............. ...................... ", -" ...................... ............ ...................... ", -" ...................... ............ ...................... ", -" ...................... ........... ...................... ", -" ...................... ........... ...................... ", -" ...................... ........... ...................... ", -" ...................... .......... ...................... ", -" ...................... ......... ...................... ", -" ...................... ....... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ........................... ...................... ", -" ...................... ............................. ...................... ", -" ...................... ............................... ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ................................ ...................... ", -" ...................... ............................... ...................... ", -" ...................... ............................... ...................... ", -" ...................... ............................... ...................... ", -" ...................... ............................... ...................... ", -" ...................... .............................. ...................... ", -" ...................... ............................. ...................... ", -" ...................... ........................... ...................... ", -" ...................... ......................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ...................... ...................... ", -" ....................... ...................... ", -" ...................... ....................... ", -" ...................... ...................... ", -" ...................... ....................... ", -" ...................... ...................... ", -" ...................... ....................... ", -" ...................... ...................... ", -" ...................... ....................... ", -" ...................... ...................... ", -" ...................... ....................... ", -" ........................................................................................................................................................................................................................................................................................................................................................................................................ ", -" .......................................................................................................................................................................................................................................................................................................................................................................................................... ", -" ........................................................................................................................................................................................................................................................................................................................................................................................................... ", -" ............................................................................................................................................................................................................................................................................................................................................................................................................ ", -" ............................................................................................................................................................................................................................................................................................................................................................................................................. ", -" .............................................................................................................................................................................................................................................................................................................................................................................................................. ", -" .............................................................................................................................................................................................................................................................................................................................................................................................................. ", -"............................................................................................................................................................................................................................................................................................................................................................................................................... ", -"................................................................................................................................................................................................................................................................................................................................................................................................................", -"................................................................................................................................................................................................................................................................................................................................................................................................................", -"................................................................................................................................................................................................................................................................................................................................................................................................................", -"................................................................................................................................................................................................................................................................................................................................................................................................................", -"............................................................................................................................................................................................................................................................................................................................................................................................................... ", -" .............................................................................................................................................................................................................................................................................................................................................................................................................. ", -" .............................................................................................................................................................................................................................................................................................................................................................................................................. ", -" ............................................................................................................................................................................................................................................................................................................................................................................................................. ", -" ........................................................................................................................................................................................................................................................................................................................................................................................................... ", -" ......................................................................................................................................................................................................................................................................................................................................................................................................... ", -" ....................................................................................................................................................................................................................................................................................................................................................................................................... ", -" ................................................................................................................................................................................................................................................................................................................................................................................................. "}; diff --git a/Modules/QtWidgetsExt/PlanarAngle_48.png b/Modules/QtWidgetsExt/resources/PlanarAngle_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarAngle_48.png rename to Modules/QtWidgetsExt/resources/PlanarAngle_48.png diff --git a/Modules/QtWidgetsExt/PlanarBezierCurve_48.png b/Modules/QtWidgetsExt/resources/PlanarBezierCurve_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarBezierCurve_48.png rename to Modules/QtWidgetsExt/resources/PlanarBezierCurve_48.png diff --git a/Modules/QtWidgetsExt/PlanarCircle_48.png b/Modules/QtWidgetsExt/resources/PlanarCircle_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarCircle_48.png rename to Modules/QtWidgetsExt/resources/PlanarCircle_48.png diff --git a/Modules/QtWidgetsExt/PlanarDoubleEllipse_48.png b/Modules/QtWidgetsExt/resources/PlanarDoubleEllipse_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarDoubleEllipse_48.png rename to Modules/QtWidgetsExt/resources/PlanarDoubleEllipse_48.png diff --git a/Modules/QtWidgetsExt/PlanarFourPointAngle_48.png b/Modules/QtWidgetsExt/resources/PlanarFourPointAngle_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarFourPointAngle_48.png rename to Modules/QtWidgetsExt/resources/PlanarFourPointAngle_48.png diff --git a/Modules/QtWidgetsExt/PlanarLine_48.png b/Modules/QtWidgetsExt/resources/PlanarLine_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarLine_48.png rename to Modules/QtWidgetsExt/resources/PlanarLine_48.png diff --git a/Modules/QtWidgetsExt/PlanarPath_48.png b/Modules/QtWidgetsExt/resources/PlanarPath_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarPath_48.png rename to Modules/QtWidgetsExt/resources/PlanarPath_48.png diff --git a/Modules/QtWidgetsExt/PlanarPolygon_48.png b/Modules/QtWidgetsExt/resources/PlanarPolygon_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarPolygon_48.png rename to Modules/QtWidgetsExt/resources/PlanarPolygon_48.png diff --git a/Modules/QtWidgetsExt/PlanarRectangle_48.png b/Modules/QtWidgetsExt/resources/PlanarRectangle_48.png similarity index 100% rename from Modules/QtWidgetsExt/PlanarRectangle_48.png rename to Modules/QtWidgetsExt/resources/PlanarRectangle_48.png diff --git a/Modules/QtWidgetsExt/resources/QmitkResources.qrc b/Modules/QtWidgetsExt/resources/QmitkResources.qrc deleted file mode 100644 index fe2dfcebfa..0000000000 --- a/Modules/QtWidgetsExt/resources/QmitkResources.qrc +++ /dev/null @@ -1,22 +0,0 @@ - - - Logo_mbiATdkfz_small.png - cross.png - QmitkStandardViewsDialogBar.xpm - play.xpm - stop.xpm - logo_mint-medical.png - Logo_mbiATdkfz_gross.png - btnSetPoints.png - btnAddPointSet.png - btnMoveUp.png - btnMoveDown.png - btnRemovePoint.png - btnSwapSets.png - ModuleView.png - Histogram.html - Histogram.js - Histogram.css - d3.v2.js - - diff --git a/Modules/QtWidgetsExt/resources/QtWidgetsExt.qrc b/Modules/QtWidgetsExt/resources/QtWidgetsExt.qrc new file mode 100644 index 0000000000..de5c63d03e --- /dev/null +++ b/Modules/QtWidgetsExt/resources/QtWidgetsExt.qrc @@ -0,0 +1,44 @@ + + + btnAddPointSet.png + btnClear.xpm + btnCube.xpm + btnCylinder.xpm + btnDown.xpm + btnEllipsoid.xpm + btnLoad.xpm + btnMoveDown.png + btnMoveUp.png + btnPyramid.xpm + btnRemovePoint.png + btnSave.xpm + btnSetPoints.png + btnSetPoints.xpm + btnSetPointsManually.xpm + btnSetSeedPoint.xpm + btnSwapSets.png + btnUp.xpm + cross.png + d3.v2.js + Histogram.css + Histogram.html + Histogram.js + icon_seedpoint.png + Logo_mbiATdkfz_gross.png + Logo_mbiATdkfz_small.png + logo_mint-medical.png + ModuleView.png + QmitkStandardViewsDialogBar.xpm + PlanarAngle_48.png + PlanarBezierCurve_48.png + PlanarCircle_48.png + PlanarDoubleEllipse_48.png + PlanarFourPointAngle_48.png + PlanarLine_48.png + PlanarPath_48.png + PlanarPolygon_48.png + PlanarRectangle_48.png + play.xpm + stop.xpm + + diff --git a/Modules/QtWidgetsExt/btnClear.xpm b/Modules/QtWidgetsExt/resources/btnClear.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnClear.xpm rename to Modules/QtWidgetsExt/resources/btnClear.xpm diff --git a/Modules/QtWidgetsExt/btnCube.xpm b/Modules/QtWidgetsExt/resources/btnCube.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnCube.xpm rename to Modules/QtWidgetsExt/resources/btnCube.xpm diff --git a/Modules/QtWidgetsExt/btnCylinder.xpm b/Modules/QtWidgetsExt/resources/btnCylinder.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnCylinder.xpm rename to Modules/QtWidgetsExt/resources/btnCylinder.xpm diff --git a/Modules/QtWidgetsExt/btnDown.xpm b/Modules/QtWidgetsExt/resources/btnDown.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnDown.xpm rename to Modules/QtWidgetsExt/resources/btnDown.xpm diff --git a/Modules/QtWidgetsExt/btnEllipsoid.xpm b/Modules/QtWidgetsExt/resources/btnEllipsoid.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnEllipsoid.xpm rename to Modules/QtWidgetsExt/resources/btnEllipsoid.xpm diff --git a/Modules/QtWidgetsExt/btnLoad.xpm b/Modules/QtWidgetsExt/resources/btnLoad.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnLoad.xpm rename to Modules/QtWidgetsExt/resources/btnLoad.xpm diff --git a/Modules/QtWidgetsExt/btnPyramid.xpm b/Modules/QtWidgetsExt/resources/btnPyramid.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnPyramid.xpm rename to Modules/QtWidgetsExt/resources/btnPyramid.xpm diff --git a/Modules/QtWidgetsExt/btnSave.xpm b/Modules/QtWidgetsExt/resources/btnSave.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnSave.xpm rename to Modules/QtWidgetsExt/resources/btnSave.xpm diff --git a/Modules/QtWidgetsExt/btnSetPoints.xpm b/Modules/QtWidgetsExt/resources/btnSetPoints.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnSetPoints.xpm rename to Modules/QtWidgetsExt/resources/btnSetPoints.xpm diff --git a/Modules/QtWidgetsExt/btnSetPointsManually.xpm b/Modules/QtWidgetsExt/resources/btnSetPointsManually.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnSetPointsManually.xpm rename to Modules/QtWidgetsExt/resources/btnSetPointsManually.xpm diff --git a/Modules/QtWidgetsExt/btnSetSeedPoint.xpm b/Modules/QtWidgetsExt/resources/btnSetSeedPoint.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnSetSeedPoint.xpm rename to Modules/QtWidgetsExt/resources/btnSetSeedPoint.xpm diff --git a/Modules/QtWidgetsExt/btnUp.xpm b/Modules/QtWidgetsExt/resources/btnUp.xpm similarity index 100% rename from Modules/QtWidgetsExt/btnUp.xpm rename to Modules/QtWidgetsExt/resources/btnUp.xpm diff --git a/Modules/QtWidgetsExt/icon_seedpoint.png b/Modules/QtWidgetsExt/resources/icon_seedpoint.png similarity index 100% rename from Modules/QtWidgetsExt/icon_seedpoint.png rename to Modules/QtWidgetsExt/resources/icon_seedpoint.png diff --git a/Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.cpp index 3e4ddfbd74..84707af8a7 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.cpp @@ -1,217 +1,215 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkRegionGrow3DToolGUI.h" #include "QmitkNewSegmentationDialog.h" #include -#include "btnSetSeedPoint.xpm" - MITK_TOOL_GUI_MACRO( , QmitkRegionGrow3DToolGUI, "") QmitkRegionGrow3DToolGUI::QmitkRegionGrow3DToolGUI():QmitkToolGUI() { QBoxLayout* mainLayout = new QVBoxLayout( this ); QBoxLayout* layout1 = new QHBoxLayout(); m_brightRadio = new QRadioButton("bright structure"); m_darkRadio = new QRadioButton("dark structure"); m_brightRadio->setChecked(true); connect(m_brightRadio, SIGNAL(toggled(bool)), this, SLOT(OnGrowingDirectionChanged(bool)) ); connect(m_darkRadio, SIGNAL(toggled(bool)), this, SLOT(OnGrowingDirectionChanged(bool)) ); layout1->addWidget(m_brightRadio); layout1->addWidget(m_darkRadio); m_SetSeedButton = new QPushButton(this); m_SetSeedButton->setCheckable(true); m_SetSeedButton->setFixedSize(32,32); - const QIcon iconAdd(btnSetSeedPoint_xpm); + const QIcon iconAdd(":/QtWidgetsExt/btnSetSeedPoint.xpm"); m_SetSeedButton->setIcon(iconAdd); connect (m_SetSeedButton, SIGNAL(toggled(bool)), this, SLOT(OnSeedButtonToggled(bool)) ); QBoxLayout* layout3 = new QHBoxLayout(); m_DecreaseTHButton = new QPushButton("-", this); m_DecreaseTHButton->setMaximumSize(25,25); connect(m_DecreaseTHButton, SIGNAL(clicked()), this, SLOT(DecreaseSlider())); m_DecreaseTHButton->setEnabled(false); m_IncreaseTHButton = new QPushButton("+", this); m_IncreaseTHButton->setMaximumSize(25,25); connect(m_IncreaseTHButton, SIGNAL(clicked()), this, SLOT(IncreaseSlider())); m_IncreaseTHButton->setEnabled(false); m_ThSlider = new QSlider(Qt::Horizontal, this); connect(m_ThSlider, SIGNAL(valueChanged(int)), this, SLOT(SliderValueChanged(int)) ); m_ThSlider->setEnabled(false); layout3->addWidget(m_DecreaseTHButton); layout3->addWidget(m_ThSlider); layout3->addWidget(m_IncreaseTHButton); m_ThValue = new QLabel("0", this); m_ThValue->setAlignment(Qt::AlignHCenter); m_ConfirmButton = new QPushButton("Confirm Segmentation", this); connect(m_ConfirmButton, SIGNAL(clicked()), this, SLOT(OnConfirmButtonClicked())); m_ConfirmButton->setEnabled(false); mainLayout->addLayout(layout1); mainLayout->addWidget(m_SetSeedButton); mainLayout->addLayout(layout3); mainLayout->addWidget(m_ThValue); mainLayout->addWidget(m_ConfirmButton); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkRegionGrow3DToolGUI::~QmitkRegionGrow3DToolGUI() { if (m_RegionGrow3DTool.IsNotNull()) { m_RegionGrow3DTool->LowerThresholdValueChanged -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnLowerThresholdValueChanged); m_RegionGrow3DTool->UpperThresholdValueChanged -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnUpperThresholdValueChanged); m_RegionGrow3DTool->SliderValueChanged -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::SliderValueChanged); m_RegionGrow3DTool->SeedButtonToggled -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnSeedButtonToggled); } QApplication::restoreOverrideCursor(); } void QmitkRegionGrow3DToolGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_RegionGrow3DTool.IsNotNull()) { m_RegionGrow3DTool->LowerThresholdValueChanged -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnLowerThresholdValueChanged); m_RegionGrow3DTool->UpperThresholdValueChanged -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnUpperThresholdValueChanged); m_RegionGrow3DTool->SliderValueChanged -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::SliderValueChanged); m_RegionGrow3DTool->SeedButtonToggled -= mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnSeedButtonToggled); } m_RegionGrow3DTool = dynamic_cast (tool); if (m_RegionGrow3DTool) { m_RegionGrow3DTool->LowerThresholdValueChanged += mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnLowerThresholdValueChanged); m_RegionGrow3DTool->UpperThresholdValueChanged += mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnUpperThresholdValueChanged); m_RegionGrow3DTool->SliderValueChanged += mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::SliderValueChanged); m_RegionGrow3DTool->SeedButtonToggled += mitk::MessageDelegate1(this, &QmitkRegionGrow3DToolGUI::OnSeedButtonToggled); } } void QmitkRegionGrow3DToolGUI::OnGrowingDirectionChanged(bool flag) { if (flag) { if (m_brightRadio->isChecked()) m_RegionGrow3DTool->SetCurrentRGDirectionIsUpwards(false); if (m_darkRadio->isChecked()) m_RegionGrow3DTool->SetCurrentRGDirectionIsUpwards(true); } m_DecreaseTHButton->setEnabled(false); m_IncreaseTHButton->setEnabled(false); m_ThSlider->setEnabled(false); m_ConfirmButton->setEnabled(false); } void QmitkRegionGrow3DToolGUI::OnLowerThresholdValueChanged(int lower) { m_ThSlider->setMinimum(lower); } void QmitkRegionGrow3DToolGUI::OnUpperThresholdValueChanged(int upper) { m_ThSlider->setMaximum(upper); } void QmitkRegionGrow3DToolGUI::IncreaseSlider() { //moves the slider one step to the right, when the "+"-button is pressed if (m_ThSlider->value() != m_ThSlider->maximum()) { int newValue = m_ThSlider->value() + 1; m_ThSlider->setValue(newValue); } } void QmitkRegionGrow3DToolGUI::DecreaseSlider() { //moves the slider one step to the left, when the "-"-button is pressed if (m_ThSlider->value() != m_ThSlider->minimum()) { int newValue = m_ThSlider->value() - 1; m_ThSlider->setValue(newValue); } } void QmitkRegionGrow3DToolGUI::OnSeedButtonToggled(bool toggled) { if (toggled) { QApplication::setOverrideCursor(QCursor(Qt::CrossCursor)); } else { QApplication::restoreOverrideCursor(); } if (m_RegionGrow3DTool.IsNotNull()) { m_RegionGrow3DTool->SetSeedPoint(toggled); if (toggled != m_SetSeedButton->isChecked()) { m_SetSeedButton->setChecked(toggled); //enable gui components m_DecreaseTHButton->setEnabled(!toggled); m_IncreaseTHButton->setEnabled(!toggled); m_ThSlider->setEnabled(!toggled); m_ConfirmButton->setEnabled(!toggled); } } } void QmitkRegionGrow3DToolGUI::OnConfirmButtonClicked() { if (m_RegionGrow3DTool.IsNotNull()) { QmitkNewSegmentationDialog* dialog = new QmitkNewSegmentationDialog(this); int returnValue = dialog->exec(); std::string name = dialog->GetSegmentationName().toLocal8Bit().data(); mitk::Color color = dialog->GetColor(); if (returnValue != QDialog::Rejected) { m_RegionGrow3DTool->ConfirmSegmentation(name, color); } else { m_RegionGrow3DTool->CancelSegmentation(); } } } void QmitkRegionGrow3DToolGUI::SliderValueChanged(int value) { if (m_RegionGrow3DTool.IsNotNull()) { m_ThSlider->setValue(value); m_ThValue->setNum(value); m_RegionGrow3DTool->ChangeLevelWindow(value); } } diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp index 95cbe02945..30f41c4acd 100644 --- a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp @@ -1,1026 +1,1026 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkDataManagerView.h" #include //# Own Includes //## mitk #include "mitkDataStorageEditorInput.h" #include "mitkIDataStorageReference.h" #include "mitkNodePredicateDataType.h" #include "mitkCoreObjectFactory.h" #include "mitkDataNodeFactory.h" #include "mitkColorProperty.h" #include "mitkCommon.h" #include "mitkNodePredicateData.h" #include "mitkNodePredicateNot.h" #include "mitkNodePredicateProperty.h" #include "mitkEnumerationProperty.h" #include "mitkLookupTableProperty.h" #include "mitkProperties.h" #include #include #include #include #include //## Qmitk #include #include #include #include #include #include "src/internal/QmitkNodeTableViewKeyFilter.h" #include "src/internal/QmitkInfoDialog.h" #include "src/internal/QmitkDataManagerItemDelegate.h" //## Berry #include #include #include #include #include #include //# Toolkit Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mitkDataNodeObject.h" #include "mitkIContextMenuAction.h" #include "berryIExtensionPointService.h" #include "mitkRenderingModeProperty.h" const std::string QmitkDataManagerView::VIEW_ID = "org.mitk.views.datamanager"; QmitkDataManagerView::QmitkDataManagerView() : m_GlobalReinitOnNodeDelete(true), m_ItemDelegate(NULL) { } QmitkDataManagerView::~QmitkDataManagerView() { //Remove all registered actions from each descriptor for (std::vector< std::pair< QmitkNodeDescriptor*, QAction* > >::iterator it = m_DescriptorActionList.begin();it != m_DescriptorActionList.end(); it++) { // first== the NodeDescriptor; second== the registered QAction (it->first)->RemoveAction(it->second); } } void QmitkDataManagerView::CreateQtPartControl(QWidget* parent) { m_CurrentRowCount = 0; m_Parent = parent; //# Preferences berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); berry::IBerryPreferences::Pointer prefs = (prefService->GetSystemPreferences()->Node(VIEW_ID)) .Cast(); assert( prefs ); prefs->OnChanged.AddListener( berry::MessageDelegate1( this , &QmitkDataManagerView::OnPreferencesChanged ) ); //# GUI m_NodeTreeModel = new QmitkDataStorageTreeModel(this->GetDataStorage()); m_NodeTreeModel->setParent( parent ); m_NodeTreeModel->SetPlaceNewNodesOnTop( prefs->GetBool("Place new nodes on top", true) ); m_NodeTreeModel->SetShowHelperObjects( prefs->GetBool("Show helper objects", false) ); m_NodeTreeModel->SetShowNodesContainingNoData( prefs->GetBool("Show nodes containing no data", false) ); m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); //# Tree View (experimental) m_NodeTreeView = new QTreeView; m_NodeTreeView->setHeaderHidden(true); m_NodeTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection ); m_NodeTreeView->setSelectionBehavior( QAbstractItemView::SelectRows ); m_NodeTreeView->setAlternatingRowColors(true); m_NodeTreeView->setDragEnabled(true); m_NodeTreeView->setDropIndicatorShown(true); m_NodeTreeView->setAcceptDrops(true); m_NodeTreeView->setContextMenuPolicy(Qt::CustomContextMenu); m_NodeTreeView->setModel(m_NodeTreeModel); m_NodeTreeView->setTextElideMode(Qt::ElideMiddle); m_NodeTreeView->installEventFilter(new QmitkNodeTableViewKeyFilter(this)); m_ItemDelegate = new QmitkDataManagerItemDelegate(m_NodeTreeView); m_NodeTreeView->setItemDelegate(m_ItemDelegate); QObject::connect( m_NodeTreeView, SIGNAL(customContextMenuRequested(const QPoint&)) , this, SLOT(NodeTableViewContextMenuRequested(const QPoint&)) ); QObject::connect( m_NodeTreeModel, SIGNAL(rowsInserted (const QModelIndex&, int, int)) , this, SLOT(NodeTreeViewRowsInserted ( const QModelIndex&, int, int )) ); QObject::connect( m_NodeTreeModel, SIGNAL(rowsRemoved (const QModelIndex&, int, int)) , this, SLOT(NodeTreeViewRowsRemoved( const QModelIndex&, int, int )) ); QObject::connect( m_NodeTreeView->selectionModel() , SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection & ) ) , this , SLOT( NodeSelectionChanged ( const QItemSelection &, const QItemSelection & ) ) ); //# m_NodeMenu m_NodeMenu = new QMenu(m_NodeTreeView); // # Actions berry::IEditorRegistry* editorRegistry = berry::PlatformUI::GetWorkbench()->GetEditorRegistry(); std::list editors = editorRegistry->GetEditors("*.mitk"); if (editors.size() > 1) { m_ShowInMapper = new QSignalMapper(this); foreach(berry::IEditorDescriptor::Pointer descriptor, editors) { QAction* action = new QAction(QString::fromStdString(descriptor->GetLabel()), this); m_ShowInActions << action; m_ShowInMapper->connect(action, SIGNAL(triggered()), m_ShowInMapper, SLOT(map())); m_ShowInMapper->setMapping(action, QString::fromStdString(descriptor->GetId())); } connect(m_ShowInMapper, SIGNAL(mapped(QString)), this, SLOT(ShowIn(QString))); } QmitkNodeDescriptor* unknownDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetUnknownDataNodeDescriptor(); QmitkNodeDescriptor* imageDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Image"); QmitkNodeDescriptor* surfaceDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Surface"); QAction* globalReinitAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"), "Global Reinit", this); QObject::connect( globalReinitAction, SIGNAL( triggered(bool) ) , this, SLOT( GlobalReinit(bool) ) ); unknownDataNodeDescriptor->AddAction(globalReinitAction); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor, globalReinitAction)); QAction* saveAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Save_48.png"), "Save...", this); QObject::connect( saveAction, SIGNAL( triggered(bool) ) , this, SLOT( SaveSelectedNodes(bool) ) ); unknownDataNodeDescriptor->AddAction(saveAction); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor,saveAction)); QAction* removeAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Remove_48.png"), "Remove", this); QObject::connect( removeAction, SIGNAL( triggered(bool) ) , this, SLOT( RemoveSelectedNodes(bool) ) ); unknownDataNodeDescriptor->AddAction(removeAction); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor,removeAction)); QAction* reinitAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"), "Reinit", this); QObject::connect( reinitAction, SIGNAL( triggered(bool) ) , this, SLOT( ReinitSelectedNodes(bool) ) ); unknownDataNodeDescriptor->AddAction(reinitAction); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor,reinitAction)); // find contextMenuAction extension points and add them to the node descriptor berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); berry::IConfigurationElement::vector cmActions( extensionPointService->GetConfigurationElementsFor("org.mitk.gui.qt.datamanager.contextMenuActions") ); berry::IConfigurationElement::vector::iterator cmActionsIt; std::string cmNodeDescriptorName; std::string cmLabel; std::string cmIcon; std::string cmClass; QmitkNodeDescriptor* tmpDescriptor; QAction* contextMenuAction; QVariant cmActionDataIt; m_ConfElements.clear(); int i=1; for (cmActionsIt = cmActions.begin() ; cmActionsIt != cmActions.end() ; ++cmActionsIt) { cmIcon.erase(); if((*cmActionsIt)->GetAttribute("nodeDescriptorName", cmNodeDescriptorName) && (*cmActionsIt)->GetAttribute("label", cmLabel) && (*cmActionsIt)->GetAttribute("class", cmClass)) { (*cmActionsIt)->GetAttribute("icon", cmIcon); // create context menu entry here tmpDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(QString::fromStdString(cmNodeDescriptorName)); if(!tmpDescriptor) { MITK_WARN << "cannot add action \"" << cmLabel << "\" because descriptor " << cmNodeDescriptorName << " does not exist"; continue; } contextMenuAction = new QAction( QString::fromStdString(cmLabel), parent); tmpDescriptor->AddAction(contextMenuAction); m_DescriptorActionList.push_back(std::pair(tmpDescriptor,contextMenuAction)); m_ConfElements[contextMenuAction] = *cmActionsIt; cmActionDataIt.setValue(i); contextMenuAction->setData( cmActionDataIt ); connect( contextMenuAction, SIGNAL( triggered(bool) ) , this, SLOT( ContextMenuActionTriggered(bool) ) ); ++i; } } m_OpacitySlider = new QSlider; m_OpacitySlider->setMinimum(0); m_OpacitySlider->setMaximum(100); m_OpacitySlider->setOrientation(Qt::Horizontal); QObject::connect( m_OpacitySlider, SIGNAL( valueChanged(int) ) , this, SLOT( OpacityChanged(int) ) ); QLabel* _OpacityLabel = new QLabel("Opacity: "); QHBoxLayout* _OpacityWidgetLayout = new QHBoxLayout; _OpacityWidgetLayout->setContentsMargins(4,4,4,4); _OpacityWidgetLayout->addWidget(_OpacityLabel); _OpacityWidgetLayout->addWidget(m_OpacitySlider); QWidget* _OpacityWidget = new QWidget; _OpacityWidget->setLayout(_OpacityWidgetLayout); QWidgetAction* opacityAction = new QWidgetAction(this); opacityAction ->setDefaultWidget(_OpacityWidget); QObject::connect( opacityAction , SIGNAL( changed() ) , this, SLOT( OpacityActionChanged() ) ); unknownDataNodeDescriptor->AddAction(opacityAction , false); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor,opacityAction)); m_ColorButton = new QPushButton; m_ColorButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); //m_ColorButton->setText("Change color"); QObject::connect( m_ColorButton, SIGNAL( clicked() ) , this, SLOT( ColorChanged() ) ); QLabel* _ColorLabel = new QLabel("Color: "); _ColorLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); QHBoxLayout* _ColorWidgetLayout = new QHBoxLayout; _ColorWidgetLayout->setContentsMargins(4,4,4,4); _ColorWidgetLayout->addWidget(_ColorLabel); _ColorWidgetLayout->addWidget(m_ColorButton); QWidget* _ColorWidget = new QWidget; _ColorWidget->setLayout(_ColorWidgetLayout); QWidgetAction* colorAction = new QWidgetAction(this); colorAction->setDefaultWidget(_ColorWidget); QObject::connect( colorAction, SIGNAL( changed() ) , this, SLOT( ColorActionChanged() ) ); unknownDataNodeDescriptor->AddAction(colorAction, false); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor,colorAction)); m_TextureInterpolation = new QAction("Texture Interpolation", this); m_TextureInterpolation->setCheckable ( true ); QObject::connect( m_TextureInterpolation, SIGNAL( changed() ) , this, SLOT( TextureInterpolationChanged() ) ); QObject::connect( m_TextureInterpolation, SIGNAL( toggled(bool) ) , this, SLOT( TextureInterpolationToggled(bool) ) ); imageDataNodeDescriptor->AddAction(m_TextureInterpolation, false); m_DescriptorActionList.push_back(std::pair(imageDataNodeDescriptor,m_TextureInterpolation)); m_ColormapAction = new QAction("Colormap", this); m_ColormapAction->setMenu(new QMenu); QObject::connect( m_ColormapAction->menu(), SIGNAL( aboutToShow() ) , this, SLOT( ColormapMenuAboutToShow() ) ); imageDataNodeDescriptor->AddAction(m_ColormapAction, false); m_DescriptorActionList.push_back(std::pair(imageDataNodeDescriptor, m_ColormapAction)); m_SurfaceRepresentation = new QAction("Surface Representation", this); m_SurfaceRepresentation->setMenu(new QMenu); QObject::connect( m_SurfaceRepresentation->menu(), SIGNAL( aboutToShow() ) , this, SLOT( SurfaceRepresentationMenuAboutToShow() ) ); surfaceDataNodeDescriptor->AddAction(m_SurfaceRepresentation, false); m_DescriptorActionList.push_back(std::pair(surfaceDataNodeDescriptor, m_SurfaceRepresentation)); QAction* showOnlySelectedNodes = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/ShowSelectedNode_48.png") , "Show only selected nodes", this); QObject::connect( showOnlySelectedNodes, SIGNAL( triggered(bool) ) , this, SLOT( ShowOnlySelectedNodes(bool) ) ); unknownDataNodeDescriptor->AddAction(showOnlySelectedNodes); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor, showOnlySelectedNodes)); QAction* toggleSelectedVisibility = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/InvertShowSelectedNode_48.png") , "Toggle visibility", this); QObject::connect( toggleSelectedVisibility, SIGNAL( triggered(bool) ) , this, SLOT( ToggleVisibilityOfSelectedNodes(bool) ) ); unknownDataNodeDescriptor->AddAction(toggleSelectedVisibility); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor,toggleSelectedVisibility)); QAction* actionShowInfoDialog = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/ShowDataInfo_48.png") , "Details...", this); QObject::connect( actionShowInfoDialog, SIGNAL( triggered(bool) ) , this, SLOT( ShowInfoDialogForSelectedNodes(bool) ) ); unknownDataNodeDescriptor->AddAction(actionShowInfoDialog); m_DescriptorActionList.push_back(std::pair(unknownDataNodeDescriptor,actionShowInfoDialog)); //obsolete... //QAction* otsuFilterAction = new QAction("Apply Otsu Filter", this); //QObject::connect( otsuFilterAction, SIGNAL( triggered(bool) ) // , this, SLOT( OtsuFilter(bool) ) ); // //Otsu filter does not work properly, remove it temporarily // imageDataNodeDescriptor->AddAction(otsuFilterAction); // m_DescriptorActionList.push_back(std::pair(imageDataNodeDescriptor,otsuFilterAction)); QGridLayout* _DndFrameWidgetLayout = new QGridLayout; _DndFrameWidgetLayout->addWidget(m_NodeTreeView, 0, 0); _DndFrameWidgetLayout->setContentsMargins(0,0,0,0); m_DndFrameWidget = new QmitkDnDFrameWidget(m_Parent); m_DndFrameWidget->setLayout(_DndFrameWidgetLayout); QVBoxLayout* layout = new QVBoxLayout(parent); layout->addWidget(m_DndFrameWidget); layout->setContentsMargins(0,0,0,0); m_Parent->setLayout(layout); } void QmitkDataManagerView::SetFocus() { } void QmitkDataManagerView::ContextMenuActionTriggered( bool ) { QAction* action = qobject_cast ( sender() ); std::map::iterator it = m_ConfElements.find( action ); if( it == m_ConfElements.end() ) { MITK_WARN << "associated conf element for action " << action->text().toStdString() << " not found"; return; } berry::IConfigurationElement::Pointer confElem = it->second; mitk::IContextMenuAction* contextMenuAction = confElem->CreateExecutableExtension("class"); std::string className; std::string smoothed; confElem->GetAttribute("class", className); confElem->GetAttribute("smoothed", smoothed); if(className == "QmitkCreatePolygonModelAction") { contextMenuAction->SetDataStorage(this->GetDataStorage()); if(smoothed == "false") { contextMenuAction->SetSmoothed(false); } else { contextMenuAction->SetSmoothed(true); } contextMenuAction->SetDecimated(m_SurfaceDecimation); } else if(className == "QmitkStatisticsAction") { contextMenuAction->SetFunctionality(this); } else if(className == "QmitkCreateSimulationAction") { contextMenuAction->SetDataStorage(this->GetDataStorage()); } contextMenuAction->Run( this->GetCurrentSelection() ); // run the action } void QmitkDataManagerView::OnPreferencesChanged(const berry::IBerryPreferences* prefs) { if( m_NodeTreeModel->GetPlaceNewNodesOnTopFlag() != prefs->GetBool("Place new nodes on top", true) ) m_NodeTreeModel->SetPlaceNewNodesOnTop( !m_NodeTreeModel->GetPlaceNewNodesOnTopFlag() ); if( m_NodeTreeModel->GetShowHelperObjectsFlag()!= prefs->GetBool("Show helper objects", false) ) m_NodeTreeModel->SetShowHelperObjects( !m_NodeTreeModel->GetShowHelperObjectsFlag() ); if( m_NodeTreeModel->GetShowNodesContainingNoDataFlag()!= prefs->GetBool("Show nodes containing no data", false) ) m_NodeTreeModel->SetShowNodesContainingNoData( !m_NodeTreeModel->GetShowNodesContainingNoDataFlag() ); m_GlobalReinitOnNodeDelete = prefs->GetBool("Call global reinit if node is deleted", true); m_NodeTreeView->expandAll(); m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); this->GlobalReinit(); } void QmitkDataManagerView::NodeTableViewContextMenuRequested( const QPoint & pos ) { QModelIndex selected = m_NodeTreeView->indexAt ( pos ); mitk::DataNode::Pointer node = m_NodeTreeModel->GetNode(selected); QList selectedNodes = this->GetCurrentSelection(); if(!selectedNodes.isEmpty()) { m_NodeMenu->clear(); QList actions; if(selectedNodes.size() == 1 ) { actions = QmitkNodeDescriptorManager::GetInstance()->GetActions(node); for(QList::iterator it = actions.begin(); it != actions.end(); ++it) { (*it)->setData(QVariant::fromValue(node.GetPointer())); } } else actions = QmitkNodeDescriptorManager::GetInstance()->GetActions(selectedNodes); if (!m_ShowInActions.isEmpty()) { QMenu* showInMenu = m_NodeMenu->addMenu("Show In"); showInMenu->addActions(m_ShowInActions); } m_NodeMenu->addActions(actions); m_NodeMenu->popup(QCursor::pos()); } } void QmitkDataManagerView::OpacityChanged(int value) { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(node) { float opacity = static_cast(value)/100.0f; node->SetFloatProperty("opacity", opacity); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void QmitkDataManagerView::OpacityActionChanged() { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(node) { float opacity = 0.0; if(node->GetFloatProperty("opacity", opacity)) { m_OpacitySlider->setValue(static_cast(opacity*100)); } } } void QmitkDataManagerView::ColorChanged() { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(node) { mitk::Color color; mitk::ColorProperty::Pointer colorProp; node->GetProperty(colorProp,"color"); if(colorProp.IsNull()) return; color = colorProp->GetValue(); QColor initial(color.GetRed()*255,color.GetGreen()*255,color.GetBlue()*255); QColor qcolor = QColorDialog::getColor(initial,0,QString("Change color")); if (!qcolor.isValid()) return; m_ColorButton->setAutoFillBackground(true); node->SetProperty("color",mitk::ColorProperty::New(qcolor.red()/255.0,qcolor.green()/255.0,qcolor.blue()/255.0)); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void QmitkDataManagerView::ColorActionChanged() { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(node) { mitk::Color color; mitk::ColorProperty::Pointer colorProp; node->GetProperty(colorProp,"color"); if(colorProp.IsNull()) return; color = colorProp->GetValue(); QString styleSheet = "background-color:rgb("; styleSheet.append(QString::number(color[0]*255)); styleSheet.append(","); styleSheet.append(QString::number(color[1]*255)); styleSheet.append(","); styleSheet.append(QString::number(color[2]*255)); styleSheet.append(")"); m_ColorButton->setStyleSheet(styleSheet); } } void QmitkDataManagerView::TextureInterpolationChanged() { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(node) { bool textureInterpolation = false; node->GetBoolProperty("texture interpolation", textureInterpolation); m_TextureInterpolation->setChecked(textureInterpolation); } } void QmitkDataManagerView::TextureInterpolationToggled( bool checked ) { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(node) { node->SetBoolProperty("texture interpolation", checked); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void QmitkDataManagerView::ColormapActionToggled( bool /*checked*/ ) { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(!node) return; mitk::LookupTableProperty::Pointer lookupTableProperty = dynamic_cast(node->GetProperty("LookupTable")); if (!lookupTableProperty) return; QAction* senderAction = qobject_cast(QObject::sender()); if(!senderAction) return; std::string activatedItem = senderAction->text().toStdString(); mitk::LookupTable::Pointer lookupTable = lookupTableProperty->GetValue(); if (!lookupTable) return; lookupTable->SetType(activatedItem); lookupTableProperty->SetValue(lookupTable); mitk::RenderingModeProperty::Pointer renderingMode = dynamic_cast(node->GetProperty("Image Rendering.Mode")); renderingMode->SetValue(mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkDataManagerView::ColormapMenuAboutToShow() { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(!node) return; mitk::LookupTableProperty::Pointer lookupTableProperty = dynamic_cast(node->GetProperty("LookupTable")); if (!lookupTableProperty) { mitk::LookupTable::Pointer mitkLut = mitk::LookupTable::New(); lookupTableProperty = mitk::LookupTableProperty::New(); lookupTableProperty->SetLookupTable(mitkLut); node->SetProperty("LookupTable", lookupTableProperty); } mitk::LookupTable::Pointer lookupTable = lookupTableProperty->GetValue(); if (!lookupTable) return; m_ColormapAction->menu()->clear(); QAction* tmp; int i = 0; std::string lutType = lookupTable->typenameList[i]; while (lutType != "END_OF_ARRAY") { tmp = m_ColormapAction->menu()->addAction(QString::fromStdString(lutType)); tmp->setCheckable(true); if (lutType == lookupTable->GetActiveTypeAsString()) { tmp->setChecked(true); } QObject::connect(tmp, SIGNAL(triggered(bool)), this, SLOT(ColormapActionToggled(bool))); lutType = lookupTable->typenameList[++i]; } } void QmitkDataManagerView::SurfaceRepresentationMenuAboutToShow() { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(!node) return; mitk::EnumerationProperty* representationProp = dynamic_cast (node->GetProperty("material.representation")); if(!representationProp) return; // clear menu m_SurfaceRepresentation->menu()->clear(); QAction* tmp; // create menu entries for(mitk::EnumerationProperty::EnumConstIterator it=representationProp->Begin(); it!=representationProp->End() ; it++) { tmp = m_SurfaceRepresentation->menu()->addAction(QString::fromStdString(it->second)); tmp->setCheckable(true); if(it->second == representationProp->GetValueAsString()) { tmp->setChecked(true); } QObject::connect( tmp, SIGNAL( triggered(bool) ) , this, SLOT( SurfaceRepresentationActionToggled(bool) ) ); } } void QmitkDataManagerView::SurfaceRepresentationActionToggled( bool /*checked*/ ) { mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); if(!node) return; mitk::EnumerationProperty* representationProp = dynamic_cast (node->GetProperty("material.representation")); if(!representationProp) return; QAction* senderAction = qobject_cast ( QObject::sender() ); if(!senderAction) return; std::string activatedItem = senderAction->text().toStdString(); if ( activatedItem != representationProp->GetValueAsString() ) { if ( representationProp->IsValidEnumerationValue( activatedItem ) ) { representationProp->SetValue( activatedItem ); representationProp->InvokeEvent( itk::ModifiedEvent() ); representationProp->Modified(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } void QmitkDataManagerView::SaveSelectedNodes( bool ) { QModelIndexList indexesOfSelectedRows = m_NodeTreeView->selectionModel()->selectedRows(); mitk::DataNode* node = 0; unsigned int indexesOfSelectedRowsSize = indexesOfSelectedRows.size(); for (unsigned int i = 0; iGetNode(indexesOfSelectedRows.at(i)); // if node is not defined or if the node contains geometry data do not remove it if ( node != 0 ) { mitk::BaseData::Pointer data = node->GetData(); if (data.IsNotNull()) { QString error; try { - mitk::QmitkIOUtil::SaveBaseDataWithDialog( data.GetPointer(), node->GetName().c_str(), m_Parent ); + QmitkIOUtil::SaveBaseDataWithDialog( data.GetPointer(), node->GetName().c_str(), m_Parent ); } catch(std::exception& e) { error = e.what(); } catch(...) { error = "Unknown error occured"; } if( !error.isEmpty() ) QMessageBox::critical( m_Parent, "Error saving...", error ); } } } } void QmitkDataManagerView::ReinitSelectedNodes( bool ) { mitk::IRenderWindowPart* renderWindow = this->GetRenderWindowPart(); if (renderWindow == NULL) renderWindow = this->OpenRenderWindowPart(false); QList selectedNodes = this->GetCurrentSelection(); foreach(mitk::DataNode::Pointer node, selectedNodes) { mitk::BaseData::Pointer basedata = node->GetData(); if ( basedata.IsNotNull() && basedata->GetTimeGeometry()->IsValid() ) { renderWindow->GetRenderingManager()->InitializeViews( basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); renderWindow->GetRenderingManager()->RequestUpdateAll(); } } } void QmitkDataManagerView::RemoveSelectedNodes( bool ) { QModelIndexList indexesOfSelectedRows = m_NodeTreeView->selectionModel()->selectedRows(); if(indexesOfSelectedRows.size() < 1) { return; } std::vector selectedNodes; mitk::DataNode* node = 0; QString question = tr("Do you really want to remove "); for (QModelIndexList::iterator it = indexesOfSelectedRows.begin() ; it != indexesOfSelectedRows.end(); it++) { node = m_NodeTreeModel->GetNode(*it); // if node is not defined or if the node contains geometry data do not remove it if ( node != 0 /*& strcmp(node->GetData()->GetNameOfClass(), "Geometry2DData") != 0*/ ) { selectedNodes.push_back(node); question.append(QString::fromStdString(node->GetName())); question.append(", "); } } // remove the last two characters = ", " question = question.remove(question.size()-2, 2); question.append(" from data storage?"); QMessageBox::StandardButton answerButton = QMessageBox::question( m_Parent , tr("DataManager") , question , QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if(answerButton == QMessageBox::Yes) { for (std::vector::iterator it = selectedNodes.begin() ; it != selectedNodes.end(); it++) { node = *it; this->GetDataStorage()->Remove(node); if (m_GlobalReinitOnNodeDelete) this->GlobalReinit(false); } } } void QmitkDataManagerView::MakeAllNodesInvisible( bool ) { QList nodes = m_NodeTreeModel->GetNodeSet(); foreach(mitk::DataNode::Pointer node, nodes) { node->SetVisibility(false); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkDataManagerView::ShowOnlySelectedNodes( bool ) { QList selectedNodes = this->GetCurrentSelection(); QList allNodes = m_NodeTreeModel->GetNodeSet(); foreach(mitk::DataNode::Pointer node, allNodes) { node->SetVisibility(selectedNodes.contains(node)); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkDataManagerView::ToggleVisibilityOfSelectedNodes( bool ) { QList selectedNodes = this->GetCurrentSelection(); bool isVisible = false; foreach(mitk::DataNode::Pointer node, selectedNodes) { isVisible = false; node->GetBoolProperty("visible", isVisible); node->SetVisibility(!isVisible); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkDataManagerView::ShowInfoDialogForSelectedNodes( bool ) { QList selectedNodes = this->GetCurrentSelection(); QmitkInfoDialog _QmitkInfoDialog(selectedNodes, this->m_Parent); _QmitkInfoDialog.exec(); } void QmitkDataManagerView::Load( bool ) { QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Load data", "", mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); for ( QStringList::Iterator it = fileNames.begin(); it != fileNames.end(); ++it ) { FileOpen((*it).toAscii(), 0); } } void QmitkDataManagerView::FileOpen( const char * fileName, mitk::DataNode* parentNode ) { mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { factory->SetFileName( fileName ); QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); factory->Update(); for ( unsigned int i = 0 ; i < factory->GetNumberOfOutputs( ); ++i ) { mitk::DataNode::Pointer node = factory->GetOutput( i ); if ( ( node.IsNotNull() ) && ( node->GetData() != NULL ) ) { this->GetDataStorage()->Add(node, parentNode); mitk::BaseData::Pointer basedata = node->GetData(); mitk::RenderingManager::GetInstance()->InitializeViews( basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } catch ( itk::ExceptionObject & ex ) { itkGenericOutputMacro( << "Exception during file open: " << ex ); } QApplication::restoreOverrideCursor(); } QItemSelectionModel *QmitkDataManagerView::GetDataNodeSelectionModel() const { return m_NodeTreeView->selectionModel(); } void QmitkDataManagerView::GlobalReinit( bool ) { mitk::IRenderWindowPart* renderWindow = this->GetRenderWindowPart(); if (renderWindow == NULL) renderWindow = this->OpenRenderWindowPart(false); // no render window available if (renderWindow == NULL) return; mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(this->GetDataStorage()); } void QmitkDataManagerView::OtsuFilter( bool ) { QList selectedNodes = this->GetCurrentSelection(); mitk::Image::Pointer mitkImage = 0; foreach(mitk::DataNode::Pointer node, selectedNodes) { mitkImage = dynamic_cast( node->GetData() ); if(mitkImage.IsNull()) continue; try { // get selected mitk image const unsigned short dim = 3; typedef short InputPixelType; typedef unsigned char OutputPixelType; typedef itk::Image< InputPixelType, dim > InputImageType; typedef itk::Image< OutputPixelType, dim > OutputImageType; typedef itk::OtsuThresholdImageFilter< InputImageType, OutputImageType > FilterType; FilterType::Pointer filter = FilterType::New(); filter->SetOutsideValue( 1 ); filter->SetInsideValue( 0 ); InputImageType::Pointer itkImage; mitk::CastToItkImage(mitkImage, itkImage); filter->SetInput( itkImage ); filter->Update(); mitk::DataNode::Pointer resultNode = mitk::DataNode::New(); std::string nameOfResultImage = node->GetName(); nameOfResultImage.append("Otsu"); resultNode->SetProperty("name", mitk::StringProperty::New(nameOfResultImage) ); resultNode->SetProperty("binary", mitk::BoolProperty::New(true) ); resultNode->SetData( mitk::ImportItkImage(filter->GetOutput())->Clone()); this->GetDataStorage()->Add(resultNode, node); } catch( std::exception& err ) { MITK_ERROR(this->GetClassName()) << err.what(); } } } void QmitkDataManagerView::NodeTreeViewRowsRemoved ( const QModelIndex & /*parent*/, int /*start*/, int /*end*/ ) { m_CurrentRowCount = m_NodeTreeModel->rowCount(); } void QmitkDataManagerView::NodeTreeViewRowsInserted( const QModelIndex & parent, int, int ) { m_NodeTreeView->setExpanded(parent, true); // a new row was inserted if( m_CurrentRowCount == 0 && m_NodeTreeModel->rowCount() == 1 ) { this->OpenRenderWindowPart(); m_CurrentRowCount = m_NodeTreeModel->rowCount(); /* std::vector nodes = m_NodeTreeModel->GetNodeSet(); if(nodes.size() == 1) { QModelIndex treeIndex = m_NodeTreeModel->GetIndex(nodes.front()); m_NodeTreeView->selectionModel()->setCurrentIndex( treeIndex, QItemSelectionModel::ClearAndSelect ); } */ } } void QmitkDataManagerView::NodeSelectionChanged( const QItemSelection & /*selected*/, const QItemSelection & /*deselected*/ ) { QList nodes = m_NodeTreeModel->GetNodeSet(); foreach(mitk::DataNode::Pointer node, nodes) { if ( node.IsNotNull() ) node->SetBoolProperty("selected", false); } nodes.clear(); nodes = this->GetCurrentSelection(); foreach(mitk::DataNode::Pointer node, nodes) { if ( node.IsNotNull() ) node->SetBoolProperty("selected", true); } //changing the selection does NOT require any rendering processes! //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkDataManagerView::ShowIn(const QString &editorId) { berry::IWorkbenchPage::Pointer page = this->GetSite()->GetPage(); berry::IEditorInput::Pointer input(new mitk::DataStorageEditorInput(this->GetDataStorageReference())); page->OpenEditor(input, editorId.toStdString(), false, berry::IWorkbenchPage::MATCH_ID); } mitk::IRenderWindowPart* QmitkDataManagerView::OpenRenderWindowPart(bool activatedEditor) { if (activatedEditor) { return this->GetRenderWindowPart(QmitkAbstractView::ACTIVATE | QmitkAbstractView::OPEN); } else { return this->GetRenderWindowPart(QmitkAbstractView::BRING_TO_FRONT | QmitkAbstractView::OPEN); } } diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionRegistrationViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionRegistrationViewControls.ui index b7489b33c7..91659dd4aa 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionRegistrationViewControls.ui +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionRegistrationViewControls.ui @@ -1,226 +1,226 @@ QmitkDiffusionRegistrationViewControls 0 0 435 744 Form 0 0 DWI Head Motion Correction Qt::Vertical 20 40 false Start DWI registration/Head Motion Correction Start Head Motion Correction Please Select Input Data Diffusion Image <html><head/><body><p><span style=" color:#ff0000;">mandatory</span></p></body></html> true Monitor Process Time: Progress: - - false Qt::LeftToRight Stop - - :/qmitk/stop.xpm:/qmitk/stop.xpm + + :/QtWidgetsExt/stop.xpm:/QtWidgetsExt/stop.xpm true QFrame::StyledPanel QFrame::Raised 9 0 9 0 4 Advanced settings Advanced Settings - + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui index 802b79836c..3bd95295ba 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui @@ -1,1115 +1,1115 @@ QmitkGibbsTrackingViewControls 0 0 463 1011 0 0 0 0 QmitkTemplate QFormLayout::AllNonFixedFieldsGrow Please Select Input Data Q-Ball/Tensor Image: Mandatory input <html><head/><body><p><span style=" color:#ff0000;">mandatory</span></p></body></html> true Mask Image: <html><head/><body><p>White matter probability mask image.</p></body></html> <html><head/><body><p><span style=" color:#969696;">optional</span></p></body></html> true QFrame::NoFrame QFrame::Plain 0 0 0 0 0 0 false No Q-Ball image selected. Qt::LeftToRight Start Tractography - - :/qmitk/play.xpm:/qmitk/play.xpm + + :/QtWidgetsExt/play.xpm:/QtWidgetsExt/play.xpm false Qt::LeftToRight Stop Tractography - - :/qmitk/stop.xpm:/qmitk/stop.xpm + + :/QtWidgetsExt/stop.xpm:/QtWidgetsExt/stop.xpm Parameters 0 Iterations: 10^7 Specify number of iterations for the tracking algorithm. 9 6 Qt::Horizontal QSlider::TicksBelow true Activate continuous visualization of intermediate results. Visualize Tractography true Visualize intermediate result. :/QmitkDiffusionImaging/Refresh_48.png:/QmitkDiffusionImaging/Refresh_48.png true Advanced Settings Output File: QFrame::NoFrame QFrame::Plain 0 0 0 0 0 0 Select output file name and folder. ... N/A true true QFrame::StyledPanel QFrame::Raised 9 0 9 0 4 Particle Width: 0 Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 0.1 Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter Particle Weight: 1 99 1 10 Qt::Horizontal QSlider::NoTicks Start Temperature: automatic estimation from gfa map and q-ball data. 0 1000 1 0 Qt::Horizontal true QSlider::NoTicks IE Bias < 0 < EE Bias -50 50 1 Qt::Horizontal QSlider::NoTicks 0.001 Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter Curvature Threshold: Balance In/Ex Energy: 45° Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter auto = 0.5 * min. spacing; sigma 100 1 Qt::Horizontal QSlider::NoTicks Particle Length: auto Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter Min. Fiber Length: Only fibers longer than specified are accepted. 500 1 40 Qt::Horizontal QSlider::NoTicks Allow only fiber curvature values smaller than the selected threshold. 180 1 45 Qt::Horizontal QSlider::NoTicks End Temperature: 40mm Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter auto Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 1 100 1 10 Qt::Horizontal false false QSlider::NoTicks auto Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter auto = 1.5 * min. spacing; l 100 1 Qt::Horizontal QSlider::NoTicks Random Seed auto Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter auto = 1.5 * min. spacing; l -1 100 1 -1 Qt::Horizontal QSlider::NoTicks QFrame::NoFrame QFrame::Plain 0 0 0 0 0 0 true Save current parameters as xml (.gtp) Qt::LeftToRight Save Parameters - - :/qmitk/btnMoveDown.png:/qmitk/btnMoveDown.png + + :/QtWidgetsExt/btnMoveDown.png:/QtWidgetsExt/btnMoveDown.png true Load parameters from xml file (.gtp) Qt::LeftToRight Load Parameters - - :/qmitk/btnMoveUp.png:/qmitk/btnMoveUp.png + + :/QtWidgetsExt/btnMoveUp.png:/QtWidgetsExt/btnMoveUp.png Monitor Progress: - Will only be updated if tracking is visualized Will only be updated if tracking is visualized Accepted Fibers: Connections: Particles: Proposal Acceptance Rate: Tracking Time: Will only be updated if tracking is visualized - - - - - Qt::Vertical QSizePolicy::Expanding 0 0 - + diff --git a/Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp b/Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp index ae1afc05e8..b3618a7b94 100644 --- a/Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp +++ b/Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp @@ -1,75 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPlanarFigureActivator.h" #include "mitkPlanarFigureObjectFactory.h" #include "QmitkNodeDescriptorManager.h" #include "mitkNodePredicateDataType.h" #include "mitkNodePredicateProperty.h" #include "mitkNodePredicateAnd.h" #include void mitk::PlanarFigureActivator::start(ctkPluginContext* /*context*/) { QmitkNodeDescriptorManager* descriptorManager = QmitkNodeDescriptorManager::GetInstance(); // Adding "PlanarLine" mitk::NodePredicateDataType::Pointer isPlanarLine = mitk::NodePredicateDataType::New("PlanarLine"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarLine"), QString(":/QmitkExt/PlanarLine_48.png"), isPlanarLine, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarLine"), QString(":/QtWidgetsExt/PlanarLine_48.png"), isPlanarLine, descriptorManager)); // Adding "PlanarCircle" mitk::NodePredicateDataType::Pointer isPlanarCircle = mitk::NodePredicateDataType::New("PlanarCircle"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarCircle"), QString(":/QmitkExt/PlanarCircle_48.png"), isPlanarCircle, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarCircle"), QString(":/QtWidgetsExt/PlanarCircle_48.png"), isPlanarCircle, descriptorManager)); // Adding "PlanarAngle" mitk::NodePredicateDataType::Pointer isPlanarAngle = mitk::NodePredicateDataType::New("PlanarAngle"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarAngle"), QString(":/QmitkExt/PlanarAngle_48.png"), isPlanarAngle, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarAngle"), QString(":/QtWidgetsExt/PlanarAngle_48.png"), isPlanarAngle, descriptorManager)); // Adding "PlanarFourPointAngle" mitk::NodePredicateDataType::Pointer isPlanarFourPointAngle = mitk::NodePredicateDataType::New("PlanarFourPointAngle"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarFourPointAngle"), QString(":/QmitkExt/PlanarFourPointAngle_48.png"), isPlanarFourPointAngle, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarFourPointAngle"), QString(":/QtWidgetsExt/PlanarFourPointAngle_48.png"), isPlanarFourPointAngle, descriptorManager)); // Adding "PlanarRectangle" mitk::NodePredicateDataType::Pointer isPlanarRectangle = mitk::NodePredicateDataType::New("PlanarRectangle"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarRectangle"), QString(":/QmitkExt/PlanarRectangle_48.png"), isPlanarRectangle, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarRectangle"), QString(":/QtWidgetsExt/PlanarRectangle_48.png"), isPlanarRectangle, descriptorManager)); // Adding "PlanarPolygon" mitk::NodePredicateDataType::Pointer isPlanarPolygon = mitk::NodePredicateDataType::New("PlanarPolygon"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarPolygon"), QString(":/QmitkExt/PlanarPolygon_48.png"), isPlanarPolygon, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarPolygon"), QString(":/QtWidgetsExt/PlanarPolygon_48.png"), isPlanarPolygon, descriptorManager)); // Adding "PlanarPath" mitk::NodePredicateProperty::Pointer isNotClosedPolygon = mitk::NodePredicateProperty::New("ClosedPlanarPolygon", mitk::BoolProperty::New(false)); mitk::NodePredicateAnd::Pointer isPlanarPath = mitk::NodePredicateAnd::New(isNotClosedPolygon, isPlanarPolygon); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarPath"), QString(":/QmitkExt/PlanarPath_48.png"), isPlanarPath, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor(QObject::tr("PlanarPath"), QString(":/QtWidgetsExt/PlanarPath_48.png"), isPlanarPath, descriptorManager)); // Adding "PlanarDoubleEllipse" mitk::NodePredicateDataType::Pointer isPlanarDoubleEllipse = mitk::NodePredicateDataType::New("PlanarDoubleEllipse"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor("PlanarDoubleEllipse", ":/QmitkExt/PlanarDoubleEllipse_48.png", isPlanarDoubleEllipse, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor("PlanarDoubleEllipse", ":/QtWidgetsExt/PlanarDoubleEllipse_48.png", isPlanarDoubleEllipse, descriptorManager)); // Adding "PlanarBezierCurve" mitk::NodePredicateDataType::Pointer isPlanarBezierCurve = mitk::NodePredicateDataType::New("PlanarBezierCurve"); - descriptorManager->AddDescriptor(new QmitkNodeDescriptor("PlanarBezierCurve", ":/QmitkExt/PlanarBezierCurve_48.png", isPlanarBezierCurve, descriptorManager)); + descriptorManager->AddDescriptor(new QmitkNodeDescriptor("PlanarBezierCurve", ":/QtWidgetsExt/PlanarBezierCurve_48.png", isPlanarBezierCurve, descriptorManager)); } void mitk::PlanarFigureActivator::stop(ctkPluginContext* /*context*/) { } Q_EXPORT_PLUGIN2(org_mitk_planarfigure, mitk::PlanarFigureActivator)