Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 
37 class QWidget;
40 class qSlicerCLIModuleUIHelperPrivate;
41 
42 //-----------------------------------------------------------------------------
43 class Q_SLICER_BASE_QTCLI_EXPORT qSlicerWidgetValueWrapper: public QObject
44 {
45  Q_OBJECT
46 public:
47  qSlicerWidgetValueWrapper(const QString& _name, const QString& _label, QObject* parent);
48  virtual ~qSlicerWidgetValueWrapper();
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 
75 signals:
76  void valueChanged();
77 
78 protected:
79  QString Name;
80  QString Label;
81 };
82 
83 //-----------------------------------------------------------------------------
84 class Q_SLICER_BASE_QTCLI_EXPORT ButtonGroupWidgetWrapper: public QWidget
85 {
86  Q_OBJECT
87 public:
88  ButtonGroupWidgetWrapper(QWidget* parentWidget = 0);
89 
90  QButtonGroup* buttonGroup()const;
91  QString checkedValue();
92 
93  void setCheckedValue(const QString& value);
94 
95 signals:
96  void valueChanged();
97 
98 private:
99  QButtonGroup* ButtonGroup;
100 };
101 
102 //-----------------------------------------------------------------------------
103 class Q_SLICER_BASE_QTCLI_EXPORT qSlicerCLIModuleUIHelper: public QObject
104 {
105  Q_OBJECT
106 public:
107 
109  virtual ~qSlicerCLIModuleUIHelper();
110 
115  QWidget* createTagWidget(const ModuleParameter& moduleParameter);
116 
119  void updateMRMLCommandLineModuleNode(vtkMRMLCommandLineModuleNode* commandLineModuleNode);
120 
122  void updateUi(vtkMRMLCommandLineModuleNode* commandLineModuleNode);
123 
125  void setCommandLineModuleParameter(vtkMRMLCommandLineModuleNode* node,
126  const QString& name,
127  const QVariant& value);
128  void setValue(const QString& name, const QVariant& type);
129 
130 signals:
131  void valueChanged(const QString& tag, const QVariant& value);
132 
133 protected slots:
134  void onValueChanged();
135 
136 protected:
137  QScopedPointer<qSlicerCLIModuleUIHelperPrivate> d_ptr;
138 
139 private:
140  Q_DECLARE_PRIVATE(qSlicerCLIModuleUIHelper);
141  Q_DISABLE_COPY(qSlicerCLIModuleUIHelper);
142 };
143 
144 #endif
static int toInt(const QString &_value)
QScopedPointer< qSlicerCLIModuleUIHelperPrivate > d_ptr
static QString toString(const QString &_value)
static double toDouble(const QString &_value)
static bool toBool(const QString &_value)
MRML node for representing the parameters allowing to run a command line interface module (CLI)...