CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkCmdLineModuleFrontend.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  Library: CTK
4 
5  Copyright (c) German Cancer Research Center,
6  Division of Medical and Biological Informatics
7 
8  Licensed under the Apache License, Version 2.0 (the "License");
9  you may not use this file except in compliance with the License.
10  You may obtain a copy of the License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14  Unless required by applicable law or agreed to in writing, software
15  distributed under the License is distributed on an "AS IS" BASIS,
16  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  See the License for the specific language governing permissions and
18  limitations under the License.
19 
20 =============================================================================*/
21 
22 #ifndef CTKCMDLINEMODULEFRONTEND_H
23 #define CTKCMDLINEMODULEFRONTEND_H
24 
25 #include "ctkCommandLineModulesCoreExport.h"
26 
27 #include <QObject>
28 
29 template<class K, class V> class QHash;
30 class QUrl;
31 
36 struct ctkCmdLineModuleFrontendPrivate;
37 
52 class CTK_CMDLINEMODULECORE_EXPORT ctkCmdLineModuleFrontend : public QObject
53 {
54  Q_OBJECT
55  Q_ENUMS(ParamterValueRole)
56 
57 public:
58 
60 
73  LocalResourceRole = 0,
74 
80  DisplayRole = 1,
81 
90  UserRole = 8
91  };
92 
95  Input = 0x01,
97  Output = 0x02,
99  All = Input | Output
100  };
101  Q_DECLARE_FLAGS(ParameterFilters, ParameterFilter)
102 
104 
114  virtual QObject* guiHandle() const = 0;
115 
123  virtual QVariant value(const QString& parameter,
124  int role = LocalResourceRole) const = 0;
125 
135  virtual void setValue(const QString& parameter, const QVariant& value,
136  int role = DisplayRole) = 0;
137 
148  virtual ctkCmdLineModuleFuture future() const;
149 
159  QUrl location() const;
160 
166  ctkCmdLineModuleReference moduleReference() const;
167 
171  virtual QList<QString> parameterNames() const;
172 
176  virtual QHash<QString,QVariant> values() const;
177 
181  virtual void setValues(const QHash<QString,QVariant>& values);
182 
188  bool isRunning() const;
189 
195  bool isPaused() const;
196 
197  // convenience methods
198 
208  const QString& type = QString(),
209  ParameterFilters filters = All);
210 
211  void resetValues();
212 
213 Q_SIGNALS:
214 
224  void valueChanged(const QString& parameter, const QVariant& value);
225 
232  void started();
233 
234 protected:
235 
240 
241 private Q_SLOTS:
242 
251  virtual void resultReady(const ctkCmdLineModuleResult& result);
252 
253 private:
254 
259  void setFuture(const ctkCmdLineModuleFuture& future);
260 
261 private:
262 
263  Q_DISABLE_COPY(ctkCmdLineModuleFrontend)
264 
265  friend struct ctkCmdLineModuleFrontendPrivate;
267  friend class ctkCmdLineModulePrivate;
268 
269  Q_PRIVATE_SLOT(d, void _q_resultReadyAt(int))
270 
271  QScopedPointer<ctkCmdLineModuleFrontendPrivate> d;
272 
273 };
274 
276 
277 #endif // CTKCMDLINEMODULEFRONTEND_H
Abstract base class for all front-end command line module implementations.
QFuture sub-class for enhanced communication with running modules.
Main manager class to handle loading and unloading of modules.
Single parameter to a module, like a threshold of a filter.
Defines a reference or handle to a module, including location, XML, description and access to the ass...
Describes a reported result of a command line module.
Q_DECLARE_OPERATORS_FOR_FLAGS(ctkVTKDataSetModel::AttributeTypes)