diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index 36a97fe6a3..569da2217f 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,80 +1,78 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(mitk_modules Core CommandLine AppUtil DCMTesting RDF LegacyIO DataTypesExt Annotation LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction SceneSerialization Gizmo GraphAlgorithms Multilabel ImageStatistics ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation - OpenViewCore QtWidgets QtWidgetsExt Chart - QmlItems SegmentationUI Classification DiffusionImaging GPGPU OpenIGTLink IGTBase IGT CameraCalibration OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI PhotoacousticsHardware PhotoacousticsAlgorithms US USUI DicomUI Remeshing Python QtPython Persistence OpenIGTLinkUI IGTUI DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware TumorInvasionAnalysis MatchPointRegistration MatchPointRegistrationUI BoundingShape RenderWindowManager RenderWindowManagerUI CEST DICOMQI ) if(MITK_ENABLE_PIC_READER) list(APPEND mitk_modules IpPicSupportIO) endif() diff --git a/Modules/OpenViewCore/CMakeLists.txt b/Modules/OpenViewCore/CMakeLists.txt deleted file mode 100644 index 208ac1f9df..0000000000 --- a/Modules/OpenViewCore/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -MITK_CREATE_MODULE( - INCLUDE_DIRS - PUBLIC include/ - PRIVATE src/ - PACKAGE_DEPENDS Qt5|Core+Quick VTK|vtkGUISupportQt+vtkRenderingOpenGL2 OpenGL - ) - diff --git a/Modules/OpenViewCore/LICENSE b/Modules/OpenViewCore/LICENSE deleted file mode 100644 index d984dbbb61..0000000000 --- a/Modules/OpenViewCore/LICENSE +++ /dev/null @@ -1,34 +0,0 @@ -Copyright (c) 2012 Kitware Inc. - -Kitware Inc. -28 Corporate Drive -Clifton Park, NY 12065 -USA - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - - * Neither the name of Kitware nor the names of any contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Modules/OpenViewCore/QVTKQuickItem.cxx b/Modules/OpenViewCore/QVTKQuickItem.cxx deleted file mode 100644 index d08007fdce..0000000000 --- a/Modules/OpenViewCore/QVTKQuickItem.cxx +++ /dev/null @@ -1,374 +0,0 @@ -/*======================================================================== - OpenView -- http://openview.kitware.com - - Copyright 2012 Kitware, Inc. - - Licensed under the BSD license. See LICENSE file for details. - ========================================================================*/ -#include "QVTKQuickItem.h" -#include - -#include -#include -#include -#include -#include -#include - -#include "QVTKInteractor.h" -#include "QVTKInteractorAdapter.h" -#include "vtkGenericOpenGLRenderWindow.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkRenderer.h" -#include "vtkRendererCollection.h" - -#include "vtkCubeSource.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" - -#include - -QVTKQuickItem::QVTKQuickItem(QQuickItem* parent) -:QQuickItem(parent) -,m_InitCalledOnce(false) -{ - setFlag(ItemHasContents); - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); - - m_interactor = vtkSmartPointer::New(); - m_interactorAdapter = new QVTKInteractorAdapter(NULL); - m_interactorAdapter->moveToThread(this->thread()); - m_interactorAdapter->setParent(this); - m_connect = vtkSmartPointer::New(); - //m_connect->Connect(m_interactor, vtkCommand::RenderEvent, this, SLOT(paint())); - vtkSmartPointer win = vtkSmartPointer::New(); - this->SetRenderWindow(win); - this->geometryChanged(QRectF(x(), y(), width(), height()), QRectF(0, 0, 100, 100)); -} - -QVTKQuickItem::~QVTKQuickItem() -{ - this->SetRenderWindow(0); -} - -void QVTKQuickItem::SetRenderWindow(vtkGenericOpenGLRenderWindow* win) -{ - if(m_win) - { - m_win->SetMapped(0); - //m_connect->Disconnect(m_win, vtkCommand::StartEvent, this, SLOT(Start())); - //m_connect->Disconnect(m_win, vtkCommand::WindowMakeCurrentEvent, this, SLOT(MakeCurrent())); - //m_connect->Disconnect(m_win, vtkCommand::EndEvent, this, SLOT(End())); - //m_connect->Disconnect(m_win, vtkCommand::WindowFrameEvent, this, SLOT(Update())); - m_connect->Disconnect(m_win, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*))); - m_connect->Disconnect(m_win, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*))); - m_connect->Disconnect(m_win, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*))); - } - - m_interactor->SetRenderWindow(win); - m_win = win; - m_interactor->Initialize(); - - if(m_win) - { - m_win->SetMapped(1); - m_win->SetDoubleBuffer(0); - m_win->SetFrontBuffer(COLOR_ATTACHMENT0_EXT); - m_win->SetFrontLeftBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); - m_win->SetBackBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); - m_win->SetBackLeftBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); - - //m_connect->Connect(m_win, vtkCommand::StartEvent, this, SLOT(Start())); - //m_connect->Connect(m_win, vtkCommand::WindowMakeCurrentEvent, this, SLOT(MakeCurrent())); - //m_connect->Connect(m_win, vtkCommand::EndEvent, this, SLOT(End())); - //m_connect->Connect(m_win, vtkCommand::WindowFrameEvent, this, SLOT(Update())); - // Qt::DirectConnection in order to execute callback immediately. - // This avoids an error when vtkTexture attempts to query driver features and it is unable to determine "IsCurrent" - m_connect->Connect(m_win, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); - m_connect->Connect(m_win, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); - m_connect->Connect(m_win, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); - } -} - -vtkGenericOpenGLRenderWindow* QVTKQuickItem::GetRenderWindow() const -{ - return m_win; -} - -QVTKInteractor* QVTKQuickItem::GetInteractor() const -{ - return m_interactor; -} - -void QVTKQuickItem::itemChange(ItemChange change, const ItemChangeData &) -{ - // The ItemSceneChange event is sent when we are first attached to a canvas. - if (change == ItemSceneChange) { - QQuickWindow *c = window(); - if (!c) - { - return; - } - - // Connect our the beforeRendering signal to our paint function. - // Since this call is executed on the rendering thread it must be - // a Qt::DirectConnection - connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); - - // If we allow QML to do the clearing, they would clear what we paint - // and nothing would show. - c->setClearBeforeRendering(false); - } -} - -void QVTKQuickItem::MakeCurrent() -{ - if (!this->window()) - { - m_win->SetAbortRender(1); - cerr << "Could not make current since there is no canvas!" << endl; - return; - } - if (QThread::currentThread() != this->window()->openglContext()->thread()) - { - m_win->SetAbortRender(1); - cerr << "Could not make current since we are on the wrong thread!" << endl; - return; - } - this->window()->openglContext()->makeCurrent(this->window()); -} - -void QVTKQuickItem::Start() -{ - MakeCurrent(); - - if (!m_win->GetAbortRender()) - { - m_win->PushState(); - m_win->OpenGLInitState(); - } -} - -void QVTKQuickItem::End() -{ - if (!m_win->GetAbortRender()) - { - m_win->PopState(); - } - -} - -void QVTKQuickItem::IsCurrent(vtkObject*, unsigned long, void*, void* call_data) -{ - bool* ptr = reinterpret_cast(call_data); - *ptr = QOpenGLContext::currentContext() == this->window()->openglContext(); -} - -void QVTKQuickItem::IsDirect(vtkObject*, unsigned long, void*, void* call_data) -{ - int* ptr = reinterpret_cast(call_data); - *ptr = 1; -} - -void QVTKQuickItem::SupportsOpenGL(vtkObject*, unsigned long, void*, void* call_data) -{ - int* ptr = reinterpret_cast(call_data); - *ptr = true; - //*ptr = QGLFormat::hasOpenGL(); -} - -void QVTKQuickItem::geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry) -{ - QQuickItem::geometryChanged(newGeometry, oldGeometry); - QSize oldSize(oldGeometry.width(), oldGeometry.height()); - QSize newSize(newGeometry.width(), newGeometry.height()); - QResizeEvent e(newSize, oldSize); - if (m_interactorAdapter) - { - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e, m_interactor); - this->m_viewLock.unlock(); - } - if(m_win.GetPointer() && window()) - { - this->m_viewLock.lock(); - m_win->SetSize(window()->width(), window()->height()); - QPointF origin = mapToScene(QPointF(0, 0)); - QPointF minPt(origin.x()/window()->width(), (window()->height() - origin.y() - height())/window()->height()); - QPointF maxPt(minPt.x() + width()/window()->width(), minPt.y() + height()/window()->height()); - if (m_win->GetRenderers()->GetFirstRenderer()) - { - m_win->GetRenderers()->GetFirstRenderer()->SetViewport(minPt.x(), minPt.y(), maxPt.x(), maxPt.y()); - } - this->m_viewLock.unlock(); - update(); - } -} - -void QVTKQuickItem::keyPressEvent(QKeyEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::keyReleaseEvent(QKeyEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mousePressEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mouseReleaseEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mouseDoubleClickEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mouseMoveEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::wheelEvent(QWheelEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::hoverEnterEvent(QHoverEvent* e) -{ - e->accept(); - QEvent e2(QEvent::Enter); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e2, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::hoverLeaveEvent(QHoverEvent* e) -{ - e->accept(); - QEvent e2(QEvent::Leave); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e2, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::hoverMoveEvent(QHoverEvent* e) -{ - e->accept(); - QMouseEvent e2(QEvent::MouseMove, e->pos(), Qt::NoButton, Qt::NoButton, e->modifiers()); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e2, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::init() -{ -} - -void QVTKQuickItem::prepareForRender() -{ -} - -void QVTKQuickItem::cleanupAfterRender() -{ -} - -QSGNode* QVTKQuickItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) -{ - QSGSimpleRectNode *n = static_cast(oldNode); - if (!n) { - n = new QSGSimpleRectNode(); - } - n->markDirty(QSGNode::DirtyForceUpdate); - return n; -} - - -void QVTKQuickItem::paint() -{ - if (!this->isVisible()) - { - return; - } - - if (!this->m_InitCalledOnce) - { - m_win->GetExtensionManager()->LoadExtension("GL_VERSION_1_4"); - m_win->GetExtensionManager()->LoadExtension("GL_VERSION_2_0"); - - init(); - - this->m_InitCalledOnce = true; - } - - this->m_viewLock.lock(); - - // Let subclasses do something each render - prepareForRender(); - - // Make sure viewport is up to date. - // This is needed because geometryChanged() is not called when parent geometry changes, so we miss when widths/heights - // of surrounding elements change. - m_win->SetSize(window()->width(), window()->height()); - QPointF origin = mapToScene(QPointF(0, 0)); - QPointF minPt(origin.x()/window()->width(), (window()->height() - origin.y() - height())/window()->height()); - QPointF maxPt(minPt.x() + width()/window()->width(), minPt.y() + height()/window()->height()); - if (m_win->GetRenderers()->GetFirstRenderer()) - { - m_win->GetRenderers()->GetFirstRenderer()->SetViewport(minPt.x(), minPt.y(), maxPt.x(), maxPt.y()); - } - - // Turn off any QML shader program - vtkgl::UseProgram(0); - - // Set blending correctly - glEnable(GL_BLEND); - vtkgl::BlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - m_win->Render(); - - // Disable alpha test for QML - glDisable(GL_ALPHA_TEST); - - cleanupAfterRender(); - - this->m_viewLock.unlock(); -} diff --git a/Modules/OpenViewCore/README b/Modules/OpenViewCore/README deleted file mode 100644 index ff10a2aeb4..0000000000 --- a/Modules/OpenViewCore/README +++ /dev/null @@ -1,15 +0,0 @@ -This code is a snapshot of the OpenView project at openview.kitware.org - -Code was - - originally taken from - https://github.com/Kitware/openview/tree/74fdaf2ac84b79d56a4ca6e370e55e7fe339a10b/core - - minor modifications were made to the QVTKQuickItem class in order to fix issues and integrate it easier with MITK - https://github.com/maleike/openview/tree/1296a52f4aa3227526bb467671aaacb54a6931fc/core - - a pull request has been filed to contribute code back - -In this MITK snapshot, only the "core" of Openview is built as an MITK module - - - the CMakeLists.txt has been replaced by a minimum MITK module definition - - some #include statements have been changed to - #include "OpenViewExports.h" - which is generated by the MITK module system diff --git a/Modules/OpenViewCore/files.cmake b/Modules/OpenViewCore/files.cmake deleted file mode 100644 index 7a9fc2ef1c..0000000000 --- a/Modules/OpenViewCore/files.cmake +++ /dev/null @@ -1,21 +0,0 @@ -file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") - -set(CPP_FILES - vtkQtConnection.cxx - QVTKMitkInteractorAdapter.cxx - QVTKQuickItem.cxx - QVTKFramebufferObjectRenderer.cxx - vtkInternalOpenGLRenderWindow.cxx -) - -set(MOC_H_FILES - include/QVTKMitkInteractorAdapter.h - include/QVTKQuickItem.h - include/vtkQtConnection.h -) - -set(UI_FILES -) - -set(QRC_FILES -) diff --git a/Modules/OpenViewCore/include/QVTKFramebufferObjectRenderer.h b/Modules/OpenViewCore/include/QVTKFramebufferObjectRenderer.h deleted file mode 100644 index 492d09cff3..0000000000 --- a/Modules/OpenViewCore/include/QVTKFramebufferObjectRenderer.h +++ /dev/null @@ -1,50 +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 __QVTKFramebufferObjectRenderer_h -#define __QVTKFramebufferObjectRenderer_h - -#include - -#include "QVTKQuickItem.h" - -#include - -class vtkInternalOpenGLRenderWindow; - -//! Part of Qml rendering prototype, see QmlMitkRenderWindowItem. -class MITKOPENVIEWCORE_EXPORT QVTKFramebufferObjectRenderer : public QQuickFramebufferObject::Renderer -{ -public: - vtkInternalOpenGLRenderWindow *m_vtkRenderWindow; - bool m_neverRendered; - bool m_readyToRender; - - QVTKQuickItem *m_vtkQuickItem; - -public: - QVTKFramebufferObjectRenderer(vtkInternalOpenGLRenderWindow *rw); - ~QVTKFramebufferObjectRenderer(); - - virtual void synchronize(QQuickFramebufferObject * item); - virtual void render(); - - QOpenGLFramebufferObject *createFramebufferObject(const QSize &size); - - friend class vtkInternalOpenGLRenderWindow; -}; - -#endif diff --git a/Modules/OpenViewCore/include/QVTKMitkInteractorAdapter.h b/Modules/OpenViewCore/include/QVTKMitkInteractorAdapter.h deleted file mode 100644 index b38231a1cd..0000000000 --- a/Modules/OpenViewCore/include/QVTKMitkInteractorAdapter.h +++ /dev/null @@ -1,87 +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. - -===================================================================*/ - -// original copyright below - -/*========================================================================= - - Program: Visualization Toolkit - Module: QVTKMitkInteractorAdapter.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -/*========================================================================= - - Copyright 2004 Sandia Corporation. - Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - license for use of this work by or on behalf of the - U.S. Government. Redistribution and use in source and binary forms, with - or without modification, are permitted provided that this Notice and any - statement of authorship are reproduced on all copies. - -=========================================================================*/ - -/*======================================================================== - For general information about using VTK and Qt, see: - http://www.trolltech.com/products/3rdparty/vtksupport.html -=========================================================================*/ - -// .NAME QVTKMitkInteractorAdapter - Handle Qt events. -// .SECTION Description -// QVTKInteractor handles relaying Qt events to VTK. - -#ifndef Q_VTK_MITK_INTERACTOR_ADAPTER_H -#define Q_VTK_MITK_INTERACTOR_ADAPTER_H - -#include - -#include - -class vtkRenderWindowInteractor; -class QEvent; - -// .NAME QVTKMitkInteractorAdapter - A QEvent translator. -// .SECTION Description -// QVTKMitkInteractorAdapter translates QEvents and send them to a -// vtkRenderWindowInteractor. -//! Part of Qml rendering prototype, see QmlMitkRenderWindowItem. -class MITKOPENVIEWCORE_EXPORT QVTKMitkInteractorAdapter : public QObject -{ - Q_OBJECT -public: - // Description: - // Constructor: takes QObject parent - QVTKMitkInteractorAdapter(QObject* parent); - - // Description: - // Destructor - ~QVTKMitkInteractorAdapter(); - - // Description: - // Process a QEvent and send it to the interactor - // returns whether the event was recognized and processed - bool ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren); -}; - -#endif diff --git a/Modules/OpenViewCore/include/QVTKQuickItem.h b/Modules/OpenViewCore/include/QVTKQuickItem.h deleted file mode 100644 index bf6c22bc00..0000000000 --- a/Modules/OpenViewCore/include/QVTKQuickItem.h +++ /dev/null @@ -1,122 +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. - -===================================================================*/ - -// original copyright below - -/*======================================================================== - OpenView -- http://openview.kitware.com - - Copyright 2012 Kitware, Inc. - - Licensed under the BSD license. See LICENSE file for details. - ========================================================================*/ - -#ifndef __QVTKQuickItem_h -#define __QVTKQuickItem_h - -#include - -#include - -#include "vtkSmartPointer.h" -#include "vtkNew.h" - -#include - -#include - -class QOpenGLContext; -class QOpenGLFramebufferObject; -class QVTKMitkInteractorAdapter; -class QVTKInteractor; -class QVTKFramebufferObjectRenderer; -class vtkEventQtSlotConnect; -class vtkOpenGLRenderWindow; -class vtkObject; -class vtkContextView; - -class MITKOPENVIEWCORE_EXPORT QVTKQuickItem : public QQuickFramebufferObject -{ - Q_OBJECT -public: - QVTKQuickItem(QQuickItem* parent = 0); - - // Description: - // destructor - ~QVTKQuickItem(); - - Renderer* createRenderer() const; - - // Description: - // get the render window used with this item - vtkOpenGLRenderWindow* GetRenderWindow() const; - - // Description: - // get the render window interactor used with this item - // this item enforces its own interactor - QVTKInteractor* GetInteractor() const; - - QMutex m_viewLock; - - protected slots: - // slot called when vtk wants to know if the context is current - virtual void IsCurrent(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data); - // slot called when vtk wants to know if a window is direct - virtual void IsDirect(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data); - // slot called when vtk wants to know if a window supports OpenGL - virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data); - void onTextureFollowsItemSizeChanged(bool follows); - -protected: - // Called ONCE from the render thread before the FBO is first created and while the GUI thread is blocked - virtual void init(); - // Called from the render thread BEFORE each update while the GUI thread blocked - virtual bool prepareForRender(); - // Called from the render thread AFTER each update while the GUI thread is NOT blocked - virtual void cleanupAfterRender(); - - // handle item key events - virtual void keyPressEvent(QKeyEvent* e); - virtual void keyReleaseEvent(QKeyEvent* e); - - // handle item mouse events - virtual void mousePressEvent(QMouseEvent* e); - virtual void mouseReleaseEvent(QMouseEvent* e); - virtual void mouseDoubleClickEvent(QMouseEvent* e); - virtual void mouseMoveEvent(QMouseEvent* e); - virtual void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry); - virtual void wheelEvent(QWheelEvent* e); - virtual void hoverEnterEvent(QHoverEvent* e); - virtual void hoverLeaveEvent(QHoverEvent* e); - virtual void hoverMoveEvent(QHoverEvent* e); - QSGNode* updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *nodeData); - - //! To be called from rendering thread while synchronized - //! with UI thread - should execute a list of queued UI events. - //! - //! Not yet implemented for QVTKQuickItem but possibly for sub-classes - virtual void processPendingEvents() {} - -private: - vtkOpenGLRenderWindow *m_win; - vtkSmartPointer m_interactor; - QVTKMitkInteractorAdapter* m_interactorAdapter; - vtkSmartPointer m_connect; - - friend class QVTKFramebufferObjectRenderer; -}; - -#endif diff --git a/Modules/OpenViewCore/include/vtkQtConnection.h b/Modules/OpenViewCore/include/vtkQtConnection.h deleted file mode 100644 index cb9be8aa87..0000000000 --- a/Modules/OpenViewCore/include/vtkQtConnection.h +++ /dev/null @@ -1,121 +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. - -===================================================================*/ - -// original copyright below - -/*========================================================================= - - Copyright 2004 Sandia Corporation. - Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - license for use of this work by or on behalf of the - U.S. Government. Redistribution and use in source and binary forms, with - or without modification, are permitted provided that this Notice and any - statement of authorship are reproduced on all copies. - -=========================================================================*/ - -/*======================================================================== - For general information about using VTK and Qt, see: - http://www.trolltech.com/products/3rdparty/vtksupport.html -=========================================================================*/ - -/*======================================================================== - !!! WARNING for those who want to contribute code to this file. - !!! If you use a commercial edition of Qt, you can modify this code. - !!! If you use an open source version of Qt, you are free to modify - !!! and use this code within the guidelines of the GPL license. - !!! Unfortunately, you cannot contribute the changes back into this - !!! file. Doing so creates a conflict between the GPL and BSD-like VTK - !!! license. -=========================================================================*/ - -// .SECTION Description -// vtkQtConnection is an internal class. - - -#ifndef VTK_QT_CONNECTION -#define VTK_QT_CONNECTION - -#include "vtkObject.h" -#include "vtkCommand.h" // for event defines -#include "qobject.h" - -#include - -class QObject; -class vtkCallbackCommand; -class vtkEventQtSlotConnect; - -// class for managing a single VTK/Qt connection -// not to be included in other projects -// only here for moc to process for vtkEventQtSlotConnect -class MITKOPENVIEWCORE_EXPORT vtkQtConnection : public QObject -{ - Q_OBJECT - - public: - - // constructor - vtkQtConnection(vtkEventQtSlotConnect* owner); - - // destructor, disconnect if necessary - ~vtkQtConnection(); - - // print function - void PrintSelf(ostream& os, vtkIndent indent); - - // callback from VTK to emit signal - void Execute(vtkObject* caller, unsigned long event, void* client_data); - - // set the connection - void SetConnection(vtkObject* vtk_obj, unsigned long event, - const QObject* qt_obj, const char* slot, - void* client_data, float priority=0.0 - ,Qt::ConnectionType type = Qt::AutoConnection); - - // check if a connection matches input parameters - bool IsConnection(vtkObject* vtk_obj, unsigned long event, - const QObject* qt_obj, const char* slot, - void* client_data); - - static void DoCallback(vtkObject* vtk_obj, unsigned long event, - void* client_data, void* call_data); - - signals: - // the qt signal for moc to take care of - void EmitExecute(vtkObject*, unsigned long, void* client_data, void* call_data, vtkCommand*); - - protected slots: - void deleteConnection(); - - protected: - - // the connection information - vtkObject* VTKObject; - vtkCallbackCommand* Callback; - const QObject* QtObject; - void* ClientData; - unsigned long VTKEvent; - QString QtSlot; - vtkEventQtSlotConnect* Owner; - - private: - vtkQtConnection(const vtkQtConnection&); - void operator=(const vtkQtConnection&); - -}; - -#endif diff --git a/Modules/OpenViewCore/src/QVTKFramebufferObjectRenderer.cxx b/Modules/OpenViewCore/src/QVTKFramebufferObjectRenderer.cxx deleted file mode 100644 index 664ae6dc0f..0000000000 --- a/Modules/OpenViewCore/src/QVTKFramebufferObjectRenderer.cxx +++ /dev/null @@ -1,94 +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 "vtkInternalOpenGLRenderWindow.h" -#include "QVTKFramebufferObjectRenderer.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -QVTKFramebufferObjectRenderer::QVTKFramebufferObjectRenderer(vtkInternalOpenGLRenderWindow *rw) : -m_vtkRenderWindow(rw), -m_neverRendered(true), -m_readyToRender(false) -{ - m_vtkRenderWindow->Register(NULL); - m_vtkRenderWindow->QtParentRenderer = this; -} - -QOpenGLFramebufferObject* QVTKFramebufferObjectRenderer::createFramebufferObject(const QSize &size) -{ - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::Depth); - format.setTextureTarget(GL_TEXTURE_2D); - format.setInternalTextureFormat(GL_RGBA32F_ARB); - QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(size, format); - m_vtkRenderWindow->SetFramebufferObject(fbo); - return fbo; -} - -void QVTKFramebufferObjectRenderer::render() -{ - if (!m_readyToRender) - { - return; - } - - // Ask VTK to render to OpenGL - m_vtkQuickItem->m_viewLock.lock(); - m_vtkRenderWindow->PushState(); - m_vtkRenderWindow->OpenGLInitState(); - m_vtkRenderWindow->InternalRender(); - m_vtkRenderWindow->OpenGLEndState(); - m_vtkRenderWindow->PopState(); - m_vtkQuickItem->m_viewLock.unlock(); -} - -void QVTKFramebufferObjectRenderer::synchronize(QQuickFramebufferObject * item) -{ - m_vtkQuickItem = static_cast(item); - - if (m_neverRendered) - { - m_neverRendered = false; - m_vtkQuickItem->init(); - } - - // Execute events (that might call VTK picking to obtain z coordinates) - // while UI and rendering are synchronized. - m_vtkQuickItem->processPendingEvents(); - - // Update MITK mapper list, then mapper outputs - m_readyToRender = m_vtkQuickItem->prepareForRender(); -} - -QVTKFramebufferObjectRenderer::~QVTKFramebufferObjectRenderer() -{ - m_vtkRenderWindow->QtParentRenderer = 0; - m_vtkRenderWindow->Delete(); -} diff --git a/Modules/OpenViewCore/src/QVTKMitkInteractorAdapter.cxx b/Modules/OpenViewCore/src/QVTKMitkInteractorAdapter.cxx deleted file mode 100644 index fbe63ade53..0000000000 --- a/Modules/OpenViewCore/src/QVTKMitkInteractorAdapter.cxx +++ /dev/null @@ -1,473 +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. - -===================================================================*/ - -// original copyright below - -/*========================================================================= - - Program: Visualization Toolkit - Module: QVTKMitkInteractorAdapter.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/* - * Copyright 2004 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the - * U.S. Government. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that this Notice and any - * statement of authorship are reproduced on all copies. - */ - -/*======================================================================== - For general information about using VTK and Qt, see: - http://www.trolltech.com/products/3rdparty/vtksupport.html -=========================================================================*/ - -#ifdef _MSC_VER -// Disable warnings that Qt headers give. -#pragma warning(disable:4127) -#pragma warning(disable:4512) -#endif - -#include "QVTKMitkInteractorAdapter.h" -#include "QVTKInteractor.h" - -#include -#include -#include -#include - -#include "vtkCommand.h" - - -// function to get VTK keysyms from ascii characters -static const char* ascii_to_key_sym(int); -// function to get VTK keysyms from Qt keys -static const char* qt_key_to_key_sym(Qt::Key, Qt::KeyboardModifiers modifiers); - -QVTKMitkInteractorAdapter::QVTKMitkInteractorAdapter(QObject* parentObject) - : QObject(parentObject) -{ -} - -QVTKMitkInteractorAdapter::~QVTKMitkInteractorAdapter() -{ -} - -bool QVTKMitkInteractorAdapter::ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren) -{ - if(iren == NULL || e == NULL) - return false; - - const QEvent::Type t = e->type(); - - if(t == QEvent::Resize) - { - QResizeEvent* e2 = static_cast(e); - QSize size = e2->size(); - iren->SetSize(size.width(), size.height()); - return true; - } - - if(t == QEvent::FocusIn) - { - // For 3DConnexion devices: - QVTKInteractor* qiren = QVTKInteractor::SafeDownCast(iren); - if(qiren) - { - qiren->StartListening(); - } - return true; - } - - if(t == QEvent::FocusOut) - { - // For 3DConnexion devices: - QVTKInteractor* qiren = QVTKInteractor::SafeDownCast(iren); - if(qiren) - { - qiren->StopListening(); - } - return true; - } - - // the following events only happen if the interactor is enabled - if(!iren->GetEnabled()) - return false; - - if(t == QEvent::MouseButtonPress || - t == QEvent::MouseButtonRelease || - t == QEvent::MouseButtonDblClick || - t == QEvent::MouseMove) - { - QMouseEvent* e2 = static_cast(e); - - // give interactor the event information - iren->SetEventInformationFlipY(e2->x(), e2->y(), - (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0, - (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0, - 0, - e2->type() == QEvent::MouseButtonDblClick ? 1 : 0); - - if(t == QEvent::MouseMove) - { - iren->InvokeEvent(vtkCommand::MouseMoveEvent, e2); - } - else if(t == QEvent::MouseButtonPress || t == QEvent::MouseButtonDblClick) - { - switch(e2->button()) - { - case Qt::LeftButton: - iren->InvokeEvent(vtkCommand::LeftButtonPressEvent, e2); - break; - - case Qt::MidButton: - iren->InvokeEvent(vtkCommand::MiddleButtonPressEvent, e2); - break; - - case Qt::RightButton: - iren->InvokeEvent(vtkCommand::RightButtonPressEvent, e2); - break; - - default: - break; - } - } - else if(t == QEvent::MouseButtonRelease) - { - switch(e2->button()) - { - case Qt::LeftButton: - iren->InvokeEvent(vtkCommand::LeftButtonReleaseEvent, e2); - break; - - case Qt::MidButton: - iren->InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, e2); - break; - - case Qt::RightButton: - iren->InvokeEvent(vtkCommand::RightButtonReleaseEvent, e2); - break; - - default: - break; - } - } - return true; - } - - if(t == QEvent::Enter) - { - iren->InvokeEvent(vtkCommand::EnterEvent, e); - return true; - } - - if(t == QEvent::Leave) - { - iren->InvokeEvent(vtkCommand::LeaveEvent, e); - return true; - } - - if(t == QEvent::KeyPress || t == QEvent::KeyRelease) - { - QKeyEvent* e2 = static_cast(e); - - // get key and keysym information - int ascii_key = e2->text().length() ? e2->text().unicode()->toLatin1() : 0; - const char* keysym = ascii_to_key_sym(ascii_key); - if(!keysym || - e2->modifiers() == Qt::KeypadModifier) - { - // get virtual keys - keysym = qt_key_to_key_sym(static_cast(e2->key()), - e2->modifiers()); - } - - if(!keysym) - { - keysym = "None"; - } - - // give interactor event information - iren->SetKeyEventInformation( - (e2->modifiers() & Qt::ControlModifier), - (e2->modifiers() & Qt::ShiftModifier), - ascii_key, e2->count(), keysym); - - if(t == QEvent::KeyPress) - { - // invoke vtk event - iren->InvokeEvent(vtkCommand::KeyPressEvent, e2); - - // invoke char event only for ascii characters - if(ascii_key) - { - iren->InvokeEvent(vtkCommand::CharEvent, e2); - } - } - else - { - iren->InvokeEvent(vtkCommand::KeyReleaseEvent, e2); - } - return true; - } - - if(t == QEvent::Wheel) - { - QWheelEvent* e2 = static_cast(e); - - iren->SetEventInformationFlipY(e2->x(), e2->y(), - (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0, - (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0); - - // invoke vtk event - // if delta is positive, it is a forward wheel event - if(e2->delta() > 0) - { - iren->InvokeEvent(vtkCommand::MouseWheelForwardEvent, e2); - } - else - { - iren->InvokeEvent(vtkCommand::MouseWheelBackwardEvent, e2); - } - return true; - } - - if(t == QEvent::ContextMenu) - { - QContextMenuEvent* e2 = static_cast(e); - - // give interactor the event information - iren->SetEventInformationFlipY(e2->x(), e2->y(), - (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0, - (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0); - - // invoke event and pass qt event for additional data as well - iren->InvokeEvent(QVTKInteractor::ContextMenuEvent, e2); - - return true; - } - - if(t == QEvent::DragEnter) - { - QDragEnterEvent* e2 = static_cast(e); - - // invoke event and pass qt event for additional data as well - iren->InvokeEvent(QVTKInteractor::DragEnterEvent, e2); - - return true; - } - - if(t == QEvent::DragLeave) - { - QDragLeaveEvent* e2 = static_cast(e); - - // invoke event and pass qt event for additional data as well - iren->InvokeEvent(QVTKInteractor::DragLeaveEvent, e2); - - return true; - } - - if(t == QEvent::DragMove) - { - QDragMoveEvent* e2 = static_cast(e); - - // give interactor the event information - iren->SetEventInformationFlipY(e2->pos().x(), e2->pos().y()); - - // invoke event and pass qt event for additional data as well - iren->InvokeEvent(QVTKInteractor::DragMoveEvent, e2); - return true; - } - - if(t == QEvent::Drop) - { - QDropEvent* e2 = static_cast(e); - - // give interactor the event information - iren->SetEventInformationFlipY(e2->pos().x(), e2->pos().y()); - - // invoke event and pass qt event for additional data as well - iren->InvokeEvent(QVTKInteractor::DropEvent, e2); - return true; - } - - return false; -} - -// ***** keysym stuff below ***** - -static const char *AsciiToKeySymTable[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, "Tab", 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - "space", "exclam", "quotedbl", "numbersign", - "dollar", "percent", "ampersand", "quoteright", - "parenleft", "parenright", "asterisk", "plus", - "comma", "minus", "period", "slash", - "0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "colon", "semicolon", "less", "equal", "greater", "question", - "at", "A", "B", "C", "D", "E", "F", "G", - "H", "I", "J", "K", "L", "M", "N", "O", - "P", "Q", "R", "S", "T", "U", "V", "W", - "X", "Y", "Z", "bracketleft", - "backslash", "bracketright", "asciicircum", "underscore", - "quoteleft", "a", "b", "c", "d", "e", "f", "g", - "h", "i", "j", "k", "l", "m", "n", "o", - "p", "q", "r", "s", "t", "u", "v", "w", - "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Delete", - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -const char* ascii_to_key_sym(int i) -{ - if(i >= 0) - { - return AsciiToKeySymTable[i]; - } - return 0; -} - -#define QVTK_HANDLE(x,y) \ - case x : \ - ret = y; \ - break; - -#define QVTK_HANDLE_KEYPAD(x, y, z) \ - case x : \ - ret = (modifiers & Qt::KeypadModifier) ? (y) : (z); \ - break; - -const char* qt_key_to_key_sym(Qt::Key i, Qt::KeyboardModifiers modifiers) -{ - const char* ret = 0; - switch(i) - { - // Cancel - QVTK_HANDLE(Qt::Key_Backspace, "BackSpace") - QVTK_HANDLE(Qt::Key_Tab, "Tab") - QVTK_HANDLE(Qt::Key_Backtab, "Tab") - QVTK_HANDLE(Qt::Key_Clear, "Clear") - QVTK_HANDLE(Qt::Key_Return, "Return") - QVTK_HANDLE(Qt::Key_Enter, "Return") - QVTK_HANDLE(Qt::Key_Shift, "Shift_L") - QVTK_HANDLE(Qt::Key_Control, "Control_L") - QVTK_HANDLE(Qt::Key_Alt, "Alt_L") - QVTK_HANDLE(Qt::Key_Pause, "Pause") - QVTK_HANDLE(Qt::Key_CapsLock, "Caps_Lock") - QVTK_HANDLE(Qt::Key_Escape, "Escape") - QVTK_HANDLE(Qt::Key_Space, "space") - QVTK_HANDLE(Qt::Key_PageUp, "Prior") - QVTK_HANDLE(Qt::Key_PageDown, "Next") - QVTK_HANDLE(Qt::Key_End, "End") - QVTK_HANDLE(Qt::Key_Home, "Home") - QVTK_HANDLE(Qt::Key_Left, "Left") - QVTK_HANDLE(Qt::Key_Up, "Up") - QVTK_HANDLE(Qt::Key_Right, "Right") - QVTK_HANDLE(Qt::Key_Down, "Down") - QVTK_HANDLE(Qt::Key_Select, "Select") - QVTK_HANDLE(Qt::Key_Execute, "Execute") - QVTK_HANDLE(Qt::Key_SysReq, "Snapshot") - QVTK_HANDLE(Qt::Key_Insert, "Insert") - QVTK_HANDLE(Qt::Key_Delete, "Delete") - QVTK_HANDLE(Qt::Key_Help, "Help") - QVTK_HANDLE_KEYPAD(Qt::Key_0, "KP_0", "0") - QVTK_HANDLE_KEYPAD(Qt::Key_1, "KP_1", "1") - QVTK_HANDLE_KEYPAD(Qt::Key_2, "KP_2", "2") - QVTK_HANDLE_KEYPAD(Qt::Key_3, "KP_3", "3") - QVTK_HANDLE_KEYPAD(Qt::Key_4, "KP_4", "4") - QVTK_HANDLE_KEYPAD(Qt::Key_5, "KP_5", "5") - QVTK_HANDLE_KEYPAD(Qt::Key_6, "KP_6", "6") - QVTK_HANDLE_KEYPAD(Qt::Key_7, "KP_7", "7") - QVTK_HANDLE_KEYPAD(Qt::Key_8, "KP_8", "8") - QVTK_HANDLE_KEYPAD(Qt::Key_9, "KP_9", "9") - QVTK_HANDLE(Qt::Key_A, "a") - QVTK_HANDLE(Qt::Key_B, "b") - QVTK_HANDLE(Qt::Key_C, "c") - QVTK_HANDLE(Qt::Key_D, "d") - QVTK_HANDLE(Qt::Key_E, "e") - QVTK_HANDLE(Qt::Key_F, "f") - QVTK_HANDLE(Qt::Key_G, "g") - QVTK_HANDLE(Qt::Key_H, "h") - QVTK_HANDLE(Qt::Key_I, "i") - QVTK_HANDLE(Qt::Key_J, "h") - QVTK_HANDLE(Qt::Key_K, "k") - QVTK_HANDLE(Qt::Key_L, "l") - QVTK_HANDLE(Qt::Key_M, "m") - QVTK_HANDLE(Qt::Key_N, "n") - QVTK_HANDLE(Qt::Key_O, "o") - QVTK_HANDLE(Qt::Key_P, "p") - QVTK_HANDLE(Qt::Key_Q, "q") - QVTK_HANDLE(Qt::Key_R, "r") - QVTK_HANDLE(Qt::Key_S, "s") - QVTK_HANDLE(Qt::Key_T, "t") - QVTK_HANDLE(Qt::Key_U, "u") - QVTK_HANDLE(Qt::Key_V, "v") - QVTK_HANDLE(Qt::Key_W, "w") - QVTK_HANDLE(Qt::Key_X, "x") - QVTK_HANDLE(Qt::Key_Y, "y") - QVTK_HANDLE(Qt::Key_Z, "z") - QVTK_HANDLE(Qt::Key_Asterisk, "asterisk") - QVTK_HANDLE(Qt::Key_Plus, "plus") - QVTK_HANDLE(Qt::Key_Bar, "bar") - QVTK_HANDLE(Qt::Key_Minus, "minus") - QVTK_HANDLE(Qt::Key_Period, "period") - QVTK_HANDLE(Qt::Key_Slash, "slash") - QVTK_HANDLE(Qt::Key_F1, "F1") - QVTK_HANDLE(Qt::Key_F2, "F2") - QVTK_HANDLE(Qt::Key_F3, "F3") - QVTK_HANDLE(Qt::Key_F4, "F4") - QVTK_HANDLE(Qt::Key_F5, "F5") - QVTK_HANDLE(Qt::Key_F6, "F6") - QVTK_HANDLE(Qt::Key_F7, "F7") - QVTK_HANDLE(Qt::Key_F8, "F8") - QVTK_HANDLE(Qt::Key_F9, "F9") - QVTK_HANDLE(Qt::Key_F10, "F10") - QVTK_HANDLE(Qt::Key_F11, "F11") - QVTK_HANDLE(Qt::Key_F12, "F12") - QVTK_HANDLE(Qt::Key_F13, "F13") - QVTK_HANDLE(Qt::Key_F14, "F14") - QVTK_HANDLE(Qt::Key_F15, "F15") - QVTK_HANDLE(Qt::Key_F16, "F16") - QVTK_HANDLE(Qt::Key_F17, "F17") - QVTK_HANDLE(Qt::Key_F18, "F18") - QVTK_HANDLE(Qt::Key_F19, "F19") - QVTK_HANDLE(Qt::Key_F20, "F20") - QVTK_HANDLE(Qt::Key_F21, "F21") - QVTK_HANDLE(Qt::Key_F22, "F22") - QVTK_HANDLE(Qt::Key_F23, "F23") - QVTK_HANDLE(Qt::Key_F24, "F24") - QVTK_HANDLE(Qt::Key_NumLock, "Num_Lock") - QVTK_HANDLE(Qt::Key_ScrollLock, "Scroll_Lock") - - default: - break; - } - return ret; -} diff --git a/Modules/OpenViewCore/src/QVTKQuickItem.cxx b/Modules/OpenViewCore/src/QVTKQuickItem.cxx deleted file mode 100644 index c78edae1ec..0000000000 --- a/Modules/OpenViewCore/src/QVTKQuickItem.cxx +++ /dev/null @@ -1,255 +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. - -===================================================================*/ - -// original copyright below - -/*======================================================================== - OpenView -- http://openview.kitware.com - - Copyright 2012 Kitware, Inc. - - Licensed under the BSD license. See LICENSE file for details. - ========================================================================*/ - -#include "QVTKQuickItem.h" - -#include -#include -#include -#include -#include - -#include "QVTKInteractor.h" -#include "QVTKMitkInteractorAdapter.h" -#include "vtkGenericOpenGLRenderWindow.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkRenderer.h" -#include "vtkRendererCollection.h" - -#include "vtkCubeSource.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" - -#include - -#include "vtkInternalOpenGLRenderWindow.h" -#include "QVTKFramebufferObjectRenderer.h" - -QVTKQuickItem::QVTKQuickItem(QQuickItem* parent) -: QQuickFramebufferObject(parent) -{ - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); - - m_interactor = vtkSmartPointer::New(); - m_interactorAdapter = new QVTKMitkInteractorAdapter(this); - m_connect = vtkSmartPointer::New(); - - m_win = vtkInternalOpenGLRenderWindow::New(); - m_interactor->SetRenderWindow(m_win); - - m_connect->Connect(m_win, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); - m_connect->Connect(m_win, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); - m_connect->Connect(m_win, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); - - connect(this, SIGNAL(textureFollowsItemSizeChanged(bool)), - this, SLOT(onTextureFollowsItemSizeChanged(bool))); -} - -QVTKQuickItem::~QVTKQuickItem() -{ - if(m_win) - { - m_connect->Disconnect(m_win, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*))); - m_connect->Disconnect(m_win, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*))); - m_connect->Disconnect(m_win, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*))); - m_win->Delete(); - } -} - -QSGNode* QVTKQuickItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *nodeData) -{ - node = QQuickFramebufferObject::updatePaintNode(node, nodeData); - if ( node != nullptr ) { - QSGSimpleTextureNode* texNode = static_cast(node); - texNode->setTextureCoordinatesTransform(QSGSimpleTextureNode::MirrorVertically); - } - return node; -} - -QQuickFramebufferObject::Renderer* QVTKQuickItem::createRenderer() const -{ - return new QVTKFramebufferObjectRenderer(static_cast(m_win)); -} - -vtkOpenGLRenderWindow* QVTKQuickItem::GetRenderWindow() const -{ - return m_win; -} - -QVTKInteractor* QVTKQuickItem::GetInteractor() const -{ - return m_interactor; -} - -void QVTKQuickItem::IsCurrent(vtkObject*, unsigned long, void*, void* call_data) -{ - bool* ptr = reinterpret_cast(call_data); - *ptr = QOpenGLContext::currentContext() == this->window()->openglContext(); -} - -void QVTKQuickItem::IsDirect(vtkObject*, unsigned long, void*, void* call_data) -{ - int* ptr = reinterpret_cast(call_data); - *ptr = 1; -} - -void QVTKQuickItem::SupportsOpenGL(vtkObject*, unsigned long, void*, void* call_data) -{ - int* ptr = reinterpret_cast(call_data); - *ptr = 1; -} - -void QVTKQuickItem::onTextureFollowsItemSizeChanged(bool follows) -{ - if (!follows) - { - qWarning("QVTKQuickItem: Mouse interaction is not (yet) supported when textureFollowsItemSize==false"); - } -} - -void QVTKQuickItem::geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry) -{ - QQuickFramebufferObject::geometryChanged(newGeometry, oldGeometry); - QSize oldSize(oldGeometry.width(), oldGeometry.height()); - QSize newSize(newGeometry.width(), newGeometry.height()); - QResizeEvent e(newSize, oldSize); - if (m_interactorAdapter) - { - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e, m_interactor); - this->m_viewLock.unlock(); - } -} - -void QVTKQuickItem::keyPressEvent(QKeyEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::keyReleaseEvent(QKeyEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mousePressEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mouseReleaseEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mouseDoubleClickEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::mouseMoveEvent(QMouseEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::wheelEvent(QWheelEvent* e) -{ - e->accept(); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(e, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::hoverEnterEvent(QHoverEvent* e) -{ - e->accept(); - QEvent e2(QEvent::Enter); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e2, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::hoverLeaveEvent(QHoverEvent* e) -{ - e->accept(); - QEvent e2(QEvent::Leave); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e2, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::hoverMoveEvent(QHoverEvent* e) -{ - e->accept(); - QMouseEvent e2(QEvent::MouseMove, e->pos(), Qt::NoButton, Qt::NoButton, e->modifiers()); - this->m_viewLock.lock(); - m_interactorAdapter->ProcessEvent(&e2, m_interactor); - this->m_viewLock.unlock(); - update(); -} - -void QVTKQuickItem::init() -{ - m_win->OpenGLInitContext(); -// m_win->GetExtensionManager()->LoadExtension("GL_VERSION_1_4"); -// m_win->GetExtensionManager()->LoadExtension("GL_VERSION_2_0"); -} - -bool QVTKQuickItem::prepareForRender() -{ - return true; -} - -void QVTKQuickItem::cleanupAfterRender() -{ -} diff --git a/Modules/OpenViewCore/src/vtkInternalOpenGLRenderWindow.cxx b/Modules/OpenViewCore/src/vtkInternalOpenGLRenderWindow.cxx deleted file mode 100644 index 33d406ae31..0000000000 --- a/Modules/OpenViewCore/src/vtkInternalOpenGLRenderWindow.cxx +++ /dev/null @@ -1,81 +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 -#include "vtk_glew.h" -#include "vtkInternalOpenGLRenderWindow.h" -#include "QVTKFramebufferObjectRenderer.h" - -#include - -vtkStandardNewMacro(vtkInternalOpenGLRenderWindow); - -vtkInternalOpenGLRenderWindow::~vtkInternalOpenGLRenderWindow() -{ - this->OffScreenRendering = false; -} - -vtkInternalOpenGLRenderWindow::vtkInternalOpenGLRenderWindow() : -QtParentRenderer(0) -{ -} - -void vtkInternalOpenGLRenderWindow::InternalRender() -{ - Superclass::Render(); -} - -void vtkInternalOpenGLRenderWindow::OpenGLEndState() -{ - glDepthMask(GL_TRUE); -} - -void vtkInternalOpenGLRenderWindow::OpenGLInitState() -{ - Superclass::OpenGLInitState(); -// vtkgl::UseProgram(0); TODO18922 - glEnable(GL_BLEND); - glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, GL_FASTEST); - glDepthMask(GL_TRUE); -} - -void vtkInternalOpenGLRenderWindow::Render() -{ - if (this->QtParentRenderer) - { - this->QtParentRenderer->update(); - } -} - -void vtkInternalOpenGLRenderWindow::SetFramebufferObject(QOpenGLFramebufferObject *fbo) -{ - this->SetFrontBuffer(GL_COLOR_ATTACHMENT0); - this->SetFrontLeftBuffer(GL_COLOR_ATTACHMENT0); - this->SetBackBuffer(GL_COLOR_ATTACHMENT0); - this->SetBackLeftBuffer(GL_COLOR_ATTACHMENT0); - - QSize fboSize = fbo->size(); - this->SetSize(fboSize.width(), fboSize.height()); - - this->NumberOfFrameBuffers = 1; - this->FrameBufferObject = static_cast(fbo->handle()); - this->DepthRenderBufferObject = 0; // static_cast(depthRenderBufferObject); - this->TextureObjects[0] = static_cast(fbo->texture()); - this->OffScreenRendering = true; - this->OffScreenUseFrameBuffer = true; - - this->Modified(); -} diff --git a/Modules/OpenViewCore/src/vtkInternalOpenGLRenderWindow.h b/Modules/OpenViewCore/src/vtkInternalOpenGLRenderWindow.h deleted file mode 100644 index bdf7b716dd..0000000000 --- a/Modules/OpenViewCore/src/vtkInternalOpenGLRenderWindow.h +++ /dev/null @@ -1,45 +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 __vtkInternalOpenGLRenderWindow_h -#define __vtkInternalOpenGLRenderWindow_h - -#include - -class QVTKFramebufferObjectRenderer; -class QOpenGLFrameBufferObject; - -//! Part of Qml rendering prototype, see QmlMitkRenderWindowItem. -class vtkInternalOpenGLRenderWindow : public vtkGenericOpenGLRenderWindow -{ -public: - static vtkInternalOpenGLRenderWindow* New(); - vtkTypeMacro(vtkInternalOpenGLRenderWindow, vtkGenericOpenGLRenderWindow) - - virtual void OpenGLInitState(); - virtual void Render(); - void OpenGLEndState(); - void InternalRender(); - void SetFramebufferObject(QOpenGLFramebufferObject *fbo); - - QVTKFramebufferObjectRenderer *QtParentRenderer; - -protected: - vtkInternalOpenGLRenderWindow(); - ~vtkInternalOpenGLRenderWindow(); -}; - -#endif diff --git a/Modules/OpenViewCore/src/vtkQtConnection.cxx b/Modules/OpenViewCore/src/vtkQtConnection.cxx deleted file mode 100644 index 64c2cfeaaf..0000000000 --- a/Modules/OpenViewCore/src/vtkQtConnection.cxx +++ /dev/null @@ -1,168 +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. - -===================================================================*/ - -// original copyright below - -/*========================================================================= - - Copyright 2004 Sandia Corporation. - Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - license for use of this work by or on behalf of the - U.S. Government. Redistribution and use in source and binary forms, with - or without modification, are permitted provided that this Notice and any - statement of authorship are reproduced on all copies. - -=========================================================================*/ - -/*======================================================================== - For general information about using VTK and Qt, see: - http://www.trolltech.com/products/3rdparty/vtksupport.html -=========================================================================*/ - -/*======================================================================== - !!! WARNING for those who want to contribute code to this file. - !!! If you use a commercial edition of Qt, you can modify this code. - !!! If you use an open source version of Qt, you are free to modify - !!! and use this code within the guidelines of the GPL license. - !!! Unfortunately, you cannot contribute the changes back into this - !!! file. Doing so creates a conflict between the GPL and BSD-like VTK - !!! license. -=========================================================================*/ - -#include "vtkQtConnection.h" -#include "vtkEventQtSlotConnect.h" -#include "vtkCallbackCommand.h" - -#include -#include - -// constructor -vtkQtConnection::vtkQtConnection(vtkEventQtSlotConnect* owner) - : Owner(owner) -{ - this->Callback = vtkCallbackCommand::New(); - this->Callback->SetCallback(vtkQtConnection::DoCallback); - this->Callback->SetClientData(this); - this->VTKObject = 0; - this->QtObject = 0; - this->ClientData = 0; - this->VTKEvent = vtkCommand::NoEvent; -} - -// destructor, disconnect if necessary -vtkQtConnection::~vtkQtConnection() -{ - if(this->VTKObject) - { - this->VTKObject->RemoveObserver(this->Callback); - //Qt takes care of disconnecting slots - } - this->Callback->Delete(); -} - -void vtkQtConnection::DoCallback(vtkObject* vtk_obj, unsigned long event, - void* client_data, void* call_data) -{ - vtkQtConnection* conn = static_cast(client_data); - conn->Execute(vtk_obj, event, call_data); -} - - -// callback from VTK to emit signal -void vtkQtConnection::Execute(vtkObject* caller, unsigned long e, void* call_data) -{ - if(e != vtkCommand::DeleteEvent || - (e == vtkCommand::DeleteEvent && this->VTKEvent == vtkCommand::DeleteEvent)) - { - emit EmitExecute(caller, e, ClientData, call_data, this->Callback); - } - - if(e == vtkCommand::DeleteEvent) - { - this->Owner->Disconnect(this->VTKObject, this->VTKEvent, this->QtObject, - this->QtSlot.toUtf8().data(), - this->ClientData); - } -} - -bool vtkQtConnection::IsConnection(vtkObject* vtk_obj, unsigned long e, - const QObject* qt_obj, const char* slot, void* client_data) -{ - if(this->VTKObject != vtk_obj) - return false; - - if(e != vtkCommand::NoEvent && e != this->VTKEvent) - return false; - - if(qt_obj && qt_obj != this->QtObject) - return false; - - if(slot && this->QtSlot != slot) - return false; - - if(client_data && this->ClientData != client_data) - return false; - - return true; -} - -// set the connection -void vtkQtConnection::SetConnection( - vtkObject* vtk_obj, unsigned long e, - const QObject* qt_obj, const char* slot, - void* client_data, float priority - , Qt::ConnectionType type) -{ - // keep track of what we connected - this->VTKObject = vtk_obj; - this->QtObject = qt_obj; - this->VTKEvent = e; - this->ClientData = client_data; - this->QtSlot = slot; - - // make a connection between this and the vtk object - vtk_obj->AddObserver(e, this->Callback, priority); - - if(e != vtkCommand::DeleteEvent) - { - vtk_obj->AddObserver(vtkCommand::DeleteEvent, this->Callback); - } - - // make a connection between this and the Qt object - qt_obj->connect( - this, SIGNAL(EmitExecute(vtkObject*,unsigned long,void*,void*,vtkCommand*)), - slot - ,type); - QObject::connect(qt_obj, SIGNAL(destroyed(QObject*)), this, - SLOT(deleteConnection())); -} - -void vtkQtConnection::deleteConnection() -{ - this->Owner->RemoveConnection(this); -} - -void vtkQtConnection::PrintSelf(ostream& os, vtkIndent indent) -{ - if(this->VTKObject && this->QtObject) - { - os << indent << - this->VTKObject->GetClassName() << ":" << - vtkCommand::GetStringFromEventId(this->VTKEvent) << " <----> " << - this->QtObject->metaObject()->className() << "::" << - this->QtSlot.toUtf8().data() << "\n"; - } -} diff --git a/Modules/QmlItems/CMakeLists.txt b/Modules/QmlItems/CMakeLists.txt deleted file mode 100644 index 867060aeb4..0000000000 --- a/Modules/QmlItems/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -MITK_CREATE_MODULE( - INCLUDE_DIRS InteractionLegacy - DEPENDS MitkCore MitkImageStatistics MitkQtWidgets MitkQtWidgetsExt MitkOpenViewCore MitkPlanarFigure - PACKAGE_DEPENDS PUBLIC Qt5|Quick -) diff --git a/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.cpp b/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.cpp deleted file mode 100644 index 5eceb06a78..0000000000 --- a/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.cpp +++ /dev/null @@ -1,124 +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 "QmitkEventAdapter.h" -#include -#include - -#include -#include - -mitk::MouseEvent -QmitkEventAdapter::AdaptMouseEvent(mitk::BaseRenderer* sender, QMouseEvent* mouseEvent) -{ - mitk::Point2D p; - p[0] = mouseEvent->x(); - p[1] = mouseEvent->y(); - - int modifiers = mouseEvent->modifiers(); - int state = 0; - - switch (mouseEvent->type()) - { - case QEvent::MouseButtonRelease: - state |= mouseEvent->button(); - break; - case QEvent::MouseMove: - state |= mouseEvent->buttons(); - break; - default: - break; - } - - if (modifiers & Qt::ShiftModifier) - state |= mitk::BS_ShiftButton; - if (modifiers & Qt::ControlModifier) - state |= mitk::BS_ControlButton; - if (modifiers & Qt::AltModifier) - state |= mitk::BS_AltButton; - if (modifiers & Qt::MetaModifier) - state |= mitk::BS_MetaButton; - if (modifiers & Qt::KeypadModifier) - state |= mitk::BS_Keypad; - - mitk::MouseEvent mitkEvent(sender, mouseEvent->type(), mouseEvent->button(), - state, mitk::Key_none, p); - - return mitkEvent; -} - -mitk::WheelEvent -QmitkEventAdapter::AdaptWheelEvent(mitk::BaseRenderer* sender, QWheelEvent* wheelEvent) -{ - mitk::Point2D p; - p[0] = wheelEvent->x(); - p[1] = wheelEvent->y(); - - int modifiers = wheelEvent->modifiers(); - int state = 0; - - state = wheelEvent->buttons(); - - if (modifiers & Qt::ShiftModifier) - state |= mitk::BS_ShiftButton; - if (modifiers & Qt::ControlModifier) - state |= mitk::BS_ControlButton; - if (modifiers & Qt::AltModifier) - state |= mitk::BS_AltButton; - if (modifiers & Qt::MetaModifier) - state |= mitk::BS_MetaButton; - if (modifiers & Qt::KeypadModifier) - state |= mitk::BS_Keypad; - - mitk::WheelEvent mitkEvent(sender, wheelEvent->type(), wheelEvent->buttons(), - state, mitk::Key_none, p, wheelEvent->delta()); - - return mitkEvent; -} - - -mitk::KeyEvent -QmitkEventAdapter::AdaptKeyEvent(mitk::BaseRenderer* sender, QKeyEvent* keyEvent, const QPoint& cp) -{ - int key = keyEvent->key(); - - // Those keycodes changed in Qt 4 - if (key >= 0x01000000 && key <= 0x01000060) - key -= (0x01000000 - 0x1000); - else if(key >= 0x01001120 && key <= 0x01001262) - key -= 0x01000000; - - mitk::Point2D p; - p[0] = cp.x(); - p[1] = cp.y(); - - int modifiers = keyEvent->modifiers(); - int state = 0; - if (modifiers & Qt::ShiftModifier) - state |= mitk::BS_ShiftButton; - if (modifiers & Qt::ControlModifier) - state |= mitk::BS_ControlButton; - if (modifiers & Qt::AltModifier) - state |= mitk::BS_AltButton; - if (modifiers & Qt::MetaModifier) - state |= mitk::BS_MetaButton; - //if (modifiers & Qt::KeypadModifier) - // state |= mitk::BS_Keypad; - - mitk::KeyEvent mke(sender, keyEvent->type(), mitk::BS_NoButton, state, key, keyEvent->text().toStdString(), p); - - return mke; -} diff --git a/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.h b/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.h deleted file mode 100644 index 94badecc1e..0000000000 --- a/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.h +++ /dev/null @@ -1,43 +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 QMITKEVENTADAPTER_H_ -#define QMITKEVENTADAPTER_H_ - -#include -#include -#include -#include -#include -#include - -/** - * \ingroup QmitkModule - * \deprecatedSince{2013_03} mitk::QmitkEventAdapter is deprecated. It will become - * obsolete. Adaption of events is now handeled (for Qt events) in QmitkRenderWindow. - * Refer to \see DataInteractionPage for general information about the concept of - * the new implementation - */ -class QmitkEventAdapter -{ -public: - - static mitk::MouseEvent AdaptMouseEvent(mitk::BaseRenderer* sender, QMouseEvent* mouseEvent); - static mitk::WheelEvent AdaptWheelEvent(mitk::BaseRenderer* sender, QWheelEvent* wheelEvent); - static mitk::KeyEvent AdaptKeyEvent(mitk::BaseRenderer* sender, QKeyEvent* keyEvent, const QPoint& point); -}; - -#endif /*QMITKEVENTADAPTER_H_*/ diff --git a/Modules/QmlItems/README b/Modules/QmlItems/README deleted file mode 100644 index 8de729e147..0000000000 --- a/Modules/QmlItems/README +++ /dev/null @@ -1,4 +0,0 @@ -This module is meant to provide the functionality of QmitkRenderWindow in QML at some time. - -In the current state, this module is just a proof-of-concept and should not be used outside -experimental code. It is subject to substantial change, so do not rely on the current state. diff --git a/Modules/QmlItems/files.cmake b/Modules/QmlItems/files.cmake deleted file mode 100644 index c5fd77cfe5..0000000000 --- a/Modules/QmlItems/files.cmake +++ /dev/null @@ -1,42 +0,0 @@ -file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") - -set(CPP_FILES - QmlMitkRenderWindowItem.cpp - QmlMitkRenderingManager.cpp - QmlMitkRenderingManagerFactory.cpp - QmlMitkBigRenderLock.cpp - QmlAxisOverlay.cpp - QmlMitkStdMultiItem.cpp - QmlMitkDatamanager.cpp - QmlMitkProperties.cpp - QmlMitkSliderLevelWindowItem.cpp - QmlMitkTransferFunctionCanvas.cpp - QmlMitkPiecewiseFunctionCanvas.cpp - QmlMitkColorTransferFunctionCanvas.cpp - QmlMitkTransferFunctionItem.cpp - QmlMitkImageNavigator.cpp - QmlMitkSliderNavigatorItem.cpp -) - -set(MOC_H_FILES - include/QmlMitkRenderWindowItem.h - include/QmlMitkRenderingManager.h - include/QmlMitkBigRenderLock.h - include/QmlMitkStdMultiItem.h - include/QmlMitkDatamanager.h - include/QmlMitkProperties.h - include/QmlMitkSliderLevelWindowItem.h - include/QmlMitkTransferFunctionCanvas.h - include/QmlMitkPiecewiseFunctionCanvas.h - include/QmlMitkColorTransferFunctionCanvas.h - include/QmlMitkTransferFunctionItem.h - include/QmlMitkImageNavigator.h - include/QmlMitkSliderNavigatorItem.h -) - -set(UI_FILES -) - -set(QRC_FILES - resource/MitkItems.qrc -) diff --git a/Modules/QmlItems/include/QmlAxisOverlay.h b/Modules/QmlItems/include/QmlAxisOverlay.h deleted file mode 100644 index dfd3bac4a4..0000000000 --- a/Modules/QmlItems/include/QmlAxisOverlay.h +++ /dev/null @@ -1,80 +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 __mitkAxisOverlay_h -#define __mitkAxisOverlay_h - -#include -#include - -#include -#include -#include -#include - -namespace mitk -{ - class AxisOverlay : public mitk::VtkAnnotation - { - public: - class LocalStorage : public mitk::VtkAnnotation::BaseLocalStorage - { - public: - /** \brief Actor of a 2D render window. */ - bool m_initialized = false; - vtkSmartPointer m_axesActor; - vtkSmartPointer m_widget; - - vtkSmartPointer m_dummyActor; - vtkSmartPointer m_dummyMapper; - vtkSmartPointer m_dummySource; - - /** \brief Timestamp of last update of stored data. */ - itk::TimeStamp m_LastUpdateTime; - - /** \brief Default constructor of the local storage. */ - LocalStorage(); - /** \brief Default deconstructor of the local storage. */ - ~LocalStorage(); - }; - - mitkClassMacro(AxisOverlay, mitk::VtkAnnotation); - itkFactorylessNewMacro(Self) itkCloneMacro(Self) - - protected : - - /** \brief The LocalStorageHandler holds all LocalStorages for the render windows. */ - mutable mitk::LocalStorageHandler m_LSH; - - virtual vtkProp *GetVtkProp(BaseRenderer *renderer) const; - void UpdateVtkAnnotation(mitk::BaseRenderer *renderer); - - /** \brief explicit constructor which disallows implicit conversions */ - explicit AxisOverlay(); - - /** \brief virtual destructor in order to derive from this class */ - virtual ~AxisOverlay(); - - private: - /** \brief copy constructor */ - AxisOverlay(const AxisOverlay &); - - /** \brief assignment operator */ - AxisOverlay &operator=(const AxisOverlay &); - }; -} - -#endif diff --git a/Modules/QmlItems/include/QmlMitkBigRenderLock.h b/Modules/QmlItems/include/QmlMitkBigRenderLock.h deleted file mode 100644 index f8b9815c71..0000000000 --- a/Modules/QmlItems/include/QmlMitkBigRenderLock.h +++ /dev/null @@ -1,47 +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 __QmlMitkBigRenderLock_h -#define __QmlMitkBigRenderLock_h - -#include - -/** - \brief Workaround lock around MITK rendering. - - QtQuick renders in a thread, MITK datastructures do not - tolerate this well. The current work-around is a big - lock that delays signal delivery while rendering is in - progress. - - The proper solution would be to make data structures - in rendering thread safe. This solution is much more - work though, so it will come later. -*/ -class QmlMitkBigRenderLock : public QObject -{ - Q_OBJECT - public: - - static QMutex& GetMutex(); - - QmlMitkBigRenderLock(QObject* parent = 0); - - protected: - bool eventFilter(QObject *obj, QEvent *event); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkColorTransferFunctionCanvas.h b/Modules/QmlItems/include/QmlMitkColorTransferFunctionCanvas.h deleted file mode 100644 index ebbaf4fdda..0000000000 --- a/Modules/QmlItems/include/QmlMitkColorTransferFunctionCanvas.h +++ /dev/null @@ -1,128 +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 __QmlMitkColorTransferFunctionCanvas_h -#define __QmlMitkColorTransferFunctionCanvas_h - -#include "QmlMitkTransferFunctionCanvas.h" -#include - -#include - -class MITKQMLITEMS_EXPORT QmlMitkColorTransferFunctionCanvas: public QmlMitkTransferFunctionCanvas -{ - Q_OBJECT - Q_PROPERTY(double greyValue READ getGreyValue WRITE setGreyValue) - -public: - - QmlMitkColorTransferFunctionCanvas(QQuickPaintedItem* parent = nullptr); - virtual void paint(QPainter* painter ) override; - int GetNearHandle(int x,int y,unsigned int maxSquaredDistance = 32) override; - void SetTitle(const QString& title); - - void setGreyValue(double value); - double getGreyValue(); - - void SetColorTransferFunction(vtkColorTransferFunction* colorTransferFunction) - { - this->m_ColorTransferFunction = colorTransferFunction; - this->SetMin(colorTransferFunction->GetRange()[0]); - this->SetMax(colorTransferFunction->GetRange()[1]); - setEnabled(true); - update(); - } - - int AddFunctionPoint(double x, double) override - { - return m_ColorTransferFunction->AddRGBPoint(x,m_ColorTransferFunction->GetRedValue(x),m_ColorTransferFunction->GetGreenValue(x),m_ColorTransferFunction->GetBlueValue(x)); - } - - void RemoveFunctionPoint(double x) override - { - 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) override - { - return m_ColorTransferFunction->GetDataPointer()[index*4]; - } - - int GetFunctionSize() override - { - return m_ColorTransferFunction->GetSize(); - } - - void DoubleClickOnHandle(int handle) override; - void MoveFunctionPoint(int index, std::pair pos) override; - - 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); - } - - double GetFunctionY(int) override - { - return 0.0; - } - - static void create(); - -protected: - vtkColorTransferFunction* m_ColorTransferFunction; - QString m_Title; - - double m_GreyValue; - -signals: - void sync(); - -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkDatamanager.h b/Modules/QmlItems/include/QmlMitkDatamanager.h deleted file mode 100644 index e988d5787a..0000000000 --- a/Modules/QmlItems/include/QmlMitkDatamanager.h +++ /dev/null @@ -1,58 +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 QmlMitkDatamanger_h -#define QmlMitkDatamanger_h - -#include "MitkQmlItemsExports.h" - -#include -#include - -#include - -class MITKQMLITEMS_EXPORT QmlMitkDatamanager : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(int index READ getIndex WRITE setIndex NOTIFY indexChanged); - -private: - int m_index; - static QmitkDataStorageListModel* model; - static mitk::DataStorage::Pointer storage; - -public: - static QmlMitkDatamanager* instance; - - int getIndex(); - void setIndex(int index); - - QmlMitkDatamanager(); - ~QmlMitkDatamanager(); - - static void create(QQmlEngine &engine, mitk::DataStorage::Pointer storage); - -public slots: - void toggleVisibility(bool checked); - void reinitNode(); - void globalReinit(); - void deleteNode(); - -signals: - void indexChanged(); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkImageNavigator.h b/Modules/QmlItems/include/QmlMitkImageNavigator.h deleted file mode 100644 index a291f61a0d..0000000000 --- a/Modules/QmlItems/include/QmlMitkImageNavigator.h +++ /dev/null @@ -1,152 +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 __QmlMitkImageNavigator_h -#define __QmlMitkImageNavigator_h - -#include "MitkQmlItemsExports.h" -#include -#include - -#include -#include -#include - -class QmitkStepperAdapter; - -/*! - * \ingroup org_mitk_gui_qt_imagenavigator_internal - * - * \class QmlMitkImageNavigator - * - * \brief Provides a means to scan quickly through a dataset via Axial, - * Coronal and Sagittal sliders, displaying millimetre location and stepper position. - * - * For images, the stepper position corresponds to a voxel index. For other datasets - * such as a surface, it corresponds to a sub-division of the bounding box. - * - * \sa QmitkAbstractView - */ -class MITKQMLITEMS_EXPORT QmlMitkImageNavigator : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QmlMitkSliderNavigatorItem* navigatorAxial READ getNavigatorAxial WRITE setNavigatorAxial) - Q_PROPERTY(QmlMitkSliderNavigatorItem* navigatorSagittal READ getNavigatorSagittal WRITE setNavigatorSagittal) - Q_PROPERTY(QmlMitkSliderNavigatorItem* navigatorCoronal READ getNavigatorCoronal WRITE setNavigatorCoronal) - Q_PROPERTY(QmlMitkSliderNavigatorItem* navigatorTime READ getNavigatorTime WRITE setNavigatorTime) - - Q_PROPERTY(double worldCoordinateX READ getWorldCoordinateX WRITE setWorldCoordinateX) - Q_PROPERTY(double worldCoordinateY READ getWorldCoordinateY WRITE setWorldCoordinateY) - Q_PROPERTY(double worldCoordinateZ READ getWorldCoordinateZ WRITE setWorldCoordinateZ) - - Q_PROPERTY(double worldCoordinateXMin READ getWorldCoordinateXMin WRITE setWorldCoordinateXMin) - Q_PROPERTY(double worldCoordinateYMin READ getWorldCoordinateYMin WRITE setWorldCoordinateYMin) - Q_PROPERTY(double worldCoordinateZMin READ getWorldCoordinateZMin WRITE setWorldCoordinateZMin) - - Q_PROPERTY(double worldCoordinateXMax READ getWorldCoordinateXMax WRITE setWorldCoordinateXMax) - Q_PROPERTY(double worldCoordinateYMax READ getWorldCoordinateYMax WRITE setWorldCoordinateYMax) - Q_PROPERTY(double worldCoordinateZMax READ getWorldCoordinateZMax WRITE setWorldCoordinateZMax) - -private: - QmlMitkSliderNavigatorItem* m_NavigatorAxial; - QmlMitkSliderNavigatorItem* m_NavigatorSagittal; - QmlMitkSliderNavigatorItem* m_NavigatorCoronal; - QmlMitkSliderNavigatorItem* m_NavigatorTime; - - double m_WorldCoordinateX; - double m_WorldCoordinateY; - double m_WorldCoordinateZ; - - double m_WorldCoordinateXMin; - double m_WorldCoordinateYMin; - double m_WorldCoordinateZMin; - - double m_WorldCoordinateXMax; - double m_WorldCoordinateYMax; - double m_WorldCoordinateZMax; - -public: - static QmlMitkImageNavigator* instance; - - QmlMitkImageNavigator(); - ~QmlMitkImageNavigator(); - - static void create(QQmlEngine &engine); - - void setNavigatorAxial(QmlMitkSliderNavigatorItem* item); - void setNavigatorSagittal(QmlMitkSliderNavigatorItem* item); - void setNavigatorCoronal(QmlMitkSliderNavigatorItem* item); - void setNavigatorTime(QmlMitkSliderNavigatorItem* item); - - QmlMitkSliderNavigatorItem* getNavigatorAxial(); - QmlMitkSliderNavigatorItem* getNavigatorSagittal(); - QmlMitkSliderNavigatorItem* getNavigatorCoronal(); - QmlMitkSliderNavigatorItem* getNavigatorTime(); - - void setWorldCoordinateX(double coordinate); - void setWorldCoordinateY(double coordinate); - void setWorldCoordinateZ(double coordinate); - - void setWorldCoordinateXMin(double coordinate); - void setWorldCoordinateYMin(double coordinate); - void setWorldCoordinateZMin(double coordinate); - - void setWorldCoordinateXMax(double coordinate); - void setWorldCoordinateYMax(double coordinate); - void setWorldCoordinateZMax(double coordinate); - - double getWorldCoordinateX(); - double getWorldCoordinateY(); - double getWorldCoordinateZ(); - - double getWorldCoordinateXMin(); - double getWorldCoordinateYMin(); - double getWorldCoordinateZMin(); - - double getWorldCoordinateXMax(); - double getWorldCoordinateYMax(); - double getWorldCoordinateZMax(); - -protected slots: - void initialize(); - void OnMillimetreCoordinateValueChanged(); - void OnRefetch(); - -protected: - //void SetBorderColors(); - //void SetBorderColor(QDoubleSpinBox *spinBox, QString colorAsStyleSheetString); - //void SetBorderColor(int axis, QString colorAsStyleSheetString); - void SetStepSizes(); - void SetStepSize(int axis); - void SetStepSize(int axis, double stepSize); - int GetClosestAxisIndex(mitk::Vector3D normal); - - QmitkStepperAdapter* m_AxialStepper; - QmitkStepperAdapter* m_SagittalStepper; - QmitkStepperAdapter* m_FrontalStepper; - QmitkStepperAdapter* m_TimeStepper; - - /** - * @brief GetDecorationColorOfGeometry helper method to get the color of a helper geometry node. - * @param renderWindow The renderwindow of the geometry - * @return the color for decoration in QString format (#RRGGBB). - */ - //QString GetDecorationColorOfGeometry(QmlMitkRenderWindowItem *renderWindow); -signals: - void sync(); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkPiecewiseFunctionCanvas.h b/Modules/QmlItems/include/QmlMitkPiecewiseFunctionCanvas.h deleted file mode 100644 index cc37f668c6..0000000000 --- a/Modules/QmlItems/include/QmlMitkPiecewiseFunctionCanvas.h +++ /dev/null @@ -1,156 +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 __QmlMitkPieceWiseFunctionCanvas_h -#define __QmlMitkPieceWiseFunctionCanvas_h - -#include "QmlMitkTransferFunctionCanvas.h" -#include - -#include - -#include -#include - -class MITKQMLITEMS_EXPORT QmlMitkPiecewiseFunctionCanvas: public QmlMitkTransferFunctionCanvas -{ - Q_OBJECT - Q_PROPERTY(double greyValue READ getGreyValue WRITE setGreyValue) - Q_PROPERTY(double opacity READ getOpacity WRITE setOpacity) - -public: - - QmlMitkPiecewiseFunctionCanvas(QQuickPaintedItem* parent = nullptr); - void paint(QPainter* painter ) override; - void SetTitle(const QString& title); - int GetNearHandle(int x,int y,unsigned int maxSquaredDistance = 32) override; - - static QmlMitkPiecewiseFunctionCanvas* instance; - - void setGreyValue(double value); - double getGreyValue(); - - void setOpacity(double opacity); - double getOpacity(); - - void SetPiecewiseFunction(vtkPiecewiseFunction* piecewiseFunction) - { - this->m_PiecewiseFunction = piecewiseFunction; - this->SetMin(m_PiecewiseFunction->GetRange()[0]); - this->SetMax(m_PiecewiseFunction->GetRange()[1]); - setEnabled(true); - - update(); - } - - int AddFunctionPoint(double x,double val) override - { - return m_PiecewiseFunction->AddPoint(x,val); - } - - void RemoveFunctionPoint(double x) override - { - 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) override - { - return m_PiecewiseFunction->GetDataPointer()[index*2]; - } - - double GetFunctionY(int index) override - { - return m_PiecewiseFunction->GetValue(m_PiecewiseFunction->GetDataPointer()[index*2]); - } - - int GetFunctionSize() override - { - return m_PiecewiseFunction->GetSize(); - } - - void DoubleClickOnHandle(int) override - { - } - - void MoveFunctionPoint(int index, std::pair pos) override; - - 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); - } - - void mousePressEvent( QMouseEvent* mouseEvent ) override; - void mouseMoveEvent( QMouseEvent* mouseEvent ) override; - void mouseReleaseEvent( QMouseEvent* mouseEvent ) override; - void mouseDoubleClickEvent( QMouseEvent* mouseEvent ) override; - void keyPressEvent(QKeyEvent* keyEvent) override; - - static void create(); - -protected: - vtkPiecewiseFunction* m_PiecewiseFunction; - QString m_Title; - mitk::SimpleHistogramCache histogramCache; - - double m_GreyValue; - double m_Opacity; - -signals: - void sync(); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkProperties.h b/Modules/QmlItems/include/QmlMitkProperties.h deleted file mode 100644 index 8ef5eb3489..0000000000 --- a/Modules/QmlItems/include/QmlMitkProperties.h +++ /dev/null @@ -1,81 +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 __QmlMitkProperties_h -#define __QmlMitkProperties_h - -#include "MitkQmlItemsExports.h" - -#include -#include - -#include -#include - -enum RenderMode -{ - RM_CPU_COMPOSITE_RAYCAST = 0, - RM_CPU_MIP_RAYCAST = 1, - RM_GPU_COMPOSITE_SLICING = 2, - RM_GPU_COMPOSITE_RAYCAST = 3, - RM_GPU_MIP_RAYCAST = 4 -}; - -class MITKQMLITEMS_EXPORT QmlMitkProperties : public QQuickItem -{ - Q_OBJECT - Q_ENUMS(RenderMode) - Q_PROPERTY(bool rendering READ getRendering WRITE setRendering NOTIFY renderingChanged); - Q_PROPERTY(bool lod READ getLod WRITE setLod NOTIFY lodChanged); - Q_PROPERTY(int mode READ getMode WRITE setMode NOTIFY modeChanged); - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged); - -private: - bool m_rendering; - bool m_lod; - int m_mode; - bool m_enabled; - mitk::WeakPointer m_node; - -public: - static QmlMitkProperties* instance; - - void setRendering(bool state); - void setLod(bool state); - void setMode(int mode); - void setEnabled(bool enabled); - - bool isEnabled(); - bool getRendering(); - bool getLod(); - int getMode(); - - void notify(mitk::DataNode::Pointer node); - - QmlMitkProperties(); - ~QmlMitkProperties(); - - static void create(QQmlEngine &engine); - -signals: - void renderingChanged(); - void lodChanged(); - void modeChanged(); - void enabledChanged(); - void sync(); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkRenderWindowItem.h b/Modules/QmlItems/include/QmlMitkRenderWindowItem.h deleted file mode 100644 index 6eee367a75..0000000000 --- a/Modules/QmlItems/include/QmlMitkRenderWindowItem.h +++ /dev/null @@ -1,140 +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 __QmlMitkRenderWindowItem_h -#define __QmlMitkRenderWindowItem_h - -#include "MitkQmlItemsExports.h" - -#include "QVTKQuickItem.h" - -#include "mitkRenderWindowBase.h" - -#include -#include - -class QmlMitkStdMultiItem; - -//! PROTOTYPE Qml item to integrate MITK render window into Qml application. -//! -//! See diagram qml-classes-mitk.jpg for an overall picture of involved classes. -//! -//! The structure implemented in these classes follows the framebuffer approach -//! described in -//! http://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html#mixing-scene-graph-and-opengl -//! -//! That is, MITK/VTK rendering is happening inside Qml's rendering thread and -//! in parallel to Qt's main thread. The rendering outputs to a GL framebuffer -//! that is used as a texture within the Qml scene. -//! Both Qt and VTK impose their structure on how rendering should be called, -//! see the two classes QVTKFramebufferObjectRenderer and vtkInternalOpenglRenderWindow. -//! -//! As in Qt widget based render windows, QmlMitkRenderWindowItem derives from -//! a Qt/VTK-integrating render window and adds its VtkPropRenderer to the VTK -//! scene. This VtkPropRenderer collects and organizes all MITK mappers and -//! makes them render when VTK asks to. -//! -//! Challenges for future development -//! * cleanup: example grew historically, structure could perhaps be simplified, -//! responsibilities could be clearer. -//! * thread-safety: this example manages execution of MITK events within -//! the Qt rendering thread. This allows access to VTK's GL context (e.g. for picking). -//! An inherent risk are collisions on data structures around -//! DataStorage: when rendering is threaded, the application -//! could modify data storage elements that are currently being -//! accessed by rendering. Working this out would probably -//! require thread-safety on multiple levels: DataStorage hierarchy, -//! DataNode methods, property (lists), and finally BaseData -//! and all its derived classes. -//! -class MITKQMLITEMS_EXPORT QmlMitkRenderWindowItem : public QVTKQuickItem, public mitk::RenderWindowBase -{ - Q_OBJECT - Q_PROPERTY(int viewType READ getViewType WRITE setViewType NOTIFY viewTypeChanged); - Q_PROPERTY(QmlMitkStdMultiItem* multiItem READ getMultiItem WRITE setMultiItem NOTIFY multiItemChanged); -private: - QmlMitkStdMultiItem* m_multiItem; - vtkSmartPointer m_annotation; - vtkSmartPointer m_rectangle; - - int m_viewType; - -public: - static QmlMitkRenderWindowItem* instance; - static QmlMitkRenderWindowItem* GetInstanceForVTKRenderWindow( vtkRenderWindow* rw ); - - QmlMitkRenderWindowItem(QQuickItem* parent = 0, const QString& name = "QML render window", mitk::VtkPropRenderer* renderer = nullptr, mitk::RenderingManager* renderingManager = nullptr); - ~QmlMitkRenderWindowItem(); - - virtual vtkRenderWindow* GetVtkRenderWindow(); - virtual vtkRenderWindowInteractor* GetVtkRenderWindowInteractor(); - - void SetDataStorage(mitk::DataStorage::Pointer storage); - void InitView( mitk::BaseRenderer::MapperSlotId mapperID, mitk::SliceNavigationController::ViewDirection viewDirection ); - - virtual bool prepareForRender(); - virtual void cleanupAfterRender(); - void createPlaneNode(); - - void setMultiItem(QmlMitkStdMultiItem* multiItem); - QmlMitkStdMultiItem* getMultiItem(); - - void setDecorationProperties(std::string text, mitk::Color color); - - void setViewType(int type); - int getViewType(); - - void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry); - - virtual void mousePressEvent(QMouseEvent* e); - virtual void mouseReleaseEvent(QMouseEvent* e); - virtual void mouseMoveEvent(QMouseEvent* e); - virtual void wheelEvent(QWheelEvent* e); - - mitk::Point2D GetMousePosition(QMouseEvent* me) const; - mitk::Point2D GetMousePositionFlipY(QMouseEvent* me) const; - mitk::Point2D GetMousePosition(QWheelEvent* we) const; - mitk::Point2D GetMousePositionFlipY(QWheelEvent* we) const; - mitk::InteractionEvent::MouseButtons GetEventButton(QMouseEvent* me) const; - mitk::InteractionEvent::MouseButtons GetButtonState(QMouseEvent* me) const; - mitk::InteractionEvent::ModifierKeys GetModifiers(QInputEvent* me) const; - mitk::InteractionEvent::MouseButtons GetButtonState(QWheelEvent* we) const; - - static QMap& GetInstances(); - -public slots: - void setupView(); - -signals: - void multiItemChanged(); - void viewTypeChanged(); - -protected: - - //! Add an event to the event queue to be executed in rendering. - //! - //! Avoids collisions between rendering and event handling, - //! both of which might act on GL buffers (e.g. picking) - void QueueEvent(mitk::InteractionEvent::Pointer e); - - //! List of events that should be treated during next rendering. - std::vector m_PendingEvents; - - //! Executes (then clears) the list of unhandled UI events (m_PendingEvents). - void processPendingEvents() override; -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkRenderingManager.h b/Modules/QmlItems/include/QmlMitkRenderingManager.h deleted file mode 100644 index ce5c530565..0000000000 --- a/Modules/QmlItems/include/QmlMitkRenderingManager.h +++ /dev/null @@ -1,84 +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 __QmlMitkRenderingManager_h -#define __QmlMitkRenderingManager_h - - - -#include "mitkRenderingManager.h" - -#include -#include - -class QmlMitkRenderingManagerFactory; - -/** - * \ingroup QmlMitkModule - * \brief Qt/Qml specific implementation of mitk::RenderingManager. - * - * This implementation defines a QmlMitkRenderingRequestEvent to realize the - * rendering request process. The event is put into Qt's event loop to - * receive it back in the GUI thread where we are allowed to do rendering. - * - */ -class QmlMitkRenderingManager : public QObject, public mitk::RenderingManager -{ - Q_OBJECT - -public: - - mitkClassMacro( QmlMitkRenderingManager, mitk::RenderingManager ); - virtual ~QmlMitkRenderingManager(); - - virtual bool event( QEvent *event ); - -protected: - - itkFactorylessNewMacro(Self); - - QmlMitkRenderingManager(); - - virtual void GenerateRenderingRequestEvent(); - virtual void StartOrResetTimer(); - - int pendingTimerCallbacks; - - protected slots: - - void TimerCallback(); - -private: - - friend class QmlMitkRenderingManagerFactory; - - void MyUpdateExecutePendingRequests(); -}; - -class QmlMitkRenderingRequestEvent : public QEvent -{ -public: - enum Type - { - RenderingRequest = QEvent::MaxUser - 1024 - }; - - QmlMitkRenderingRequestEvent() - : QEvent( (QEvent::Type) RenderingRequest ) {}; -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkRenderingManagerFactory.h b/Modules/QmlItems/include/QmlMitkRenderingManagerFactory.h deleted file mode 100644 index 009c4a34f2..0000000000 --- a/Modules/QmlItems/include/QmlMitkRenderingManagerFactory.h +++ /dev/null @@ -1,41 +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 __QmlMitkRenderingManagerFactory_h -#define __QmlMitkRenderingManagerFactory_h - -#include "mitkRenderingManagerFactory.h" - -/** - * \ingroup QmlMitkModule - * \brief Qt specific implementation of mitk::RenderingManagerFactory. - * - * This class create QmlMitkRenderingManager instances via - * CreateRenderingManager(). - * - */ -class QmlMitkRenderingManagerFactory : public mitk::RenderingManagerFactory -{ -public: - - QmlMitkRenderingManagerFactory(); - ~QmlMitkRenderingManagerFactory(); - - virtual mitk::RenderingManager::Pointer CreateRenderingManager() const; -}; - - -#endif diff --git a/Modules/QmlItems/include/QmlMitkSliderLevelWindowItem.h b/Modules/QmlItems/include/QmlMitkSliderLevelWindowItem.h deleted file mode 100644 index 8f7ece9a25..0000000000 --- a/Modules/QmlItems/include/QmlMitkSliderLevelWindowItem.h +++ /dev/null @@ -1,134 +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 __qmlMitkSliderLevelWindowItem_h -#define __qmlMitkSliderLevelWindowItem_h - -#include - -#include -#include - -#include -#include - -class MITKQMLITEMS_EXPORT QmlMitkSliderLevelWindowItem : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QColor fontColor READ fontColor WRITE setFontColor) - Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) - Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(int level READ getLevel WRITE setLevel NOTIFY levelChanged) - Q_PROPERTY(int window READ getWindow WRITE setWindow NOTIFY windowChanged) - -private: - static mitk::DataStorage::Pointer storage; - - /// change notifications from the mitkLevelWindowManager - void OnPropertyModified(const itk::EventObject& e); - - QColor m_Color; - QColor m_BorderColor; - QColor m_FontColor; - QFont m_Font; - - bool m_Enabled; - - int m_Level; - int m_Window; - - mitk::LevelWindow m_LevelWindow; - mitk::LevelWindowManager::Pointer m_Manager; - -public: - static QmlMitkSliderLevelWindowItem* instance; - - QmlMitkSliderLevelWindowItem(QQuickPaintedItem * parent = nullptr); - ~QmlMitkSliderLevelWindowItem(); - - void setLevelWindowManager(mitk::LevelWindowManager* levelWindowManager); - void setDataStorage(mitk::DataStorage* ds); - - mitk::LevelWindowManager* GetManager(); - - QColor color() const; - void setColor(const QColor &color); - - QColor fontColor() const; - void setFontColor(const QColor &color); - - QColor borderColor() const; - void setBorderColor(const QColor &color); - - int getLevel(); - void setLevel(int level); - - int getWindow(); - void setWindow(int window); - - int fontSize() const; - void setFontSize(const int &fontSize); - - bool isEnabled(); - void setEnabled(bool enable); - - static void create(QQmlEngine &engine, mitk::DataStorage::Pointer storage); - -protected: - QRect m_Rect; - QPoint m_StartPos; - - QRect m_LowerBound; - QRect m_UpperBound; - - bool m_Resize; - bool m_Bottom; - bool m_MouseDown; - bool m_Leftbutton; - bool m_CtrlPressed; - bool m_ScaleVisible; - - int m_FontSize; - int m_MoveHeight; - - unsigned long m_ObserverTag; - bool m_IsObserverTagSet; - - void paint(QPainter* painter) override; - - void mouseMoveEvent(QMouseEvent* mouseEvent ) override; - void mousePressEvent(QMouseEvent* mouseEvent ) override; - void mouseReleaseEvent(QMouseEvent* mouseEvent ) override; - - void hoverMoveEvent(QHoverEvent* event) override; - void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry) override; - - virtual void update( ); - -protected slots: - void hideScale(); - void showScale(); - -signals: - void enabledChanged(); - void levelChanged(); - void windowChanged(); - void sync(); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkSliderNavigatorItem.h b/Modules/QmlItems/include/QmlMitkSliderNavigatorItem.h deleted file mode 100644 index 77626ed1e1..0000000000 --- a/Modules/QmlItems/include/QmlMitkSliderNavigatorItem.h +++ /dev/null @@ -1,118 +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 __QmlMitkSliderNavigatorItem_h -#define __QmlMitkSliderNavigatorItem_h - -#include "MitkQmlItemsExports.h" -#include -#include -#include - -class MITKQMLITEMS_EXPORT QmlMitkSliderNavigatorItem : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(double min READ getMin WRITE setMin NOTIFY minChanged); - Q_PROPERTY(double max READ getMax WRITE setMax NOTIFY maxChanged); - Q_PROPERTY(double value READ getValue WRITE setValue NOTIFY valueChanged); - -private: - double m_Min; - double m_Max; - double m_Value; - -public: - QmlMitkSliderNavigatorItem(QQuickItem* parent = nullptr); - - void setMin(double min); - void setMax(double max); - void setValue(double value); - - double getMin(); - double getMax(); - double getValue(); - - 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(); - static void create(); - -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: - /** - * \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 ); - -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; -signals: - void minChanged(); - void maxChanged(); - void valueChanged(); - void sync(); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkStdMultiItem.h b/Modules/QmlItems/include/QmlMitkStdMultiItem.h deleted file mode 100644 index 060c5c5d1a..0000000000 --- a/Modules/QmlItems/include/QmlMitkStdMultiItem.h +++ /dev/null @@ -1,70 +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 QmlMitkStdMultiItem_h -#define QmlMitkStdMultiItem_h - -#include "MitkQmlItemsExports.h" - -#include -#include - -#include -#include - -class QmlMitkRenderWindowItem; - -class MITKQMLITEMS_EXPORT QmlMitkStdMultiItem : public QObject -{ - Q_OBJECT - -private: - QmlMitkRenderWindowItem* m_viewerAxial; - QmlMitkRenderWindowItem* m_viewerFrontal; - QmlMitkRenderWindowItem* m_viewerSagittal; - QmlMitkRenderWindowItem* m_viewerOriginal; - - mitk::DataNode::Pointer m_planeAxial; - mitk::DataNode::Pointer m_planeFrontal; - mitk::DataNode::Pointer m_planeSagittal; - - mitk::MouseModeSwitcher::Pointer m_mouseMode; - - static mitk::DataStorage::Pointer storage; - -public: - static QmlMitkStdMultiItem* instance; - - QmlMitkStdMultiItem(); - ~QmlMitkStdMultiItem(); - - void registerViewerItem(QmlMitkRenderWindowItem* viewerItem); - void moveCrossToPosition(const mitk::Point3D& newPosition); - void addPlanes(); - const mitk::Point3D getCrossPosition() const; - - QmlMitkRenderWindowItem* getViewerAxial(); - QmlMitkRenderWindowItem* getViewerSagittal(); - QmlMitkRenderWindowItem* getViewerCoronal(); - QmlMitkRenderWindowItem* getViewerOriginal(); - - static void create(QQmlEngine &engine, mitk::DataStorage::Pointer storage); - public slots: - void init(); - void togglePlanes(); -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkTransferFunctionCanvas.h b/Modules/QmlItems/include/QmlMitkTransferFunctionCanvas.h deleted file mode 100644 index be1b9ce14f..0000000000 --- a/Modules/QmlItems/include/QmlMitkTransferFunctionCanvas.h +++ /dev/null @@ -1,158 +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 __QmlMitkTransferFunctionCanvas_h -#define __QmlMitkTransferFunctionCanvas_h - -#include "MitkQmlItemsExports.h" - -#include -#include - -#include - -class MITKQMLITEMS_EXPORT QmlMitkTransferFunctionCanvas : public QQuickPaintedItem -{ - - Q_OBJECT - -public: - - QmlMitkTransferFunctionCanvas(QQuickPaintedItem* parent = nullptr); - - 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; - } - - virtual void paint(QPainter* painter) = 0; - - void mousePressEvent( QMouseEvent* mouseEvent ) override; - virtual void DoubleClickOnHandle(int handle) = 0; - - void mouseMoveEvent( QMouseEvent* mouseEvent ) override; - void mouseReleaseEvent( QMouseEvent* mouseEvent ) override; - void mouseDoubleClickEvent( QMouseEvent* mouseEvent ) override; - void keyPressEvent(QKeyEvent * event) override; - void PaintHistogram(QPainter* painter); - - virtual int GetNearHandle(int x,int y,unsigned int maxSquaredDistance = 32) = 0; - virtual int 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 double 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 SetImmediateUpdate(bool state); - - std::pair ValidateCoord( std::pair x ) - { - double max = m_Histogram->GetMax(); - double min = m_Histogram->GetMin(); - if( x.first < min ) x.first = min; - if( x.first > max ) x.first = max; - 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(); - } - } - -protected: - bool m_ImmediateUpdate; - float m_Range; - - double m_GreyValue; - double m_Opacity; - - bool m_LineEditAvailable; -}; - -#endif diff --git a/Modules/QmlItems/include/QmlMitkTransferFunctionItem.h b/Modules/QmlItems/include/QmlMitkTransferFunctionItem.h deleted file mode 100644 index 572ea02475..0000000000 --- a/Modules/QmlItems/include/QmlMitkTransferFunctionItem.h +++ /dev/null @@ -1,105 +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 __QmlmMitkTransferFunctionItem_h -#define __QmlmMitkTransferFunctionItem_h - -#include "MitkQmlItemsExports.h" - -#include -#include -#include - -#include -#include - -#include -#include -#include - -namespace mitk -{ - class BaseRenderer; -} - -class MITKQMLITEMS_EXPORT QmlMitkTransferFunctionItem: public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QmlMitkPiecewiseFunctionCanvas* opacityItem READ getOpacityItem WRITE setOpactityItem); - Q_PROPERTY(QmlMitkColorTransferFunctionCanvas* colorItem READ getColorItem WRITE setColorItem); - - Q_PROPERTY(double min READ getMin WRITE setMin NOTIFY minChanged); - Q_PROPERTY(double max READ getMax WRITE setMax NOTIFY maxChanged); - Q_PROPERTY(double currentMin READ getCurrentMin WRITE setCurrentMin NOTIFY currentMinChanged); - Q_PROPERTY(double currentMax READ getCurrentMax WRITE setCurrentMax NOTIFY currentMaxChanged); -public: - static QmlMitkTransferFunctionItem* instance; - - QmlMitkTransferFunctionItem(QQuickItem* parent = nullptr); - ~QmlMitkTransferFunctionItem () ; - - void SetDataNode(mitk::DataNode* node, const mitk::BaseRenderer* renderer = nullptr); - -public slots: - void OnUpdateCanvas(); - void UpdateRanges(); - void OnResetSlider(); - - void wheelEvent(QWheelEvent* event) override; - - void OnSpanChanged (int lower, int upper); - - void setOpactityItem(QmlMitkPiecewiseFunctionCanvas* item); - void setColorItem(QmlMitkColorTransferFunctionCanvas* item); - - QmlMitkPiecewiseFunctionCanvas* getOpacityItem(); - QmlMitkColorTransferFunctionCanvas* getColorItem(); - - void setMin(double min); - void setMax(double max); - void setCurrentMin(double currentMin); - void setCurrentMax(double currentMax); - - double getMin(); - double getMax(); - double getCurrentMin(); - double getCurrentMax(); - - static void create(); - -protected: - mitk::TransferFunctionProperty::Pointer tfpToChange; - - int m_Min; - int m_Max; - - int m_CurrentMin; - int m_CurrentMax; - - QmlMitkColorTransferFunctionCanvas* m_ColorItem; - QmlMitkPiecewiseFunctionCanvas* m_OpacityItem; - - mitk::SimpleHistogramCache histogramCache; - -signals: - void currentMinChanged(); - void currentMaxChanged(); - void minChanged(); - void maxChanged(); - void sync(); -}; - -#endif diff --git a/Modules/QmlItems/qml-classes-mitk.jpg b/Modules/QmlItems/qml-classes-mitk.jpg deleted file mode 100644 index 47647800fa..0000000000 Binary files a/Modules/QmlItems/qml-classes-mitk.jpg and /dev/null differ diff --git a/Modules/QmlItems/resource/MitkDataManager.qml b/Modules/QmlItems/resource/MitkDataManager.qml deleted file mode 100644 index f8411fa160..0000000000 --- a/Modules/QmlItems/resource/MitkDataManager.qml +++ /dev/null @@ -1,143 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 -import Mitk.Views 1.0 -import "./components" as Mitk - -Item -{ - id: root - property var tooltipArea; - - DataManager - { - id: dataManager - } - - Behavior on width - { - PropertyAnimation - { - duration: 120 - } - } - - Rectangle - { - anchors.fill: parent - color: "#2E2E2E" - - ListView - { - id: list - - anchors.fill: parent - model: dataStorage - clip: true - - delegate: Component - { - Rectangle - { - id: listItem - width: parent.width - height: 30 - color: "#aa333333" - - MouseArea - { - anchors.fill: parent - onClicked: list.currentIndex = index - } - - Row - { - anchors.fill: parent - anchors.leftMargin: 10 - - spacing: 10 - height: parent.height - - Mitk.Checkbox - { - id: cb - checked: true - anchors.verticalCenter: parent.verticalCenter - - onCheckedChanged: - { - list.currentIndex = index - dataManager.toggleVisibility(checked) - } - } - - Text - { - anchors.verticalCenter: parent.verticalCenter - text: model.display - color: "#ffffff" - font.pointSize: 10 - font.weight: Font.DemiBold - } - } - - Rectangle - { - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 1 - color: "#262626" - } - - ListView.onAdd: list.currentIndex = index - } - } - - Mitk.DataToolbar - { - id: toolbar - - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - - height: 22 - - tooltipArea: root.tooltipArea - datamanager: dataManager - } - - highlight: Rectangle - { - color: "#006EFF" - } - - highlightMoveDuration: 0 - highlightResizeDuration: 0 - - onCurrentIndexChanged: - { - dataManager.index = list.currentIndex - } - - onCountChanged: - { - if(list.count > 0) - toolbar.enabled = true; - else - toolbar.enabled = false; - } - } - } - - Rectangle - { - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: parent.bottom - - width: 1 - color: "#242424" - } -} diff --git a/Modules/QmlItems/resource/MitkImageNavigator.qml b/Modules/QmlItems/resource/MitkImageNavigator.qml deleted file mode 100644 index de518a9ad1..0000000000 --- a/Modules/QmlItems/resource/MitkImageNavigator.qml +++ /dev/null @@ -1,127 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import Mitk.Views 1.0 -import "./components" as Mitk - -ImageNavigator -{ - id: imageNavigator - - Row - { - id: worldCoordItem - - anchors.left: parent.left - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: 5 - spacing: 5 - //height: 50 - - Mitk.Spinbox - { - id: worldCoordX - decimals: 2 - borderColor: "#40B358" - - onValueChanged: - { - imageNavigator.worldCoordinateX = value - } - } - - Mitk.Spinbox - { - id: worldCoordY - decimals: 2 - borderColor: "#0250AB" - - onValueChanged: - { - imageNavigator.worldCoordinateY = value - } - } - - Mitk.Spinbox - { - id: worldCoordZ - decimals: 2 - borderColor: "#E15944" - - onValueChanged: - { - imageNavigator.worldCoordinateZ = value - } - } - } - - Column - { - anchors.left: parent.left - anchors.top: worldCoordItem.bottom - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.topMargin: 5 - - spacing: -3 - - Mitk.SliderNavigator - { - id: navigator_axial - height: parent.height/4 - - text: "Axial" - } - - Mitk.SliderNavigator - { - id: navigator_sagittal - height: parent.height/4 - - text: "Sagittal" - } - - Mitk.SliderNavigator - { - id: navigator_cornal - height: parent.height/4 - - text: "Coronal" - } - - Mitk.SliderNavigator - { - id: navigator_time - height: parent.height/4 - - text: "Time" - } - } - - Component.onCompleted: - { - imageNavigator.navigatorAxial = navigator_axial; - imageNavigator.navigatorSagittal = navigator_sagittal; - imageNavigator.navigatorCoronal = navigator_cornal; - imageNavigator.navigatorTime = navigator_time; - - imageNavigator.initialize() - } - - onSync: - { - - worldCoordX.value = imageNavigator.worldCoordinateX; - worldCoordY.value = imageNavigator.worldCoordinateY; - worldCoordZ.value = imageNavigator.worldCoordinateZ; - - worldCoordX.minimumValue = imageNavigator.worldCoordinateXMin; - worldCoordY.minimumValue = imageNavigator.worldCoordinateYMin; - worldCoordZ.minimumValue = imageNavigator.worldCoordinateZMin; - - worldCoordX.maximumValue = imageNavigator.worldCoordinateXMax; - worldCoordY.maximumValue = imageNavigator.worldCoordinateYMax; - worldCoordZ.maximumValue = imageNavigator.worldCoordinateZMax; - - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/MitkItems.qrc b/Modules/QmlItems/resource/MitkItems.qrc deleted file mode 100644 index e1e59f1f77..0000000000 --- a/Modules/QmlItems/resource/MitkItems.qrc +++ /dev/null @@ -1,20 +0,0 @@ - - - components/DataToolbar.qml - components/MultiToolbar.qml - components/VectorIcon.qml - fonts/font-awesome/fontawesome-webfont.ttf - components/Checkbox.qml - components/Combobox.qml - components/TransferFunction.qml - components/TextField.qml - components/SliderNavigator.qml - components/Slider.qml - components/TransferOverlay.qml - components/Spinbox.qml - MitkDataManager.qml - MitkProperties.qml - MitkImageNavigator.qml - MitkStdMultiItem.qml - - diff --git a/Modules/QmlItems/resource/MitkProperties.qml b/Modules/QmlItems/resource/MitkProperties.qml deleted file mode 100644 index cf4f73b194..0000000000 --- a/Modules/QmlItems/resource/MitkProperties.qml +++ /dev/null @@ -1,165 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 -import Mitk.Views 1.0 -import "./components" as Mitk - -Item -{ - id: root - property var tooltipArea; - - property bool wRendering: properties.rendering; - - Properties - { - id: properties - } - - Behavior on width - { - PropertyAnimation - { - duration: 120 - } - } - - Rectangle - { - id: attributes - - anchors.fill: parent - color: "#2E2E2E" - - Rectangle - { - id: visualization - - anchors.left: parent.left - anchors.top: parent.top - anchors.right: parent.right - - height: 22 - - gradient: Gradient { - GradientStop { position: 0.0; color: "#4C4C4C" } - GradientStop { position: 1.0; color: "#474747" } - } - - Text - { - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 5 - text: "Volume Visualization" - color: "#ffffff" - font.pointSize: 12 - } - } - - Mitk.Checkbox - { - id: cb_volumerendering - - anchors.left: parent.left - anchors.right: parent.right - anchors.top: visualization.bottom - anchors.leftMargin: 10 - anchors.rightMargin: 10 - anchors.topMargin: 7 - text: "Volumerendering" - checked: false - enabled: false - - onCheckedChanged: - { - properties.rendering = checked - } - } - - Mitk.Checkbox - { - id: cb_lod - - anchors.left: parent.left - anchors.right: parent.right - anchors.top: cb_volumerendering.bottom - anchors.leftMargin: 10 - anchors.rightMargin: 10 - anchors.topMargin: 7 - checked: false - enabled: false - - text: "Level of Detail" - - onCheckedChanged: - { - properties.lod = checked - } - } - - Mitk.Combobox - { - id: opt_mode; - - anchors.left: parent.left - anchors.top: cb_lod.bottom - anchors.right: parent.right - anchors.leftMargin: 10 - anchors.rightMargin: 10 - anchors.topMargin: 7 - currentIndex: 0 - enabled: false - - model: [ - "CPU raycast", - "CPU MIP raycast", - "GPU slicing", - "GPU raycast", - "GPU MIP raycast", - ] - - onCurrentIndexChanged: - { - properties.mode = currentIndex - } - } - - Mitk.TransferFunction - { - anchors.left: parent.left - anchors.right: parent.right - anchors.top: opt_mode.bottom - anchors.topMargin: 10 - height: 185 - enabled: cb_volumerendering.checked - } - } - - Rectangle - { - anchors.left: parent.left - anchors.top: parent.top - anchors.bottom: parent.bottom - - width: 1 - color: "#242424" - } - - Connections - { - target: properties; - - onSync: - { - opt_mode.currentIndex = properties.mode; - opt_mode.enabled = properties.enabled; - - cb_lod.checked = properties.lod; - cb_lod.enabled = properties.enabled; - - cb_volumerendering.checked = properties.rendering; - cb_volumerendering.enabled = properties.enabled; - } - } -} diff --git a/Modules/QmlItems/resource/MitkStdMultiItem.qml b/Modules/QmlItems/resource/MitkStdMultiItem.qml deleted file mode 100644 index 90bbbbe37f..0000000000 --- a/Modules/QmlItems/resource/MitkStdMultiItem.qml +++ /dev/null @@ -1,300 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Window 2.2 -import QtQuick.Controls 1.3 -import QtQuick.Layouts 1.0 -import Mitk.Views 1.0 -import "./components" as Mitk - -Rectangle -{ - id: root; - property var tooltipArea; - property color splitColor: "#4C4C4C"; - - MultiItem - { - id: stdmultiItem - } - - Mitk.MultiToolbar - { - id: toolbar - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - - height: 15 - - tooltipArea: root.tooltipArea - multiItem: stdmultiItem - } - - LevelWindow - { - id: levelWindow - anchors.top: toolbar.bottom - anchors.right: parent.right - anchors.bottom: parent.bottom - - width: 50 - color: "#4C4C4C" - borderColor: "transparent" - fontSize: 9 - fontColor: "white" - - onEnabledChanged: - { - if(enabled) - levelWindow.width = 50 - else - levelWindow.width = 0 - - } - - Behavior on width - { - PropertyAnimation - { - duration: 120 - } - } - - Mitk.TextField - { - id: window_field - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.margins: 3 - - text: "" - - Keys.onPressed: - { - if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) - { - levelWindow.window = text - } - } - - } - - Mitk.TextField - { - id: level_field - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: window_field.top - anchors.margins: 3 - - text: "" - - Keys.onPressed: - { - if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) - { - levelWindow.level = text - } - } - } - - } - - Connections - { - target: levelWindow; - - onSync: - { - window_field.text = levelWindow.window; - level_field.text = levelWindow.level; - } - } - - SplitView - { - id: splitView - anchors.left: parent.left - anchors.top: toolbar.bottom - anchors.right: levelWindow.left - anchors.bottom: parent.bottom - orientation: Qt.Vertical - - /* - handleDelegate: Rectangle - { - width: 3 - height: 3 - color: root.splitColor - } - */ - - SplitView - { - - height: parent.height/2 - orientation: Qt.Horizontal - /* - handleDelegate: Rectangle - { - width: 3 - height: 3 - color: root.splitColor - } - */ - - ViewItem - { - id: viewer_axial; - - multiItem: stdmultiItem - width: parent.width/2 - viewType: 0; - - Component.onCompleted: - { - viewer_axial.setupView(); - } - - Text - { - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.leftMargin: 5 - anchors.bottomMargin: 5 - color: "#E15944" - text: "Axial" - } - - Rectangle - { - anchors.fill: parent - color: "transparent" - border.width: 1 - border.color: "#E15944" - } - - } - - ViewItem - { - id: viewer_sagittal; - - multiItem: stdmultiItem - width: parent.width/2 - viewType: 2; - - Component.onCompleted: - { - viewer_sagittal.setupView(); - } - - Text - { - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.leftMargin: 5 - anchors.bottomMargin: 5 - color: "#40B358" - text: "Sagittal" - } - - Rectangle - { - anchors.fill: parent - color: "transparent" - border.width: 1 - border.color: "#40B358" - } - } - -} - -SplitView -{ - - height: parent.height/2 - orientation: Qt.Horizontal - /* - handleDelegate: Rectangle - { - width: 3 - height: 3 - color: root.splitColor -} -*/ - -ViewItem -{ - id: viewer_frontal; - - multiItem: stdmultiItem - width: parent.width/2 - viewType: 1; - - Component.onCompleted: - { - viewer_frontal.setupView(); - } - - Text - { - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.leftMargin: 5 - anchors.bottomMargin: 5 - color: "#0250AB" - text: "Coronal" - } - - Rectangle - { - anchors.fill: parent - color: "transparent" - border.width: 1 - border.color: "#0250AB" - } -} - - - -ViewItem -{ - id: viewer_default; - - multiItem: stdmultiItem - width: parent.width/2 - viewType: 3; - - Component.onCompleted: - { - viewer_default.setupView(); - } - - Text - { - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.leftMargin: 5 - anchors.bottomMargin: 5 - color: "#F0CA3E" - text: "3D" - } - Rectangle - { - anchors.fill: parent - color: "transparent" - border.width: 1 - border.color: "#F0CA3E" - - } - -} -} -} - -Component.onCompleted: -{ - stdmultiItem.init() -} -} diff --git a/Modules/QmlItems/resource/components/Checkbox.qml b/Modules/QmlItems/resource/components/Checkbox.qml deleted file mode 100644 index e71fc3a603..0000000000 --- a/Modules/QmlItems/resource/components/Checkbox.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.3 -import QtQuick.Controls.Styles 1.3 - -CheckBox -{ - id: checkBox; - - style: CheckBoxStyle - { - indicator: Rectangle - { - implicitWidth: 16 - implicitHeight: 16 - radius: 3 - color: "#565656" - border.color: "#282828" - border.width: 1 - - VectorIcon - { - visible: control.checked - anchors.centerIn: parent; - pixelSize: 10; - icon: "\uf00c"; - color: "#fff"; - - opacity: 1; - } - } - - label: Label - { - verticalAlignment: Qt.AlignVCenter - anchors.left: parent.left - anchors.leftMargin: 5 - - text: checkBox.text; - font.weight: Font.Normal; - font.pixelSize: 12; - color: checkBox.enabled ? "white" : "#666666"; - } - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/Combobox.qml b/Modules/QmlItems/resource/components/Combobox.qml deleted file mode 100644 index 5a0120c09b..0000000000 --- a/Modules/QmlItems/resource/components/Combobox.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 - -ComboBox -{ - id: control; - - anchors.left: parent.left - anchors.top: parent.top - anchors.right: parent.right - - height: 20 - - style: ComboBoxStyle - { - background: Rectangle - { - id: compBackground; - - width: parent.width; - height: parent.height; - color: "#565656"; - border.color: "#282828"; - border.width: 1; - radius: 3; - - VectorIcon - { - id: icon; - - anchors.verticalCenter: parent.verticalCenter; - anchors.right: parent.right; - anchors.rightMargin: 6; - font.pixelSize: 10; - - icon: "\uf0dc"; - } - } - - label: Label - { - verticalAlignment: Qt.AlignVCenter - anchors.left: parent.left - anchors.leftMargin: 5 - - text: control.currentText; - font.weight: Font.Normal; - font.pixelSize: 12; - color: control.enabled ? "white" : "#666666"; - } - - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/DataToolbar.qml b/Modules/QmlItems/resource/components/DataToolbar.qml deleted file mode 100644 index e973bdc018..0000000000 --- a/Modules/QmlItems/resource/components/DataToolbar.qml +++ /dev/null @@ -1,53 +0,0 @@ -import QtQuick 2.4 -import "../components" as Mitk - -Rectangle -{ - id: root - property var tooltipArea; - property bool enabled; - property var datamanager; - - gradient: Gradient { - GradientStop { position: 0.0; color: "#4C4C4C" } - GradientStop { position: 1.0; color: "#474747" } - } - - Row - { - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 10 - spacing: 15 - - Mitk.VectorIcon - { - icon: "\uf021" - tooltip: "Reinit selected node" - toolArea: root.tooltipArea - enabled: root.enabled - - onClicked: datamanager.reinitNode() - } - - Mitk.VectorIcon - { - icon: "\uf0ac" - tooltip: "Global Reinit" - toolArea: root.tooltipArea - enabled: root.enabled - - onClicked: datamanager.globalReinit() - } - - Mitk.VectorIcon - { - icon: "\uf1f8" - tooltip: "Delete seleted node" - toolArea: root.tooltipArea - enabled: root.enabled - - onClicked: datamanager.deleteNode() - } - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/MultiToolbar.qml b/Modules/QmlItems/resource/components/MultiToolbar.qml deleted file mode 100644 index 5199e13ae4..0000000000 --- a/Modules/QmlItems/resource/components/MultiToolbar.qml +++ /dev/null @@ -1,35 +0,0 @@ -import QtQuick 2.4 -import "../components" as Mitk - -Rectangle -{ - id: root - property var tooltipArea; - property var multiItem; - - gradient: Gradient { - GradientStop { position: 0.0; color: "#334C4C4C" } - GradientStop { position: 1.0; color: "#33474747" } - } - - Row - { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 10 - spacing: 15 - - Mitk.VectorIcon - { - icon: "\uf1cb" - tooltip: "Toggle planes" - toolArea: root.tooltipArea - pixelSize: 13 - enabled: true - defaultColor: "#666666"; - disableColor: "#EFEFEF" - - onClicked: multiItem.togglePlanes() - } - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/Slider.qml b/Modules/QmlItems/resource/components/Slider.qml deleted file mode 100644 index 494fea9e32..0000000000 --- a/Modules/QmlItems/resource/components/Slider.qml +++ /dev/null @@ -1,148 +0,0 @@ -import QtQuick 2.5 - -Item -{ - id: root - - property real minimumValue: 0; - property real maximumValue: 100; - property real valueLower: minimumValue; - property real valueUpper: minimumValue; - - width: 200 - height: 6 - - onMinimumValueChanged: updatePos(); - onMaximumValueChanged: updatePos(); - onValueLowerChanged: updatePos(); - onValueUpperChanged: updatePos(); - - signal valueUpperChangedByHandle; - signal valueLowerChangedByHandle; - - function updatePos() - { - if(slider.width < 1) - return - - if(maximumValue > minimumValue) - { - var posLower = (valueLower-minimumValue)*slider.width/(maximumValue-minimumValue)- btn1.width/2 - var posUpper = (valueUpper-minimumValue)*slider.width/(maximumValue-minimumValue)-btn2.width/2 - - btn1.x = posLower - btn2.x = posUpper - } - } - - onWidthChanged: - { - updatePos(); - } - - Rectangle - { - id: slider - width: parent.width - height: parent.height - anchors.centerIn: parent - color: "gray" - /* - gradient: Gradient { - GradientStop { position: 0.0; color: "#C0C0C0" } - GradientStop { position: 1.0; color: "#CCCCCC" } - } - */ - - border.width: 1 - border.color: "#888888" - - radius: 3 - - Item - { - id: sliderItem - - Rectangle - { - height: slider.height - anchors.left: btn1.left - anchors.right: btn2.right - - border.width: 1 - border.color: "#387FB8" - - gradient: Gradient { - GradientStop { position: 0.0; color: "#69BAFB" } - GradientStop { position: 1.0; color: "#55A8EB"} - } - } - - Rectangle - { - id: btn1 - - width: 16 - height: 16 - radius: 2 - color: "#565656" - - y: (slider.height-width)/2 - - border.width: 1 - border.color: "#282828" - - MouseArea - { - id: btn1MouseArea - anchors.fill: parent - drag.axis: Drag.XAxis - drag.target: parent - drag.minimumX: -btn1.width/2 - drag.maximumX: btn2.x - drag.threshold: 0 - - onPositionChanged: - { - valueLower = Math.max(minimumValue, Math.min(maximumValue, (maximumValue - minimumValue) * (btn1.x + btn1.width/2)/slider.width + minimumValue)) - root.valueLowerChangedByHandle(); - } - } - } - - Rectangle - { - id: btn2 - - width: 16 - height: 16 - radius: 2 - color: "#565656" - - y: (slider.height-width)/2 - - border.width: 1 - border.color: "#282828" - - MouseArea - { - id: btn2MouseArea - anchors.fill: parent - drag.axis: Drag.XAxis - drag.target: parent - drag.minimumX: btn1.x - drag.maximumX: slider.width - btn2.width/2 - - drag.threshold: 0 - onPositionChanged: - { - valueUpper = Math.max(minimumValue, Math.min(maximumValue, (maximumValue - minimumValue) * (btn2.x + btn2.width/2)/slider.width + minimumValue)) - root.valueUpperChangedByHandle(); - } - } - } - - - } - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/SliderNavigator.qml b/Modules/QmlItems/resource/components/SliderNavigator.qml deleted file mode 100644 index f143932a08..0000000000 --- a/Modules/QmlItems/resource/components/SliderNavigator.qml +++ /dev/null @@ -1,91 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 -import Mitk.Views 1.0 -import "../components" as Mitk - -SliderNavigator -{ - id: sliderNavigator - - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: 5 - anchors.rightMargin: 5 - - property alias text: label.text - - Row - { - anchors.fill: parent - spacing: 5 - - Label - { - id: label - anchors.verticalCenter: parent.verticalCenter - width: parent.width/4 - color: "white" - font.pixelSize: 12 - } - - Slider - { - id: slider - anchors.verticalCenter: parent.verticalCenter - width: parent.width/2 -10 - value: 0 - - style: SliderStyle { - groove: Rectangle { - implicitWidth: 20 - implicitHeight: 4 - color: "gray" - radius: 3 - } - handle: Rectangle { - anchors.centerIn: parent - color: control.pressed ? "white" : "lightgray" - border.color: "gray" - border.width: 1 - implicitWidth: 10 - implicitHeight: 10 - radius: 2 - } - } - - onValueChanged: - { - sliderNavigator.value = value - } - } - - Mitk.Spinbox - { - id: spinbox - value: 0 - width: parent.width/4 - anchors.verticalCenter: parent.verticalCenter - borderColor: "#282828" - - onValueChanged: - { - sliderNavigator.value = value - } - } - - } - - onSync: - { - spinbox.value = sliderNavigator.value - slider.value = sliderNavigator.value - - spinbox.minimumValue = sliderNavigator.min - slider.minimumValue = sliderNavigator.min - - spinbox.maximumValue = sliderNavigator.max - slider.maximumValue = sliderNavigator.max - } - -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/Spinbox.qml b/Modules/QmlItems/resource/components/Spinbox.qml deleted file mode 100644 index 3a4ab30a5c..0000000000 --- a/Modules/QmlItems/resource/components/Spinbox.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.3 -import QtQuick.Controls.Styles 1.3 - -SpinBox -{ - id: root - property color borderColor; - - style: SpinBoxStyle - { - id: spinStyle - textColor: "white" - font.pixelSize: 12; - background: Rectangle - { - implicitWidth: 70 - implicitHeight: 20 - border.width: 1 - border.color: root.borderColor - color: "#565656" - radius: 2 - } - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/TextField.qml b/Modules/QmlItems/resource/components/TextField.qml deleted file mode 100644 index e6229465ad..0000000000 --- a/Modules/QmlItems/resource/components/TextField.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.3 -import QtQuick.Controls.Styles 1.3 - -TextField -{ - id: textField; - - style: TextFieldStyle - { - textColor: "white" - font.weight: Font.Normal; - font.pixelSize: 12; - background: Rectangle - { - radius: 2 - implicitWidth: 100 - implicitHeight: 20 - color: "#565656" - border.color: "#282828" - border.width: 1 - } - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/TransferFunction.qml b/Modules/QmlItems/resource/components/TransferFunction.qml deleted file mode 100644 index 9d2877501e..0000000000 --- a/Modules/QmlItems/resource/components/TransferFunction.qml +++ /dev/null @@ -1,139 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 -import Mitk.Views 1.0 -import "../components" as Mitk - -TransferItem -{ - id: root - - PiecewiseItem - { - id: opacityItem - anchors.left: parent.left - anchors.top: parent.top - anchors.right: parent.right - anchors.leftMargin: 10 - anchors.rightMargin: 10 - height: 150 - focus: true - enabled: root.enabled - - Mitk.TransferOverlay - { - id: opacityField - anchors.top: parent.top - anchors.right: parent.right - anchors.topMargin: 2 - label: "Opacity" - enabled: root.enabled - - onPressed: - { - opacityItem.opacity = text - } - } - - Mitk.TransferOverlay - { - id: grayField - anchors.top: opacityField.bottom - anchors.right: parent.right - anchors.topMargin: 2 - label: "Value" - enabled: root.enabled - - onPressed: - { - opacityItem.greyValue = text - } - } - - Mitk.TransferOverlay - { - id: colorField - anchors.top: grayField.bottom - anchors.right: parent.right - anchors.topMargin: 2 - label: "Color" - enabled: root.enabled - - onPressed: - { - colorItem.greyValue = text - } - } - } - - ColorItem - { - id: colorItem - anchors.left: parent.left - anchors.right: parent.right - anchors.top: opacityItem.bottom - anchors.leftMargin: 10 - anchors.rightMargin: 10 - height: 20 - enabled: root.enabled - } - - Mitk.Slider - { - id: slider - anchors.top: colorItem.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.topMargin: 9 - anchors.leftMargin: 10 - anchors.rightMargin: 10 - - minimumValue: root.min; - maximumValue: root.max; - - onValueLowerChangedByHandle: - { - root.currentMin = valueLower; - } - - onValueUpperChangedByHandle: - { - root.currentMax = valueUpper; - } - } - - Connections - { - target: colorItem; - - onSync: - { - colorField.text = colorItem.greyValue.toFixed(2); - } - } - - - Connections - { - target: opacityItem; - - onSync: - { - grayField.text = opacityItem.greyValue.toFixed(2); - opacityField.text = opacityItem.opacity.toFixed(2); - } - } - - onSync: - { - slider.valueUpper = root.currentMax - slider.valueLower = root.currentMin - } - - Component.onCompleted: - { - root.opacityItem = opacityItem; - root.colorItem = colorItem; - } -} \ No newline at end of file diff --git a/Modules/QmlItems/resource/components/TransferOverlay.qml b/Modules/QmlItems/resource/components/TransferOverlay.qml deleted file mode 100644 index cfafabde28..0000000000 --- a/Modules/QmlItems/resource/components/TransferOverlay.qml +++ /dev/null @@ -1,67 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.3 -import QtQuick.Controls.Styles 1.3 - -Rectangle -{ - id: root - - property alias text: text_field.text - property alias label: label.text - - color: "#33000000" - - height: 15 - width: 70 - radius: 3 - - signal pressed; - - Label - { - id: label - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 4 - color: root.enabled ? "white" : "#666666" - font.pointSize: 9 - } - - TextField - { - id: text_field - - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - anchors.rightMargin: 2 - enabled: root.enabled - - horizontalAlignment: TextInput.AlignRight - text: "--" - width: 40 - - validator: RegExpValidator - { - regExp: /[-+]?[0-9]*\.?[0-9]*/ - } - - Keys.onPressed: - { - if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) - { - root.pressed() - } - } - - style: TextFieldStyle - { - textColor: enabled ? "white" : "#666666" - font.weight: Font.Normal; - font.pointSize: 9; - background: Rectangle - { - color: "transparent" - } - } - } -} diff --git a/Modules/QmlItems/resource/components/VectorIcon.qml b/Modules/QmlItems/resource/components/VectorIcon.qml deleted file mode 100644 index 657e9a5064..0000000000 --- a/Modules/QmlItems/resource/components/VectorIcon.qml +++ /dev/null @@ -1,66 +0,0 @@ -import QtQuick 2.4 - -Text -{ - id: root; - - property var toolArea; - property string icon: "-"; - property string tooltip: "-"; - property int fadeDuration: 100; - property int pixelSize: 15; - property int clickMargin: 0; - property color defaultColor: "#EFEFEF"; - property color disableColor: "#333333" - property bool enabled: false; - - signal clicked; - - FontLoader - { - id: fontLoader; - source: "../../fonts/font-awesome/fontawesome-webfont.ttf"; - } - - textFormat: Text.PlainText; - style: Text.Normal; - color: !root.enabled ? root.disableColor : mouseArea.pressed ? Qt.darker(root.defaultColor, 1.5) : root.defaultColor - font.family: fontLoader.name; - font.pixelSize: root.pixelSize; - verticalAlignment: Text.AlignVCenter; - text: root.icon; - - Behavior on color - { - ColorAnimation - { - duration: root.fadeDuration; - } - } - - MouseArea - { - id: mouseArea; - - anchors.fill: parent; - - hoverEnabled: true; - - onClicked: - { - root.clicked(); - } - - onEntered: - { - if(root.toolArea) - root.toolArea.text = root.tooltip; - } - - onExited: - { - if(root.toolArea) - root.toolArea.text = ""; - } - } -} diff --git a/Modules/QmlItems/resource/fonts/font-awesome/fontawesome-webfont.ttf b/Modules/QmlItems/resource/fonts/font-awesome/fontawesome-webfont.ttf deleted file mode 100644 index ed9372f8ea..0000000000 Binary files a/Modules/QmlItems/resource/fonts/font-awesome/fontawesome-webfont.ttf and /dev/null differ diff --git a/Modules/QmlItems/src/QmlAxisOverlay.cpp b/Modules/QmlItems/src/QmlAxisOverlay.cpp deleted file mode 100644 index 9a32ecd860..0000000000 --- a/Modules/QmlItems/src/QmlAxisOverlay.cpp +++ /dev/null @@ -1,67 +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 "QmlAxisOverlay.h" -#include -#include -#include -//#include "Util_Debug.h" -#include "mitkPoint.h" - -mitk::AxisOverlay::AxisOverlay() -{ -} - -mitk::AxisOverlay::~AxisOverlay() -{ -} - -mitk::AxisOverlay::LocalStorage::~LocalStorage() -{ -} - -mitk::AxisOverlay::LocalStorage::LocalStorage() -{ - this->m_axesActor = vtkSmartPointer::New(); - this->m_widget = vtkSmartPointer::New(); - this->m_dummyActor = vtkSmartPointer::New(); - this->m_dummyMapper = vtkSmartPointer::New(); - this->m_dummySource = vtkSmartPointer::New(); - this->m_dummyMapper->SetInputConnection(m_dummySource->GetOutputPort()); - this->m_dummyActor->SetMapper(this->m_dummyMapper); - this->m_dummyActor->SetVisibility(false); - this->m_dummyActor->GetProperty()->SetOpacity(0.0); -} - -void mitk::AxisOverlay::UpdateVtkAnnotation(mitk::BaseRenderer *renderer) -{ - LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); - if (ls->IsGenerateDataRequired(renderer, this)) - { - ls->m_widget->SetOrientationMarker(ls->m_axesActor); - ls->m_widget->SetInteractor(renderer->GetRenderWindow()->GetInteractor()); - ls->m_widget->SetEnabled(true); - ls->m_widget->SetOutlineColor(0.3, 0, 0); - ls->m_widget->SetInteractive(true); - ls->m_initialized = true; - } -} - -vtkProp *mitk::AxisOverlay::GetVtkProp(BaseRenderer *renderer) const -{ - LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer); - return ls->m_dummyActor; -} diff --git a/Modules/QmlItems/src/QmlMitkBigRenderLock.cpp b/Modules/QmlItems/src/QmlMitkBigRenderLock.cpp deleted file mode 100644 index a800f1edc8..0000000000 --- a/Modules/QmlItems/src/QmlMitkBigRenderLock.cpp +++ /dev/null @@ -1,60 +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 "QmlMitkBigRenderLock.h" -#include "QVTKQuickItem.h" - -QMutex& QmlMitkBigRenderLock::GetMutex() -{ - static QMutex globalRenderingLock; - return globalRenderingLock; -} - -QmlMitkBigRenderLock::QmlMitkBigRenderLock(QObject* parent) -:QObject(parent) -{ -} - -bool QmlMitkBigRenderLock::eventFilter(QObject* /*obj*/, QEvent* /*event*/) -{ - /* - TODO - - this should BLOCK during rendering, i.e. - - it should acquire a mutex lock which is also acquired by the rendering method in QVTKQuickItem - - TODO: - - THIS MUST BE CHANGED! - - It is NOT sufficient to delay signal delivery, BUT we must block rendering until the signal is completely processed. - TODO: what would happen if a signal receiver calls rendering->ForceImmediateUpdateAll ? - */ - - if ( GetMutex().tryLock() ) - { - // ok, let's continue - } - else - { - GetMutex().lock(); - } - - GetMutex().unlock(); - - return false; // don't actually filter/remove events -} diff --git a/Modules/QmlItems/src/QmlMitkColorTransferFunctionCanvas.cpp b/Modules/QmlItems/src/QmlMitkColorTransferFunctionCanvas.cpp deleted file mode 100644 index 96d7c545e8..0000000000 --- a/Modules/QmlItems/src/QmlMitkColorTransferFunctionCanvas.cpp +++ /dev/null @@ -1,173 +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 "QmlMitkColorTransferFunctionCanvas.h" - -#include -#include - -QmlMitkColorTransferFunctionCanvas::QmlMitkColorTransferFunctionCanvas(QQuickPaintedItem* parent): -QmlMitkTransferFunctionCanvas(parent), m_ColorTransferFunction(nullptr) -{ -} - -void QmlMitkColorTransferFunctionCanvas::SetTitle(const QString& title) -{ - m_Title=title; -} - -void QmlMitkColorTransferFunctionCanvas::setGreyValue(double value) -{ - this->m_GreyValue = value; - this->SetX(value); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -double QmlMitkColorTransferFunctionCanvas::getGreyValue() -{ - return this->m_GreyValue; -} - -void QmlMitkColorTransferFunctionCanvas::paint(QPainter* painter) -{ - // Render gray background - QRectF contentsRect = this->boundingRect(); - painter->setPen(Qt::gray); - - 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->boundingRect().height()-qr_min.height()+10; - 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->boundingRect().height()-qr_max.height()+10; - x=this->boundingRect().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 && this->isEnabled()) - { - // 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) - { - this->m_GreyValue = QString::number(GetFunctionX(m_GrabbedHandle), 'g', 4).toFloat(); - emit this->sync(); - } - } - } -} - -int QmlMitkColorTransferFunctionCanvas::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 QmlMitkColorTransferFunctionCanvas::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 QmlMitkColorTransferFunctionCanvas::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 QmlMitkColorTransferFunctionCanvas::AddRGB(double x, double r, double g, - double b) -{ - m_ColorTransferFunction->AddRGBPoint(x, r, g, b); -} - -void QmlMitkColorTransferFunctionCanvas::create() -{ - qmlRegisterType("Mitk.Views", 1, 0, "ColorItem"); -} diff --git a/Modules/QmlItems/src/QmlMitkDatamanager.cpp b/Modules/QmlItems/src/QmlMitkDatamanager.cpp deleted file mode 100644 index 20e1da04ec..0000000000 --- a/Modules/QmlItems/src/QmlMitkDatamanager.cpp +++ /dev/null @@ -1,125 +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 "QmlMitkDatamanager.h" - -#include -#include -#include - -#include -#include - -#include -#include - -QmlMitkDatamanager* QmlMitkDatamanager::instance = nullptr; -QmitkDataStorageListModel* QmlMitkDatamanager::model = nullptr; -mitk::DataStorage::Pointer QmlMitkDatamanager::storage = nullptr; - -QmlMitkDatamanager::QmlMitkDatamanager() -{ - instance = this; -} - -QmlMitkDatamanager::~QmlMitkDatamanager() -{ -} - -void QmlMitkDatamanager::toggleVisibility(bool checked) -{ - QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index); - mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex); - node->SetVisibility(checked); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmlMitkDatamanager::setIndex(int index) -{ - this->m_index = index; - - if(index >= 0) - { - QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index); - mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex); - - if(dynamic_cast(node->GetData()) && dynamic_cast(node->GetData())->GetDimension()>=3 ) - { - QmlMitkProperties::instance->notify(node); - QmlMitkTransferFunctionItem::instance->SetDataNode(node); - } - else - { - QmlMitkProperties::instance->setEnabled(false); - emit QmlMitkProperties::instance->sync(); - } - } - else - { - QmlMitkProperties::instance->setEnabled(false); - emit QmlMitkProperties::instance->sync(); - } - - emit this->indexChanged(); -} - -int QmlMitkDatamanager::getIndex() -{ - return this->m_index; -} - -void QmlMitkDatamanager::reinitNode() -{ - QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index); - mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex); - - mitk::BaseData::Pointer basedata = node->GetData(); - if ( basedata.IsNotNull() && - basedata->GetTimeGeometry()->IsValid() ) - { - mitk::RenderingManager::GetInstance()->InitializeViews(basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - } -} - -void QmlMitkDatamanager::globalReinit() -{ - mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(QmlMitkDatamanager::storage); -} - -void QmlMitkDatamanager::deleteNode() -{ - QModelIndex modelIndex = QmlMitkDatamanager::model->index(this->m_index); - mitk::DataNode::Pointer node = QmlMitkDatamanager::model->getNode(modelIndex); - - QmlMitkDatamanager::storage->Remove(node); - this->globalReinit(); -} - -void QmlMitkDatamanager::create(QQmlEngine &engine, mitk::DataStorage::Pointer storage) -{ - qmlRegisterType("Mitk.Views", 1, 0, "DataManager"); - - mitk::NodePredicateBase::Pointer filter = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true))).GetPointer(); - - QmlMitkDatamanager::storage = storage; - QmlMitkDatamanager::model = new QmitkDataStorageListModel(storage, filter); - - QQmlContext* context = engine.rootContext(); - context->setContextProperty("dataStorage", QmlMitkDatamanager::model); - - QQmlComponent component(&engine, QUrl("qrc:/views/MitkDataManager.qml")); -} diff --git a/Modules/QmlItems/src/QmlMitkImageNavigator.cpp b/Modules/QmlItems/src/QmlMitkImageNavigator.cpp deleted file mode 100644 index 595edb7d72..0000000000 --- a/Modules/QmlItems/src/QmlMitkImageNavigator.cpp +++ /dev/null @@ -1,379 +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 "QmlMitkImageNavigator.h" - -#include -#include - -QmlMitkImageNavigator* QmlMitkImageNavigator::instance = nullptr; - -QmlMitkImageNavigator::QmlMitkImageNavigator() -: m_AxialStepper(0) -, m_SagittalStepper(0) -, m_FrontalStepper(0) -, m_TimeStepper(0) -{ - instance = this; -} - -QmlMitkImageNavigator::~QmlMitkImageNavigator() -{ -} - -void QmlMitkImageNavigator::setNavigatorAxial(QmlMitkSliderNavigatorItem *item) -{ - this->m_NavigatorAxial = item; -} - -void QmlMitkImageNavigator::setNavigatorSagittal(QmlMitkSliderNavigatorItem *item) -{ - this->m_NavigatorSagittal = item; -} - -void QmlMitkImageNavigator::setNavigatorCoronal(QmlMitkSliderNavigatorItem *item) -{ - this->m_NavigatorCoronal = item; -} - -void QmlMitkImageNavigator::setNavigatorTime(QmlMitkSliderNavigatorItem *item) -{ - this->m_NavigatorTime = item; -} - -QmlMitkSliderNavigatorItem* QmlMitkImageNavigator::getNavigatorAxial() -{ - return this->m_NavigatorAxial; -} - -QmlMitkSliderNavigatorItem* QmlMitkImageNavigator::getNavigatorSagittal() -{ - return this->m_NavigatorSagittal; -} - -QmlMitkSliderNavigatorItem* QmlMitkImageNavigator::getNavigatorCoronal() -{ - return this->m_NavigatorCoronal; -} - -QmlMitkSliderNavigatorItem* QmlMitkImageNavigator::getNavigatorTime() -{ - return this->m_NavigatorTime; -} - -void QmlMitkImageNavigator::setWorldCoordinateX(double coordinate) -{ - this->m_WorldCoordinateX = coordinate; - this->OnMillimetreCoordinateValueChanged(); -} - -void QmlMitkImageNavigator::setWorldCoordinateY(double coordinate) -{ - this->m_WorldCoordinateY = coordinate; - this->OnMillimetreCoordinateValueChanged(); -} - -void QmlMitkImageNavigator::setWorldCoordinateZ(double coordinate) -{ - this->m_WorldCoordinateZ = coordinate; - this->OnMillimetreCoordinateValueChanged(); -} - -void QmlMitkImageNavigator::setWorldCoordinateXMin(double coordinate) -{ - this->m_WorldCoordinateXMin = coordinate; -} - -void QmlMitkImageNavigator::setWorldCoordinateYMin(double coordinate) -{ - this->m_WorldCoordinateYMin = coordinate; -} - -void QmlMitkImageNavigator::setWorldCoordinateZMin(double coordinate) -{ - this->m_WorldCoordinateZMin = coordinate; -} - -void QmlMitkImageNavigator::setWorldCoordinateXMax(double coordinate) -{ - this->m_WorldCoordinateXMax = coordinate; -} - -void QmlMitkImageNavigator::setWorldCoordinateYMax(double coordinate) -{ - this->m_WorldCoordinateYMax = coordinate; -} - -void QmlMitkImageNavigator::setWorldCoordinateZMax(double coordinate) -{ - this->m_WorldCoordinateZMax = coordinate; -} - -double QmlMitkImageNavigator::getWorldCoordinateX() -{ - return this->m_WorldCoordinateX; -} - -double QmlMitkImageNavigator::getWorldCoordinateY() -{ - return this->m_WorldCoordinateY; -} - -double QmlMitkImageNavigator::getWorldCoordinateZ() -{ - return this->m_WorldCoordinateZ; -} - -double QmlMitkImageNavigator::getWorldCoordinateXMin() -{ - return this->m_WorldCoordinateXMin; -} - -double QmlMitkImageNavigator::getWorldCoordinateYMin() -{ - return this->m_WorldCoordinateYMin; -} - -double QmlMitkImageNavigator::getWorldCoordinateZMin() -{ - return this->m_WorldCoordinateZMin; -} - -double QmlMitkImageNavigator::getWorldCoordinateXMax() -{ - return this->m_WorldCoordinateXMax; -} - -double QmlMitkImageNavigator::getWorldCoordinateYMax() -{ - return this->m_WorldCoordinateYMax; -} - -double QmlMitkImageNavigator::getWorldCoordinateZMax() -{ - return this->m_WorldCoordinateZMax; -} - -void QmlMitkImageNavigator::initialize() -{ - if(!QmlMitkStdMultiItem::instance) - return; - - QmlMitkRenderWindowItem* renderWindow = QmlMitkStdMultiItem::instance->getViewerAxial(); - - if (renderWindow) - { - if (m_AxialStepper) m_AxialStepper->deleteLater(); - m_AxialStepper = new QmitkStepperAdapter(this->m_NavigatorAxial, - renderWindow->GetSliceNavigationController()->GetSlice(), - "sliceNavigatorAxialFromSimpleExample"); - - connect(m_AxialStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); - } - else - { - this->m_NavigatorAxial->setEnabled(false); - } - - renderWindow = QmlMitkStdMultiItem::instance->getViewerSagittal(); - if (renderWindow) - { - if (m_SagittalStepper) m_SagittalStepper->deleteLater(); - m_SagittalStepper = new QmitkStepperAdapter(this->m_NavigatorSagittal, - renderWindow->GetSliceNavigationController()->GetSlice(), - "sliceNavigatorSagittalFromSimpleExample"); - connect(m_SagittalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); - } - else - { - this->m_NavigatorSagittal->setEnabled(false); - } - - renderWindow = QmlMitkStdMultiItem::instance->getViewerCoronal(); - if (renderWindow) - { - if (m_FrontalStepper) m_FrontalStepper->deleteLater(); - m_FrontalStepper = new QmitkStepperAdapter(this->m_NavigatorCoronal, - renderWindow->GetSliceNavigationController()->GetSlice(), - "sliceNavigatorFrontalFromSimpleExample"); - connect(m_FrontalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); - } - else - { - this->m_NavigatorCoronal->setEnabled(false); - } - - mitk::SliceNavigationController* timeController = mitk::RenderingManager::GetInstance()->GetTimeNavigationController(); - if (timeController) - { - if (m_TimeStepper) m_TimeStepper->deleteLater(); - m_TimeStepper = new QmitkStepperAdapter(this->m_NavigatorTime, - timeController->GetTime(), - "sliceNavigatorTimeFromSimpleExample"); - } - else - { - this->m_NavigatorTime->setEnabled(false); - } -} - -int QmlMitkImageNavigator::GetClosestAxisIndex(mitk::Vector3D normal) -{ - // cos(theta) = normal . axis - // cos(theta) = (a, b, c) . (d, e, f) - // cos(theta) = (a, b, c) . (1, 0, 0) = a - // cos(theta) = (a, b, c) . (0, 1, 0) = b - // cos(theta) = (a, b, c) . (0, 0, 1) = c - double absCosThetaWithAxis[3]; - - for (int i = 0; i < 3; i++) - { - absCosThetaWithAxis[i] = fabs(normal[i]); - } - int largestIndex = 0; - double largestValue = absCosThetaWithAxis[0]; - for (int i = 1; i < 3; i++) - { - if (absCosThetaWithAxis[i] > largestValue) - { - largestValue = absCosThetaWithAxis[i]; - largestIndex = i; - } - } - return largestIndex; -} - -void QmlMitkImageNavigator::SetStepSizes() -{ - this->SetStepSize(0); - this->SetStepSize(1); - this->SetStepSize(2); -} - -void QmlMitkImageNavigator::SetStepSize(int axis) -{ - mitk::BaseGeometry::ConstPointer geometry = QmlMitkStdMultiItem::instance->getViewerAxial()->GetSliceNavigationController()->GetInputWorldGeometry3D(); - - if (geometry.IsNotNull()) - { - mitk::Point3D crossPositionInIndexCoordinates; - mitk::Point3D crossPositionInIndexCoordinatesPlus1; - mitk::Point3D crossPositionInMillimetresPlus1; - mitk::Vector3D transformedAxisDirection; - - mitk::Point3D crossPositionInMillimetres = QmlMitkStdMultiItem::instance->getCrossPosition(); - geometry->WorldToIndex(crossPositionInMillimetres, crossPositionInIndexCoordinates); - - crossPositionInIndexCoordinatesPlus1 = crossPositionInIndexCoordinates; - crossPositionInIndexCoordinatesPlus1[axis] += 1; - - geometry->IndexToWorld(crossPositionInIndexCoordinatesPlus1, crossPositionInMillimetresPlus1); - - transformedAxisDirection = crossPositionInMillimetresPlus1 - crossPositionInMillimetres; - - int closestAxisInMillimetreSpace = this->GetClosestAxisIndex(transformedAxisDirection); - double stepSize = transformedAxisDirection.GetNorm(); - this->SetStepSize(closestAxisInMillimetreSpace, stepSize); - } -} - -void QmlMitkImageNavigator::SetStepSize(int, double) -{ -} - - -void QmlMitkImageNavigator::OnMillimetreCoordinateValueChanged() -{ - mitk::TimeGeometry::ConstPointer geometry = QmlMitkStdMultiItem::instance->getViewerAxial()->GetSliceNavigationController()->GetInputWorldTimeGeometry(); - - if (geometry.IsNotNull()) - { - mitk::Point3D positionInWorldCoordinates; - positionInWorldCoordinates[0] = this->m_WorldCoordinateX; - positionInWorldCoordinates[1] = this->m_WorldCoordinateY; - positionInWorldCoordinates[2] = this->m_WorldCoordinateZ; - - QmlMitkStdMultiItem::instance->moveCrossToPosition(positionInWorldCoordinates); - } -} - - -void QmlMitkImageNavigator::OnRefetch() -{ - mitk::BaseGeometry::ConstPointer geometry = QmlMitkStdMultiItem::instance->getViewerAxial()->GetSliceNavigationController()->GetInputWorldGeometry3D(); - mitk::TimeGeometry::ConstPointer timeGeometry = QmlMitkStdMultiItem::instance->getViewerAxial()->GetSliceNavigationController()->GetInputWorldTimeGeometry(); - - if (geometry.IsNull() && timeGeometry.IsNotNull()) - { - mitk::TimeStepType timeStep = QmlMitkStdMultiItem::instance->getViewerAxial()->GetSliceNavigationController()->GetTime()->GetPos(); - geometry = timeGeometry->GetGeometryForTimeStep(timeStep); - } - - if (geometry.IsNotNull()) - { - mitk::BoundingBox::BoundsArrayType bounds = geometry->GetBounds(); - - mitk::Point3D cornerPoint1InIndexCoordinates; - cornerPoint1InIndexCoordinates[0] = bounds[0]; - cornerPoint1InIndexCoordinates[1] = bounds[2]; - cornerPoint1InIndexCoordinates[2] = bounds[4]; - - mitk::Point3D cornerPoint2InIndexCoordinates; - cornerPoint2InIndexCoordinates[0] = bounds[1]; - cornerPoint2InIndexCoordinates[1] = bounds[3]; - cornerPoint2InIndexCoordinates[2] = bounds[5]; - - if (!geometry->GetImageGeometry()) - { - cornerPoint1InIndexCoordinates[0] += 0.5; - cornerPoint1InIndexCoordinates[1] += 0.5; - cornerPoint1InIndexCoordinates[2] += 0.5; - cornerPoint2InIndexCoordinates[0] -= 0.5; - cornerPoint2InIndexCoordinates[1] -= 0.5; - cornerPoint2InIndexCoordinates[2] -= 0.5; - } - - mitk::Point3D crossPositionInWorldCoordinates = QmlMitkStdMultiItem::instance->getCrossPosition(); - - mitk::Point3D cornerPoint1InWorldCoordinates; - mitk::Point3D cornerPoint2InWorldCoordinates; - - geometry->IndexToWorld(cornerPoint1InIndexCoordinates, cornerPoint1InWorldCoordinates); - geometry->IndexToWorld(cornerPoint2InIndexCoordinates, cornerPoint2InWorldCoordinates); - - this->m_WorldCoordinateXMin = std::min(cornerPoint1InWorldCoordinates[0], cornerPoint2InWorldCoordinates[0]); - this->m_WorldCoordinateYMin = std::min(cornerPoint1InWorldCoordinates[1], cornerPoint2InWorldCoordinates[1]); - this->m_WorldCoordinateZMin = std::min(cornerPoint1InWorldCoordinates[2], cornerPoint2InWorldCoordinates[2]); - - this->m_WorldCoordinateXMax = std::max(cornerPoint1InWorldCoordinates[0], cornerPoint2InWorldCoordinates[0]); - this->m_WorldCoordinateYMax = std::max(cornerPoint1InWorldCoordinates[1], cornerPoint2InWorldCoordinates[1]); - this->m_WorldCoordinateZMax = std::max(cornerPoint1InWorldCoordinates[2], cornerPoint2InWorldCoordinates[2]); - - this->m_WorldCoordinateX = crossPositionInWorldCoordinates[0]; - this->m_WorldCoordinateY = crossPositionInWorldCoordinates[1]; - this->m_WorldCoordinateZ = crossPositionInWorldCoordinates[2]; - - emit this->sync(); - } -} - -void QmlMitkImageNavigator::create(QQmlEngine &engine) -{ - QmlMitkSliderNavigatorItem::create(); - - qmlRegisterType("Mitk.Views", 1, 0, "ImageNavigator"); - QQmlComponent component(&engine, QUrl("qrc:/MitkImageNavigator.qml")); -} diff --git a/Modules/QmlItems/src/QmlMitkPiecewiseFunctionCanvas.cpp b/Modules/QmlItems/src/QmlMitkPiecewiseFunctionCanvas.cpp deleted file mode 100644 index 8f9f4a1133..0000000000 --- a/Modules/QmlItems/src/QmlMitkPiecewiseFunctionCanvas.cpp +++ /dev/null @@ -1,180 +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 "QmlMitkPiecewiseFunctionCanvas.h" - -#include - -QmlMitkPiecewiseFunctionCanvas* QmlMitkPiecewiseFunctionCanvas::instance = nullptr; - -QmlMitkPiecewiseFunctionCanvas::QmlMitkPiecewiseFunctionCanvas(QQuickPaintedItem* parent) : -QmlMitkTransferFunctionCanvas(parent), m_PiecewiseFunction(nullptr) -{ - instance = this; - setAcceptedMouseButtons(Qt::AllButtons); -} - -void QmlMitkPiecewiseFunctionCanvas::setGreyValue(double value) -{ - this->m_GreyValue = value; - this->SetX(value); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -double QmlMitkPiecewiseFunctionCanvas::getGreyValue() -{ - return this->m_GreyValue; -} - -void QmlMitkPiecewiseFunctionCanvas::setOpacity(double opacity) -{ - this->m_Opacity = opacity; - this->SetY(opacity); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -double QmlMitkPiecewiseFunctionCanvas::getOpacity() -{ - return this->m_Opacity; -} - -void QmlMitkPiecewiseFunctionCanvas::SetTitle(const QString& title) -{ - m_Title=title; -} - -void QmlMitkPiecewiseFunctionCanvas::paint(QPainter* painter) -{ - 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); - } - - painter->setPen(Qt::gray); - - 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)); - - this->m_Opacity = QString::number(GetFunctionY(m_GrabbedHandle), 'g', 4).toFloat(); - this->m_GreyValue = QString::number(GetFunctionX(m_GrabbedHandle), 'g', 4).toFloat(); - - emit this->sync(); - - } - else - { - painter->setBrush(QBrush(Qt::green)); - } - painter->drawEllipse(point.first - 4, point.second - 4, 8, 8); - } - - painter->setBrush(Qt::NoBrush); - } -} - -int QmlMitkPiecewiseFunctionCanvas::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 QmlMitkPiecewiseFunctionCanvas::MoveFunctionPoint(int index, - std::pair pos) -{ - RemoveFunctionPoint(GetFunctionX(index)); - m_GrabbedHandle = AddFunctionPoint(pos.first, pos.second); -} - -void QmlMitkPiecewiseFunctionCanvas::mousePressEvent( QMouseEvent* mouseEvent ) -{ - QmlMitkTransferFunctionCanvas::mousePressEvent(mouseEvent); -} - -void QmlMitkPiecewiseFunctionCanvas::mouseMoveEvent( QMouseEvent* mouseEvent ) -{ - QmlMitkTransferFunctionCanvas::mouseMoveEvent(mouseEvent); -} - -void QmlMitkPiecewiseFunctionCanvas::mouseReleaseEvent( QMouseEvent* mouseEvent ) -{ - QmlMitkTransferFunctionCanvas::mouseReleaseEvent(mouseEvent); -} - -void QmlMitkPiecewiseFunctionCanvas::mouseDoubleClickEvent( QMouseEvent* mouseEvent ) -{ - QmlMitkTransferFunctionCanvas::mouseDoubleClickEvent(mouseEvent); -} - -void QmlMitkPiecewiseFunctionCanvas::keyPressEvent(QKeyEvent *keyEvent) -{ - QmlMitkTransferFunctionCanvas::keyPressEvent(keyEvent); -} - -void QmlMitkPiecewiseFunctionCanvas::create() -{ - qmlRegisterType("Mitk.Views", 1, 0, "PiecewiseItem"); -} diff --git a/Modules/QmlItems/src/QmlMitkProperties.cpp b/Modules/QmlItems/src/QmlMitkProperties.cpp deleted file mode 100644 index 0e675875d5..0000000000 --- a/Modules/QmlItems/src/QmlMitkProperties.cpp +++ /dev/null @@ -1,178 +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 "QmlMitkProperties.h" - -#include -#include -#include -#include - -#include -#include - -QmlMitkProperties* QmlMitkProperties::instance = nullptr; - -QmlMitkProperties::QmlMitkProperties() -{ - instance = this; -} - -QmlMitkProperties::~QmlMitkProperties() -{ -} - -void QmlMitkProperties::setRendering(bool state) -{ - this->m_rendering = state; - if(this->m_node) - { - this->m_node->SetBoolProperty("volumerendering", state); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - QmlMitkTransferFunctionItem::instance->OnUpdateCanvas(); - } - - emit this->renderingChanged(); -} - -void QmlMitkProperties::setLod(bool state) -{ - this->m_lod = state; - if(this->m_node) - { - this->m_node->SetBoolProperty("volumerendering.uselod", state); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - - emit this->lodChanged(); -} - -void QmlMitkProperties::setMode(int mode) -{ - if (!this->m_node) - return; - - this->m_mode = mode; - - bool usegpu=mode==RM_GPU_COMPOSITE_SLICING; - // Only with VTK 5.6 or above -#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) )) - bool useray=(mode==RM_GPU_COMPOSITE_RAYCAST)||(mode==RM_GPU_MIP_RAYCAST); -#endif - bool usemip=(mode==RM_GPU_MIP_RAYCAST)||(mode==RM_CPU_MIP_RAYCAST); - - this->m_node->SetBoolProperty("volumerendering.usegpu",usegpu); - // Only with VTK 5.6 or above -#if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) )) - this->m_node->SetBoolProperty("volumerendering.useray",useray); -#endif - this->m_node->SetBoolProperty("volumerendering.usemip",usemip); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - emit this->modeChanged(); -} - -bool QmlMitkProperties::getRendering() -{ - return this->m_rendering; -} - -bool QmlMitkProperties::getLod() -{ - return this->m_lod; -} - -int QmlMitkProperties::getMode() -{ - return this->m_mode; -} - -void QmlMitkProperties::setEnabled(bool enabled) -{ - this->m_enabled = enabled; - emit this->enabledChanged(); -} - -bool QmlMitkProperties::isEnabled() -{ - return this->m_enabled; -} - -void QmlMitkProperties::notify(mitk::DataNode::Pointer node) -{ - this->m_node = node; - - if(!this->m_node) - { - this->setEnabled(false); - emit this->sync(); - return; - } - - mitk::Image::Pointer image = static_cast(this->m_node->GetData()); - - if(image->GetDimension() == 2) - this->setEnabled(false); - else - this->setEnabled(true); - - bool use_volumerendering; - bool use_lod; - bool use_ray; - bool use_mip; - bool use_gpu; - - this->m_node->GetBoolProperty("volumerendering", use_volumerendering); - this->m_node->GetBoolProperty("volumerendering.uselod", use_lod); - this->m_node->GetBoolProperty("volumerendering.useray", use_ray); - this->m_node->GetBoolProperty("volumerendering.usemip", use_mip); - this->m_node->GetBoolProperty("volumerendering.usegpu", use_gpu); - - this->setRendering(use_volumerendering); - this->setLod(use_lod); - - int mode = 0; - - if(use_ray) - { - if(use_mip) - mode=RM_GPU_MIP_RAYCAST; - else - mode=RM_GPU_COMPOSITE_RAYCAST; - } - else if(use_gpu) - mode=RM_GPU_COMPOSITE_SLICING; - else - { - if(use_mip) - mode=RM_CPU_MIP_RAYCAST; - else - mode=RM_CPU_COMPOSITE_RAYCAST; - } - - this->setMode(mode); - - emit this->sync(); -} - -void QmlMitkProperties::create(QQmlEngine &engine) -{ - qmlRegisterType("Mitk.Views", 1, 0, "Properties"); - - QQmlComponent component(&engine, QUrl("qrc:/MitkProperties.qml")); -} diff --git a/Modules/QmlItems/src/QmlMitkRenderWindowItem.cpp b/Modules/QmlItems/src/QmlMitkRenderWindowItem.cpp deleted file mode 100644 index 445ffe5138..0000000000 --- a/Modules/QmlItems/src/QmlMitkRenderWindowItem.cpp +++ /dev/null @@ -1,410 +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 "QmlMitkRenderWindowItem.h" - -#include - -#include -#include -#include - -#include "mitkMouseWheelEvent.h" -#include "mitkMousePressEvent.h" -#include "mitkMouseMoveEvent.h" -#include "mitkMouseDoubleClickEvent.h" -#include "mitkMouseReleaseEvent.h" -#include "mitkInteractionKeyEvent.h" -#include "mitkInternalEvent.h" -#include "mitkPlaneGeometryDataMapper2D.h" -#include "mitkCameraController.h" - -#include "QmlMitkStdMultiItem.h" -#include "QVTKFramebufferObjectRenderer.h" -#include - -QmlMitkRenderWindowItem* QmlMitkRenderWindowItem::instance = nullptr; - -QmlMitkRenderWindowItem* QmlMitkRenderWindowItem::GetInstanceForVTKRenderWindow(vtkRenderWindow* rw) -{ - if (GetInstances().contains(rw)) - { - return GetInstances()[rw]; - } - return 0; -} - -QMap& QmlMitkRenderWindowItem::GetInstances() -{ - static QMap s_Instances; - return s_Instances; -} - -QmlMitkRenderWindowItem::QmlMitkRenderWindowItem(QQuickItem* parent, const QString& name, mitk::VtkPropRenderer* , mitk::RenderingManager* renderingManager) : QVTKQuickItem(parent) -{ - instance = this; - - mitk::RenderWindowBase::Initialize(renderingManager, name.toStdString().c_str()); - GetInstances()[QVTKQuickItem::GetRenderWindow()] = this; - - this->m_annotation = vtkSmartPointer::New(); - this->m_rectangle = vtkSmartPointer::New(); -} - -void QmlMitkRenderWindowItem::createPlaneNode() -{ - mitk::DataStorage::Pointer m_DataStorage = mitk::RenderWindowBase::GetRenderer()->GetDataStorage(); - if (m_DataStorage.IsNotNull()) - { - mitk::RenderingManager::GetInstance()->InitializeViews( m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()) ); - } - - if (this->GetRenderer()->GetSliceNavigationController()->GetDefaultViewDirection() == mitk::SliceNavigationController::Original) - return; - - mitk::DataNode::Pointer planeNode; - mitk::IntProperty::Pointer layer; - mitk::PlaneGeometryDataMapper2D::Pointer mapper = mitk::PlaneGeometryDataMapper2D::New(); - - layer = mitk::IntProperty::New(1000); - - planeNode = this->GetRenderer()->GetCurrentWorldPlaneGeometryNode(); - - planeNode->SetProperty("visible", mitk::BoolProperty::New(true)); - planeNode->SetProperty("name", mitk::StringProperty::New("plane")); - planeNode->SetProperty("isPlane", mitk::BoolProperty::New(true)); - planeNode->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); - planeNode->SetProperty("helper object", mitk::BoolProperty::New(true)); - planeNode->SetProperty("layer", layer); - planeNode->SetMapper(mitk::BaseRenderer::Standard2D, mapper); - - switch (this->GetRenderer()->GetSliceNavigationController()->GetDefaultViewDirection()) - { - case mitk::SliceNavigationController::Axial: - planeNode->SetColor(0.88, 0.35, 0.27); - break; - case mitk::SliceNavigationController::Sagittal: - planeNode->SetColor(0.25, 0.7, 0.35); - break; - case mitk::SliceNavigationController::Frontal: - planeNode->SetColor(0.01, 0.31, 0.67); - break; - default: - planeNode->SetColor(1.0, 1.0, 0.0); - } - -} - -void QmlMitkRenderWindowItem::setViewType(int viewType) -{ - this->m_viewType = viewType; - - emit this->viewTypeChanged(); -} - -void QmlMitkRenderWindowItem::setDecorationProperties(std::string text, mitk::Color color) -{ - this->m_annotation->SetText(0, text.c_str()); - this->m_annotation->SetMaximumFontSize(12); - this->m_annotation->GetTextProperty()->SetColor( color[0],color[1],color[2] ); - - - if(!this->GetRenderer()->GetVtkRenderer()->HasViewProp(this->m_annotation)) - { - this->GetRenderer()->GetVtkRenderer()->AddViewProp(this->m_annotation); - } - - this->m_rectangle->SetColor(color[0],color[1],color[2]); - - if(!this->GetRenderer()->GetVtkRenderer()->HasViewProp(this->m_rectangle)) - { - this->GetRenderer()->GetVtkRenderer()->AddViewProp(this->m_rectangle); - } -} - -void QmlMitkRenderWindowItem::setupView() -{ - switch (this->m_viewType) - { - case 0: - this->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D); - this->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Axial); - break; - case 1: - this->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D); - this->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Frontal); - break; - case 2: - this->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D); - this->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Sagittal); - break; - case 3: - this->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard3D); - this->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Original); - break; - default: - break; - } -} - -void QmlMitkRenderWindowItem::setMultiItem(QmlMitkStdMultiItem* multiItem) -{ - if(this->m_multiItem == multiItem) - return; - - this->m_multiItem = multiItem; - this->m_multiItem->registerViewerItem(this); -} - -QmlMitkStdMultiItem* QmlMitkRenderWindowItem::getMultiItem() -{ - return this->m_multiItem; -} - -void QmlMitkRenderWindowItem::SetDataStorage(mitk::DataStorage::Pointer storage) -{ - this->GetRenderer()->SetDataStorage(storage); -} - -mitk::Point2D QmlMitkRenderWindowItem::GetMousePosition(QMouseEvent* me) const -{ - qreal ratio = this->window()->effectiveDevicePixelRatio(); - mitk::Point2D point; - point[0] = me->x()*ratio; - point[1] = me->y()*ratio; - return point; -} - -mitk::Point2D QmlMitkRenderWindowItem::GetMousePositionFlipY(QMouseEvent* me) const -{ - mitk::Point2D point = GetMousePosition(me); - point[1] = const_cast(this)->GetRenderer()->GetSizeY() - point[1]; - return point; -} - -mitk::Point2D QmlMitkRenderWindowItem::GetMousePosition(QWheelEvent* we) const -{ - qreal ratio = this->window()->effectiveDevicePixelRatio(); - mitk::Point2D point; - point[0] = we->x()*ratio; - point[1] = we->y()*ratio; - return point; -} - -mitk::Point2D QmlMitkRenderWindowItem::GetMousePositionFlipY(QWheelEvent* we) const -{ - mitk::Point2D point = GetMousePosition(we); - point[1] = const_cast(this)->GetRenderer()->GetSizeY() - point[1]; - return point; -} - -mitk::InteractionEvent::MouseButtons QmlMitkRenderWindowItem::GetEventButton(QMouseEvent* me) const -{ - mitk::InteractionEvent::MouseButtons eventButton; - switch (me->button()) - { - case Qt::LeftButton: - eventButton = mitk::InteractionEvent::LeftMouseButton; - break; - case Qt::RightButton: - eventButton = mitk::InteractionEvent::RightMouseButton; - break; - case Qt::MidButton: - eventButton = mitk::InteractionEvent::MiddleMouseButton; - break; - default: - eventButton = mitk::InteractionEvent::NoButton; - break; - } - return eventButton; -} - -mitk::InteractionEvent::MouseButtons QmlMitkRenderWindowItem::GetButtonState(QMouseEvent* me) const -{ - mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; - - if (me->buttons() & Qt::LeftButton) - { - buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; - } - if (me->buttons() & Qt::RightButton) - { - buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; - } - if (me->buttons() & Qt::MidButton) - { - buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; - } - return buttonState; -} - -mitk::InteractionEvent::ModifierKeys QmlMitkRenderWindowItem::GetModifiers(QInputEvent* me) const -{ - mitk::InteractionEvent::ModifierKeys modifiers = mitk::InteractionEvent::NoKey; - - if (me->modifiers() & Qt::ALT) - { - modifiers = modifiers | mitk::InteractionEvent::AltKey; - } - if (me->modifiers() & Qt::CTRL) - { - modifiers = modifiers | mitk::InteractionEvent::ControlKey; - } - if (me->modifiers() & Qt::SHIFT) - { - modifiers = modifiers | mitk::InteractionEvent::ShiftKey; - } - return modifiers; -} - -mitk::InteractionEvent::MouseButtons QmlMitkRenderWindowItem::GetButtonState(QWheelEvent* we) const -{ - mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; - - if (we->buttons() & Qt::LeftButton) - { - buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; - } - if (we->buttons() & Qt::RightButton) - { - buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; - } - if (we->buttons() & Qt::MidButton) - { - buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; - } - return buttonState; -} - - -int QmlMitkRenderWindowItem::getViewType() -{ - return this->m_viewType; -} - -void QmlMitkRenderWindowItem::mousePressEvent(QMouseEvent* me) -{ - mitk::Point2D mousePosition = GetMousePositionFlipY(me); - - auto mitkEvent = mitk::MousePressEvent::New(mitk::RenderWindowBase::GetRenderer(), - mousePosition, - GetButtonState(me), - GetModifiers(me), - GetEventButton(me)); - - QueueEvent(mitkEvent.GetPointer()); - - QVTKQuickItem::mousePressEvent(me); -} - -void QmlMitkRenderWindowItem::mouseReleaseEvent(QMouseEvent* me) -{ - mitk::Point2D mousePosition = GetMousePositionFlipY(me); - - auto mitkEvent = mitk::MouseReleaseEvent::New(mitk::RenderWindowBase::GetRenderer(), - mousePosition, - GetButtonState(me), - GetModifiers(me), - GetEventButton(me)); - - QueueEvent(mitkEvent.GetPointer()); - - QVTKQuickItem::mouseReleaseEvent(me); -} - -void QmlMitkRenderWindowItem::mouseMoveEvent(QMouseEvent* me) -{ - mitk::Point2D mousePosition = GetMousePositionFlipY(me); - - auto mitkEvent = mitk::MouseMoveEvent::New(mitk::RenderWindowBase::GetRenderer(), - mousePosition, - GetButtonState(me), - GetModifiers(me)); - - QueueEvent(mitkEvent.GetPointer()); - - QVTKQuickItem::mouseMoveEvent(me); -} - -void QmlMitkRenderWindowItem::wheelEvent(QWheelEvent *we) -{ - mitk::Point2D mousePosition = GetMousePositionFlipY(we); - - auto mitkEvent = mitk::MouseWheelEvent::New(mitk::RenderWindowBase::GetRenderer(), - mousePosition, - GetButtonState(we), - GetModifiers(we), - we->delta()); - - QueueEvent(mitkEvent.GetPointer()); - - QVTKQuickItem::wheelEvent(we); -} - -bool QmlMitkRenderWindowItem::prepareForRender() -{ - - mitk::VtkPropRenderer *vPR = dynamic_cast(mitk::BaseRenderer::GetInstance(this->GetRenderWindow())); - if (vPR) - { - vPR->PrepareRender(); - } - - mitk::RenderWindowBase::GetRenderer()->ForceImmediateUpdate(); - - return true; -} - -void QmlMitkRenderWindowItem::cleanupAfterRender() -{ -} - -void QmlMitkRenderWindowItem::geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry) -{ - QVTKQuickItem::geometryChanged(newGeometry, oldGeometry); - mitk::BaseRenderer::GetInstance(this->GetRenderWindow())->GetCameraController()->Fit(); -} - -QmlMitkRenderWindowItem::~QmlMitkRenderWindowItem() -{ - this->Destroy(); -} - -vtkRenderWindow* QmlMitkRenderWindowItem::GetVtkRenderWindow() -{ - return QVTKQuickItem::GetRenderWindow(); -} - -vtkRenderWindowInteractor* QmlMitkRenderWindowItem::GetVtkRenderWindowInteractor() -{ - return QVTKQuickItem::GetInteractor(); -} - -void QmlMitkRenderWindowItem::QueueEvent(mitk::InteractionEvent::Pointer e) -{ - m_PendingEvents.push_back(e); -} - -// To be called while rendering is blocked (in Qml sync methods) -// so picking can access a "still image" and data to be rendered -// can be modified by interaction -void QmlMitkRenderWindowItem::processPendingEvents() -{ - for (auto e : m_PendingEvents) { - mitk::RenderWindowBase::HandleEvent(e); - } - m_PendingEvents.clear(); -} diff --git a/Modules/QmlItems/src/QmlMitkRenderingManager.cpp b/Modules/QmlItems/src/QmlMitkRenderingManager.cpp deleted file mode 100644 index f454fae159..0000000000 --- a/Modules/QmlItems/src/QmlMitkRenderingManager.cpp +++ /dev/null @@ -1,125 +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 "QmlMitkRenderingManager.h" -#include "QmlMitkRenderWindowItem.h" -#include "mitkGeometry3D.h" -#include "mitkBaseRenderer.h" -#include "mitkSliceNavigationController.h" -#include -#include - -QmlMitkRenderingManager -::QmlMitkRenderingManager() -:pendingTimerCallbacks(0) -{ -} - -QmlMitkRenderingManager -::~QmlMitkRenderingManager() -{ -} - -void -QmlMitkRenderingManager -::GenerateRenderingRequestEvent() -{ - QCoreApplication::postEvent( this, new QmlMitkRenderingRequestEvent ); -} - - -void -QmlMitkRenderingManager -::StartOrResetTimer() -{ - QTimer::singleShot(200, this, SLOT(TimerCallback())); - pendingTimerCallbacks++; -} - -void -QmlMitkRenderingManager -::TimerCallback() -{ - if(!--pendingTimerCallbacks) - { - this->ExecutePendingHighResRenderingRequest(); - } -} - -#include - -bool -QmlMitkRenderingManager -::event( QEvent *event ) -{ - if ( event->type() == (QEvent::Type) QmlMitkRenderingRequestEvent::RenderingRequest ) - { - // Directly process all pending rendering requests - //this->ExecutePendingRequests(); - this->MyUpdateExecutePendingRequests(); - - return true; - } - - return false; -} - -#include "QVTKQuickItem.h" - -void QmlMitkRenderingManager::MyUpdateExecutePendingRequests() -{ - m_UpdatePending = false; - - // Satisfy all pending update requests - RenderWindowList::iterator it; - int i = 0; - for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it, ++i ) - { - if ( it->second == RENDERING_REQUESTED ) - { - vtkRenderWindow* renderWindow = it->first; - - // If the renderWindow is not valid, we do not want to inadvertantly create - // an entry in the m_RenderWindowList map. It is possible if the user is - // regularly calling AddRenderer and RemoveRenderer for a rendering update - // to come into this method with a renderWindow pointer that is valid in the - // sense that the window does exist within the application, but that - // renderWindow has been temporarily removed from this RenderingManager for - // performance reasons. - if (m_RenderWindowList.find( renderWindow ) == m_RenderWindowList.end()) - { - continue; - } - - // Erase potentially pending requests for this window - m_RenderWindowList[renderWindow] = RENDERING_INACTIVE; - - m_UpdatePending = false; - - // Immediately repaint this window (implementation platform specific) - // If the size is 0 it crahses - int *size = renderWindow->GetSize(); - if ( 0 != size[0] && 0 != size[1] ) - { - QmlMitkRenderWindowItem* qqi = QmlMitkRenderWindowItem::GetInstanceForVTKRenderWindow( renderWindow ); - if (qqi) - { - qqi->update(); - } - } - } - } -} diff --git a/Modules/QmlItems/src/QmlMitkRenderingManagerFactory.cpp b/Modules/QmlItems/src/QmlMitkRenderingManagerFactory.cpp deleted file mode 100644 index 2ad254f1d6..0000000000 --- a/Modules/QmlItems/src/QmlMitkRenderingManagerFactory.cpp +++ /dev/null @@ -1,37 +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 "QmlMitkRenderingManagerFactory.h" -#include "QmlMitkRenderingManager.h" - -QmlMitkRenderingManagerFactory -::QmlMitkRenderingManagerFactory() -{ - mitk::RenderingManager::SetFactory( this ); -} - -QmlMitkRenderingManagerFactory -::~QmlMitkRenderingManagerFactory() -{ -} - -mitk::RenderingManager::Pointer -QmlMitkRenderingManagerFactory -::CreateRenderingManager() const -{ - QmlMitkRenderingManager::Pointer specificSmartPtr = QmlMitkRenderingManager::New(); - return specificSmartPtr.GetPointer(); -} diff --git a/Modules/QmlItems/src/QmlMitkSliderLevelWindowItem.cpp b/Modules/QmlItems/src/QmlMitkSliderLevelWindowItem.cpp deleted file mode 100644 index 35b715a169..0000000000 --- a/Modules/QmlItems/src/QmlMitkSliderLevelWindowItem.cpp +++ /dev/null @@ -1,571 +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 - -#include -#include -#include -#include -#include - -#include -#include - -#include - -QmlMitkSliderLevelWindowItem* QmlMitkSliderLevelWindowItem::instance = nullptr; -mitk::DataStorage::Pointer QmlMitkSliderLevelWindowItem::storage = nullptr; - -QmlMitkSliderLevelWindowItem::QmlMitkSliderLevelWindowItem( QQuickPaintedItem * parent ) -: QQuickPaintedItem(parent) -{ - m_Manager = mitk::LevelWindowManager::New(); - m_Manager->SetDataStorage(QmlMitkSliderLevelWindowItem::storage); - - itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); - command->SetCallbackFunction(this, &QmlMitkSliderLevelWindowItem::OnPropertyModified); - m_ObserverTag = m_Manager->AddObserver(itk::ModifiedEvent(), command); - m_IsObserverTagSet = true; - - setAcceptedMouseButtons(Qt::AllButtons); - setAcceptHoverEvents(true); - setAntialiasing(true); - - m_Resize = false; - m_Bottom = false; - m_CtrlPressed = false; - m_MouseDown = false; - m_ScaleVisible = true; - - this->setEnabled(false); - - update(); -} - -QmlMitkSliderLevelWindowItem::~QmlMitkSliderLevelWindowItem() -{ - if ( m_IsObserverTagSet) - { - m_Manager->RemoveObserver(m_ObserverTag); - m_IsObserverTagSet = false; - } -} - -void QmlMitkSliderLevelWindowItem::setLevelWindowManager(mitk::LevelWindowManager* levelWindowManager) -{ - if ( m_IsObserverTagSet) - { - m_Manager->RemoveObserver(m_ObserverTag); - m_IsObserverTagSet = false; - } - m_Manager = levelWindowManager; - if ( m_Manager.IsNotNull() ) - { - itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); - command->SetCallbackFunction(this, &QmlMitkSliderLevelWindowItem::OnPropertyModified); - m_ObserverTag = m_Manager->AddObserver(itk::ModifiedEvent(), command); - m_IsObserverTagSet = true; - } -} - -void QmlMitkSliderLevelWindowItem::OnPropertyModified(const itk::EventObject& ) -{ - try - { - m_LevelWindow = m_Manager->GetLevelWindow(); - - this->m_Level = (int)m_LevelWindow.GetLevel(); - this->m_Window = (int)m_LevelWindow.GetWindow(); - this->setEnabled(true); - - emit this->sync(); - update(); - } - catch(...) - { - this->setEnabled(false); - } - - QQuickPaintedItem::update(); -} - -bool QmlMitkSliderLevelWindowItem::isEnabled() -{ - return this->m_Enabled; -} - -void QmlMitkSliderLevelWindowItem::setEnabled(bool enable) -{ - this->m_Enabled = enable; - emit this->enabledChanged(); -} - -int QmlMitkSliderLevelWindowItem::fontSize() const -{ - return this->m_FontSize; -} - -void QmlMitkSliderLevelWindowItem::setFontSize(const int &fontSize) -{ - this->m_FontSize = fontSize; - this->m_Font.setPointSize(fontSize); -} - -QColor QmlMitkSliderLevelWindowItem::fontColor() const -{ - return this->m_FontColor; -} - -void QmlMitkSliderLevelWindowItem::setFontColor(const QColor &color) -{ - this->m_FontColor = color; -} - -QColor QmlMitkSliderLevelWindowItem::color() const -{ - return this->m_Color; -} - -void QmlMitkSliderLevelWindowItem::setColor(const QColor &color) -{ - this->m_Color = color; -} - -QColor QmlMitkSliderLevelWindowItem::borderColor() const -{ - return this->m_BorderColor; -} - -void QmlMitkSliderLevelWindowItem::setBorderColor(const QColor &color) -{ - this->m_BorderColor = color; -} - -void QmlMitkSliderLevelWindowItem::setLevel(int level) -{ - - if(level != m_LevelWindow.GetLevel()) - { - m_LevelWindow.SetLevelWindow(level, m_LevelWindow.GetWindow()); - m_Manager->SetLevelWindow(m_LevelWindow); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - - this->m_Level = level; -} - -int QmlMitkSliderLevelWindowItem::getLevel() -{ - return this->m_Level; -} - -void QmlMitkSliderLevelWindowItem::setWindow(int window) -{ - - if(window != m_LevelWindow.GetWindow()) - { - m_LevelWindow.SetLevelWindow(m_LevelWindow.GetLevel(), window); - m_Manager->SetLevelWindow(m_LevelWindow); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - - this->m_Window = window; -} - -int QmlMitkSliderLevelWindowItem::getWindow() -{ - return this->m_Window; -} - -void QmlMitkSliderLevelWindowItem::paint( QPainter* painter ) -{ - if(!this->m_Enabled) - return; - - m_MoveHeight = boundingRect().height() - 55; - - painter->setFont( m_Font ); - painter->setPen(this->m_BorderColor); - - painter->setBrush(this->m_Color); - painter->drawRoundedRect(m_Rect, 3, 3); - - painter->setPen(this->m_FontColor); - - float mr = m_LevelWindow.GetRange(); - - if ( mr < 1 ) - mr = 1; - - float fact = (float) m_MoveHeight / mr; - - //begin draw scale - if (m_ScaleVisible) - { - int minRange = (int)m_LevelWindow.GetRangeMin(); - int maxRange = (int)m_LevelWindow.GetRangeMax(); - int yValue = m_MoveHeight + (int)(minRange*fact); - QString s = " 0"; - if (minRange <= 0 && maxRange >= 0) - { - painter->drawLine( 5, yValue , 15, yValue); - painter->drawText( 21, yValue + 3, s ); - } - - int count = 1; - int k = 5; - bool enoughSpace = false; - bool enoughSpace2 = false; - - double dStepSize = pow(10,floor(log10(mr/100))+1); - - for(int i = m_MoveHeight + (int)(minRange*fact); i < m_MoveHeight;)//negative - { - if (-count*dStepSize < minRange) - break; - yValue = m_MoveHeight + (int)((minRange + count*dStepSize)*fact); - - s = QString::number(-count*dStepSize); - if (count % k && ((dStepSize*fact) > 2.5)) - { - painter->drawLine( 8, yValue, 12, yValue); - enoughSpace = true; - } - else if (!(count % k)) - { - if ((k*dStepSize*fact) > 7) - { - painter->drawLine( 5, yValue, 15, yValue); - painter->drawText( 21, yValue + 3, s ); - enoughSpace2 = true; - } - else - { - k += 5; - } - } - if (enoughSpace) - { - i=yValue; - count++; - } - else if (enoughSpace2) - { - i=yValue; - count += k; - } - else - { - i=yValue; - count = k; - } - } - count = 1; - k = 5; - enoughSpace = false; - enoughSpace2 = false; - - for(int i = m_MoveHeight + (int)(minRange*fact); i >= 0;) - { - if (count*dStepSize > maxRange) - break; - yValue = m_MoveHeight + (int)((minRange - count*dStepSize)*fact); - - s = QString::number(count*dStepSize); - if(count % k && ((dStepSize*fact) > 2.5)) - { - if (!(minRange > 0 && (count*dStepSize) < minRange)) - painter->drawLine( 8, yValue, 12, yValue); - enoughSpace = true; - } - else if (!(count % k)) - { - if ((k*dStepSize*fact) > 7) - { - if (!(minRange > 0 && (count*dStepSize) < minRange)) - { - painter->drawLine( 5, yValue, 15, yValue); - painter->drawText( 21, yValue + 3, s ); - } - enoughSpace2 = true; - } - else - { - k += 5; - } - } - if (enoughSpace) - { - i=yValue; - count++; - } - else if (enoughSpace2) - { - i=yValue; - count += k; - } - else - { - i=yValue; - count = k; - } - } - } -} - -void QmlMitkSliderLevelWindowItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - update(); - QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry); -} - -void QmlMitkSliderLevelWindowItem::hoverMoveEvent(QHoverEvent *mouseEvent) -{ - if ( mouseEvent->pos().y() >= 0 - && mouseEvent->pos().y() <= (m_Rect.topLeft().y() + 3) ) - { - setCursor(Qt::SizeVerCursor); - m_UpperBound.setRect(m_Rect.topLeft().x(), m_Rect.topLeft().y() - 3, 17, 7); - //this->setToolTip("Ctrl + left click to change only upper bound"); - m_Resize = true; - } - else if ( mouseEvent->pos().y() >= (m_Rect.bottomLeft().y() - 3) ) - { - setCursor(Qt::SizeVerCursor); - m_LowerBound.setRect(m_Rect.bottomLeft().x(), m_Rect.bottomLeft().y() - 3, 17, 7); - //this->setToolTip("Ctrl + left click to change only lower bound"); - m_Resize = true; - m_Bottom = true; - } - else - { - setCursor(Qt::ArrowCursor); - //this->setToolTip("Left click and mouse move to adjust the slider"); - m_Resize = false; - m_Bottom = false; - } -} -/** - * - */ -void QmlMitkSliderLevelWindowItem::mouseMoveEvent( QMouseEvent* mouseEvent ) -{ - if(!mouseEvent && !m_MouseDown) - return; - if ( m_LevelWindow.IsFixed() ) - return; - - - float fact = (float) m_MoveHeight / m_LevelWindow.GetRange(); - - if ( m_Leftbutton ) - { - if (m_Resize && !m_CtrlPressed) - { - double diff = (mouseEvent->pos().y()) / fact; - diff -= (m_StartPos.y()) / fact; - m_StartPos = mouseEvent->pos(); - - if (diff == 0) return; - float value; - if (m_Bottom) - value = m_LevelWindow.GetWindow() + ( ( 2 * diff ) ); - else - value = m_LevelWindow.GetWindow() - ( ( 2 * diff ) ); - - if ( value < 0 ) - value = 0; - - m_LevelWindow.SetLevelWindow( m_LevelWindow.GetLevel(), value ); - } - else if(m_Resize && m_CtrlPressed) - { - if (!m_Bottom) - { - double diff = (mouseEvent->pos().y()) / fact; - diff -= (m_StartPos.y()) / fact; - m_StartPos = mouseEvent->pos(); - - if (diff == 0) return; - float value; - - value = m_LevelWindow.GetWindow() - ( ( diff ) ); - - if ( value < 0 ) - value = 0; - float oldWindow; - float oldLevel; - float newLevel; - oldWindow = m_LevelWindow.GetWindow(); - oldLevel = m_LevelWindow.GetLevel(); - newLevel = oldLevel + (value - oldWindow)/2; - if (!((newLevel + value/2) > m_LevelWindow.GetRangeMax())) - m_LevelWindow.SetLevelWindow( newLevel, value ); - } - else - { - double diff = (mouseEvent->pos().y()) / fact; - diff -= (m_StartPos.y()) / fact; - m_StartPos = mouseEvent->pos(); - - if (diff == 0) return; - float value; - - value = m_LevelWindow.GetWindow() + ( ( diff ) ); - - if ( value < 0 ) - value = 0; - float oldWindow; - float oldLevel; - float newLevel; - oldWindow = m_LevelWindow.GetWindow(); - oldLevel = m_LevelWindow.GetLevel(); - newLevel = oldLevel - (value - oldWindow)/2; - if (!((newLevel - value/2) < m_LevelWindow.GetRangeMin())) - m_LevelWindow.SetLevelWindow( newLevel, value ); - } - } - else - { - const float minv = m_LevelWindow.GetRangeMin(); - - const float level = (m_MoveHeight - mouseEvent->pos().y()) / fact + minv; - - double diff = (mouseEvent->pos().x()) / fact; - diff -= (m_StartPos.x()) / fact; - m_StartPos = mouseEvent->pos(); - - float window; - if (m_Bottom) - window = m_LevelWindow.GetWindow() + ( ( 2 * diff ) ); - else - window = m_LevelWindow.GetWindow() - ( ( 2 * diff ) ); - - if ( window < 0 ) - window = 0; - - m_LevelWindow.SetLevelWindow( level, window ); - } - m_Manager->SetLevelWindow(m_LevelWindow); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - -} - -/** - * - */ -void QmlMitkSliderLevelWindowItem::mousePressEvent( QMouseEvent* mouseEvent ) { - if ( m_LevelWindow.IsFixed() ) - return; - m_MouseDown = true; - m_StartPos = mouseEvent->pos(); - - if ( mouseEvent->button() == Qt::LeftButton ) - { - if (mouseEvent->modifiers() == Qt::ControlModifier || mouseEvent->modifiers() == Qt::ShiftModifier) - { - m_CtrlPressed = true; - } - else - { - m_CtrlPressed = false; - } - m_Leftbutton = true; - } - else - m_Leftbutton = false; - - mouseMoveEvent( mouseEvent ); -} - -/** - * - */ -void QmlMitkSliderLevelWindowItem::mouseReleaseEvent( QMouseEvent* ) -{ - if ( m_LevelWindow.IsFixed() ) - return; - m_MouseDown = false; -} - -/** - * - */ -void QmlMitkSliderLevelWindowItem::update() -{ - - int rectWidth; - if(m_ScaleVisible) - { - rectWidth = 16; - } - else - { - rectWidth = 26; - } - - float mr = m_LevelWindow.GetRange(); - - if ( mr < 1 ) - mr = 1; - - float fact = (float) m_MoveHeight / mr; - - float rectHeight = m_LevelWindow.GetWindow() * fact; - - if ( rectHeight < 15 ) - rectHeight = 15; - - if ( m_LevelWindow.GetLowerWindowBound() < 0 ) - m_Rect.setRect( 2, (int) (m_MoveHeight - (m_LevelWindow.GetUpperWindowBound() - m_LevelWindow.GetRangeMin()) * fact) , rectWidth, (int) rectHeight ); - else - m_Rect.setRect( 2, (int) (m_MoveHeight - (m_LevelWindow.GetUpperWindowBound() - m_LevelWindow.GetRangeMin()) * fact), rectWidth, (int) rectHeight ); - - QQuickPaintedItem::update(); -} - - -void QmlMitkSliderLevelWindowItem::hideScale() -{ - m_ScaleVisible = false; - update(); -} - -void QmlMitkSliderLevelWindowItem::showScale() -{ - m_ScaleVisible = true; - update(); -} - -void QmlMitkSliderLevelWindowItem::setDataStorage(mitk::DataStorage* ds) -{ - m_Manager->SetDataStorage(ds); -} - -mitk::LevelWindowManager* QmlMitkSliderLevelWindowItem::GetManager() -{ - return m_Manager.GetPointer(); -} - -void QmlMitkSliderLevelWindowItem::create(QQmlEngine &, mitk::DataStorage::Pointer storage) -{ - qmlRegisterType("Mitk.Views", 1, 0, "LevelWindow"); - - QmlMitkSliderLevelWindowItem::storage = storage; -} diff --git a/Modules/QmlItems/src/QmlMitkSliderNavigatorItem.cpp b/Modules/QmlItems/src/QmlMitkSliderNavigatorItem.cpp deleted file mode 100644 index ace69f8e41..0000000000 --- a/Modules/QmlItems/src/QmlMitkSliderNavigatorItem.cpp +++ /dev/null @@ -1,197 +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 "QmlMitkSliderNavigatorItem.h" - -QmlMitkSliderNavigatorItem::QmlMitkSliderNavigatorItem(QQuickItem* parent) - : QQuickItem(parent) -{ - - // this avoids trying to use m_Stepper until it is set to something != nullptr - // (additionally to the avoiding recursions during refetching) - m_InRefetch = true; - m_HasLabels = false; - m_HasLabelUnit = true; - m_InverseDirection = false; -} - -void QmlMitkSliderNavigatorItem::setMin(double min) -{ - this->m_Min = min; -} - -void QmlMitkSliderNavigatorItem::setMax(double max) -{ - this->m_Max = max; -} - -void QmlMitkSliderNavigatorItem::setValue(double value) -{ - this->m_Value = value; - - if(!m_InRefetch) - { - if (m_InverseDirection) - { - m_Stepper->SetPos( m_Stepper->GetSteps()-1-value ); - } - else - { - m_Stepper->SetPos( value ); - } - this->Refetch(); - } -} - -double QmlMitkSliderNavigatorItem::getMax() -{ - return this->m_Max; -} - -double QmlMitkSliderNavigatorItem::getMin() -{ - return this->m_Min; -} - -double QmlMitkSliderNavigatorItem::getValue() -{ - return this->m_Value; -} - -void QmlMitkSliderNavigatorItem::Refetch() -{ - if (!m_InRefetch) - { - m_InRefetch = true; - - this->m_Min = 0; - this->m_Max = m_Stepper->GetSteps()-1; - - if(m_InverseDirection) - this->m_Value = m_Stepper->GetSteps()-1-m_Stepper->GetPos(); - else - this->m_Value = m_Stepper->GetPos(); - - m_InRefetch = false; - - emit this->sync(); - } -} - - -void QmlMitkSliderNavigatorItem::SetStepper( mitk::Stepper * stepper) -{ - m_Stepper = stepper; - - // this avoids trying to use m_Stepper until it is set to something != nullptr - // (additionally to the avoiding recursions during refetching) - m_InRefetch = (stepper==nullptr); -} - -void QmlMitkSliderNavigatorItem::ShowLabels( bool show ) -{ - m_HasLabels = show; -} - -void QmlMitkSliderNavigatorItem::ShowLabelUnit( bool show ) -{ - m_HasLabelUnit = show; -} - -void QmlMitkSliderNavigatorItem::SetLabelValues( float min, float max ) -{ - m_MinValue = min; - m_MaxValue = max; -} - -void QmlMitkSliderNavigatorItem::SetLabelValuesValid( bool minValid, bool maxValid ) -{ - m_MinValueValid = minValid; - m_MaxValueValid = maxValid; -} - -void QmlMitkSliderNavigatorItem::SetLabelUnit( const char *unit ) -{ - m_LabelUnit = unit; -} - -QString QmlMitkSliderNavigatorItem::GetLabelUnit() -{ - return m_LabelUnit; -} - -QString QmlMitkSliderNavigatorItem::ClippedValueToString( float value ) -{ - if ( value < -10000000.0 ) - { - return "-INF"; - } - else if ( value > 10000000.0 ) - { - return "+INF"; - } - else - { - return QString::number( value, 'f', 2 ); - } -} - -QString QmlMitkSliderNavigatorItem::GetMinValueLabel() -{ - if ( m_MinValueValid ) - { - return this->ClippedValueToString( m_MinValue ); - } - else - { - return "N/A"; - } -} - -QString QmlMitkSliderNavigatorItem::GetMaxValueLabel() -{ - if ( m_MaxValueValid ) - { - return this->ClippedValueToString( m_MaxValue ); - } - else - { - return "N/A"; - } -} - -int QmlMitkSliderNavigatorItem::GetPos() -{ - return m_Stepper->GetPos(); -} - -void QmlMitkSliderNavigatorItem::SetPos(int val) -{ - if (!m_InRefetch) - { - m_Stepper->SetPos( val ); - } -} - -void QmlMitkSliderNavigatorItem::SetInverseDirection(bool inverseDirection) -{ - m_InverseDirection = inverseDirection; -} - -void QmlMitkSliderNavigatorItem::create() -{ - qmlRegisterType("Mitk.Views", 1, 0, "SliderNavigator"); -} diff --git a/Modules/QmlItems/src/QmlMitkStdMultiItem.cpp b/Modules/QmlItems/src/QmlMitkStdMultiItem.cpp deleted file mode 100644 index a8543c3bcf..0000000000 --- a/Modules/QmlItems/src/QmlMitkStdMultiItem.cpp +++ /dev/null @@ -1,160 +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 "QmlMitkStdMultiItem.h" -#include "QmlMitkRenderWindowItem.h" - -#include -#include -#include -#include -#include - -QmlMitkStdMultiItem* QmlMitkStdMultiItem::instance = nullptr; -mitk::DataStorage::Pointer QmlMitkStdMultiItem::storage = nullptr; - -QmlMitkStdMultiItem::QmlMitkStdMultiItem() -{ - instance = this; -} - -QmlMitkStdMultiItem::~QmlMitkStdMultiItem() -{ -} - -void QmlMitkStdMultiItem::registerViewerItem(QmlMitkRenderWindowItem *viewerItem) -{ - viewerItem->setupView(); - viewerItem->createPlaneNode(); - - switch (viewerItem->GetRenderer()->GetSliceNavigationController()->GetDefaultViewDirection()) - { - case mitk::SliceNavigationController::Axial: - this->m_viewerAxial = viewerItem; - break; - case mitk::SliceNavigationController::Frontal: - this->m_viewerFrontal = viewerItem; - break; - case mitk::SliceNavigationController::Sagittal: - this->m_viewerSagittal = viewerItem; - break; - default: - this->m_viewerOriginal = viewerItem; - } -} - -void QmlMitkStdMultiItem::init() -{ - if(QmlMitkStdMultiItem::storage.IsNull()) - QmlMitkStdMultiItem::storage = mitk::StandaloneDataStorage::New(); - - this->m_mouseMode = mitk::MouseModeSwitcher::New(); - this->m_mouseMode->SetInteractionScheme(mitk::MouseModeSwitcher::InteractionScheme::MITK); - - this->m_viewerAxial->SetDataStorage(QmlMitkStdMultiItem::storage); - this->m_viewerFrontal->SetDataStorage(QmlMitkStdMultiItem::storage); - this->m_viewerSagittal->SetDataStorage(QmlMitkStdMultiItem::storage); - this->m_viewerOriginal->SetDataStorage(QmlMitkStdMultiItem::storage); - - this->addPlanes(); - - mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(QmlMitkStdMultiItem::storage); -} - -void QmlMitkStdMultiItem::togglePlanes() -{ - bool toggle; - this->m_planeAxial->GetBoolProperty("visible", toggle); - - this->m_planeAxial->SetVisibility(!toggle); - this->m_planeFrontal->SetVisibility(!toggle); - this->m_planeSagittal->SetVisibility(!toggle); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmlMitkStdMultiItem::addPlanes() -{ - this->m_planeAxial = this->m_viewerAxial->GetRenderer()->GetCurrentWorldPlaneGeometryNode(); - this->m_planeFrontal = this->m_viewerFrontal->GetRenderer()->GetCurrentWorldPlaneGeometryNode(); - this->m_planeSagittal = this->m_viewerSagittal->GetRenderer()->GetCurrentWorldPlaneGeometryNode(); - - QmlMitkStdMultiItem::storage->Add(this->m_planeAxial); - QmlMitkStdMultiItem::storage->Add(this->m_planeFrontal); - QmlMitkStdMultiItem::storage->Add(this->m_planeSagittal); -} - -void QmlMitkStdMultiItem::moveCrossToPosition(const mitk::Point3D& newPosition) -{ - this->m_viewerAxial->GetSliceNavigationController()->SelectSliceByPoint(newPosition); - this->m_viewerFrontal->GetSliceNavigationController()->SelectSliceByPoint(newPosition); - this->m_viewerSagittal->GetSliceNavigationController()->SelectSliceByPoint(newPosition); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -const mitk::Point3D QmlMitkStdMultiItem::getCrossPosition() const -{ - const mitk::PlaneGeometry *plane1 = this->m_viewerAxial->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - const mitk::PlaneGeometry *plane2 = this->m_viewerFrontal->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - const mitk::PlaneGeometry *plane3 = this->m_viewerSagittal->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - - mitk::Line3D line; - if ( (plane1 != nullptr) && (plane2 != nullptr) - && (plane1->IntersectionLine( plane2, line )) ) - { - mitk::Point3D point; - if ( (plane3 != nullptr) - && (plane3->IntersectionPoint( line, point )) ) - { - return point; - } - } - // TODO BUG POSITIONTRACKER; - mitk::Point3D p; - return p; - //return m_LastLeftClickPositionSupplier->GetCurrentPoint(); -} - - -QmlMitkRenderWindowItem* QmlMitkStdMultiItem::getViewerAxial() -{ - return this->m_viewerAxial; -} - -QmlMitkRenderWindowItem* QmlMitkStdMultiItem::getViewerCoronal() -{ - return this->m_viewerFrontal; -} - -QmlMitkRenderWindowItem* QmlMitkStdMultiItem::getViewerSagittal() -{ - return this->m_viewerSagittal; -} - -QmlMitkRenderWindowItem* QmlMitkStdMultiItem::getViewerOriginal() -{ - return this->m_viewerOriginal; -} - -void QmlMitkStdMultiItem::create(QQmlEngine &engine, mitk::DataStorage::Pointer storage) -{ - QmlMitkStdMultiItem::storage = storage; - - qmlRegisterType("Mitk.Views", 1, 0, "MultiItem"); - qmlRegisterType("Mitk.Views", 1, 0, "ViewItem"); - QQmlComponent component(&engine, QUrl("qrc:/views/MitkStdMultiItem.qml")); -} diff --git a/Modules/QmlItems/src/QmlMitkTransferFunctionCanvas.cpp b/Modules/QmlItems/src/QmlMitkTransferFunctionCanvas.cpp deleted file mode 100644 index 6cbf0da511..0000000000 --- a/Modules/QmlItems/src/QmlMitkTransferFunctionCanvas.cpp +++ /dev/null @@ -1,216 +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 "QmlMitkTransferFunctionCanvas.h" - -#include -#include - -QmlMitkTransferFunctionCanvas::QmlMitkTransferFunctionCanvas(QQuickPaintedItem * parent) -: QQuickPaintedItem(parent), -m_GrabbedHandle(-1), -m_Lower(0.0), -m_Upper(1.0), -m_Min(0.0), -m_Max(1.0), -m_Histogram(nullptr), -m_ImmediateUpdate(false), -m_Range(0.0f), -m_LineEditAvailable(false) -{ - setAcceptedMouseButtons(Qt::AllButtons); - setAcceptHoverEvents(true); - setAntialiasing(true); -} - - -std::pair QmlMitkTransferFunctionCanvas::FunctionToCanvas(std::pair functionPoint) -{ - return std::make_pair( - static_cast(((functionPoint.first - m_Lower) / (m_Upper - m_Lower) * boundingRect().width()) + boundingRect().x()), - static_cast((boundingRect().height() * (1 - functionPoint.second)) + boundingRect().y())); -} - -std::pair QmlMitkTransferFunctionCanvas::CanvasToFunction(std::pair canvasPoint) -{ - return std::make_pair( - (canvasPoint.first - boundingRect().x()) * (m_Upper - m_Lower) / boundingRect().width() + m_Lower, - 1.0 - static_cast((canvasPoint.second - boundingRect().y()) / boundingRect().height())); -} - -void QmlMitkTransferFunctionCanvas::mouseDoubleClickEvent(QMouseEvent* mouseEvent) -{ - int nearHandle = GetNearHandle(mouseEvent->pos().x(), mouseEvent->pos().y()); - if (nearHandle != -1) - { - this->DoubleClickOnHandle(nearHandle); - } -} - -/** returns index of a near handle or -1 if none is near - */ -int QmlMitkTransferFunctionCanvas::GetNearHandle(int, int, unsigned int) -{ - return -1; -} - - -void QmlMitkTransferFunctionCanvas::mousePressEvent(QMouseEvent* mouseEvent) -{ - forceActiveFocus(); - - if(mouseEvent->button() == Qt::RightButton) - mouseEvent->setAccepted(false); - - 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(); - } - - update(); -} - -void QmlMitkTransferFunctionCanvas::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); - - update(); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } -} - -void QmlMitkTransferFunctionCanvas::mouseReleaseEvent(QMouseEvent*) -{ - update(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmlMitkTransferFunctionCanvas::PaintHistogram(QPainter* p) -{ - if(m_Histogram) - { - p->save(); - - p->setPen(Qt::gray); - - int displayWidth = boundingRect().width(); - int displayHeight = boundingRect().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 QmlMitkTransferFunctionCanvas::keyPressEvent(QKeyEvent * e) -{ - if( m_GrabbedHandle == -1) - return; - - switch(e->key()) - { - case Qt::Key_Backspace: - 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 QmlMitkTransferFunctionCanvas::SetImmediateUpdate(bool state) -{ - m_ImmediateUpdate = state; -} diff --git a/Modules/QmlItems/src/QmlMitkTransferFunctionItem.cpp b/Modules/QmlItems/src/QmlMitkTransferFunctionItem.cpp deleted file mode 100644 index d2753c32c3..0000000000 --- a/Modules/QmlItems/src/QmlMitkTransferFunctionItem.cpp +++ /dev/null @@ -1,241 +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 "QmlMitkTransferFunctionItem.h" - -#include - -QmlMitkTransferFunctionItem* QmlMitkTransferFunctionItem::instance = nullptr; - -QmlMitkTransferFunctionItem::QmlMitkTransferFunctionItem(QQuickItem* parent): -QQuickItem(parent) -{ - instance = this; - - this->m_Max = 0; - this->m_Min = 0; - - this->m_CurrentMin = 0; - this->m_CurrentMax = 0; - - this->setEnabled(false); - - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::AllButtons); -} - -QmlMitkTransferFunctionItem::~QmlMitkTransferFunctionItem() -{ -} - -void QmlMitkTransferFunctionItem::wheelEvent(QWheelEvent *event) -{ - int fact = -event->delta() * 0.15; - - if(event->orientation() == Qt::Horizontal) - { - int lower = this->m_CurrentMin + fact; - int upper = this->m_CurrentMax + fact; - - if(lower < this->m_Min ) - { - this->m_CurrentMin = this->m_Min; - } - else if (upper > this->m_Max) - { - this->m_CurrentMax = this->m_Max; - } - else - { - this->m_CurrentMin = lower; - this->m_CurrentMax = upper; - } - emit this->sync(); - - UpdateRanges(); - } -} - -void QmlMitkTransferFunctionItem::SetDataNode(mitk::DataNode* node, const mitk::BaseRenderer* renderer) -{ - if (node) - { - tfpToChange = dynamic_cast(node->GetProperty("TransferFunction", renderer)); - - if(!tfpToChange) - { - if (! dynamic_cast(node->GetData())) - { - MITK_WARN << "QmlMitkTransferFunctionItem::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]; - - this->setMin(h->GetMin()); - this->setMax(h->GetMax()); - - this->m_CurrentMin = h->GetMin(); - this->m_CurrentMax = h->GetMax(); - - this->m_ColorItem->SetHistogram( h ); - this->m_OpacityItem->SetHistogram( h ); - // m_ColorTransferFunctionCanvas->SetHistogram( h ); - - emit this->sync(); - } - - OnUpdateCanvas(); - - return; - } -} - -void QmlMitkTransferFunctionItem::OnUpdateCanvas() -{ - - if(tfpToChange.IsNull()) - return; - - mitk::TransferFunction::Pointer tf = tfpToChange->GetValue(); - - if(tf.IsNull()) - return; - - this->m_OpacityItem->SetPiecewiseFunction( tf->GetScalarOpacityFunction() ); - //m_GradientOpacityCanvas->SetPiecewiseFunction( tf->GetGradientOpacityFunction() ); - this->m_ColorItem->SetColorTransferFunction( tf->GetColorTransferFunction() ); - - UpdateRanges(); - - this->m_ColorItem->update(); - //m_GradientOpacityCanvas->update(); - this->m_OpacityItem->update(); -} - -void QmlMitkTransferFunctionItem::setColorItem(QmlMitkColorTransferFunctionCanvas *item) -{ - this->m_ColorItem = item; -} - -QmlMitkColorTransferFunctionCanvas* QmlMitkTransferFunctionItem::getColorItem() -{ - return this->m_ColorItem; -} - -void QmlMitkTransferFunctionItem::setOpactityItem(QmlMitkPiecewiseFunctionCanvas *item) -{ - this->m_OpacityItem = item; -} - -QmlMitkPiecewiseFunctionCanvas* QmlMitkTransferFunctionItem::getOpacityItem() -{ - return this->m_OpacityItem; -} - -void QmlMitkTransferFunctionItem::UpdateRanges() -{ - int lower = this->m_CurrentMin; - int upper = this->m_CurrentMax; - - this->m_OpacityItem->SetMin(lower); - this->m_OpacityItem->SetMax(upper); - - // m_GradientOpacityCanvas->SetMin(lower); - // m_GradientOpacityCanvas->SetMax(upper); - - this->m_ColorItem->SetMin(lower); - this->m_ColorItem->SetMax(upper); - - this->m_OpacityItem->update(); - this->m_ColorItem->update(); -} - - -void QmlMitkTransferFunctionItem::OnSpanChanged(int, int) -{ - UpdateRanges(); - - //m_GradientOpacityCanvas->update(); - this->m_OpacityItem->update(); - this->m_ColorItem->update(); -} - -void QmlMitkTransferFunctionItem::OnResetSlider() -{ - this->m_CurrentMin = this->m_Min; - this->m_CurrentMax = this->m_Max; - - UpdateRanges(); -} - -void QmlMitkTransferFunctionItem::setMin(double min) -{ - this->m_Min = min; - emit this->minChanged(); -} - -void QmlMitkTransferFunctionItem::setMax(double max) -{ - this->m_Max = max; - emit this->maxChanged(); -} - -void QmlMitkTransferFunctionItem::setCurrentMin(double currentMin) -{ - this->m_CurrentMin = currentMin; - UpdateRanges(); -} - -void QmlMitkTransferFunctionItem::setCurrentMax(double currentMax) -{ - this->m_CurrentMax = currentMax; - UpdateRanges(); -} - -double QmlMitkTransferFunctionItem::getMin() -{ - return this->m_Min; -} - -double QmlMitkTransferFunctionItem::getMax() -{ - return this->m_Max; -} - -double QmlMitkTransferFunctionItem::getCurrentMin() -{ - return this->m_CurrentMin; -} - -double QmlMitkTransferFunctionItem::getCurrentMax() -{ - return this->m_CurrentMax; -} - -void QmlMitkTransferFunctionItem::create() -{ - QmlMitkPiecewiseFunctionCanvas::create(); - QmlMitkColorTransferFunctionCanvas::create(); - qmlRegisterType("Mitk.Views", 1, 0, "TransferItem"); -}