Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

pipelinetreewidget.h 6.9 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13
14
15
16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18
19
20
21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22
23
24
// 
// ================================================================================================

25
26
27
28
29
30
31
32
#ifndef PIPELINETREEWIDGET_H__
#define PIPELINETREEWIDGET_H__

#include <QAbstractItemModel>
#include <QTreeWidget>
#include <QList>
#include <QVariant>

33
#include "core/datastructures/datacontainer.h"
34
35
#include "core/pipeline/abstractpipeline.h"
#include "core/pipeline/abstractprocessor.h"
36
37

#include "application/applicationapi.h"
38
#include "application/tools/treeitem.h"
39

40
41
#include <vector>

schultezub's avatar
schultezub committed
42
namespace campvis {
43
44

// = TreeModel items ==============================================================================
45
    
schultezub's avatar
schultezub committed
46
47
48
    /**
     * Specialization for root TreeItems.
     */
49
    class CAMPVIS_APPLICATION_API PipelineTreeRootItem : public TreeItem {
50
    public:
51
        explicit PipelineTreeRootItem(TreeItem* parent = 0);
52
        virtual ~PipelineTreeRootItem();
53

schultezub's avatar
schultezub committed
54
        /// \see TreeItem::getData()
55
        virtual QVariant getData(int column, int role) const;
56
57
    };

58
59
60
    /**
     * Specialization for TreeItems hosting an AbstracPipeline.
     */
61
    class CAMPVIS_APPLICATION_API DataContainerTreeItem : public TreeItem {
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    public:
        DataContainerTreeItem(DataContainer* dc, TreeItem* parent);
        virtual ~DataContainerTreeItem();

        /// \see TreeItem::getData()
        virtual QVariant getData(int column, int role) const;

        /// \see TreeItem::setData()
        virtual bool setData(int column, int role, const QVariant& value) const;

    private:
        DataContainer* _dataContainer;        ///< Base DataContainer
    };

schultezub's avatar
schultezub committed
76
77
78
    /**
     * Specialization for TreeItems hosting an AbstracPipeline.
     */
79
    class CAMPVIS_APPLICATION_API PipelineTreeItem : public TreeItem {
80
81
82
83
    public:
        PipelineTreeItem(AbstractPipeline* pipeline, TreeItem* parent);
        virtual ~PipelineTreeItem();

schultezub's avatar
schultezub committed
84
        /// \see TreeItem::getData()
85
        virtual QVariant getData(int column, int role) const;
86

87
88
89
        /// \see TreeItem::setData()
        virtual bool setData(int column, int role, const QVariant& value) const;

90
    private:
schultezub's avatar
schultezub committed
91
        AbstractPipeline* _pipeline;        ///< Base pipeline
92
93
    };

schultezub's avatar
schultezub committed
94
95
96
    /**
     * Specialization for TreeItems hosting an AbstractProcessor.
     */
97
    class CAMPVIS_APPLICATION_API ProcessorTreeItem : public TreeItem {
98
99
100
101
    public:
        ProcessorTreeItem(AbstractProcessor* processor, TreeItem* parent);
        virtual ~ProcessorTreeItem();

schultezub's avatar
schultezub committed
102
        /// \see TreeItem::getData()
103
        virtual QVariant getData(int column, int role) const;
104

105
106
107
        /// \see TreeItem::setData()
        virtual bool setData(int column, int role, const QVariant& value) const;

108
    private:
schultezub's avatar
schultezub committed
109
        AbstractProcessor* _processor;      ///< Base processor
110
111
112
113
    };

// = TreeModel ====================================================================================

schultezub's avatar
schultezub committed
114
115
116
    /**
     * QItemModel for displaying a list of pipelines and their processors in the PipelineTreeWidget.
     */
117
    class CAMPVIS_APPLICATION_API PipelineTreeModel : public QAbstractItemModel {
118
119
120
        Q_OBJECT

    public:
121
        explicit PipelineTreeModel(QObject *parent = 0);
122
123
        ~PipelineTreeModel();

124
        void setData(const std::vector<DataContainer*>& dataContainers, const std::vector<AbstractPipeline*>& pipelines);
125
126

        QVariant data(const QModelIndex &index, int role) const;
127
128
129
130
131
132
133
134
135

        /**
         * Sets the data at index \a index to \a value.
         * \param   index   position where to set data
         * \param   value   new data
         * \param   role    edit role
         **/
        bool setData(const QModelIndex& index, const QVariant& value, int role);

136
137
138
139
140
141
142
143
144
145
146
147
148
149
        Qt::ItemFlags flags(const QModelIndex &index) const;
        QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
        QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
        QModelIndex parent(const QModelIndex &index) const;

        int rowCount(const QModelIndex &parent = QModelIndex()) const;
        int columnCount(const QModelIndex &parent = QModelIndex()) const;

    private:
        TreeItem* _rootItem;
    };

// = Widget =======================================================================================

schultezub's avatar
schultezub committed
150
151
152
    /**
     * Qt widget for showing a list of pipelines and their processors in a QTreeView.
     */
153
    class CAMPVIS_APPLICATION_API PipelineTreeWidget : public QTreeView {
154
155
156
        Q_OBJECT;

    public:
schultezub's avatar
schultezub committed
157
158
159
160
        /**
         * Creates a new PipelineTreeWidget.
         * \param   parent  Parent widget
         */
161
        explicit PipelineTreeWidget(QWidget* parent = 0);
162

schultezub's avatar
schultezub committed
163
164
165
        /**
         * Destructor
         */
166
167
        virtual ~PipelineTreeWidget();

168
169
170
171
172
173
174
175
        /**
         * Return the recommended size for the widget.
         *
         * This method tries to calculate a sensible height for the wigdet, while still reusing QTreeView's hardcoded
         * width.
         */
        virtual QSize sizeHint() const;

176

177
178
179
180
181
    signals:
        /// Emitted whenever the currently selected item changes
        void itemChanged(const QModelIndex& index);


182
    public slots:
schultezub's avatar
schultezub committed
183
184
185
186
        /**
         * Updates the data in the tree view by the given collection of pipelines \a pipelines.
         * \param   pipelines   
         */
187
        void update(const std::vector<DataContainer*>& dataContainers, const std::vector<AbstractPipeline*>& pipelines);
188
189


190
191
192
193
    protected:

        virtual void selectionChanged(const QItemSelection& selected, const QItemSelection &deselected);

194
    private:
schultezub's avatar
schultezub committed
195
196
197
        /**
         * Sets up the widget.
         */
198
199
        void setupWidget();

schultezub's avatar
schultezub committed
200
        PipelineTreeModel* _treeModel;      ///< Data model for the TreeView.
201
202
203
204
205

    };
}

#endif // PIPELINETREEWIDGET_H__