Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qMRMLUtils.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Kitware Inc.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17 and was partially funded by NIH grant 3P41RR013218-12S1
18
19==============================================================================*/
20
21#ifndef __qMRMLUtils_h
22#define __qMRMLUtils_h
23
25#include <QString>
26#include <QVector>
27#include <QIcon>
28#include <QPixmap>
29
30#include "vtkIdList.h"
31#include "qMRMLWidgetsExport.h"
32
33class QMimeData;
34class QStyle;
35class vtkMRMLNode;
37class vtkTransform;
38class vtkMatrix4x4;
39class vtkMRMLScene;
40class vtkImageData;
41
42#define compare_double(x, y) (((x-y)<0.000001) && ((x-y)>-0.000001))
43
44class QMRML_WIDGETS_EXPORT qMRMLUtils : public QObject
45{
46 Q_OBJECT;
47public:
49 qMRMLUtils(QObject* parent = nullptr);
50 ~qMRMLUtils() override;
51
54 Q_INVOKABLE static void vtkMatrixToQVector(vtkMatrix4x4* matrix, QVector<double> & vector);
55
57 Q_INVOKABLE static void getTransformInCoordinateSystem(vtkMRMLNode* transformNode, bool global,
58 vtkTransform* transform);
59 Q_INVOKABLE static void getTransformInCoordinateSystem(vtkMRMLTransformNode* transformNode,
60 bool global, vtkTransform* transform);
61
63 Q_INVOKABLE static int countVisibleViewNode(vtkMRMLScene* scene);
64
66 Q_INVOKABLE static QPixmap createColorPixmap(QStyle * style, const QColor& color);
67
69 Q_INVOKABLE static bool vtkImageDataToQImage(vtkImageData* vtkimage, QImage& img);
70
72 Q_INVOKABLE static bool qImageToVtkImageData(const QImage& img, vtkImageData* vtkimage);
73
75 Q_INVOKABLE static void colorToQColor(const double *color, QColor &qcolor);
76
78 Q_INVOKABLE static void qColorToColor(const QColor &qcolor, double* color);
79
80 Q_INVOKABLE static void mimeDataToSubjectHierarchyItemIDs(const QMimeData* mimeData, vtkIdList* idList);
81
82private:
83 Q_DISABLE_COPY(qMRMLUtils);
84
85};
86
87#endif
~qMRMLUtils() override
static Q_INVOKABLE int countVisibleViewNode(vtkMRMLScene *scene)
Retrieve the number of visible view node associated with scene.
static Q_INVOKABLE bool qImageToVtkImageData(const QImage &img, vtkImageData *vtkimage)
Convert QImage to vtkImageData.
static Q_INVOKABLE void getTransformInCoordinateSystem(vtkMRMLTransformNode *transformNode, bool global, vtkTransform *transform)
static Q_INVOKABLE void qColorToColor(const QColor &qcolor, double *color)
Convert QColor to C++ RGB array.
static Q_INVOKABLE QPixmap createColorPixmap(QStyle *style, const QColor &color)
Create Icon using the given color.
qMRMLUtils(QObject *parent=nullptr)
static Q_INVOKABLE void mimeDataToSubjectHierarchyItemIDs(const QMimeData *mimeData, vtkIdList *idList)
static Q_INVOKABLE void vtkMatrixToQVector(vtkMatrix4x4 *matrix, QVector< double > &vector)
Convert a vtkMatrix to a QVector.
static Q_INVOKABLE void getTransformInCoordinateSystem(vtkMRMLNode *transformNode, bool global, vtkTransform *transform)
static Q_INVOKABLE bool vtkImageDataToQImage(vtkImageData *vtkimage, QImage &img)
Convert vtkImageData to QImage.
static Q_INVOKABLE void colorToQColor(const double *color, QColor &qcolor)
Convert C++ RGB array to QColor.
qMRMLUtils Self
Definition qMRMLUtils.h:48
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node for representing a transformation between this node space and a parent node space.