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
qSlicerCLIModuleUIHelper.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 __qSlicerCLIModuleUIHelper_h
22#define __qSlicerCLIModuleUIHelper_h
23
24// Qt includes
25#include <QButtonGroup>
26#include <QObject>
27#include <QWidget>
28
29// CTK includes
30#include <ctkPimpl.h>
31
33#include <ModuleDescription.h>
34
35#include "qSlicerBaseQTCLIExport.h"
36
37class QWidget;
40class qSlicerCLIModuleUIHelperPrivate;
41
42//-----------------------------------------------------------------------------
43class Q_SLICER_BASE_QTCLI_EXPORT qSlicerWidgetValueWrapper: public QObject
44{
45 Q_OBJECT
46public:
47 qSlicerWidgetValueWrapper(const QString& _name, const QString& _label, QObject* parent);
49 virtual QVariant value() = 0;
50 QString label(){ return this->Label; }
51 QString name(){ return this->Name; }
52
53 virtual void setValue(const QString& _value) = 0;
54
55 static QString toString(const QString& _value)
56 {
57 return _value;
58 }
59
60 static bool toBool(const QString& _value)
61 {
62 return (_value.compare("true", Qt::CaseInsensitive) == 0);
63 }
64
65 static int toInt(const QString& _value)
66 {
67 return _value.toInt();
68 }
69
70 static double toDouble(const QString& _value)
71 {
72 return _value.toDouble();
73 }
74
75signals:
77
78protected:
79 QString Name;
80 QString Label;
81};
82
83//-----------------------------------------------------------------------------
84class Q_SLICER_BASE_QTCLI_EXPORT ButtonGroupWidgetWrapper: public QWidget
85{
86 Q_OBJECT
87public:
88 ButtonGroupWidgetWrapper(QWidget* parentWidget = nullptr);
89
90 QButtonGroup* buttonGroup()const;
91 QString checkedValue();
92
93 void setCheckedValue(const QString& value);
94
95signals:
97
98private:
99 QButtonGroup* ButtonGroup;
100};
101
102//-----------------------------------------------------------------------------
103class Q_SLICER_BASE_QTCLI_EXPORT qSlicerCLIModuleUIHelper: public QObject
104{
105 Q_OBJECT
106public:
107
110
115 QWidget* createTagWidget(const ModuleParameter& moduleParameter);
116
120
122 void updateUi(vtkMRMLCommandLineModuleNode* commandLineModuleNode);
123
126 const QString& name,
127 const QVariant& value);
128 void setValue(const QString& name, const QVariant& type);
129
130signals:
131 void valueChanged(const QString& tag, const QVariant& value);
132
133protected slots:
135
136protected:
137 QScopedPointer<qSlicerCLIModuleUIHelperPrivate> d_ptr;
138
139private:
140 Q_DECLARE_PRIVATE(qSlicerCLIModuleUIHelper);
141 Q_DISABLE_COPY(qSlicerCLIModuleUIHelper);
142};
143
144#endif
ButtonGroupWidgetWrapper(QWidget *parentWidget=nullptr)
void setCheckedValue(const QString &value)
QButtonGroup * buttonGroup() const
QWidget * createTagWidget(const ModuleParameter &moduleParameter)
void setCommandLineModuleParameter(vtkMRMLCommandLineModuleNode *node, const QString &name, const QVariant &value)
Set parameter to the command line module node.
~qSlicerCLIModuleUIHelper() override
void updateMRMLCommandLineModuleNode(vtkMRMLCommandLineModuleNode *commandLineModuleNode)
Update commandLineModuleNode properties using value entered from the UI.
void valueChanged(const QString &tag, const QVariant &value)
void setValue(const QString &name, const QVariant &type)
QScopedPointer< qSlicerCLIModuleUIHelperPrivate > d_ptr
qSlicerCLIModuleUIHelper(qSlicerCLIModuleWidget *cliModuleWidget)
void updateUi(vtkMRMLCommandLineModuleNode *commandLineModuleNode)
Update user interface using the given commandLineModuleNode parameters.
virtual QVariant value()=0
static int toInt(const QString &_value)
~qSlicerWidgetValueWrapper() override
virtual void setValue(const QString &_value)=0
static double toDouble(const QString &_value)
qSlicerWidgetValueWrapper(const QString &_name, const QString &_label, QObject *parent)
static QString toString(const QString &_value)
static bool toBool(const QString &_value)
MRML node for representing the parameters allowing to run a command line interface module (CLI)....