From 920bea7d8d6c084913cd35fe5fd56cc677d7bba7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20=C5=A0toura=C4=8D?= <525032@mail.muni.cz>
Date: Wed, 22 May 2024 22:13:55 +0200
Subject: [PATCH] change imported RW modules to internal folder, add ui
 controls desc

---
 data/rofi/internal/UM.json          | 302 ++++++++++++++++++++++
 data/rofi/internal/cube_full.json   | 227 +++++++++++++++++
 data/rofi/rofiworlds/cubeman.json   | 375 ++++++++++++++++++++++++++++
 src/filein/src/rofiworld_loader.cpp |   6 +-
 src/gui/src/ui.cpp                  |   1 +
 5 files changed, 908 insertions(+), 3 deletions(-)
 create mode 100644 data/rofi/internal/UM.json
 create mode 100644 data/rofi/internal/cube_full.json
 create mode 100644 data/rofi/rofiworlds/cubeman.json

diff --git a/data/rofi/internal/UM.json b/data/rofi/internal/UM.json
new file mode 100644
index 0000000..55ce9b4
--- /dev/null
+++ b/data/rofi/internal/UM.json
@@ -0,0 +1,302 @@
+{
+        "components" : [
+            {
+                "parent" : 1,
+                "type" : "UM shoe"
+            },
+            {
+                "parent" : 1,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 1,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 1,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 1,
+                "type" : "UM shoe"
+            },
+            {
+                "parent" : 1,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 1,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 1,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 1,
+                "type" : "UM body"
+            },
+            {
+                "parent" : 1,
+                "type" : "UM body"
+            }
+        ],
+        "id" : 1,
+        "joints" : [
+            {
+                "from" : 8,
+                "joint" : {
+                    "axis" : [
+                        1,
+                        0,
+                        0,
+                        0
+                    ],
+                    "limits" : {
+                        "max" : 90,
+                        "min" : -90
+                    },
+                    "positions" : [
+                        0
+                    ],
+                    "postMatrix" : "identity",
+                    "preMatrix" : "identity",
+                    "type" : "rotational"
+                },
+                "to" : 0
+            },
+            {
+                "from" : 9,
+                "joint" : {
+                    "axis" : [
+                        1,
+                        0,
+                        0,
+                        0
+                    ],
+                    "limits" : {
+                        "max" : 90,
+                        "min" : -90
+                    },
+                    "positions" : [
+                        0
+                    ],
+                    "postMatrix" : "identity",
+                    "preMatrix" : "identity",
+                    "type" : "rotational"
+                },
+                "to" : 4
+            },
+            {
+                "from" : 8,
+                "joint" : {
+                    "axis" : [
+                        0,
+                        0,
+                        1,
+                        0
+                    ],
+                    "modulo" : 360,
+                    "positions" : [
+                        0
+                    ],
+                    "postMatrix" : [
+                        [
+                            -1,
+                            0,
+                            -8.74228e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            1,
+                            0,
+                            0
+                        ],
+                        [
+                            8.74228e-08,
+                            0,
+                            -1,
+                            1
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "preMatrix" : "identity",
+                    "type" : "modRotational"
+                },
+                "to" : 9
+            },
+            {
+                "from" : 0,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            5.96046e-08,
+                            8.74228e-08,
+                            1,
+                            0
+                        ],
+                        [
+                            0,
+                            -1,
+                            8.74228e-08,
+                            0
+                        ],
+                        [
+                            1,
+                            0,
+                            5.96046e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 1
+            },
+            {
+                "from" : 0,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            -1,
+                            0,
+                            -8.74228e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            1,
+                            0,
+                            0
+                        ],
+                        [
+                            8.74228e-08,
+                            0,
+                            -1,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 2
+            },
+            {
+                "from" : 0,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : "identity",
+                    "type" : "rigid"
+                },
+                "to" : 3
+            },
+            {
+                "from" : 4,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            5.96046e-08,
+                            8.74228e-08,
+                            1,
+                            0
+                        ],
+                        [
+                            0,
+                            -1,
+                            8.74228e-08,
+                            0
+                        ],
+                        [
+                            1,
+                            0,
+                            5.96046e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 5
+            },
+            {
+                "from" : 4,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            -1,
+                            0,
+                            -8.74228e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            1,
+                            0,
+                            0
+                        ],
+                        [
+                            8.74228e-08,
+                            0,
+                            -1,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 6
+            },
+            {
+                "from" : 4,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : "identity",
+                    "type" : "rigid"
+                },
+                "to" : 7
+            }
+        ],
+        "type" : "universal"
+    }
\ No newline at end of file
diff --git a/data/rofi/internal/cube_full.json b/data/rofi/internal/cube_full.json
new file mode 100644
index 0000000..8be341d
--- /dev/null
+++ b/data/rofi/internal/cube_full.json
@@ -0,0 +1,227 @@
+{
+        "components" : [
+            {
+                "parent" : 6,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 6,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 6,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 6,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 6,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 6,
+                "type" : "roficom"
+            },
+            {
+                "parent" : 6,
+                "type" : "Cube body"
+            }
+        ],
+        "id" : 6,
+        "joints" : [
+            {
+                "from" : 6,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : "identity",
+                    "type" : "rigid"
+                },
+                "to" : 0
+            },
+            {
+                "from" : 6,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            -1,
+                            0,
+                            -8.74228e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            1,
+                            0,
+                            0
+                        ],
+                        [
+                            8.74228e-08,
+                            0,
+                            -1,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 1
+            },
+            {
+                "from" : 6,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            5.96046e-08,
+                            8.74228e-08,
+                            1,
+                            0
+                        ],
+                        [
+                            0,
+                            -1,
+                            8.74228e-08,
+                            0
+                        ],
+                        [
+                            1,
+                            0,
+                            5.96046e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 2
+            },
+            {
+                "from" : 6,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            5.96046e-08,
+                            0,
+                            1,
+                            0
+                        ],
+                        [
+                            0,
+                            1,
+                            0,
+                            0
+                        ],
+                        [
+                            -1,
+                            0,
+                            5.96046e-08,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 3
+            },
+            {
+                "from" : 6,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            1.19209e-07,
+                            0,
+                            1,
+                            0
+                        ],
+                        [
+                            1,
+                            1.19209e-07,
+                            0,
+                            0
+                        ],
+                        [
+                            0,
+                            1,
+                            1.19209e-07,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 4
+            },
+            {
+                "from" : 6,
+                "joint" : {
+                    "positions" : [
+
+                    ],
+                    "sourceToDestination" : [
+                        [
+                            1.19209e-07,
+                            0,
+                            1,
+                            0
+                        ],
+                        [
+                            -1,
+                            1.19209e-07,
+                            0,
+                            0
+                        ],
+                        [
+                            0,
+                            -1,
+                            1.19209e-07,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "type" : "rigid"
+                },
+                "to" : 5
+            }
+        ],
+        "type" : "cube"
+    }
\ No newline at end of file
diff --git a/data/rofi/rofiworlds/cubeman.json b/data/rofi/rofiworlds/cubeman.json
new file mode 100644
index 0000000..7954cf2
--- /dev/null
+++ b/data/rofi/rofiworlds/cubeman.json
@@ -0,0 +1,375 @@
+{
+        "modules" : [
+            {
+                "id" : 12,
+                "type" : "cube"
+            },
+            {
+                "id" : 13,
+                "type" : "cube"
+            },
+            {
+                "id" : 11,
+                "type" : "cube"
+            },
+            {
+                "alpha" : 0,
+                "beta" : -45,
+                "gamma" : 0,
+                "id" : 14,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 0,
+                "beta" : 45,
+                "gamma" : 0,
+                "id" : 15,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 90,
+                "beta" : 90,
+                "gamma" : 0,
+                "id" : 18,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 0,
+                "beta" : 0,
+                "gamma" : 0,
+                "id" : 7,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 0,
+                "beta" : -45,
+                "gamma" : 0,
+                "id" : 8,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 0,
+                "beta" : 0,
+                "gamma" : 0,
+                "id" : 16,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 90,
+                "beta" : -90,
+                "gamma" : -0,
+                "id" : 5,
+                "type" : "universal"
+            },
+            {
+                "alpha" : -90,
+                "beta" : 0,
+                "gamma" : -0,
+                "id" : 0,
+                "type" : "universal"
+            },
+            {
+                "id" : 3,
+                "type" : "cube"
+            },
+            {
+                "id" : 2,
+                "type" : "cube"
+            },
+            {
+                "id" : 10,
+                "type" : "cube"
+            },
+            {
+                "alpha" : -90,
+                "beta" : 0,
+                "gamma" : -0,
+                "id" : 1,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 90,
+                "beta" : -90,
+                "gamma" : -0,
+                "id" : 4,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 0,
+                "beta" : 0,
+                "gamma" : 0,
+                "id" : 6,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 0,
+                "beta" : -45,
+                "gamma" : 0,
+                "id" : 9,
+                "type" : "universal"
+            },
+            {
+                "alpha" : 0,
+                "beta" : 0,
+                "gamma" : -0,
+                "id" : 17,
+                "type" : "universal"
+            }
+        ],
+        "spaceJoints" : [
+            {
+                "point" : [
+                    1.51992e-06,
+                    1.86221e-06,
+                    2.98021e-08
+                ],
+                "joint" : {
+                    "type" : "rigid",
+                    "sourceToDestination" : [
+                        [
+                            1,
+                            1.78813e-07,
+                            -2.07739e-07,
+                            0
+                        ],
+                        [
+                            2.07739e-07,
+                            3.57628e-07,
+                            1,
+                            0
+                        ],
+                        [
+                            1.78813e-07,
+                            -1,
+                            3.57628e-07,
+                            0
+                        ],
+                        [
+                            0,
+                            0,
+                            0,
+                            1
+                        ]
+                    ],
+                    "positions" : [
+
+                    ]
+                },
+                "to" : {
+                    "component" : 0,
+                    "id" : 0
+                }
+            }
+        ],
+        "moduleJoints" : [
+            {
+                "from" : {
+                    "id" : 0,
+                    "connector" : "B-Z"
+                },
+                "to" : {
+                    "id" : 3,
+                    "connector" : 2
+                },
+                "orientation" : "North"
+            },
+            {
+                "from" : {
+                    "id" : 2,
+                    "connector" : 2
+                },
+                "to" : {
+                    "id" : 1,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "North"
+            },
+            {
+                "from" : {
+                    "id" : 4,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 2,
+                    "connector" : 3
+                },
+                "orientation" : "East"
+            },
+            {
+                "from" : {
+                    "id" : 5,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 3,
+                    "connector" : 3
+                },
+                "orientation" : "West"
+            },
+            {
+                "from" : {
+                    "id" : 6,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 4,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "North"
+            },
+            {
+                "from" : {
+                    "id" : 7,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 5,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 10,
+                    "connector" : 2
+                },
+                "to" : {
+                    "id" : 6,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "North"
+            },
+            {
+                "from" : {
+                    "id" : 11,
+                    "connector" : 2
+                },
+                "to" : {
+                    "id" : 7,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 11,
+                    "connector" : 5
+                },
+                "to" : {
+                    "id" : 10,
+                    "connector" : 5
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 8,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 10,
+                    "connector" : 4
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 9,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 11,
+                    "connector" : 4
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 16,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 10,
+                    "connector" : 3
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 17,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 11,
+                    "connector" : 3
+                },
+                "orientation" : "North"
+            },
+            {
+                "from" : {
+                    "id" : 13,
+                    "connector" : 4
+                },
+                "to" : {
+                    "id" : 9,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 12,
+                    "connector" : 0
+                },
+                "to" : {
+                    "id" : 8,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 14,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 12,
+                    "connector" : 1
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 15,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 13,
+                    "connector" : 5
+                },
+                "orientation" : "South"
+            },
+            {
+                "from" : {
+                    "id" : 18,
+                    "connector" : "A-Z"
+                },
+                "to" : {
+                    "id" : 16,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "North"
+            },
+            {
+                "from" : {
+                    "id" : 18,
+                    "connector" : "B-Z"
+                },
+                "to" : {
+                    "id" : 17,
+                    "connector" : "B-Z"
+                },
+                "orientation" : "South"
+            }
+        ]
+    }
\ No newline at end of file
diff --git a/src/filein/src/rofiworld_loader.cpp b/src/filein/src/rofiworld_loader.cpp
index c7e0163..56262d9 100644
--- a/src/filein/src/rofiworld_loader.cpp
+++ b/src/filein/src/rofiworld_loader.cpp
@@ -354,7 +354,7 @@ void get_rofiworld_data(const boost::json::object &json_object,
 
 bool import_modules(rofiworld_ptr rofiworld, const boost::json::array &modules_array)
 {
-    const std::string modules_directory = "./data/rofi/modules/";
+    const std::string internal_modules_directory = "./data/rofi/internal/";
     // const auto universal = import_module(modules_directory + std::string("UM.json"));
     // const auto cube = import_module(modules_directory + std::string("cube_full.json"));
 
@@ -372,7 +372,7 @@ bool import_modules(rofiworld_ptr rofiworld, const boost::json::array &modules_a
 
         if (*module_type_string == "universal")
         {
-            module_copy = import_module(modules_directory + std::string("UM.json"));
+            module_copy = import_module(internal_modules_directory + std::string("UM.json"));
 
             rofi::VoxelGraph::linkImportVoxelGraphToNodes(module_copy->getParts());
             rofi::Module::setModuleNodeHierarchy(module_copy->getParts(), std::string(*module_type_string));
@@ -381,7 +381,7 @@ bool import_modules(rofiworld_ptr rofiworld, const boost::json::array &modules_a
         }
         else if (*module_type_string == "cube")
         {
-            module_copy = import_module(modules_directory + std::string("cube_full.json"));
+            module_copy = import_module(internal_modules_directory + std::string("cube_full.json"));
 
             rofi::VoxelGraph::linkImportVoxelGraphToNodes(module_copy->getParts());
             rofi::Module::setModuleNodeHierarchy(module_copy->getParts(), std::string(*module_type_string));
diff --git a/src/gui/src/ui.cpp b/src/gui/src/ui.cpp
index 9b4a140..560ecc5 100644
--- a/src/gui/src/ui.cpp
+++ b/src/gui/src/ui.cpp
@@ -1376,6 +1376,7 @@ void phase_ii_controls_tab()
 
     ImGui::SeparatorText("Connect Module:");
     ImGui::BulletText("Press 'LMB' to select a RoFICoM.");
+    ImGui::BulletText("Press 'Escape' to cancel current RoFICoM selection.");
     ImGui::BulletText("Press 'M' to connect / disconnect two selected modules.");
     ImGui::Spacing();
 
-- 
GitLab