*CBApp: a cross-platform desktop application for computational electrodynamic modeling with C++
Note:
CBApp is just a generic, placeholder name I've given to this project for the purpose of having an identifier in the build system.
TOC
...
This project seeks to develop a cross-platform, GUI-based desktop application for performing computational physics simulations. Our project is built using modern C++ (cpp-20+), the docking branch of Dear ImGui, OpenGL, and GLFW.
Video 1. 1D FDTD Simulation; work was taken from an FDTD engine I developed for a recent paper and migrated into the CBApp interface.
Our application is built using CMake; minGW is used as a cross-platform toolchain to build the project for Windows. The set of third-party dependencies is kept to a minimum to maximize the compatibility our application for use across a variety of different machines that may/may-not have access to certain installations. Currently, these dependencies are limited to the ImPlot extension for Dear ImGui and nlohmann's JSON for modern C++.
...
Fundamentally, our application must facilitate each of the following tasks:
- (1) Create and design an electrodynamic system along with the relevant parameters for each item within,
- (2) Perform a simulation of the conditions we specified within the system we created,
- (3) Present a visualization of the simulation results and allow the user to interact with and analyze the data.
...
More...
In this pursuit, our design has been structured in a manner as to adhere to the following goals:
Implementing a highly funcitonal user-interface is often an extremely time consuming and potentially frustrating task. What's more---this is further pronounced when maintaining, refactoring, or extending an existing UI that is poorly thought-out. At the penalty of increased complexity and initial development time, our goal has been to establish a robust and extensible UI that is accomodating to change, additions, or extensions.
The overal layout of the UI design is inspired by the desigon of the Ableton Live application:
- Menu Bar: The bar at the very top of the application containing the "File", "Window", "Help", etc, drop-down menus.
- Control Bar: The 'banner-style' panel that is found below the Menu Bar and spans the entire width of the main window.
- Browser: The collapsible window pane found on the left hand side of the main window and spanning its entire height.
- Main Section: The primary window pane located beneath the Control Bar and to the right of the Browser.
- Detail View: A second collapsible window pane located below the Main Section.
Taking advantage of the
viewportsanddockingfeatures of Dear ImGui---the user is able to rearrange and customize the appearance and window layout of each part of the main application to suit their needs and preferences.Each window of the application can be undocked and moved to a different docing location or even set aside to serve as an entirely seperate, stand-alone window.
The colors, geometry, and fonts of the application can be customized, saved/loaded to an external file, overriden as the default settings of the app, and so forth.
Each major responsibility of the application is allocated to a
delegatorclass in order to prevent the centralAppclass from becoming bloated and cumbersome and, instead, delegating away certain responsibilities, as the name suggests.This is a modular system that allows for additional windows, tools, and other features to be easily integrated into the core application services.
...
Figure 4-1. Menubar list displaying each tool that is available in the application.
...
4A.1. THE EDITOR APPLICATION
More...
The
Figure 4A.1-2. Text...EditorApplication is designed to be a CAD or Vector-Artwork style tool that will be used to create the system that will ultimately be simulated by the FDTD engine (see "GraphApplication" below).This tool provides a host of different tools to create objects and customize their geometry in a manner following that of a classic, solid-body modeling program. This includes the ability to create exotic curvature in each object with a Bezier curve editing tool whose design was heavily inspired by that of the "Pen Tool" in Adobe Illustrator.
![]()
Figure 4A.1-2. Using a right-click context menu to set the Payload of an object.
Each object carries a
Payload---which is used to carry the data that categorizes what the role of this object is within the FDTD simulation. That is---by default, each object is simply an element of pure geometry that has no significance to the simulation on its own. By assigning thePayloadsfor each object---we create the additional information that is needed to define each element of the system. The host of differentPayloadsincludes things like the following:
Sources:
- E or B sources such as Gaussian Pulse, Time-Harmonic, Ricker Wavelets, Monochromatic Plane Waves, and so forth, which are responsible for stimulating the field of the simulation.
- Each source may have a variety of additional properties depending on its particular type. This includes, but is not limitied to, its frequency, the length of time it will be active for, its amplitude or intensity, whether or not it is a Hard or Soft source, descriptions of its dispersion or coherence properties, and so on.
Materials:
- This describes the various media that are contained within the simulated domain, such as dielectrics, conductors, and so on.
Boundary Conditions:
- of the simulation (such as a Murr ABC, TF/SF, PML, etc)
Monitors and Measurements:
- Monitors are used to indicate certain points or regions of interest within the simulation. Placing a monitor at a certain region allows us to explicitly dictate what specific quantities of data we wish to record from the simulation.
4A.2. THE MIMIC APPLICATION
4A.3. THE GRAPH APPLICATION (THIS WILL LATER BE RENAMED...)
More...
This application is the actual FDTD Engine that will compute the simulation of the system that was designed with the
Editorapplication. Note that this name is just temporarly and will evelntually be replaced with a more-appropriate name once development proceeds further.Some more text...
4B.1. THE CCOUNTER APPLICATION
More...
Figure 4-1. Primary view of the Coincidence Counter plots as data is streamed from the Python script connected to the FPGA.
Figure 4B.1-1. Display of the plots presenting the A, B, C, and D counter values for the APD detectors as well as each coincident permutation (e.g.: AB, AC, AD, ABC, etc...).Designed to facilitate our work in the laboratory on Spontaneous Parametric Down-Conversion (SPDC) due to a pump laser that is incident upon a Birifringent, Anisotropic BBO crystal.
The Coincidence Counter device in our lab is responsible for detecting and counting the number of single-photon arrivals which are produced by the SPDC process. The way this is achieved is via a series of Avalanche Photodiode Detectors (APD) which are carefully placed at positions that coorespond to the trajectories of the phase-matching SPDC emission cones. The output signal of each APD is monitored by a National Instruments Field Programmable Gate Array (FPGA) device. The CCounter application runs a Python script inside a child process to interface with the FPGA using NI's Python API. Hence---the ImGui application is responsible for fetching the data that is returned from the FPGA, displaying it in real-time, and allowing the user to perform data analysis and/or modifications to the FPGA.
4B.2. THE SPR CALCULATOR APPLICATION
More...
Figure 4B.2-2. Text...This was a project to re-create an application that my professor, Dr. Erik J. Sánchez, had designed in 2000 as a tool to accompany our experiments in the field of
plasmonics. The re-creation I made was done inPythonusing theTkinter/Custom Tkinterpackages to create the GUI.As I have continued to learn more about
Dear ImGui, it has become overwhelmingly clear to me that the best direction to proceed with the SPR Calculator project is to create an additionalAppletwithinCBAppand migrate this project into my existing ecosystem. I learned a great deal about retained mode GUIs and a number of other topics from my work on this project in Python. However---Tkinterpackages and the nature ofPythonas a whole is not conducive for creating a robust tool that is able to withstand the test of time. This, however, is not to say that such a result is impossible to achieve; but the
4C. ADDITIONAL TOOLS AND UTILITIES
More...
A number of smaller utility tools have been created in order to solve certain problems that have arisen over the development of this project. These tools remain accessible to the end user in the event that they should perhaps ever find them to be useful.
4C.1. THE DEAR IMGUI TOOLS
Each of the tools provided by the Dear ImGui demos can be accessed from the "Window > Show" menu in the Menu Bar. This includes the Dear ImGui Demo and Style Editor, the ImPlot Demo and Style Editor, and etc. Using these tools, the user can customize the appearance of the paplication to their requirements and subequently save these settings for future useage. For DEBUG builds of the project, the ImGui Debugger tools will also be available under the same menu.
4C.2. THE THE COLOR TOOL
While constructing the UI of the project, a number of principles from color-theory were used to produce shades and color palettes which assist in communicating design intentions to the user as well as providing a visually appealing design for the application. While creating these color schemes, a numner of tools were developed to compute the ideal shades and values programatically. These tools remain available in the application for the user's convienence.
4C.3. THE THE COLORMAP TOOL
Similarly, a number of custom colormaps were generated to conform to specific needs of certain data visualization and analysis tasks. Additionally, the entire suite of colormaps that are available within the popular matplotlib package for Python have been extracted and included in CBApp as well. The tools for importing/exporting and creating custom colormaps have also been included within the application.
...
- The project is built exclusively using
CMaketo ensure a that a widely available system with a great deal of support and resources is used.
I have created a shell script to simplify the steps required to obtain the latest source code for the project, install each dependency that is needed to build and run the application, and produce a project file that can be immediately used to work with the application.
Currently, there is ONLY such a script that works for the macOS build of the project and generates an Xcode project file. In the near future, I will develop an additional script to bootstrap development on a Windows machine and generate a VSCode / Visual Studio project file.
There are (ideally) two things that are required to get the project setup...
(1) Download the Xcode IDE from the AppStore. Make sure to open the application once it is installed and allow it to install any additional tooling that it may request upon first running it.
(2) Download this script (macOS) from the repository. You may need to give the script the appropriate RWE permissions before your machine will allow you to run it.
(3) You may also need to go into System Preferences and give Xcode and Terminal permission to access files on the Desktop if it is the first time your machine has done this kind of work.
(4) Finally, we are ready to run the script and get the project setup:
sudo xcodebuild -license accept sudo xcodebuild -runFirstLaunch xcode-select -p sudo xcode-select -s /Applications/Xcode.app/Contents/Developer chmod u+x setup_cbapp.sh ./setup_cbapp.command
The script is located inside the
CBApp/scripts/other/there is a filesetup_cbapp.sh. This file is designed to be a single-click bootstrap for the program. Currently, this ONLY works for the macOS build---but I will be creating an additional script for a Windows bootstrap.In other words, this is all that is required to use this scriot:
- (1) download the Xcode IDE from the AppStore.
- (2) download this file from the repository.
- and run it on your local system---it will:
- install each dependency needed to build the app (Homebrew, CMake, GLFW, etc),
- check if any of these dependencies are out-of-date,
- create a directory
CBApp/scripts/other/
...
> > > > ```bash > > # OUT-OF-DATE --- I NEED TO UPDATE THIS INFORMATION (July 25, 2025)... > > > > git clone https://github.com/your-username/CBApp.git > > cd CBApp && mkdir build && cd build > > cmake -G "Xcode" .. # or use "Unix Makefiles" > > cmake --build . > > ./CBApp # launch the app > > ``` > > >...
- Collin A. Bond
- A Recent Conference Paper on FDTD.
- Student of Physics and Computer Science.
- Portland State University.
Distributed under the MIT License. See LICENSE.txt for details.
A special thanks goes out to the following individuals:
- Dr. Erik J. Sánchez
- Department of Physics, Portland State University.
- Dr. Andres H. La Rosa
- Department of Physics, Portland State University.
- Prof. John B. Schneider
- School of Electrical Engineering and Computer Science, Washington State University.
- His outstanding book, Understanding the Finite-Difference Time-Domain Method.
- Dr. Jeroen Vleggaar
- The Huygens Optics YouTube Channel.










