VPTissue Reference Manual
GraphicsPreferences.h
Go to the documentation of this file.
1 #ifndef EXPORTERS_GRAPHICS_PREFERENCES_H_INCLUDED
2 #define EXPORTERS_GRAPHICS_PREFERENCES_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
23 
24 #include <boost/property_tree/ptree.hpp>
25 #include <boost/property_tree/xml_parser.hpp>
26 #include <boost/optional.hpp>
27 
28 #include <array>
29 
30 namespace SimPT_Shell
31 {
32 
35 {
36  std::string m_arrow_color;
37  double m_arrow_size;
38  std::string m_background_color;
39  std::string m_cell_color;
40  int m_cell_number_size;
41  std::string m_cell_outline_color;
42  double m_mesh_magnification;
43  std::array<double, 3> m_mesh_offset;
44  double m_node_magnification;
45  int m_node_number_size;
46  double m_outline_width;
47  std::string m_text_color;
48  bool m_window_preset;
49  double m_window_x_min;
50  double m_window_x_max;
51  double m_window_y_min;
52  double m_window_y_max;
53 
55  bool m_cells;
56  bool m_cell_axes;
60  bool m_fluxes;
61  bool m_nodes;
64  bool m_tooltips;
65  bool m_walls;
66 
68  : m_mesh_offset{{0.0, 0.0, 0.0}}
69  {
70  // Dummy values; actual values set via a Preferences ptree.
71  m_arrow_color = "darkGreen";
72  m_arrow_size = 10.0;
73  m_background_color = "white";
74  m_cell_color = "size";
75  m_cell_number_size = 1;
76  m_cell_outline_color = "forestgreen";
77  m_mesh_magnification = 1.0;
78  m_node_magnification = 1.0;
79  m_node_number_size = 1.0;
80  m_outline_width = 0.0;
81  m_text_color = "red";
82  m_window_preset = false;
83  m_window_x_min = 0.0;
84  m_window_x_max = 0.0;
85  m_window_y_min = 0.0;
86  m_window_y_max = 0.0;
87 
88  m_border_cells = false;
89  m_cells = true;
90  m_cell_axes = false;
91  m_cell_centers = false;
92  m_cell_numbers = false;
93  m_cell_strain = false;
94  m_fluxes = false;
95  m_nodes = false;
96  m_node_numbers = false;
97  m_only_tissue_boundary = false;
98  m_tooltips = false;
99  m_walls = false;
100  }
101 
102  virtual ~GraphicsPreferences() {}
103 
104  virtual void Update(const SimShell::Ws::Event::MergedPreferencesChanged& e)
105  {
106  auto g = e.source->GetGlobal()->GetChild("graphics");
107  m_arrow_color = g->Get<std::string>("colors_sizes.arrow_color");
108  m_arrow_size = g->Get<double>("colors_sizes.arrow_size");
109  m_background_color = g->Get<std::string>("colors_sizes.background_color");
110  m_cell_color = g->Get<std::string>("colors_sizes.cell_color");
111  m_cell_number_size = g->Get<int>("colors_sizes.cell_number_size");
112  m_cell_outline_color = g->Get<std::string>("colors_sizes.cell_outline_color");
113  m_mesh_magnification = g->Get<double>("colors_sizes.mesh_magnification", 1.0);
114  m_mesh_offset[0] = g->Get<double>("colors_sizes.mesh_offset_x", 0.0);
115  m_mesh_offset[1] = g->Get<double>("colors_sizes.mesh_offset_x", 0.0);
116  m_node_magnification = g->Get<double>("colors_sizes.node_magnification");
117  m_node_number_size = g->Get<int>("colors_sizes.node_number_size");
118  m_outline_width = g->Get<double>("colors_sizes.outline_width");
119  m_text_color = g->Get<std::string>("colors_sizes.text_color");
120 
121  m_window_preset = false;
122  try {
123  auto w = e.source->GetChild("source_window");
124  m_window_x_min = w->Get<double>("x_min");
125  m_window_x_max = w->Get<double>("x_max");
126  m_window_y_min = w->Get<double>("y_min");
127  m_window_y_max = w->Get<double>("y_max");
128  m_window_preset = true;
129  } catch (boost::property_tree::ptree_error& e) {}
130 
131  m_border_cells = g->Get<bool>("visualization.border_cells");
132  m_cells = g->Get<bool>("visualization.cells");
133  m_cell_axes = g->Get<bool>("visualization.cell_axes");
134  m_cell_centers = g->Get<bool>("visualization.cell_centers");
135  m_cell_numbers = g->Get<bool>("visualization.cell_numbers");
136  m_cell_strain = g->Get<bool>("visualization.cell_strain");
137  m_fluxes = g->Get<bool>("visualization.fluxes");
138  m_nodes = g->Get<bool>("visualization.nodes");
139  m_node_numbers = g->Get<bool>("visualization.node_numbers");
140  m_only_tissue_boundary = g->Get<bool>("visualization.only_leaf_boundary");
141  m_tooltips = g->Get<bool>("visualization.tooltips");
142  m_walls = g->Get<bool>("visualization.walls");
143  }
144 };
145 
146 } // namespace
147 
148 #endif
bool m_cells
Switch for drawing cells.
bool m_tooltips
Switch for drawing tool tips.
Namespace for SimPT shell package.
Definition: Client.cpp:50
bool m_cell_numbers
Switch for drawing cell numbers.
bool m_fluxes
Switch for drawing fluxes.
bool m_node_numbers
Switch for drawing node numbers.
bool m_only_tissue_boundary
Switch for drawing boundary.
std::string m_background_color
Qt color or "transparent".
Preferences for graphics viewer.
Interface for MergedPreferences.
bool m_nodes
Switch for drawing nodes.
bool m_walls
Switch for drawing wall.
bool m_cell_strain
Switch for drawing cell strain.
bool m_cell_axes
Switch for drawing cell axes.
bool m_cell_centers
Switch for drawing cell centers.
bool m_border_cells
Switch for drawing borders.