Developer documentation
Version 3.0.3-105-gd3941f44
model.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gui_mrview_tool_odf_model_h__
18#define __gui_mrview_tool_odf_model_h__
19
20#include <memory>
21#include <string>
22
23#include "types.h"
24
27
28namespace MR
29{
30 namespace GUI
31 {
32 namespace MRView
33 {
34 namespace Tool
35 {
36
37
38
39 class ODF_Model : public QAbstractItemModel
40 { MEMALIGN(ODF_Model)
41 public:
42
43 ODF_Model (QObject* parent) :
44 QAbstractItemModel (parent) { }
45
46 QVariant data (const QModelIndex& index, int role) const {
47 if (!index.isValid()) return {};
48 if (role != Qt::DisplayRole && role != Qt::ToolTipRole) return {};
49 return qstr (items[index.row()]->image.get_filename());
50 }
51
52 bool setData (const QModelIndex& index, const QVariant& value, int role) {
53 return QAbstractItemModel::setData (index, value, role);
54 }
55
56 Qt::ItemFlags flags (const QModelIndex& index) const {
57 if (!index.isValid()) return {};
58 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
59 }
60
61 QModelIndex parent (const QModelIndex&) const {
62 return {};
63 }
64
65 int rowCount (const QModelIndex& parent = QModelIndex()) const {
66 (void) parent; // to suppress warnings about unused parameters
67 return items.size();
68 }
69
70 int columnCount (const QModelIndex& parent = QModelIndex()) const {
71 (void) parent; // to suppress warnings about unused parameters
72 return 1;
73 }
74
75 size_t add_items (const vector<std::string>& list, const odf_type_t type, bool colour_by_direction, bool hide_negative_lobes, float scale);
76
77 QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex()) const {
78 (void ) parent; // to suppress warnings about unused parameters
79 return createIndex (row, column);
80 }
81
82 void remove_item (QModelIndex& index) {
83 beginRemoveRows (QModelIndex(), index.row(), index.row());
84 items.erase (items.begin() + index.row());
85 endRemoveRows();
86 }
87
88 ODF_Item* get_image (QModelIndex& index) {
89 return index.isValid() ? dynamic_cast<ODF_Item*>(items[index.row()].get()) : NULL;
90 }
91
93 };
94
95 }
96 }
97 }
98}
99
100#endif
101
102
103
104
105
VectorType::Scalar value(const VectorType &coefs, typename VectorType::Scalar cos_elevation, typename VectorType::Scalar cos_azimuth, typename VectorType::Scalar sin_azimuth, int lmax)
Definition: SH.h:233
mat4 scale(float x, float y, float z)
QString qstr(const std::string &s)
Definition: gui.h:31
Definition: base.h:24
size_t index