Developer documentation
Version 3.0.3-105-gd3941f44
item.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_roi_editor_item_h__
18#define __gui_mrview_tool_roi_editor_item_h__
19
20
21#include <array>
22
23#include "header.h"
24#include "types.h"
25#include "algo/loop.h"
26#include "gui/mrview/volume.h"
28
29
30namespace MR
31{
32 namespace GUI
33 {
34 namespace MRView
35 {
36 namespace Tool
37 {
38
39
40
41 namespace {
42 constexpr std::array<std::array<GLubyte,3>,6> preset_colours = { {
43 { { 255, 255, 0 } },
44 { { 255, 0, 255 } },
45 { { 0, 255, 255 } },
46 { { 255, 0, 0 } },
47 { { 0, 255, 255 } },
48 { { 0, 0, 255 } }
49 } };
50 }
51
52
53
54 class ROI_Item : public Volume { MEMALIGN(ROI_Item)
55 public:
57
58 void zero ();
59 void load ();
60
61 template <class ImageType>
62 void save (ImageType&&, GLubyte*);
63
64 bool has_undo () { return current_undo >= 0; }
65 bool has_redo () { return current_undo < int(undo_list.size()-1); }
66
67 ROI_UndoEntry& current () { return undo_list[current_undo]; }
68 void start (ROI_UndoEntry&& entry);
69
70 void undo ();
71 void redo ();
72
73 bool saved;
74 float min_brush_size, max_brush_size, brush_size;
75
76 private:
77 vector<ROI_UndoEntry> undo_list;
78 int current_undo;
79
80 static int number_of_undos;
81 static int current_preset_colour;
82 static int new_roi_counter;
83 };
84
85
86
87 template <class ImageType>
88 void ROI_Item::save (ImageType&& out, GLubyte* data)
89 {
90 for (auto l = Loop(out) (out); l; ++l)
91 out.value() = data[out.index(0) + out.size(0) * (out.index(1) + out.size(1)*out.index(2))];
92 saved = true;
93 filename = out.name();
94 }
95
96
97
98 }
99 }
100 }
101}
102
103#endif
104
105
FORCE_INLINE LoopAlongAxes Loop()
Definition: loop.h:419
Definition: base.h:24
#define MEMALIGN(...)
Definition: types.h:185
Definition: undoentry.h:42