Skip to content

Commit afe7c1c

Browse files
committed
disable unimplemented elements
1 parent a2e6fb2 commit afe7c1c

File tree

5 files changed

+95
-83
lines changed

5 files changed

+95
-83
lines changed

src/MarlinSimulator/application.cpp

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Application::Application() {
2121

2222
sim.vis.create();
2323

24-
user_interface.addElement<UiWindow>("MainMenu", [this](UiWindow* window){
24+
user_interface.m_main_menu = [this](){
2525
if (ImGui::BeginMainMenuBar()) {
2626
if (ImGui::BeginMenu("File")) {
27-
if (ImGui::MenuItem("Preferences")) {
28-
user_interface.ui_elements["Preferences"]->enable();
29-
}
27+
// if (ImGui::MenuItem("Preferences")) {
28+
// user_interface.ui_elements["Preferences"]->enable();
29+
// }
3030
if (ImGui::MenuItem("Quit")) {
3131
Kernel::quit_requested = true;
3232
active = false;
@@ -55,7 +55,7 @@ Application::Application() {
5555
}
5656
ImGui::EndMainMenuBar();
5757
}
58-
});
58+
};
5959

6060
user_interface.addElement<SerialMonitor>("Serial Monitor(0)", serial_stream_0);
6161
user_interface.addElement<SerialMonitor>("Serial Monitor(1)", serial_stream_1);
@@ -221,57 +221,52 @@ Application::Application() {
221221
ImGui::InputText("Pin regex", export_regex, sizeof(export_regex));
222222

223223
if (ImGuiFileDialog::Instance()->Display("PulseExportDlgKey", ImGuiWindowFlags_NoDocking)) {
224-
try{
225-
if (ImGuiFileDialog::Instance()->IsOk()) {
226-
std::string image_filename = ImGuiFileDialog::Instance()->GetFilePathName();
224+
try {
225+
if (ImGuiFileDialog::Instance()->IsOk()) {
226+
std::string image_filename = ImGuiFileDialog::Instance()->GetFilePathName();
227227

228-
using namespace vcd;
228+
using namespace vcd;
229229

230-
HeadPtr head = makeVCDHeader(static_cast<TimeScale>(50), TimeScaleUnit::ns, utils::now());
231-
VCDWriter writer{image_filename, head};
230+
HeadPtr head = makeVCDHeader(static_cast<TimeScale>(50), TimeScaleUnit::ns, utils::now());
231+
VCDWriter writer {image_filename, head};
232232

233-
if (export_single_pin) {
234-
std::string pin_name(active_label);
235-
auto scope = pin_name.substr(0, pin_name.find_first_of('_'));
236-
auto var = writer.register_var(scope, pin_name, VariableType::wire, 1);
233+
if (export_single_pin) {
234+
std::string pin_name(active_label);
235+
auto scope = pin_name.substr(0, pin_name.find_first_of('_'));
236+
auto var = writer.register_var(scope, pin_name, VariableType::wire, 1);
237237

238-
if (Gpio::pin_map[monitor_pin].event_log.size() && pin_array[monitor_pin].is_digital) {
239-
for (const auto &value : Gpio::pin_map[monitor_pin].event_log) {
240-
writer.change(var, value.timestamp / 50, utils::format("%u", value.value));
238+
if (Gpio::pin_map[monitor_pin].event_log.size() && pin_array[monitor_pin].is_digital) {
239+
for (const auto& value : Gpio::pin_map[monitor_pin].event_log) {
240+
writer.change(var, value.timestamp / 50, utils::format("%u", value.value));
241+
}
242+
}
243+
} else {
244+
std::map<size_t, VarPtr> pin_to_var_map;
245+
std::regex expression(export_regex);
246+
247+
for (auto pin : pin_array) {
248+
std::string pin_name(pin.name);
249+
bool regex_match = strlen(export_regex) == 0 || std::regex_search(pin_name, expression);
250+
auto scope = pin_name.substr(0, pin_name.find_first_of('_'));
251+
if (pin.is_digital && regex_match) pin_to_var_map[pin.pin] = writer.register_var(scope, pin_name, VariableType::wire, 1);
241252
}
242-
}
243-
}
244-
else {
245-
std::map<size_t, VarPtr> pin_to_var_map;
246-
std::regex expression(export_regex);
247-
248-
for (auto pin : pin_array) {
249-
std::string pin_name(pin.name);
250-
bool regex_match = strlen(export_regex) == 0 || std::regex_search(pin_name, expression);
251-
auto scope = pin_name.substr(0, pin_name.find_first_of('_'));
252-
if (pin.is_digital && regex_match)
253-
pin_to_var_map[pin.pin] = writer.register_var(scope, pin_name, VariableType::wire, 1);
254-
}
255253

256-
std::multimap<uint64_t, std::pair<pin_t, uint16_t> > timestamp_pin_change_map;
254+
std::multimap<uint64_t, std::pair<pin_t, uint16_t>> timestamp_pin_change_map;
257255

258-
for (auto pin : pin_array) {
259-
if (pin.is_digital && pin_to_var_map.find(pin.pin) != pin_to_var_map.end())
260-
for (const auto &data : Gpio::pin_map[pin.pin].event_log)
261-
{
262-
timestamp_pin_change_map.emplace(std::make_pair(data.timestamp, std::make_pair(pin.pin, data.value)));
263-
}
264-
}
256+
for (auto pin : pin_array) {
257+
if (pin.is_digital && pin_to_var_map.find(pin.pin) != pin_to_var_map.end())
258+
for (const auto& data : Gpio::pin_map[pin.pin].event_log) {
259+
timestamp_pin_change_map.emplace(std::make_pair(data.timestamp, std::make_pair(pin.pin, data.value)));
260+
}
261+
}
265262

266-
auto timestamp_offset = timestamp_pin_change_map.begin()->first;
267-
for (const auto &timestamp : timestamp_pin_change_map) {
268-
writer.change(pin_to_var_map[timestamp.second.first], (timestamp.first - timestamp_offset) / 50, utils::format("%u", timestamp.second.second));
263+
auto timestamp_offset = timestamp_pin_change_map.begin()->first;
264+
for (const auto& timestamp : timestamp_pin_change_map) {
265+
writer.change(pin_to_var_map[timestamp.second.first], (timestamp.first - timestamp_offset) / 50, utils::format("%u", timestamp.second.second));
266+
}
269267
}
270268
}
271-
}
272-
}
273-
catch (const std::exception& e)
274-
{
269+
} catch (const std::exception& e) {
275270
auto test = e.what();
276271
}
277272
ImGuiFileDialog::Instance()->Close();

src/MarlinSimulator/resources/resource_data.h

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,10 @@ static const char * data_shader_default_fs = R"SHADERSTR(
201201

202202
}
203203

204-
/**
205-
* |-----|-----|------|
206-
* |Stat | LCD | |
207-
* | | |
208-
* | | 3D |
209-
* |-----------| |
210-
* |Ser | |
211-
* |-----------|------|
212-
*/
213-
214204
static constexpr char const* imgui_ini = R"(
215205
[Window][DockSpaceWindwow]
216-
Pos=0,0
217-
Size=1280,720
206+
Pos=0,19
207+
Size=1280,701
218208
Collapsed=0
219209
220210
[Window][Debug##Default]
@@ -223,20 +213,20 @@ Size=400,400
223213
Collapsed=0
224214
225215
[Window][Components]
226-
Pos=1003,0
227-
Size=277,720
216+
Pos=1003,19
217+
Size=277,701
228218
Collapsed=0
229219
DockId=0x00000006,0
230220
231221
[Window][Simulation]
232-
Pos=0,0
233-
Size=313,107
222+
Pos=0,19
223+
Size=313,351
234224
Collapsed=0
235-
DockId=0x00000003,0
225+
DockId=0x0000000B,0
236226
237227
[Window][Viewport]
238-
Pos=315,0
239-
Size=686,482
228+
Pos=315,19
229+
Size=686,463
240230
Collapsed=0
241231
DockId=0x00000009,0
242232
@@ -247,14 +237,14 @@ Collapsed=0
247237
DockId=0x00000004,0
248238
249239
[Window][Signal Analyser]
250-
Pos=315,0
251-
Size=686,482
240+
Pos=315,19
241+
Size=686,463
252242
Collapsed=0
253243
DockId=0x00000009,1
254244
255245
[Window][Pin List]
256-
Pos=1003,0
257-
Size=277,720
246+
Pos=1003,19
247+
Size=277,701
258248
Collapsed=0
259249
DockId=0x00000006,1
260250
@@ -293,24 +283,48 @@ Pos=271,95
293283
Size=678,431
294284
Collapsed=0
295285
286+
[Window][Debug]
287+
Pos=0,372
288+
Size=313,348
289+
Collapsed=0
290+
DockId=0x0000000C,0
291+
292+
[Window][Log]
293+
Pos=315,484
294+
Size=686,236
295+
Collapsed=0
296+
DockId=0x0000000A,4
297+
298+
[Window][Choose File##ChooseSDFileDlgKey]
299+
Pos=271,95
300+
Size=678,431
301+
Collapsed=0
302+
296303
[Table][0x5E7B4F09,4]
297304
RefScale=13
298305
Column 0 Sort=0v
299-
Column 1
300-
Column 2
301-
Column 3
306+
307+
[Table][0xD049C3E8,4]
308+
RefScale=13
309+
Column 0 Sort=0v
310+
311+
[Table][0xC6018A16,4]
312+
RefScale=13
313+
Column 0 Sort=0v
302314
303315
[Docking][Data]
304-
DockSpace ID=0x6F13380E Window=0x49B6D357 Pos=0,0 Size=1280,720 Split=X
316+
DockSpace ID=0x6F13380E Window=0x49B6D357 Pos=0,19 Size=1280,701 Split=X
305317
DockNode ID=0x00000005 Parent=0x6F13380E SizeRef=1001,720 Split=X
306318
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=313,720 Split=Y Selected=0x7CAC602A
307-
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=637,107 Selected=0x848745AB
319+
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=637,107 Split=Y Selected=0xFBEA9FC2
320+
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=313,351 Selected=0xFBEA9FC2
321+
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=313,348 Selected=0x392A5ADD
308322
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=637,611 Selected=0x7CAC602A
309323
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=686,720 Split=Y Selected=0x995B0CF8
310324
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=448,451 Split=Y Selected=0x995B0CF8
311-
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=623,482 CentralNode=1 Selected=0x995B0CF8
312-
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=623,236 Selected=0xB516B7B1
325+
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=623,482 CentralNode=1 Selected=0x13926F0B
326+
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=623,236 Selected=0x4B8A34E6
313327
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=448,267 Selected=0xB42549D5
314-
DockNode ID=0x00000006 Parent=0x6F13380E SizeRef=277,720 Selected=0xA115F62D
328+
DockNode ID=0x00000006 Parent=0x6F13380E SizeRef=277,720 Selected=0xFCB30AB3
315329
316330
)";

src/MarlinSimulator/user_interface.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ void UserInterface::show() {
4949
ImGui_ImplSDL2_NewFrame();
5050
ImGui::NewFrame();
5151
renderer::gl_log_error();
52-
5352
DockSpace();
53+
if (m_main_menu) {
54+
m_main_menu();
55+
}
5456
for (auto element : ui_elements) {
5557
element.second->show();
5658
}

src/MarlinSimulator/user_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class UserInterface {
103103

104104
bool post_init_complete = false;
105105
std::function<void(void)> post_init;
106+
std::function<void(void)> m_main_menu;
106107

107108
static std::map<std::string, std::shared_ptr<UiWindow>> ui_elements;
108109
};

src/MarlinSimulator/visualisation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ void Visualisation::ui_viewport_menu_callback(UiWindow*) {
339339
camera.rotation = {-192.0f, -25.0, 0.0f};
340340
camera.up = {0.0f, 1.0f, 0.0f};
341341
}
342-
if (ImGui::BeginMenu("Mode")) {
343-
if (ImGui::MenuItem("Fly", nullptr, true, true)) { }
344-
if (ImGui::MenuItem("Orbit", nullptr, false, true)) { }
345-
ImGui::EndMenu();
346-
}
342+
// if (ImGui::BeginMenu("Mode")) {
343+
// if (ImGui::MenuItem("Fly", nullptr, true, true)) { }
344+
// if (ImGui::MenuItem("Orbit", nullptr, false, true)) { }
345+
// ImGui::EndMenu();
346+
// }
347347
if (ImGui::BeginMenu("Focus View")) {
348348
if (ImGui::MenuItem("Centre X (Right)")) {
349349
camera.position = {build_plate_dimension.x, 10.0f, -(build_plate_dimension.y / 2.0f)};

0 commit comments

Comments
 (0)