Closed otto-link closed 7 months ago
How to split
// ONLY USE FOR NODE EDITOR LINKS, base class GNode::Tree already has a link storage system
struct Link
{
// related to GNode and Hesiod
std::string node_id_from;
std::string port_id_from;
int port_hash_id_from;
std::string node_id_to;
std::string port_id_to;
int port_hash_id_to;
Link();
Link(std::string node_id_from,
std::string port_id_from,
int port_hash_id_from,
std::string node_id_to,
std::string port_id_to,
int port_hash_id_to);
SERIALIZATION_V2_IMPLEMENT_BASE();
};
// NEW CLASS INHERITANCE:
// ViewTree WILL THEN BE DECLARED AS: class ViewTree : public ControlTree
// ControlTree DECLARED AS: class ControlTree: public gnode::Tree, public serialization::SerializationBase
class ViewTree : public gnode::Tree, public serialization::SerializationBase
{
public:
ViewTree(std::string id,
hmap::Vec2<int> shape,
hmap::Vec2<int> tiling,
float overlap);
~ViewTree();
// VIEW
Link *get_link_ref_by_id(int link_id);
// CONTROL
std::string get_new_id();
// VIEW
ImU32 get_node_color(std::string node_id);
// CONTROL
std::string get_node_type(std::string node_id) const;
// VIEW
ax::NodeEditor::EditorContext *get_p_node_editor_context() const;
// CONTROL
void set_sto(hmap::Vec2<int> new_shape,
hmap::Vec2<int> new_tiling,
float new_overlap);
// VIEW
void set_viewer_node_id(std::string node_id);
// VIEW (CREATE add_control_node for CTRL)
std::string add_view_node(std::string control_node_type,
std::string node_id = "");
// VIEW
void automatic_node_layout();
// VIEW and CONTROL
void clear();
// VIEW
void export_view3d(std::string fname);
// VIEW
void insert_clone_node(std::string node_id);
// VIEW
void new_link(int port_hash_id_from, int port_hash_id_to);
// VIEW
void new_link(std::string node_id_from, // out
std::string port_id_from,
std::string node_id_to, // in
std::string port_id_to);
// VIEW
void post_update();
// VIEW
void remove_link(int link_id);
// VIEW
void remove_view_node(std::string node_id);
// VIEW
void render_links();
// VIEW
std::string render_new_node_popup();
// VIEW
std::string render_new_node_treeview(const ImVec2 node_position = {0.f, 0.f});
// VIEW
void render_node_editor();
// VIEW
void render_node_list();
// VIEW
void render_settings(std::string node_id);
// VIEW
void render_view_node(std::string node_id);
// VIEW
void render_view_nodes();
// VIEW
void render_view2d();
// VIEW
void render_view3d();
// VIEW
void update_image_texture_view2d();
// VIEW
void update_image_texture_view3d(bool vertex_array_update = true);
// VIEW
void update_view3d_basemesh();
// used for serialization now
// see class ControlNodeInstancing
// CONTROL
inline hmap::Vec2<int> get_shape()
{
return this->shape;
}
// CONTROL
inline hmap::Vec2<int> get_tiling()
{
return this->tiling;
}
// CONTROL
inline float get_overlap()
{
return this->overlap;
}
// serialization
// VIEW and create same for CTRL
void load_state(std::string fname);
// VIEW and create same for CTRL
void save_state(std::string fname);
// VIEW and create same for CTRL
SERIALIZATION_V2_IMPLEMENT_BASE();
private:
// CONTROL
hmap::Vec2<int> shape;
// CONTROL
hmap::Vec2<int> tiling;
// CONTROL
float overlap;
// VIEW
std::map<int, Link> links = {};
// CONTROL
int id_counter = 0;
// CONTROL
std::string json_filename = "";
// VIEW
std::vector<ax::NodeEditor::NodeId> selected_node_hid = {};
// VIEW
ax::NodeEditor::EditorContext *p_node_editor_context = nullptr;
// VIEW
bool open_node_list_window = false;
// VIEW
std::string viewer_node_id = "";
// VIEW FOR ALL THE REMAINING PAS THIS LINE
// 2D viewer
bool open_view2d_window = false;
GLuint image_texture_view2d;
hmap::Vec2<int> shape_view2d = {512, 512};
int cmap_view2d = hmap::cmap::inferno;
bool hillshade_view2d = false;
float view2d_zoom = 100.f;
ImVec2 view2d_uv0 = {0.f, 0.f};
std::map<std::string, int> cmap_map = {
{"gray", hmap::cmap::gray},
{"inferno", hmap::cmap::inferno},
{"nipy_spectral", hmap::cmap::nipy_spectral},
{"terrain", hmap::cmap::terrain}};
// 3D viewer
bool open_view3d_window = false;
bool show_view3d_on_background = false;
GLuint image_texture_view3d;
GLuint shader_id;
GLuint vertex_array_id;
GLuint vertex_buffer;
GLuint color_buffer;
GLuint FBO;
GLuint RBO;
hmap::Vec2<int> shape_view3d = {512, 512};
std::vector<GLfloat> vertices = {};
std::vector<GLfloat> colors = {};
float scale = 0.7f;
float h_scale = 0.4f;
float alpha_x = 35.f;
float alpha_y = -25.f;
float delta_x = 0.f;
float delta_y = 0.f;
bool wireframe = false;
bool auto_rotate = false;
bool show_settings = false;
ax::NodeEditor::NodeId context_menu_node_hid;
std::vector<std::string> key_sort;
};