Tatooine
field_from_file.h
Go to the documentation of this file.
1#ifndef TATOOINE_FLOWEXPLORER_NODES_FIELD_FROM_FILE_H
2#define TATOOINE_FLOWEXPLORER_NODES_FIELD_FROM_FILE_H
3//==============================================================================
5#include <tatooine/sampled_grid_property_field.h>
6//==============================================================================
8//==============================================================================
9template <arithmetic Real, size_t N, bool is_time_dependent,
10 size_t... TensorDims>
12 : sampled_grid_property_field_creator_t<Real, N, is_time_dependent,
13 TensorDims...>,
14 ui::node<field_from_file<Real, N, is_time_dependent, TensorDims...>> {
15 //============================================================================
16 using this_type = field_from_file<Real, N, is_time_dependent, TensorDims...>;
18 //============================================================================
19 private:
20 std::string m_path;
21 bool m_picking_file = false;
22
23 //============================================================================
24 public:
25 auto path() const -> auto const& { return m_path; }
26 auto path() -> auto & { return m_path; }
27
28 //============================================================================
29 public:
31 : ui::node<field_from_file>{"Field", s} {
32 this->template insert_output_pin<polymorphic::field<double, N, TensorDims...>>(
33 "Field Out", *this);
34 }
35 //----------------------------------------------------------------------------
36 virtual ~field_from_file() = default;
37 //============================================================================
38 auto draw_properties() -> bool override {
39 auto& win = this->scene().window();
40 if (!win.file_explorer_is_opened() && ImGui::Button("read")) {
41 m_picking_file = true;
42 win.open_file_explorer("Load File", {".am", ".vtk"}, *this);
43 }
44 bool changed = false;
45 return changed;
46 }
47 //----------------------------------------------------------------------------
48 auto on_path_selected(std::string const& path) -> void override {
49 auto& win = this->scene().window();
50 m_path = path;
51 std::cerr << m_path << '\n';
52 this->read(m_path);
53 win.close_file_explorer();
54 }
55 //----------------------------------------------------------------------------
56 auto deserialize(toml::table const& serialized_node) -> void override {
57 node_parent_type::deserialize(serialized_node);
58 if (!m_path.empty()) {
59 std::cerr << "read: " << m_path << '\n';
60 this->read(m_path);
61 }
62 }
63};
64//==============================================================================
65template <arithmetic Real, size_t N, size_t... TensorDims>
66using unsteady_field_from_file = field_from_file<Real, N, true, TensorDims...>;
67// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
68template <arithmetic Real, size_t N, size_t... TensorDims>
69using steady_field_from_file = field_from_file<Real, N, false, TensorDims...>;
70//==============================================================================
75//------------------------------------------------------------------------------
80//==============================================================================
81} // namespace tatooine::flowexplorer::nodes
82//==============================================================================
85 TATOOINE_REFLECTION_INSERT_GETTER(path));
88 TATOOINE_REFLECTION_INSERT_GETTER(path));
91 TATOOINE_REFLECTION_INSERT_GETTER(path));
94 TATOOINE_REFLECTION_INSERT_GETTER(path));
97 TATOOINE_REFLECTION_INSERT_GETTER(path));
100 TATOOINE_REFLECTION_INSERT_GETTER(path));
103 TATOOINE_REFLECTION_INSERT_GETTER(path));
106 TATOOINE_REFLECTION_INSERT_GETTER(path));
107#endif
Definition: concepts.h:33
TATOOINE_FLOWEXPLORER_REGISTER_NODE(tatooine::flowexplorer::nodes::steady_scalarfield_2d, TATOOINE_REFLECTION_INSERT_GETTER(path))
Definition: abcflow.h:7
Definition: field_from_file.h:14
auto path() const -> auto const &
Definition: field_from_file.h:25
field_from_file(flowexplorer::scene &s)
Definition: field_from_file.h:30
auto draw_properties() -> bool override
Definition: field_from_file.h:38
auto deserialize(toml::table const &serialized_node) -> void override
Definition: field_from_file.h:56
std::string m_path
Definition: field_from_file.h:20
auto path() -> auto &
Definition: field_from_file.h:26
auto on_path_selected(std::string const &path) -> void override
Definition: field_from_file.h:48
bool m_picking_file
Definition: field_from_file.h:21
Definition: scene.h:17
auto scene() const -> auto const &
Definition: node.h:72
auto insert_output_pin(std::string const &title, T &ref, icon_type const t=icon_type::flow) -> auto &
Definition: node.h:63
Definition: node.h:382
auto deserialize(toml::table const &serialized_node) -> void override
Definition: node.h:390
Definition: field.h:13