CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ctkWorkflowWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkWorkflowWidget_h
22 #define __ctkWorkflowWidget_h
23 
24 // Qt includes
25 #include <QWidget>
26 #include <QVariant>
27 class QAbstractButton;
28 
29 // CTK includes
30 #include "ctkPimpl.h"
31 #include "ctkWidgetsExport.h"
32 class ctkWorkflow;
33 class ctkWorkflowStep;
37 
38 class ctkWorkflowWidgetPrivate;
39 
44 class CTK_WIDGETS_EXPORT ctkWorkflowWidget : public QWidget
45 {
46  Q_OBJECT
47  Q_PROPERTY(bool showButtonBoxWidget READ showButtonBoxWidget WRITE setShowButtonBoxWidget)
48 public:
49 
50  typedef QWidget Superclass;
51  explicit ctkWorkflowWidget(QWidget* parent = 0);
52  virtual ~ctkWorkflowWidget();
53 
55  Q_INVOKABLE virtual ctkWorkflow* workflow()const;
56  Q_INVOKABLE virtual void setWorkflow(ctkWorkflow* newWorkflow);
57 
58  Q_INVOKABLE ctkWorkflowWidgetStep* widgetStep(const QString& id)const;
59 
62  Q_INVOKABLE virtual ctkWorkflowGroupBox* workflowGroupBox()const;
63 
65  bool showButtonBoxWidget()const;
66  void setShowButtonBoxWidget(bool newShowButtonBoxWidget);
67 
69  Q_INVOKABLE ctkWorkflowButtonBoxWidget* buttonBoxWidget()const;
70 
94  static void formatButton(QAbstractButton* button, const QString& format, ctkWorkflowWidgetStep* step);
97  static QString formatText(const QString& format, ctkWorkflowWidgetStep* step);
98 
99 public Q_SLOTS:
102  virtual void onCurrentStepChanged(ctkWorkflowStep* currentStep);
103 
104 protected Q_SLOTS:
105  void onStepRegistered(ctkWorkflowStep* step);
106 
107 protected:
108 
109  // Triggers updates of the workflowGroupBox when the current workflow step has changed.
110  virtual void updateStepUI(ctkWorkflowStep* currentStep);
111 
112  // Triggers updates of the buttonBoxWidget when the current workflow step has changed.
113  void updateButtonBoxUI(ctkWorkflowStep* currentStep);
114 
117  static QVariant buttonItem(QString formatItem, ctkWorkflowWidgetStep* step);
120  static QMap<QString, QVariant> parse(const QString& format, ctkWorkflowWidgetStep* step);
121 
122 protected:
123  QScopedPointer<ctkWorkflowWidgetPrivate> d_ptr;
124 
125 private:
126  Q_DECLARE_PRIVATE(ctkWorkflowWidget);
127  Q_DISABLE_COPY(ctkWorkflowWidget);
128 
129 };
130 
131 #endif
132