33#include < transformer/transformer.h>
44#include < graphics/graphics.h>
55#include < interactions/interactions.h>
6+ #include < graphics/3d/camera_state.h>
67#include < string>
78#include < iostream>
89
@@ -304,12 +305,6 @@ void render_and_update(FunctionState& state, ViewState& view_state, unsigned int
304305 ImGui::Unindent ();
305306 }
306307 }
307- if (UI::CollapsingHeader (" 3D Keybinds" )) {
308- ImGui::BulletText (" WASD: Move" );
309- ImGui::BulletText (" Right click + Drag: Move camera" );
310- ImGui::BulletText (" Shift/Spacebar: Go up" );
311- ImGui::BulletText (" Ctrl: Go down" );
312- }
313308 if (UI::CollapsingHeader (" Help & Keybinds" )) {
314309 ImGui::BulletText (" Left Click + Drag: Pan Camera" );
315310 ImGui::BulletText (" Scroll Wheel: Zoom" );
@@ -446,34 +441,86 @@ void render_and_update(FunctionState& state, ViewState& view_state, unsigned int
446441 }
447442 }
448443 if (view_state.is_high_precision ) {
449- ImGui::Begin (" High Precision Render" , &view_state.is_high_precision , ImGuiWindowFlags_AlwaysAutoResize);
450- if (view_state.hp_texture != 0 ) {
451- ImGui::Text (" Resolution: %dx%d" , view_state.hp_width , view_state.hp_height );
452- if (view_state.is_rendering_hp ) {
453- glBindTexture (GL_TEXTURE_2D, view_state.hp_texture );
454- glTexSubImage2D (GL_TEXTURE_2D, 0 , 0 , 0 , view_state.hp_width , view_state.hp_height , GL_RGBA, GL_UNSIGNED_BYTE, view_state.hp_cpu_buffer .data ());
455-
456- float progress = (float )view_state.hp_rows_completed / (float )view_state.hp_height ;
457- ImGui::ProgressBar (progress, ImVec2 (-1 .0f , 0 .0f ), " Loading..." );
458- }
459- else {
460- if (ImGui::Button (" Save to PNG" )) {
461- std::string filename = " high_precision_" + std::to_string (view_state.hp_width ) + " x" + std::to_string (view_state.hp_height ) + " .png" ;
462- export_plot_to_png (view_state.hp_cpu_buffer .data (),view_state.hp_width ,view_state.hp_height ," complex-plot-high-precision.png" );
463- view_state.show_export_success = true ;
464- }
465- }
466- ImGui::Image (
467- (void *)(intptr_t )view_state.hp_texture ,
468- ImVec2 ((float )view_state.hp_width , (float )view_state.hp_height ),
469- ImVec2 (0 , 0 ),
470- ImVec2 (1 , 1 )
471- );
472- }
473- else {
474- ImGui::Text (" Initializing..." );
444+ ImGui::Begin (" High Precision Render" , &view_state.is_high_precision , ImGuiWindowFlags_AlwaysAutoResize);
445+ if (view_state.hp_texture != 0 ) {
446+ ImGui::Text (" Resolution: %dx%d" , view_state.hp_width , view_state.hp_height );
447+ if (view_state.is_rendering_hp ) {
448+ glBindTexture (GL_TEXTURE_2D, view_state.hp_texture );
449+ glTexSubImage2D (GL_TEXTURE_2D, 0 , 0 , 0 , view_state.hp_width , view_state.hp_height , GL_RGBA, GL_UNSIGNED_BYTE, view_state.hp_cpu_buffer .data ());
450+
451+ float progress = (float )view_state.hp_rows_completed / (float )view_state.hp_height ;
452+ ImGui::ProgressBar (progress, ImVec2 (-1 .0f , 0 .0f ), " Loading..." );
453+ }
454+ else {
455+ if (ImGui::Button (" Save to PNG" )) {
456+ std::string filename = " high_precision_" + std::to_string (view_state.hp_width ) + " x" + std::to_string (view_state.hp_height ) + " .png" ;
457+ export_plot_to_png (view_state.hp_cpu_buffer .data (),view_state.hp_width ,view_state.hp_height ," complex-plot-high-precision.png" );
458+ view_state.show_export_success = true ;
475459 }
476- ImGui::End ();
477460 }
461+ ImGui::Image (
462+ (void *)(intptr_t )view_state.hp_texture ,
463+ ImVec2 ((float )view_state.hp_width , (float )view_state.hp_height ),
464+ ImVec2 (0 , 0 ),
465+ ImVec2 (1 , 1 )
466+ );
467+ }
468+ else {
469+ ImGui::Text (" Initializing..." );
470+ }
471+ ImGui::End ();
472+ }
473+ if (view_state.is_3d ) {
474+ ImGui::Begin (" 3D Settings" );
475+ ImGui::Text (" Height = " );
476+ if (ImGui::IsItemHovered ()) ImGui::SetTooltip (" Height function. 'z' evaluates on the output of f(z). Defaults to mag(z)." );
477+ ImGui::SameLine ();
478+ bool height_pressed_enter = ImGui::InputText (" ##height_source" ,
479+ &state.height_expression ,
480+ ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackAlways,
481+ FunctionInputCallback,
482+ (void *)&state);
483+ ImGui::SameLine ();
484+ if (UI::Button (" Compile##Height" )) {
485+ height_pressed_enter = true ;
486+ }
487+ if (ImGui::IsItemHovered ()) {
488+ ImGui::SetMouseCursor (ImGuiMouseCursor_Hand);
489+ }
490+ if (height_pressed_enter) {
491+ state.needs_height_reparse = true ;
492+ }
493+ ImGui::Spacing ();
494+ if (UI::CollapsingHeader (" Camera Settings" ), nullptr , ImGuiWindowFlags_AlwaysAutoResize) {
495+ ImGui::Text (" Camera Mode:" );
496+ ImGui::SameLine ();
497+
498+ if (UI::RadioButton (" Free" , !camera_state.is_orbit )) {
499+ camera_state.is_orbit = false ;
500+ camera_state.switch_to_free ();
501+ }
502+ ImGui::SameLine ();
503+ if (UI::RadioButton (" Orbit" , camera_state.is_orbit )) {
504+ camera_state.is_orbit = true ;
505+ camera_state.switch_to_orbit ();
506+ update_camera_vectors (camera_state);
507+ }
508+ if (UI::Button (" Snap camera to origin" )) {
509+ CameraState new_camerastate;
510+ new_camerastate.is_orbit = camera_state.is_orbit ;
511+ camera_state = new_camerastate;
512+
513+ }
514+ }
515+ if (UI::CollapsingHeader (" 3D Keybinds" )) {
516+ ImGui::BulletText (" WASD: Move" );
517+ ImGui::BulletText (" Right click + Drag: Move camera" );
518+ ImGui::BulletText (" Shift/Spacebar: Go up" );
519+ ImGui::BulletText (" Ctrl: Go down" );
520+ }
521+
522+
523+ ImGui::End ();
524+ }
478525 ImGui::End ();
479526}
0 commit comments