BlosSOM
Interactive dimensionality reduction on large datasets (EmbedSOM and FLOWER combined)
color_data.h
Go to the documentation of this file.
1/* This file is part of BlosSOM.
2 *
3 * Copyright (C) 2021 Mirek Kratochvil
4 * Sona Molnarova
5 *
6 * BlosSOM is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
10 *
11 * BlosSOM is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * BlosSOM. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef COLOR_DATA_H
21#define COLOR_DATA_H
22
23#include <glm/glm.hpp>
24
25#include "batch_size_gen.h"
26#include "cluster_data.h"
27#include "dirty.h"
28#include "frame_stats.h"
29#include "landmark_model.h"
30#include "trans_data.h"
31
32#include <string>
33#include <vector>
34
35/**
36 * @brief Storage of the color data.
37 *
38 */
39struct ColorData : public Sweeper
40{
41 /**
42 * @brief Types of coloring.
43 *
44 */
46 {
50 };
51
52 const glm::vec3 default_landmark_color = { 0.4, 0.4, 0.4 };
53
55
56 /** Colors of the 2D data points. Array has the size of the number of 2D
57 * data points.
58 */
59 std::vector<glm::vec4> data;
60 /** Colors of the landmarks and id of the cluster. Array has the size of the
61 * number of landmarks. <color, cluster id>
62 */
63 std::vector<std::pair<const glm::vec3 *, int>> landmarks;
64 /** Type of the coloring method. */
66 /** Index of the column used in expression coloring. */
68 /** Name of the currently used color palette. */
69 std::string col_palette;
70
72 /** Alpha channel of RGBA color. It is the same for all 2D data points. */
73 float alpha;
74 /** Flag indicating if the colors of the color palette should be reversed.
75 */
76 bool reverse;
77
79
80 /**
81 * @brief Calls @ref reset() method to set initial values.
82 *
83 */
85
86 /**
87 * @brief Recomputes color of the 2D data points if user has changed any of
88 * the color settings.
89 *
90 * @param td Transformed data received from the data flow pipeline.
91 */
92 void update(const TransData &td,
93 const LandmarkModel &lm,
94 FrameStats &frame_stats);
95 /**
96 * @brief Notifies @ref Sweeper that the color settings has been modified
97 * and that the data has to be recomputed.
98 *
99 */
100
101 /**
102 * @brief Color landmarks by active cluster.
103 *
104 * @param idxs Ids of landmarks that will be colored.
105 */
106 void color_landmarks(const std::vector<size_t> &idxs);
107
108 /**
109 * @brief Reset colors and cluster ids of all landmarks
110 * in the cluster with input id.
111 *
112 * @param id Input
113 */
114 void reset_landmark_color(int id);
115
116 void remove_landmark(size_t ind);
117
118 void touch_config() { refresh(data.size()); }
119 /**
120 * @brief Resets color settings to their initial values.
121 *
122 */
123 void reset();
124
125private:
126 /** Color the landmark according to the active cluster.*/
127 void color_landmark(size_t ind);
128};
129
130#endif
Generator of the size of the next point batch.
A piece of cache that keeps track of the dirty status.
Definition: dirty.h:51
Storage of data used for cluster coloring.
Definition: cluster_data.h:37
Storage of the color data.
Definition: color_data.h:40
void update(const TransData &td, const LandmarkModel &lm, FrameStats &frame_stats)
Recomputes color of the 2D data points if user has changed any of the color settings.
Definition: color_data.cpp:25
void reset()
Resets color settings to their initial values.
Definition: color_data.cpp:121
void color_landmarks(const std::vector< size_t > &idxs)
Notifies Sweeper that the color settings has been modified and that the data has to be recomputed.
Definition: color_data.cpp:96
std::vector< std::pair< const glm::vec3 *, int > > landmarks
Colors of the landmarks and id of the cluster.
Definition: color_data.h:63
bool reverse
Flag indicating if the colors of the color palette should be reversed.
Definition: color_data.h:76
float alpha
Alpha channel of RGBA color.
Definition: color_data.h:73
int expr_col
Index of the column used in expression coloring.
Definition: color_data.h:67
Coloring
Types of coloring.
Definition: color_data.h:46
void reset_landmark_color(int id)
Reset colors and cluster ids of all landmarks in the cluster with input id.
Definition: color_data.cpp:104
void remove_landmark(size_t ind)
Definition: color_data.cpp:114
ClusterData clustering
Definition: color_data.h:71
void touch_config()
Definition: color_data.h:118
Cleaner lm_watch
Definition: color_data.h:54
int coloring
Type of the coloring method.
Definition: color_data.h:65
void color_landmark(size_t ind)
Color the landmark according to the active cluster.
Definition: color_data.cpp:139
std::string col_palette
Name of the currently used color palette.
Definition: color_data.h:69
std::vector< glm::vec4 > data
Colors of the 2D data points.
Definition: color_data.h:59
ColorData()
Calls reset() method to set initial values.
Definition: color_data.h:84
const glm::vec3 default_landmark_color
Definition: color_data.h:52
BatchSizeGen batch_size_gen
Definition: color_data.h:78
Model of the high- and low-dimensional landmarks.
A piece of multi-object cache.
Definition: dirty.h:95
void refresh(const Dirts &d)
Force-refresh the whole range.
Definition: dirty.h:105
Storage of the transformed data.
Definition: trans_data.h:74