Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Build doxygen
run: |
doxygen docs/doxygen.config
(cd docs/latex; make; ls; mv refman.pdf SimpleFastOpenAtomicVisualiser.pdf)
(cd docs/latex; buf_size=1000000 make; ls; mv refman.pdf SimpleFastOpenAtomicVisualiser.pdf)

- name: Upload PDF
uses: actions/upload-artifact@v4
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ include/vendored/VulkanSDK/Windows/Include
include/vendored/VulkanSDK/Windows/lib
docs/html
docs/latex
*.mp4
*.mp4
imgui.ini
2 changes: 1 addition & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Miscellaneous key bindings are:
| :----- | :---- | :---- |
| X | Toggle drawing the coordinate axes | |
| C | Toggle drawing the simulation cell | |
| I | Toggle information text | |
| U | Toggle user interface windows | |
| G | Screen grab | |
| V | Start or finish a video recording | |
| ESC | Quit | |
Expand Down
26 changes: 26 additions & 0 deletions LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,30 @@ END OF TERMS AND CONDITIONS
```
public domain Simple, Minimalistic, No Allocations MPEG writer - http://jonolick.com
Converted to C by Wladislav Artsimovich https://blog.frost.kiwi/jo-mpeg-in-c
```

# Dear Imgui

```
The MIT License (MIT)

Copyright (c) 2014-2025 Omar Cornut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Miscellaneous key bindings are:
| :----- | :---- | :---- |
| X | Toggle drawing the coordinate axes | |
| C | Toggle drawing the simulation cell | |
| I | Toggle information text | |
| U | Toggle user interface windows | |
| G | Screen grab | |
| V | Start or finish a video recording | |
| ESC | Quit | |
Expand Down
234 changes: 234 additions & 0 deletions include/cameraWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
#ifndef CAMERAWINDOW_H
#define CAMERAWINDOW_H

#include <imgui/imgui.h>
#include <imgui/imgui_impl_glfw.h>
#include <imgui/imgui_impl_opengl3.h>

#ifdef WINDOWS
#include <imgui/imgui_impl_win32.h>
#endif

#ifdef MACOS
#include <imgui/imgui_impl_osx.h>
#endif

#include <camera.h>
#include <commandLine.h>
#include <atom.h>
#include <helpMarker.h>

/**
* @brief The camera controls window.
*
*/
class CameraWindow
{
public:

/**
* @brief If the Camera or Atoms require updates.
*
*/
struct CameraUpdates
{
CameraUpdates()
: cameraMoved(false),
atomsMoved(false)
{}

bool cameraMoved;
bool atomsMoved;
};

CameraWindow() {}

/**
* @brief Draw the window with Imgui
*
* @param options the current options.
*
* @remark Actions in the UI are queued for later application.
* @see CameraWindow::applyQueueActions.
*/
void draw
(
CommandLine & options
)
{
ImGui::Begin("Camera");
ImGui::Text("Zoom ");
ImGui::SameLine();

ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
if (ImGui::ArrowButton("##zoomin", ImGuiDir_Up)) { zoomQueue--; }
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if (ImGui::ArrowButton("##zoomout", ImGuiDir_Down)) { zoomQueue++; }
ImGui::PopItemFlag();
ImGui::SameLine(); HelpMarker("Zoom to and from the focus (W/S)");

ImGui::Text("Rotate ");
ImGui::SameLine();

ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
if (ImGui::ArrowButton("##rotatel", ImGuiDir_Left)) { rotateQueue--; }
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if (ImGui::ArrowButton("##rotater", ImGuiDir_Right)) { rotateQueue++; }
ImGui::PopItemFlag();
ImGui::SameLine(); HelpMarker("Rotate around the focus (A/D)");

ImGui::Text("Incline ");
ImGui::SameLine();

ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
if (ImGui::ArrowButton("##inclineu", ImGuiDir_Up)) { inclineQueue--; }
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if (ImGui::ArrowButton("##inclined", ImGuiDir_Down)) { inclineQueue++; }
ImGui::PopItemFlag();
ImGui::SameLine(); HelpMarker("Incline around the focus (Q/E)");

ImGui::Text("Pan x ");
ImGui::SameLine();

ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
if (ImGui::ArrowButton("##panx-", ImGuiDir_Left)) { panxQueue--; }
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if (ImGui::ArrowButton("##panx+", ImGuiDir_Right)) { panxQueue++; }
ImGui::PopItemFlag();
ImGui::SameLine(); HelpMarker("Pan in x (Left/Right)");

ImGui::Text("Pan y ");
ImGui::SameLine();

ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
if (ImGui::ArrowButton("##pany-", ImGuiDir_Left)) { panyQueue--; }
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if (ImGui::ArrowButton("##pany+", ImGuiDir_Right)) { panyQueue++; }
ImGui::PopItemFlag();
ImGui::SameLine(); HelpMarker("Pan in y (Up/Down)");

ImGui::Text("Pan z ");
ImGui::SameLine();

ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
if (ImGui::ArrowButton("##panz-", ImGuiDir_Left)) { panzQueue--; }
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if (ImGui::ArrowButton("##panz+", ImGuiDir_Right)) { panzQueue++; }
ImGui::PopItemFlag();
ImGui::SameLine(); HelpMarker("Pan in z (.//)");

ImGui::PushItemWidth(200);
ImGui::InputFloat("Zoom speed: ", &options.cameraZoomSpeed.value, 0.01f, 1.0f, "%.2f");
ImGui::SameLine(); HelpMarker("Modify zoom rate (CTRL-CLICK for faster steps)");

ImGui::PushItemWidth(200);
ImGui::InputFloat("Rotate speed: ", &options.cameraRotateSpeed.value, 0.01f, 1.0f, "%.2f");
ImGui::SameLine(); HelpMarker("Modify rotate rate (CTRL-CLICK for faster steps)");

ImGui::PushItemWidth(200);
ImGui::InputFloat("Incline speed: ", &options.cameraInclineSpeed.value, 0.01f, 1.0f, "%.2f");
ImGui::SameLine(); HelpMarker("Modify inclination rate (CTRL-CLICK for faster steps)");

ImGui::PushItemWidth(200);
ImGui::InputFloat("Pan speed: ", &options.cameraPanSpeed.value, 0.01f, 1.0f, "%.2f");
ImGui::SameLine(); HelpMarker("Modify pan rate (CTRL-CLICK for faster steps)");

if (ImGui::Button("Reset Camera "))
{
resetCamera = true;
}

ImGui::End();
}

/**
* @brief Apply queued actions from the UI.
*
* @param camera the Camera to update.
* @param atoms the Atoms to update.
* @param options the options to use for actions.
* @param dr the length unit.
* @param dtheta the rotation unit.
* @param dphi the incline unit.
* @return CameraUpdates Whether the Camera or Atoms were updated.
*/
CameraUpdates applyQueueActions
(
Camera & camera,
std::vector<Atom> & atoms,
const CommandLine & options,
const float & dr,
const float & dtheta,
const float & dphi
)
{
CameraUpdates moved;

if (zoomQueue != 0)
{
camera.zoom(dr*options.cameraZoomSpeed.value*zoomQueue);
zoomQueue = 0;
moved.cameraMoved = true;
}

if (rotateQueue != 0)
{
camera.rotate(dtheta*options.cameraRotateSpeed.value*rotateQueue);
rotateQueue = 0;
moved.cameraMoved = true;
}

if (inclineQueue != 0)
{
camera.incline(dphi*options.cameraInclineSpeed.value*inclineQueue);
inclineQueue = 0;
moved.cameraMoved = true;
}

if (resetCamera)
{
if (!options.noCentering.value) { center(atoms); }
if (options.focus.value < atoms.size()) { centerOn(atoms, options.focus.value); }
camera.reset(atoms);
moved.atomsMoved = true;
moved.cameraMoved = true;
resetCamera = false;
}

if (panxQueue != 0)
{
translate(atoms, {dr*options.cameraPanSpeed.value*panxQueue, 0.0, 0.0});
panxQueue = 0;
moved.atomsMoved = true;
}

if (panyQueue != 0)
{
translate(atoms, {0.0, dr*options.cameraPanSpeed.value*panyQueue, 0.0});
panyQueue = 0;
moved.atomsMoved = true;
}

if (panzQueue != 0)
{
translate(atoms, {0.0, 0.0, dr*options.cameraPanSpeed.value*panzQueue});
panzQueue = 0;
moved.atomsMoved = true;
}

return moved;
}

private:

inline static int zoomQueue = 0;
inline static int rotateQueue = 0;
inline static int inclineQueue = 0;
inline static int panxQueue = 0;
inline static int panyQueue = 0;
inline static int panzQueue = 0;
inline static bool resetCamera = false;

};

#endif /* CAMERAWINDOW_H */
14 changes: 9 additions & 5 deletions include/commandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ struct CommandLine
extractFlag(hideAtoms, flags);
extractFlag(showAxes, flags);
extractFlag(showCell, flags);
extractFlag(hideInfoText, flags);
extractFlag(hideUI, flags);
extractFlag(play, flags);
extractFlag(meshes, flags);
extractFlag(darkTheme, flags);
Expand Down Expand Up @@ -353,7 +353,7 @@ struct CommandLine
Argument<std::filesystem::path> colourmap = {"colourmap", "The colourmap path.", "", {}};
Argument<std::filesystem::path> atomColours = {"atomColours", "Path for per-atom colour overrides.", "", {}};
Argument<std::string> videoName = {"videoName", "Name of saved video.", "", ""};
Argument<vec<2>> resolution = {"resolution", "Window resolution in pixels.", "", {512, 512}};
Argument<vec<2>> resolution = {"resolution", "Window resolution in pixels.", "", {800, 800}};
Argument<uint64_t> bondFocus = {"bondFocus", "Only draw bonds for this atom.", "", NULL_INDEX};
Argument<uint64_t> focus = {"focus", "Centre on a particular atom.", "", NULL_INDEX};
Argument<float> cameraZoomSpeed = {"cameraZoomSpeed", "Speed of the camera's zoom.", "", 1.0};
Expand All @@ -376,7 +376,7 @@ struct CommandLine
Argument<bool> hideAtoms = {"hideAtoms", "Hide atoms.", "Toggleable at runtime.", false};
Argument<bool> showAxes = {"showAxes", "Show the coordinate axes.", "Toggleable at runtime.", false};
Argument<bool> showCell = {"showCell", "Show the simulation cell.", "Toggleable at runtime.", false};
Argument<bool> hideInfoText = {"hideInfoText", "Hide information and statistics text.", "Toggleable at runtime.", false};
Argument<bool> hideUI = {"hideUI", "Hide information and statistics text.", "Toggleable at runtime.", false};
Argument<bool> play = {"play", "Play trajectory.", "Toggleable at runtime.", false};
Argument<bool> noCentering = {"noCentering", "Do not centre the atoms", "Toggleable at runtime.", false};
Argument<bool> darkTheme = {"darkTheme", "Use dark theme", "Toggleable at runtime.", false};
Expand Down Expand Up @@ -629,7 +629,7 @@ struct CommandLine
<< "\n"
<< sidebyside(argumentHelp(noCentering), argumentHelp(noTransparencySorting), 42)
<< "\n"
<< sidebyside(argumentHelp(levelOfDetail), argumentHelp(hideInfoText), 42)
<< sidebyside(argumentHelp(levelOfDetail), argumentHelp(hideUI), 42)
<< "\n"
<< sidebyside(argumentHelp(videoName), argumentHelp(fieldOfView), 42)
<< "\n"
Expand Down Expand Up @@ -759,6 +759,10 @@ jo_mpeg
Public domain.
Jon Olick.

Dear Imgui
MIT.
Omar Cornut.

With thanks, Jerboa.
)";

Expand Down Expand Up @@ -935,7 +939,7 @@ END OF TERMS AND CONDITIONS)";
{hideAtoms.name, hideAtoms},
{showAxes.name, showAxes},
{showCell.name, showCell},
{hideInfoText.name, hideInfoText},
{hideUI.name, hideUI},
{play.name, play},
{noCentering.name, noCentering},
{darkTheme.name, darkTheme},
Expand Down
4 changes: 4 additions & 0 deletions include/font.h

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions include/helpMarker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef HELPMARKER_H
#define HELPMARKER_H

#include <imgui/imgui.h>
#include <imgui/imgui_impl_glfw.h>
#include <imgui/imgui_impl_opengl3.h>

#ifdef WINDOWS
#include <imgui/imgui_impl_win32.h>
#endif

#ifdef MACOS
#include <imgui/imgui_impl_osx.h>
#endif

/**
* @brief Draw a help marker (?) in Imgui UIs
*
* @param desc the help message.
*/
static void HelpMarker(const char* desc)
{
ImGui::TextDisabled("(?)");
if (ImGui::BeginItemTooltip())
{
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(desc);
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

#endif /* HELPMARKER_H */
Loading