diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.cpp b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.cpp index af8e485885..f34909e777 100644 --- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.cpp @@ -1,136 +1,191 @@ /*=================================================================== 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 #include #include #include #include "QmitkExternalProgramsPreferencePage.h" static berry::IPreferences::Pointer GetPreferences() { berry::IPreferencesService::Pointer preferencesService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); if (preferencesService.IsNotNull()) { berry::IPreferences::Pointer systemPreferences = preferencesService->GetSystemPreferences(); if (systemPreferences.IsNotNull()) return systemPreferences->Node("/org.mitk.gui.qt.ext.externalprograms"); } mitkThrow(); } QmitkExternalProgramsPreferencePage::QmitkExternalProgramsPreferencePage() : m_Preferences(GetPreferences()), m_Ui(new Ui::QmitkExternalProgramsPreferencePage), m_Control(NULL), + m_FFmpegProcess(NULL), m_GnuplotProcess(NULL) { } QmitkExternalProgramsPreferencePage::~QmitkExternalProgramsPreferencePage() { } void QmitkExternalProgramsPreferencePage::CreateQtControl(QWidget* parent) { m_Control = new QWidget(parent); + m_FFmpegProcess = new QProcess(m_Control); m_GnuplotProcess = new QProcess(m_Control); m_Ui->setupUi(m_Control); + connect(m_FFmpegProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(OnFFmpegProcessError(QProcess::ProcessError))); + connect(m_FFmpegProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(OnFFmpegProcessFinished(int, QProcess::ExitStatus))); + connect(m_Ui->ffmpegButton, SIGNAL(clicked()), this, SLOT(OnFFmpegButtonClicked())); + connect(m_GnuplotProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(OnGnuplotProcessError(QProcess::ProcessError))); connect(m_GnuplotProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(OnGnuplotProcessFinished(int, QProcess::ExitStatus))); connect(m_Ui->gnuplotButton, SIGNAL(clicked()), this, SLOT(OnGnuplotButtonClicked())); this->Update(); } +void QmitkExternalProgramsPreferencePage::OnFFmpegButtonClicked() +{ + QString filter = "FFmpeg executable "; + +#if defined(WIN32) + filter += "(ffmpeg.exe)"; +#else + filter += "(ffmpeg)"; +#endif + + QString ffmpegPath = QFileDialog::getOpenFileName(m_Control, "FFmpeg", "", filter); + + if (!ffmpegPath.isEmpty()) + { + m_FFmpegPath = ffmpegPath; + m_FFmpegProcess->start(ffmpegPath, QStringList() << "-version", QProcess::ReadOnly); + } +} + +void QmitkExternalProgramsPreferencePage::OnFFmpegProcessError(QProcess::ProcessError) +{ + m_FFmpegPath.clear(); + m_Ui->ffmpegLineEdit->clear(); +} + +void QmitkExternalProgramsPreferencePage::OnFFmpegProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) +{ + if (exitStatus == QProcess::NormalExit && exitCode == 0) + { + QString version = QTextCodec::codecForName("UTF-8")->toUnicode(m_FFmpegProcess->readAllStandardOutput()).trimmed(); + + if (version.startsWith("ffmpeg")) + { + version = version.section(' ', 0, 2, QString::SectionSkipEmpty); + m_Ui->ffmpegLineEdit->setText(QString("%1 (%2)").arg(m_FFmpegPath).arg(version)); + return; + } + } + + m_FFmpegPath.clear(); + m_Ui->ffmpegLineEdit->clear(); +} + void QmitkExternalProgramsPreferencePage::OnGnuplotButtonClicked() { - QString filter = "Gnuplot executable "; + QString filter = "gnuplot executable "; #if defined(WIN32) filter += "(gnuplot.exe)"; #else filter += "(gnuplot)"; #endif QString gnuplotPath = QFileDialog::getOpenFileName(m_Control, "Gnuplot", "", filter); if (!gnuplotPath.isEmpty()) { m_GnuplotPath = gnuplotPath; m_GnuplotProcess->start(gnuplotPath, QStringList() << "--version", QProcess::ReadOnly); } } void QmitkExternalProgramsPreferencePage::OnGnuplotProcessError(QProcess::ProcessError) { m_GnuplotPath.clear(); m_Ui->gnuplotLineEdit->clear(); } void QmitkExternalProgramsPreferencePage::OnGnuplotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { if (exitStatus == QProcess::NormalExit && exitCode == 0) { QString version = QTextCodec::codecForName("UTF-8")->toUnicode(m_GnuplotProcess->readAllStandardOutput()).trimmed(); if (version.startsWith("gnuplot")) { - m_Ui->gnuplotLineEdit->setText(QString("%1 (%2)").arg(m_GnuplotPath).arg(version.trimmed())); + m_Ui->gnuplotLineEdit->setText(QString("%1 (%2)").arg(m_GnuplotPath).arg(version)); return; } } m_GnuplotPath.clear(); m_Ui->gnuplotLineEdit->clear(); } QWidget* QmitkExternalProgramsPreferencePage::GetQtControl() const { return m_Control; } void QmitkExternalProgramsPreferencePage::Init(berry::IWorkbench::Pointer) { } void QmitkExternalProgramsPreferencePage::PerformCancel() { } bool QmitkExternalProgramsPreferencePage::PerformOk() { + m_Preferences->Put("ffmpeg", m_FFmpegPath.toStdString()); m_Preferences->Put("gnuplot", m_GnuplotPath.toStdString()); return true; } void QmitkExternalProgramsPreferencePage::Update() { + m_FFmpegPath = QString::fromStdString(m_Preferences->Get("ffmpeg", "")); + + if (!m_FFmpegPath.isEmpty()) + m_FFmpegProcess->start(m_FFmpegPath, QStringList() << "-version", QProcess::ReadOnly); + m_GnuplotPath = QString::fromStdString(m_Preferences->Get("gnuplot", "")); if (!m_GnuplotPath.isEmpty()) m_GnuplotProcess->start(m_GnuplotPath, QStringList() << "--version", QProcess::ReadOnly); } diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.h index e766b3b400..fb4da45609 100644 --- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.h +++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.h @@ -1,59 +1,67 @@ /*=================================================================== 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 QmitkExternalProgramsPreferencePage_h #define QmitkExternalProgramsPreferencePage_h #include #include #include #include namespace Ui { class QmitkExternalProgramsPreferencePage; } class QmitkExternalProgramsPreferencePage : public QObject, public berry::IQtPreferencePage { Q_OBJECT Q_INTERFACES(berry::IPreferencePage) public: QmitkExternalProgramsPreferencePage(); ~QmitkExternalProgramsPreferencePage(); void CreateQtControl(QWidget* parent); QWidget* GetQtControl() const; void Init(berry::IWorkbench::Pointer); void PerformCancel(); bool PerformOk(); void Update(); private slots: + void OnFFmpegButtonClicked(); + void OnFFmpegProcessError(QProcess::ProcessError error); + void OnFFmpegProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); + void OnGnuplotButtonClicked(); void OnGnuplotProcessError(QProcess::ProcessError error); void OnGnuplotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); private: berry::IPreferences::Pointer m_Preferences; QScopedPointer m_Ui; QWidget* m_Control; + + QProcess* m_FFmpegProcess; + QString m_FFmpegPath; + QProcess* m_GnuplotProcess; QString m_GnuplotPath; }; #endif diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.ui b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.ui index ace9d303c8..61f67ee3a0 100644 --- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.ui +++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExternalProgramsPreferencePage.ui @@ -1,65 +1,92 @@ QmitkExternalProgramsPreferencePage 0 0 400 300 External Programs - - + + + + + FFmpeg executable: + + + Qt::PlainText + + + gnuplotButton + + + + + + + true + + + + + + + ... + + + + - Gnuplot &executable: + gnuplot executable: Qt::PlainText gnuplotButton - + true - + ... Qt::Vertical 20 248 diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/files.cmake b/Plugins/org.mitk.gui.qt.moviemaker2/files.cmake index ed9cd876c2..cf08e2cdb0 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/files.cmake +++ b/Plugins/org.mitk.gui.qt.moviemaker2/files.cmake @@ -1,47 +1,49 @@ set(SRC_CPP_FILES ) set(INTERNAL_CPP_FILES org_mitk_gui_qt_moviemaker2_Activator.cpp QmitkAnimationItem.cpp QmitkAnimationItemDelegate.cpp + QmitkAnimationWidget.cpp QmitkMovieMaker2View.cpp QmitkOrbitAnimationItem.cpp QmitkOrbitAnimationWidget.cpp QmitkSliceAnimationItem.cpp QmitkSliceAnimationWidget.cpp ) set(UI_FILES src/internal/QmitkMovieMaker2View.ui src/internal/QmitkOrbitAnimationWidget.ui src/internal/QmitkSliceAnimationWidget.ui ) set(MOC_H_FILES src/internal/org_mitk_gui_qt_moviemaker2_Activator.h src/internal/QmitkAnimationItemDelegate.h + src/internal/QmitkAnimationWidget.h src/internal/QmitkMovieMaker2View.h src/internal/QmitkOrbitAnimationWidget.h src/internal/QmitkSliceAnimationWidget.h ) set(CACHED_RESOURCE_FILES resources/camera-video.png plugin.xml ) set(QRC_FILES resources/org_mitk_gui_qt_moviemaker2.qrc ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach() foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach() diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItem.h b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItem.h index b2500c69f5..47ae1fd79b 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItem.h +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItem.h @@ -1,53 +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. ===================================================================*/ #ifndef QmitkAnimationItem_h #define QmitkAnimationItem_h #include class QmitkAnimationItem : public QStandardItem { public: enum AnimationItemDataRole { WidgetKeyRole = Qt::UserRole + 2, DurationRole, DelayRole, StartWithPreviousRole, + RenderWindowRole, FromRole, ToRole, ReverseRole, AngleRole }; explicit QmitkAnimationItem(const QString& widgetKey, double duration = 2.0, double delay = 0.0, bool startWithPrevious = false); virtual ~QmitkAnimationItem(); QString GetWidgetKey() const; void SetWidgetKey(const QString& widgetKey); double GetDuration() const; void SetDuration(double duration); double GetDelay() const; void SetDelay(double delay); bool GetStartWithPrevious() const; void SetStartWithPrevious(bool startWithPrevious); }; #endif diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItemDelegate.cpp b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItemDelegate.cpp index c05ed2ee7b..1ae598bdcb 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItemDelegate.cpp +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationItemDelegate.cpp @@ -1,99 +1,101 @@ /*=================================================================== 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 "QmitkAnimationItem.h" #include "QmitkAnimationItemDelegate.h" #include #include #include QmitkAnimationItemDelegate::QmitkAnimationItemDelegate(QObject* parent) : QStyledItemDelegate(parent) { } QmitkAnimationItemDelegate::~QmitkAnimationItemDelegate() { } void QmitkAnimationItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { const QStandardItemModel* model = dynamic_cast(index.model()); const QmitkAnimationItem* thisItem = dynamic_cast(model->item(index.row(), 1)); QList items; const int rowCount = model->rowCount(); for (int i = 0; i < rowCount; ++i) items << dynamic_cast(model->item(i, 1)); double totalDuration = 0.0; double previousStart = 0.0; double thisStart = 0.0; Q_FOREACH(const QmitkAnimationItem* item, items) { if (item->GetStartWithPrevious()) { totalDuration = std::max(totalDuration, previousStart + item->GetDelay() + item->GetDuration()); } else { previousStart = totalDuration; totalDuration += item->GetDelay() + item->GetDuration(); } if (item == thisItem) thisStart = previousStart; } - QColor color("CornflowerBlue"); + QColor color = thisItem->GetStartWithPrevious() + ? QColor("Khaki") + : QColor("DarkKhaki"); painter->setBrush(color); painter->setPen(Qt::NoPen); const QRect& rect = option.rect; const double widthPerSecond = rect.width() / totalDuration; painter->drawRect( rect.x() + static_cast(widthPerSecond * (thisStart + thisItem->GetDelay())), rect.y() + 1, static_cast(widthPerSecond * thisItem->GetDuration()), rect.height() - 2); if (thisItem->GetDelay() > std::numeric_limits::min()) { QPen pen(color); painter->setPen(pen); painter->drawLine( rect.x() + static_cast(widthPerSecond * thisStart), rect.y() + 1, rect.x() + static_cast(widthPerSecond * thisStart), rect.y() + rect.height() - 2); pen.setStyle(Qt::DashLine); painter->setPen(pen); painter->drawLine( rect.x() + static_cast(widthPerSecond * thisStart), rect.y() + rect.height() / 2, rect.x() + static_cast(widthPerSecond * (thisStart + thisItem->GetDelay())) - 1, rect.y() + rect.height() / 2); } QStyledItemDelegate::paint(painter, option, index); } diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.cpp b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationWidget.cpp similarity index 63% copy from Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.cpp copy to Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationWidget.cpp index 664713ffbe..45c861d9ab 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.cpp +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationWidget.cpp @@ -1,29 +1,26 @@ /*=================================================================== 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 "QmitkSliceAnimationWidget.h" -#include +#include "QmitkAnimationWidget.h" -QmitkSliceAnimationWidget::QmitkSliceAnimationWidget(QWidget* parent) - : QWidget(parent), - m_Ui(new Ui::QmitkSliceAnimationWidget) +QmitkAnimationWidget::QmitkAnimationWidget(QWidget* parent) + : QWidget(parent) { - m_Ui->setupUi(this); } -QmitkSliceAnimationWidget::~QmitkSliceAnimationWidget() +QmitkAnimationWidget::~QmitkAnimationWidget() { } diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.h b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationWidget.h similarity index 63% copy from Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.h copy to Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationWidget.h index bd8781e2f6..103a7b5f6e 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.h +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkAnimationWidget.h @@ -1,39 +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 QmitkOrbitAnimationWidget_h -#define QmitkOrbitAnimationWidget_h +#ifndef QmitkAnimationWidget_h +#define QmitkAnimationWidget_h #include -namespace Ui -{ - class QmitkOrbitAnimationWidget; -} +class QmitkAnimationItem; -class QmitkOrbitAnimationWidget : public QWidget +class QmitkAnimationWidget : public QWidget { Q_OBJECT public: - explicit QmitkOrbitAnimationWidget(QWidget* parent = NULL); - ~QmitkOrbitAnimationWidget(); + explicit QmitkAnimationWidget(QWidget* parent = NULL); + virtual ~QmitkAnimationWidget(); -private: - Ui::QmitkOrbitAnimationWidget* m_Ui; + virtual void SetAnimationItem(QmitkAnimationItem* animationItem) = 0; }; #endif diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.cpp b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.cpp index 01f8f46c07..c73d39a4c1 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.cpp +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.cpp @@ -1,421 +1,385 @@ /*=================================================================== 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 "QmitkAnimationItemDelegate.h" #include "QmitkMovieMaker2View.h" #include "QmitkOrbitAnimationItem.h" #include "QmitkOrbitAnimationWidget.h" #include "QmitkSliceAnimationItem.h" #include "QmitkSliceAnimationWidget.h" #include #include #include #include #include -static QmitkOrbitAnimationItem* CreateDefaultOrbitAnimation() -{ - return new QmitkOrbitAnimationItem(360.0, false); -} - -static QmitkSliceAnimationItem* CreateDefaultSliceAnimation() -{ - return new QmitkSliceAnimationItem(0, 0, false); -} - static QmitkAnimationItem* CreateDefaultAnimation(const QString& widgetKey) { if (widgetKey == "Orbit") - return CreateDefaultOrbitAnimation(); + return new QmitkOrbitAnimationItem(360.0, false); if (widgetKey == "Slice") - return CreateDefaultSliceAnimation(); + return new QmitkSliceAnimationItem(0, 0, 999, false); return NULL; } -static QString GetPrettyRenderWindowName(const QString& name) -{ - QMap map; - map["stdmulti.widget1"] = "Axial"; - map["stdmulti.widget2"] = "Sagittal"; - map["stdmulti.widget3"] = "Coronal"; - map["stdmulti.widget4"] = "3D"; - - return map.contains(name) - ? map[name] - : name; -} - const std::string QmitkMovieMaker2View::VIEW_ID = "org.mitk.views.moviemaker2"; QmitkMovieMaker2View::QmitkMovieMaker2View() : m_Ui(new Ui::QmitkMovieMaker2View), m_AnimationModel(NULL), m_AddAnimationMenu(NULL), m_RecordMenu(NULL) { } QmitkMovieMaker2View::~QmitkMovieMaker2View() { } void QmitkMovieMaker2View::CreateQtPartControl(QWidget* parent) { m_Ui->setupUi(parent); this->InitializeAnimationWidgets(); this->InitializeAnimationTreeViewWidgets(); this->InitializePlaybackAndRecordWidgets(); m_Ui->animationWidgetGroupBox->setVisible(false); } void QmitkMovieMaker2View::InitializeAnimationWidgets() { m_AnimationWidgets["Orbit"] = new QmitkOrbitAnimationWidget; m_AnimationWidgets["Slice"] = new QmitkSliceAnimationWidget; Q_FOREACH(QWidget* widget, m_AnimationWidgets.values()) { if (widget != NULL) { widget->setVisible(false); m_Ui->animationWidgetGroupBoxLayout->addWidget(widget); } } this->ConnectAnimationWidgets(); } void QmitkMovieMaker2View::InitializeAnimationTreeViewWidgets() { this->InitializeAnimationModel(); this->InitializeAddAnimationMenu(); this->ConnectAnimationTreeViewWidgets(); } void QmitkMovieMaker2View::InitializePlaybackAndRecordWidgets() { + this->InitializeRecordMenu(); this->ConnectPlaybackAndRecordWidgets(); } void QmitkMovieMaker2View::InitializeAnimationModel() { m_AnimationModel = new QStandardItemModel(m_Ui->animationTreeView); m_AnimationModel->setHorizontalHeaderLabels(QStringList() << "Animation" << "Timeline"); m_Ui->animationTreeView->setModel(m_AnimationModel); m_Ui->animationTreeView->setItemDelegateForColumn(1, new QmitkAnimationItemDelegate(m_Ui->animationTreeView)); } void QmitkMovieMaker2View::InitializeAddAnimationMenu() { m_AddAnimationMenu = new QMenu(m_Ui->addAnimationButton); Q_FOREACH(const QString& key, m_AnimationWidgets.keys()) { m_AddAnimationMenu->addAction(key); } } void QmitkMovieMaker2View::InitializeRecordMenu() { - if (m_RecordMenu == NULL) - { - m_RecordMenu = new QMenu(m_Ui->recordButton); - } - else - { - m_RecordMenu->clear(); - } - - const mitk::RenderingManager::RenderWindowVector& renderWindows - = mitk::RenderingManager::GetInstance()->GetAllRegisteredRenderWindows(); + m_RecordMenu = new QMenu(m_Ui->recordButton); - Q_FOREACH(const mitk::RenderingManager::RenderWindowVector::value_type renderWindow, renderWindows) - { - QString name = mitk::BaseRenderer::GetInstance(renderWindow)->GetName(); - m_RecordMenu->addAction(GetPrettyRenderWindowName(name)); - } + m_RecordMenu->addAction("Axial"); + m_RecordMenu->addAction("Sagittal"); + m_RecordMenu->addAction("Coronal"); + m_RecordMenu->addAction("3D"); } void QmitkMovieMaker2View::ConnectAnimationTreeViewWidgets() { this->connect(m_AnimationModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(OnAnimationTreeViewRowsInserted(const QModelIndex&, int, int))); this->connect(m_AnimationModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(OnAnimationTreeViewRowsRemoved(const QModelIndex&, int, int))); this->connect(m_Ui->animationTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(OnAnimationTreeViewSelectionChanged(const QItemSelection&, const QItemSelection&))); this->connect(m_Ui->moveAnimationUpButton, SIGNAL(clicked()), this, SLOT(OnMoveAnimationUpButtonClicked())); this->connect(m_Ui->moveAnimationDownButton, SIGNAL(clicked()), this, SLOT(OnMoveAnimationDownButtonClicked())); this->connect(m_Ui->addAnimationButton, SIGNAL(clicked()), this, SLOT(OnAddAnimationButtonClicked())); this->connect(m_Ui->removeAnimationButton, SIGNAL(clicked()), this, SLOT(OnRemoveAnimationButtonClicked())); } void QmitkMovieMaker2View::ConnectAnimationWidgets() { this->connect(m_Ui->startComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnStartComboBoxCurrentIndexChanged(int))); this->connect(m_Ui->durationSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnDurationSpinBoxValueChanged(double))); this->connect(m_Ui->delaySpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnDelaySpinBoxValueChanged(double))); } void QmitkMovieMaker2View::ConnectPlaybackAndRecordWidgets() { this->connect(m_Ui->recordButton, SIGNAL(clicked()), this, SLOT(OnRecordButtonClicked())); } void QmitkMovieMaker2View::SetFocus() { m_Ui->addAnimationButton->setFocus(); } void QmitkMovieMaker2View::OnMoveAnimationUpButtonClicked() { const QItemSelection selection = m_Ui->animationTreeView->selectionModel()->selection(); if (!selection.isEmpty()) { const int selectedRow = selection[0].top(); if (selectedRow > 0) m_AnimationModel->insertRow(selectedRow - 1, m_AnimationModel->takeRow(selectedRow)); } } void QmitkMovieMaker2View::OnMoveAnimationDownButtonClicked() { const QItemSelection selection = m_Ui->animationTreeView->selectionModel()->selection(); if (!selection.isEmpty()) { const int rowCount = m_AnimationModel->rowCount(); const int selectedRow = selection[0].top(); if (selectedRow < rowCount - 1) m_AnimationModel->insertRow(selectedRow + 1, m_AnimationModel->takeRow(selectedRow)); } } void QmitkMovieMaker2View::OnAddAnimationButtonClicked() { QAction* action = m_AddAnimationMenu->exec(QCursor::pos()); if (action != NULL) { const QString widgetKey = action->text(); m_AnimationModel->appendRow(QList() << new QStandardItem(widgetKey) << CreateDefaultAnimation(widgetKey)); m_Ui->playbackAndRecordingGroupBox->setEnabled(true); } } void QmitkMovieMaker2View::OnRecordButtonClicked() { - this->InitializeRecordMenu(); - - if (m_RecordMenu->isEmpty()) - QMessageBox::warning(NULL, QString::fromStdString(this->GetPartName()), "Could not find any render window."); - QAction* action = m_RecordMenu->exec(QCursor::pos()); if (action != NULL) { + // TODO: Ensure render window is opened // TODO } } void QmitkMovieMaker2View::OnRemoveAnimationButtonClicked() { const QItemSelection selection = m_Ui->animationTreeView->selectionModel()->selection(); if (!selection.isEmpty()) - { m_AnimationModel->removeRow(selection[0].top()); - } - else - { - m_Ui->playbackAndRecordingGroupBox->setEnabled(false); - } } void QmitkMovieMaker2View::OnAnimationTreeViewRowsInserted(const QModelIndex& parent, int start, int) { m_Ui->animationTreeView->selectionModel()->select( m_AnimationModel->index(start, 0, parent), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } void QmitkMovieMaker2View::OnAnimationTreeViewRowsRemoved(const QModelIndex&, int, int) { this->UpdateWidgets(); } void QmitkMovieMaker2View::OnAnimationTreeViewSelectionChanged(const QItemSelection&, const QItemSelection&) { this->UpdateWidgets(); } void QmitkMovieMaker2View::OnStartComboBoxCurrentIndexChanged(int index) { QmitkAnimationItem* item = this->GetSelectedAnimationItem(); if (item != NULL) { item->SetStartWithPrevious(index); this->RedrawTimeline(); } } void QmitkMovieMaker2View::OnDurationSpinBoxValueChanged(double value) { QmitkAnimationItem* item = this->GetSelectedAnimationItem(); if (item != NULL) { item->SetDuration(value); this->RedrawTimeline(); } } void QmitkMovieMaker2View::OnDelaySpinBoxValueChanged(double value) { QmitkAnimationItem* item = this->GetSelectedAnimationItem(); if (item != NULL) { item->SetDelay(value); this->RedrawTimeline(); } } void QmitkMovieMaker2View::UpdateWidgets() { const QItemSelection selection = m_Ui->animationTreeView->selectionModel()->selection(); if (selection.isEmpty()) { m_Ui->moveAnimationUpButton->setEnabled(false); m_Ui->moveAnimationDownButton->setEnabled(false); m_Ui->removeAnimationButton->setEnabled(false); + m_Ui->playbackAndRecordingGroupBox->setEnabled(false); this->HideCurrentAnimationWidget(); } else { const int rowCount = m_AnimationModel->rowCount(); const int selectedRow = selection[0].top(); m_Ui->moveAnimationUpButton->setEnabled(rowCount > 1 && selectedRow != 0); m_Ui->moveAnimationDownButton->setEnabled(rowCount > 1 && selectedRow < rowCount - 1); m_Ui->removeAnimationButton->setEnabled(true); + m_Ui->playbackAndRecordingGroupBox->setEnabled(true); - this->ShowAnimationWidget(m_AnimationModel->item(selectedRow, 1)->data(QmitkAnimationItem::WidgetKeyRole).toString()); + this->ShowAnimationWidget(dynamic_cast(m_AnimationModel->item(selectedRow, 1))); } this->UpdateAnimationWidgets(); } void QmitkMovieMaker2View::UpdateAnimationWidgets() { QmitkAnimationItem* item = this->GetSelectedAnimationItem(); if (item != NULL) { m_Ui->startComboBox->setCurrentIndex(item->GetStartWithPrevious()); m_Ui->durationSpinBox->setValue(item->GetDuration()); m_Ui->delaySpinBox->setValue(item->GetDelay()); m_Ui->animationGroupBox->setEnabled(true); } else { m_Ui->animationGroupBox->setEnabled(false); } } void QmitkMovieMaker2View::HideCurrentAnimationWidget() { if (m_Ui->animationWidgetGroupBox->isVisible()) { m_Ui->animationWidgetGroupBox->setVisible(false); int numWidgets = m_Ui->animationWidgetGroupBoxLayout->count(); for (int i = 0; i < numWidgets; ++i) m_Ui->animationWidgetGroupBoxLayout->itemAt(i)->widget()->setVisible(false); } } -void QmitkMovieMaker2View::ShowAnimationWidget(const QString& key) +void QmitkMovieMaker2View::ShowAnimationWidget(QmitkAnimationItem* animationItem) { this->HideCurrentAnimationWidget(); - QWidget* widget = NULL; + if (animationItem == NULL) + return; + + const QString widgetKey = animationItem->GetWidgetKey(); + QmitkAnimationWidget* animationWidget = NULL; - if (m_AnimationWidgets.contains(key)) + if (m_AnimationWidgets.contains(widgetKey)) { - widget = m_AnimationWidgets[key]; + animationWidget = m_AnimationWidgets[widgetKey]; - if (widget != NULL) + if (animationWidget != NULL) { - m_Ui->animationWidgetGroupBox->setTitle(key); - widget->setVisible(true); + m_Ui->animationWidgetGroupBox->setTitle(widgetKey); + animationWidget->SetAnimationItem(animationItem); + animationWidget->setVisible(true); } } - m_Ui->animationWidgetGroupBox->setVisible(widget != NULL); + m_Ui->animationWidgetGroupBox->setVisible(animationWidget != NULL); } void QmitkMovieMaker2View::RedrawTimeline() { if (m_AnimationModel->rowCount() > 1) { m_Ui->animationTreeView->dataChanged( m_AnimationModel->index(0, 1), m_AnimationModel->index(m_AnimationModel->rowCount() - 1, 1)); } } QmitkAnimationItem* QmitkMovieMaker2View::GetSelectedAnimationItem() const { const QItemSelection selection = m_Ui->animationTreeView->selectionModel()->selection(); return !selection.isEmpty() ? dynamic_cast(m_AnimationModel->item(selection[0].top(), 1)) : NULL; } diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.h b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.h index 1daf25dcf9..2dd3187d0e 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.h +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkMovieMaker2View.h @@ -1,81 +1,82 @@ /*=================================================================== 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 QmitkMovieMaker2View_h #define QmitkMovieMaker2View_h #include class QmitkAnimationItem; +class QmitkAnimationWidget; class QMenu; class QStandardItemModel; namespace Ui { class QmitkMovieMaker2View; } class QmitkMovieMaker2View : public QmitkAbstractView { Q_OBJECT public: static const std::string VIEW_ID; QmitkMovieMaker2View(); ~QmitkMovieMaker2View(); void CreateQtPartControl(QWidget* parent); void SetFocus(); private slots: void OnMoveAnimationUpButtonClicked(); void OnMoveAnimationDownButtonClicked(); void OnAddAnimationButtonClicked(); void OnRemoveAnimationButtonClicked(); void OnAnimationTreeViewRowsInserted(const QModelIndex& parent, int start, int end); void OnAnimationTreeViewRowsRemoved(const QModelIndex& parent, int start, int end); void OnAnimationTreeViewSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); void OnStartComboBoxCurrentIndexChanged(int index); void OnDurationSpinBoxValueChanged(double value); void OnDelaySpinBoxValueChanged(double value); void OnRecordButtonClicked(); private: void InitializeAnimationWidgets(); void InitializeAnimationTreeViewWidgets(); void InitializeAnimationModel(); void InitializeAddAnimationMenu(); void InitializePlaybackAndRecordWidgets(); void InitializeRecordMenu(); void ConnectAnimationTreeViewWidgets(); void ConnectAnimationWidgets(); void ConnectPlaybackAndRecordWidgets(); void UpdateWidgets(); void UpdateAnimationWidgets(); void HideCurrentAnimationWidget(); - void ShowAnimationWidget(const QString& key); + void ShowAnimationWidget(QmitkAnimationItem* animationItem); void RedrawTimeline(); QmitkAnimationItem* GetSelectedAnimationItem() const; Ui::QmitkMovieMaker2View* m_Ui; QStandardItemModel* m_AnimationModel; - QMap m_AnimationWidgets; + QMap m_AnimationWidgets; QMenu* m_AddAnimationMenu; QMenu* m_RecordMenu; }; #endif diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.cpp b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.cpp index f7482d5b31..c063526cb5 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.cpp +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.cpp @@ -1,48 +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. ===================================================================*/ #include "QmitkOrbitAnimationItem.h" QmitkOrbitAnimationItem::QmitkOrbitAnimationItem(double angle, bool reverse, double duration, double delay, bool startWithPrevious) : QmitkAnimationItem("Orbit", duration, delay, startWithPrevious) { this->SetAngle(angle); this->SetReverse(reverse); } QmitkOrbitAnimationItem::~QmitkOrbitAnimationItem() { } -double QmitkOrbitAnimationItem::GetAngle() const +int QmitkOrbitAnimationItem::GetAngle() const { - return this->data(AngleRole).toDouble(); + return this->data(AngleRole).toInt(); } -void QmitkOrbitAnimationItem::SetAngle(double angle) +void QmitkOrbitAnimationItem::SetAngle(int angle) { this->setData(angle, AngleRole); } bool QmitkOrbitAnimationItem::GetReverse() const { return this->data(ReverseRole).toBool(); } void QmitkOrbitAnimationItem::SetReverse(bool reverse) { this->setData(reverse, ReverseRole); } diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.h b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.h index 9097a8d104..c37a63afcb 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.h +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationItem.h @@ -1,35 +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 QmitkOrbitAnimationItem_h #define QmitkOrbitAnimationItem_h #include "QmitkAnimationItem.h" class QmitkOrbitAnimationItem : public QmitkAnimationItem { public: QmitkOrbitAnimationItem(double angle, bool reverse, double duration = 2.0, double delay = 0.0, bool startWithPrevious = false); virtual ~QmitkOrbitAnimationItem(); - double GetAngle() const; - void SetAngle(double angle); + int GetAngle() const; + void SetAngle(int angle); bool GetReverse() const; void SetReverse(bool reverse); }; #endif diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.cpp b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.cpp index c0c33a9975..6aef423902 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.cpp +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.cpp @@ -1,29 +1,71 @@ /*=================================================================== 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 "QmitkOrbitAnimationItem.h" #include "QmitkOrbitAnimationWidget.h" #include QmitkOrbitAnimationWidget::QmitkOrbitAnimationWidget(QWidget* parent) - : QWidget(parent), + : QmitkAnimationWidget(parent), m_Ui(new Ui::QmitkOrbitAnimationWidget) { m_Ui->setupUi(this); + + this->connect(m_Ui->angleSlider, SIGNAL(valueChanged(int)), + m_Ui->angleSpinBox, SLOT(setValue(int))); + + this->connect(m_Ui->angleSpinBox, SIGNAL(valueChanged(int)), + m_Ui->angleSlider, SLOT(setValue(int))); + + this->connect(m_Ui->angleSpinBox, SIGNAL(valueChanged(int)), + this, SLOT(OnAngleChanged(int))); + + this->connect(m_Ui->reverseCheckBox, SIGNAL(clicked(bool)), + this, SLOT(OnReverseChanged(bool))); } QmitkOrbitAnimationWidget::~QmitkOrbitAnimationWidget() { } + +void QmitkOrbitAnimationWidget::SetAnimationItem(QmitkAnimationItem* orbitAnimationItem) +{ + m_AnimationItem = dynamic_cast(orbitAnimationItem); + + if (m_AnimationItem == NULL) + return; + + m_Ui->angleSlider->setValue(m_AnimationItem->GetAngle()); + m_Ui->reverseCheckBox->setChecked(m_AnimationItem->GetReverse()); +} + +void QmitkOrbitAnimationWidget::OnAngleChanged(int angle) +{ + if (m_AnimationItem == NULL) + return; + + if (m_AnimationItem->GetAngle() != angle) + m_AnimationItem->SetAngle(angle); +} + +void QmitkOrbitAnimationWidget::OnReverseChanged(bool reverse) +{ + if (m_AnimationItem == NULL) + return; + + if (m_AnimationItem->GetReverse() != reverse) + m_AnimationItem->SetReverse(reverse); +} diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.h b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.h index bd8781e2f6..cc6306683b 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.h +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.h @@ -1,39 +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 QmitkOrbitAnimationWidget_h #define QmitkOrbitAnimationWidget_h -#include +#include "QmitkAnimationWidget.h" + +class QmitkOrbitAnimationItem; namespace Ui { class QmitkOrbitAnimationWidget; } -class QmitkOrbitAnimationWidget : public QWidget +class QmitkOrbitAnimationWidget : public QmitkAnimationWidget { Q_OBJECT public: explicit QmitkOrbitAnimationWidget(QWidget* parent = NULL); ~QmitkOrbitAnimationWidget(); + void SetAnimationItem(QmitkAnimationItem* orbitAnimationItem); + +private slots: + void OnAngleChanged(int angle); + void OnReverseChanged(bool reverse); + private: Ui::QmitkOrbitAnimationWidget* m_Ui; + QmitkOrbitAnimationItem* m_AnimationItem; }; #endif diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.ui b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.ui index 892cc21cc3..4ba7cc31c6 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.ui +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkOrbitAnimationWidget.ui @@ -1,97 +1,91 @@ QmitkOrbitAnimationWidget 0 0 - 304 - 96 + 345 + 63 QmitkOrbitAnimationWidget - + 0 0 - Window: + Angle: - windowComboBox + angleSlider - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Angle: - - - - - - - 360.000000000000000 - - - 360.000000000000000 - - - Qt::Horizontal - - + + + + + 360 + + + 360 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + ° + + + 360 + + + 360 + + + + - + 0 0 Reverse - - - ctkDoubleSlider - QWidget -
ctkDoubleSlider.h
-
-
- windowComboBox + angleSlider + angleSpinBox reverseCheckBox
diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.cpp b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.cpp index 81aa6506a6..19114b60c4 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.cpp +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.cpp @@ -1,59 +1,70 @@ /*=================================================================== 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 "QmitkSliceAnimationItem.h" -QmitkSliceAnimationItem::QmitkSliceAnimationItem(int from, int to, bool reverse, double duration, double delay, bool startWithPrevious) +QmitkSliceAnimationItem::QmitkSliceAnimationItem(int renderWindow, int from, int to, bool reverse, double duration, double delay, bool startWithPrevious) : QmitkAnimationItem("Slice", duration, delay, startWithPrevious) { + this->SetRenderWindow(renderWindow); this->SetFrom(from); this->SetTo(to); this->SetReverse(reverse); } QmitkSliceAnimationItem::~QmitkSliceAnimationItem() { } +int QmitkSliceAnimationItem::GetRenderWindow() const +{ + return this->data(RenderWindowRole).toInt(); +} + +void QmitkSliceAnimationItem::SetRenderWindow(int renderWindow) +{ + this->setData(renderWindow, RenderWindowRole); +} + int QmitkSliceAnimationItem::GetFrom() const { return this->data(FromRole).toInt(); } void QmitkSliceAnimationItem::SetFrom(int from) { this->setData(from, FromRole); } int QmitkSliceAnimationItem::GetTo() const { return this->data(ToRole).toInt(); } void QmitkSliceAnimationItem::SetTo(int to) { this->setData(to, ToRole); } bool QmitkSliceAnimationItem::GetReverse() const { return this->data(ReverseRole).toBool(); } void QmitkSliceAnimationItem::SetReverse(bool reverse) { this->setData(reverse, ReverseRole); } diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.h b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.h index 6a17edd93e..31975d8a08 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.h +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationItem.h @@ -1,38 +1,41 @@ /*=================================================================== 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 QmitkSliceAnimationItem_h #define QmitkSliceAnimationItem_h #include "QmitkAnimationItem.h" class QmitkSliceAnimationItem : public QmitkAnimationItem { public: - QmitkSliceAnimationItem(int from, int to, bool reverse, double duration = 2.0, double delay = 0.0, bool startWithPrevious = false); + QmitkSliceAnimationItem(int renderWindow, int from, int to, bool reverse, double duration = 2.0, double delay = 0.0, bool startWithPrevious = false); virtual ~QmitkSliceAnimationItem(); + int GetRenderWindow() const; + void SetRenderWindow(int renderWindow); + int GetFrom() const; void SetFrom(int from); int GetTo() const; void SetTo(int to); bool GetReverse() const; void SetReverse(bool reverse); }; #endif diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.cpp b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.cpp index 664713ffbe..13537054ad 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.cpp +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.cpp @@ -1,29 +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. ===================================================================*/ +#include "QmitkSliceAnimationItem.h" #include "QmitkSliceAnimationWidget.h" #include QmitkSliceAnimationWidget::QmitkSliceAnimationWidget(QWidget* parent) - : QWidget(parent), + : QmitkAnimationWidget(parent), m_Ui(new Ui::QmitkSliceAnimationWidget) { m_Ui->setupUi(this); + + this->connect(m_Ui->windowComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(OnRenderWindowChanged(int))); + + this->connect(m_Ui->sliceRangeWidget, SIGNAL(minimumValueChanged(double)), + this, SLOT(OnFromChanged(double))); + + this->connect(m_Ui->sliceRangeWidget, SIGNAL(maximumValueChanged(double)), + this, SLOT(OnToChanged(double))); + + this->connect(m_Ui->reverseCheckBox, SIGNAL(clicked(bool)), + this, SLOT(OnReverseChanged(bool))); } QmitkSliceAnimationWidget::~QmitkSliceAnimationWidget() { } + +void QmitkSliceAnimationWidget::SetAnimationItem(QmitkAnimationItem* sliceAnimationItem) +{ + m_AnimationItem = dynamic_cast(sliceAnimationItem); + + if (m_AnimationItem == NULL) + return; + + m_Ui->windowComboBox->setCurrentIndex(m_AnimationItem->GetRenderWindow()); + m_Ui->sliceRangeWidget->setValues(m_AnimationItem->GetFrom(), m_AnimationItem->GetTo()); + m_Ui->reverseCheckBox->setChecked(m_AnimationItem->GetReverse()); +} + +void QmitkSliceAnimationWidget::OnRenderWindowChanged(int renderWindow) +{ + if (m_AnimationItem == NULL) + return; + + if (m_AnimationItem->GetRenderWindow() != renderWindow) + m_AnimationItem->SetRenderWindow(renderWindow); +} + +void QmitkSliceAnimationWidget::OnFromChanged(double from) +{ + if (m_AnimationItem == NULL) + return; + + int intFrom = static_cast(from); + + if (m_AnimationItem->GetFrom() != intFrom) + m_AnimationItem->SetFrom(intFrom); +} + +void QmitkSliceAnimationWidget::OnToChanged(double to) +{ + if (m_AnimationItem == NULL) + return; + + int intTo = static_cast(to); + + if (m_AnimationItem->GetTo() != intTo) + m_AnimationItem->SetTo(intTo); +} + +void QmitkSliceAnimationWidget::OnReverseChanged(bool reverse) +{ + if (m_AnimationItem == NULL) + return; + + if (m_AnimationItem->GetReverse() != reverse) + m_AnimationItem->SetReverse(reverse); +} diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.h b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.h index d67fa41373..a12de9ed58 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.h +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.h @@ -1,39 +1,50 @@ /*=================================================================== 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 QmitkSliceAnimationWidget_h #define QmitkSliceAnimationWidget_h -#include +#include "QmitkAnimationWidget.h" + +class QmitkSliceAnimationItem; namespace Ui { class QmitkSliceAnimationWidget; } -class QmitkSliceAnimationWidget : public QWidget +class QmitkSliceAnimationWidget : public QmitkAnimationWidget { Q_OBJECT public: explicit QmitkSliceAnimationWidget(QWidget* parent = NULL); ~QmitkSliceAnimationWidget(); + void SetAnimationItem(QmitkAnimationItem* sliceAnimationItem); + +private slots: + void OnRenderWindowChanged(int renderWindow); + void OnFromChanged(double from); + void OnToChanged(double to); + void OnReverseChanged(bool reverse); + private: Ui::QmitkSliceAnimationWidget* m_Ui; + QmitkSliceAnimationItem* m_AnimationItem; }; #endif diff --git a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.ui b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.ui index 02546bfb14..303795a91b 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.ui +++ b/Plugins/org.mitk.gui.qt.moviemaker2/src/internal/QmitkSliceAnimationWidget.ui @@ -1,97 +1,117 @@ QmitkSliceAnimationWidget 0 0 304 96 QmitkSliceAnimationWidget 0 0 Window: windowComboBox 0 0 + + + Axial + + + + + Sagittal + + + + + Coronal + + + + + 3D + + 0 0 Slice range: 0 999.000000000000000 999.000000000000000 0 0 Reverse ctkRangeWidget QWidget
ctkRangeWidget.h
windowComboBox reverseCheckBox