Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Algol68
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C with Coccinelle
C++ with Coccinelle
C++ (Circle)
CIRCT
Clean
Clojure
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Helion
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Mojo
Nim
Numba
Nix
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
PTX
Python
Racket
Raku
Ruby
Rust
Sail
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
Triton
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Yul (Solidity IR)
Zig
Javascript
GIMPLE
Ygen
sway
c++ source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 12.4.0
ARM GCC 12.5.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 13.3.0 (unknown-eabi)
ARM GCC 13.4.0
ARM GCC 13.4.0 (unknown-eabi)
ARM GCC 14.1.0
ARM GCC 14.1.0 (unknown-eabi)
ARM GCC 14.2.0
ARM GCC 14.2.0 (unknown-eabi)
ARM GCC 14.3.0
ARM GCC 14.3.0 (unknown-eabi)
ARM GCC 15.1.0
ARM GCC 15.1.0 (unknown-eabi)
ARM GCC 15.2.0
ARM GCC 15.2.0 (unknown-eabi)
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (ex-WINE)
ARM msvc v19.10 (ex-WINE)
ARM msvc v19.14 (ex-WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 12.4.0
ARM64 gcc 12.5.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 13.4.0
ARM64 gcc 14.1.0
ARM64 gcc 14.2.0
ARM64 gcc 14.3.0
ARM64 gcc 15.1.0
ARM64 gcc 15.2.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (ex-WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 12.4.0
AVR gcc 12.5.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 13.4.0
AVR gcc 14.1.0
AVR gcc 14.2.0
AVR gcc 14.3.0
AVR gcc 15.1.0
AVR gcc 15.2.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF clang 19.1.0
BPF clang 20.1.0
BPF clang 21.1.0
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
EDG 6.7
EDG 6.7 (GNU mode gcc 14)
EDG 6.8
EDG 6.8 (GNU mode gcc 15)
FRC 2019
FRC 2020
FRC 2023
HPPA gcc 14.2.0
HPPA gcc 14.3.0
HPPA gcc 15.1.0
HPPA gcc 15.2.0
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
KVX ACB 5.2.0 (GCC 13.2.1)
LoongArch64 clang (trunk)
LoongArch64 clang 17.0.1
LoongArch64 clang 18.1.0
LoongArch64 clang 19.1.0
LoongArch64 clang 20.1.0
LoongArch64 clang 21.1.0
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 13.4.0
M68K gcc 14.1.0
M68K gcc 14.2.0
M68K gcc 14.3.0
M68K gcc 15.1.0
M68K gcc 15.2.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
MinGW gcc 14.3.0
MinGW gcc 15.2.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 12.4.0
RISC-V (32-bits) gcc 12.5.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 13.4.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 14.2.0
RISC-V (32-bits) gcc 14.3.0
RISC-V (32-bits) gcc 15.1.0
RISC-V (32-bits) gcc 15.2.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 12.4.0
RISC-V (64-bits) gcc 12.5.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 13.4.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 14.2.0
RISC-V (64-bits) gcc 14.3.0
RISC-V (64-bits) gcc 15.1.0
RISC-V (64-bits) gcc 15.2.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 19.1.0
RISC-V rv32gc clang 20.1.0
RISC-V rv32gc clang 21.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 19.1.0
RISC-V rv64gc clang 20.1.0
RISC-V rv64gc clang 21.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 12.4.0
SPARC LEON gcc 12.5.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 13.4.0
SPARC LEON gcc 14.1.0
SPARC LEON gcc 14.2.0
SPARC LEON gcc 14.3.0
SPARC LEON gcc 15.1.0
SPARC LEON gcc 15.2.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 12.4.0
SPARC gcc 12.5.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 13.4.0
SPARC gcc 14.1.0
SPARC gcc 14.2.0
SPARC gcc 14.3.0
SPARC gcc 15.1.0
SPARC gcc 15.2.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 12.4.0
SPARC64 gcc 12.5.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 13.4.0
SPARC64 gcc 14.1.0
SPARC64 gcc 14.2.0
SPARC64 gcc 14.3.0
SPARC64 gcc 15.1.0
SPARC64 gcc 15.2.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 12.4.0
TI C6x gcc 12.5.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 13.4.0
TI C6x gcc 14.1.0
TI C6x gcc 14.2.0
TI C6x gcc 14.3.0
TI C6x gcc 15.1.0
TI C6x gcc 15.2.0
TI CL430 21.6.1
Tricore gcc 11.3.0 (EEESlab)
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
VAX gcc NetBSDELF 12.4.0 (Apr 16 05:27 2025)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 14.2.0 (20241119)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 14.2.0 (20241119)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 14.2.0 (20241119)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
arm64 msvc v19.39 VS17.9
arm64 msvc v19.40 VS17.10
arm64 msvc v19.41 VS17.11
arm64 msvc v19.42 VS17.12
arm64 msvc v19.43 VS17.13
arm64 msvc v19.44 VS17.14
arm64 msvc v19.latest
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 19.1.0
armv7-a clang 20.1.0
armv7-a clang 21.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 19.1.0
armv8-a clang 20.1.0
armv8-a clang 21.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
clad trunk (clang 21.1.0)
clad v1.10 (clang 20.1.0)
clad v1.8 (clang 18.1.0)
clad v1.9 (clang 19.1.0)
clad v2.00 (clang 20.1.0)
clad v2.1 (clang 21.1.0)
clad v2.2 (clang 21.1.0)
clang-cl 18.1.0
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
ez80-clang 15.0.0
ez80-clang 15.0.7
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 12.4.0
loongarch64 gcc 12.5.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 13.4.0
loongarch64 gcc 14.1.0
loongarch64 gcc 14.2.0
loongarch64 gcc 14.3.0
loongarch64 gcc 15.1.0
loongarch64 gcc 15.2.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips clang 19.1.0
mips clang 20.1.0
mips clang 21.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 12.4.0
mips gcc 12.5.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 13.4.0
mips gcc 14.1.0
mips gcc 14.2.0
mips gcc 14.3.0
mips gcc 15.1.0
mips gcc 15.2.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 12.4.0
mips64 (el) gcc 12.5.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 13.4.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 14.2.0
mips64 (el) gcc 14.3.0
mips64 (el) gcc 15.1.0
mips64 (el) gcc 15.2.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 clang 19.1.0
mips64 clang 20.1.0
mips64 clang 21.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 12.4.0
mips64 gcc 12.5.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 13.4.0
mips64 gcc 14.1.0
mips64 gcc 14.2.0
mips64 gcc 14.3.0
mips64 gcc 15.1.0
mips64 gcc 15.2.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mips64el clang 19.1.0
mips64el clang 20.1.0
mips64el clang 21.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel clang 19.1.0
mipsel clang 20.1.0
mipsel clang 21.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 12.4.0
mipsel gcc 12.5.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 13.4.0
mipsel gcc 14.1.0
mipsel gcc 14.2.0
mipsel gcc 14.3.0
mipsel gcc 15.1.0
mipsel gcc 15.2.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 12.4.0
power gcc 12.5.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 13.4.0
power gcc 14.1.0
power gcc 14.2.0
power gcc 14.3.0
power gcc 15.1.0
power gcc 15.2.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 12.4.0
power64 gcc 12.5.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 13.4.0
power64 gcc 14.1.0
power64 gcc 14.2.0
power64 gcc 14.3.0
power64 gcc 15.1.0
power64 gcc 15.2.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 12.4.0
power64le gcc 12.5.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 13.4.0
power64le gcc 14.1.0
power64le gcc 14.2.0
power64le gcc 14.3.0
power64le gcc 15.1.0
power64le gcc 15.2.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
qnx 8.0.0
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 12.4.0
s390x gcc 12.5.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 13.4.0
s390x gcc 14.1.0
s390x gcc 14.2.0
s390x gcc 14.3.0
s390x gcc 15.1.0
s390x gcc 15.2.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 12.4.0
sh gcc 12.5.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 13.4.0
sh gcc 14.1.0
sh gcc 14.2.0
sh gcc 14.3.0
sh gcc 15.1.0
sh gcc 15.2.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (ex-WINE)
x64 msvc v19.10 (ex-WINE)
x64 msvc v19.14 (ex-WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x64 msvc v19.39 VS17.9
x64 msvc v19.40 VS17.10
x64 msvc v19.41 VS17.11
x64 msvc v19.42 VS17.12
x64 msvc v19.43 VS17.13
x64 msvc v19.44 VS17.14
x64 msvc v19.latest
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 g++ 1.27
x86 msvc v19.0 (ex-WINE)
x86 msvc v19.10 (ex-WINE)
x86 msvc v19.14 (ex-WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 msvc v19.39 VS17.9
x86 msvc v19.40 VS17.10
x86 msvc v19.41 VS17.11
x86 msvc v19.42 VS17.12
x86 msvc v19.43 VS17.13
x86 msvc v19.44 VS17.14
x86 msvc v19.latest
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.11
x86 nvc++ 24.3
x86 nvc++ 24.5
x86 nvc++ 24.7
x86 nvc++ 24.9
x86 nvc++ 25.1
x86 nvc++ 25.11
x86 nvc++ 25.3
x86 nvc++ 25.5
x86 nvc++ 25.7
x86 nvc++ 25.9
x86-64 Zapcc 190308
x86-64 clang (-fimplicit-constexpr)
x86-64 clang (Chris Bazley N3089)
x86-64 clang (EricWF contracts)
x86-64 clang (amd-staging)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2561)
x86-64 clang (experimental P2998)
x86-64 clang (experimental P3068)
x86-64 clang (experimental P3309)
x86-64 clang (experimental P3334)
x86-64 clang (experimental P3367)
x86-64 clang (experimental P3372)
x86-64 clang (experimental P3385)
x86-64 clang (experimental P3776)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (old concepts branch)
x86-64 clang (p1974)
x86-64 clang (pattern matching - P2688)
x86-64 clang (reflection - C++26)
x86-64 clang (reflection - TS)
x86-64 clang (resugar)
x86-64 clang (string interpolation - P3412)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 19.1.0
x86-64 clang 19.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 20.1.0
x86-64 clang 20.1.0 (assertions)
x86-64 clang 21.1.0
x86-64 clang 21.1.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 clang rocm-6.0.2
x86-64 clang rocm-6.1.2
x86-64 clang rocm-6.2.4
x86-64 clang rocm-6.3.3
x86-64 clang rocm-6.4.0
x86-64 clang rocm-7.0.1
x86-64 gcc (C++26 contracts + GNU extensions)
x86-64 gcc (C++26 contracts)
x86-64 gcc (C++26 reflection)
x86-64 gcc (P2034 lambdas)
x86-64 gcc (Thomas Healy)
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.3 (assertions)
x86-64 gcc 10.4
x86-64 gcc 10.4 (assertions)
x86-64 gcc 10.5
x86-64 gcc 10.5 (assertions)
x86-64 gcc 11.1
x86-64 gcc 11.1 (assertions)
x86-64 gcc 11.2
x86-64 gcc 11.2 (assertions)
x86-64 gcc 11.3
x86-64 gcc 11.3 (assertions)
x86-64 gcc 11.4
x86-64 gcc 11.4 (assertions)
x86-64 gcc 12.1
x86-64 gcc 12.1 (assertions)
x86-64 gcc 12.2
x86-64 gcc 12.2 (assertions)
x86-64 gcc 12.3
x86-64 gcc 12.3 (assertions)
x86-64 gcc 12.4
x86-64 gcc 12.4 (assertions)
x86-64 gcc 12.5
x86-64 gcc 12.5 (assertions)
x86-64 gcc 13.1
x86-64 gcc 13.1 (assertions)
x86-64 gcc 13.2
x86-64 gcc 13.2 (assertions)
x86-64 gcc 13.3
x86-64 gcc 13.3 (assertions)
x86-64 gcc 13.4
x86-64 gcc 13.4 (assertions)
x86-64 gcc 14.1
x86-64 gcc 14.1 (assertions)
x86-64 gcc 14.2
x86-64 gcc 14.2 (assertions)
x86-64 gcc 14.3
x86-64 gcc 14.3 (assertions)
x86-64 gcc 15.1
x86-64 gcc 15.1 (assertions)
x86-64 gcc 15.2
x86-64 gcc 15.2 (assertions)
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
x86-64 icx 2024.1.0
x86-64 icx 2024.2.0
x86-64 icx 2024.2.1
x86-64 icx 2025.0.0
x86-64 icx 2025.0.1
x86-64 icx 2025.0.3
x86-64 icx 2025.0.4
x86-64 icx 2025.1.0
x86-64 icx 2025.1.1
x86-64 icx 2025.2.0
x86-64 icx 2025.2.1
x86-64 icx 2025.3.0
x86-64 icx 2025.3.1
x86-64 icx 2025.3.1
z180-clang 15.0.0
z180-clang 15.0.7
z80-clang 15.0.0
z80-clang 15.0.7
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.12.1
zig c++ 0.13.0
zig c++ 0.14.0
zig c++ 0.14.1
zig c++ 0.15.1
zig c++ 0.15.2
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
#include "app.h" #include "ui_app.h" #include <QScrollBar> /*! * \brief Constructor * \param parent Qt parent: default = nullptr */ App::App(QWidget *parent) : QMainWindow(parent) , ui(new Ui::App) { ui->setupUi(this); // ===== CONFIG ROTORTEST LIBRARY ===== // // Define the library directory paths: QString dir_parts, dir_materials, dir_excitations; #ifdef QT_DEBUG #ifdef __APPLE__ dir_parts = "../../../../../rotortest/library/parts"; dir_materials = "../../../../../rotortest/library/materials"; dir_excitations = "../../../../../rotortest/library/excitations"; #else dir_parts = "../../rotortest/library/parts"; dir_materials = "../../rotortest/library/materials"; dir_excitations = "../../rotortest/library/excitations"; #endif #else // RELEASE MODE: dir_parts = "./library/parts"; dir_materials = "./library/materials"; dir_excitations = "./library/excitations"; #endif // Join string paths in a list: std::list<QString> library_dirs; library_dirs.push_back(dir_parts); library_dirs.push_back(dir_materials); library_dirs.push_back(dir_excitations); // Load all RTT libraries: loadLibraries(library_dirs); // ===== CONFIG DEFAULT UI PROPERTIES ===== // // TOP MENUS: // Menu File: ui->actionSave->setDisabled(true); ui->actionSave_As->setDisabled(true); // Menu File ui->actionClose_Project->setDisabled(true); ui->menuImport->setDisabled(true); ui->menuExport->setDisabled(true); // Menu Material: ui->menuMaterial->setDisabled(true); // Menu Geometry: ui->menuGeometry->setDisabled(true); // Set console to read-only mode: ui->console_txt->setReadOnly(true); ui->console_txt->setCenterOnScroll(true); // ======================= // ===== PLUGIN LOADER ===== // QDir pluginsDir = QDir::currentPath(); #if defined(Q_OS_WIN) if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") pluginsDir.cdUp(); #elif defined(Q_OS_MAC) if (pluginsDir.dirName() == "MacOS") { pluginsDir.cdUp(); pluginsDir.cdUp(); pluginsDir.cdUp(); #if defined (QT_DEBUG) pluginsDir.cdUp(); #endif } #endif //pluginsDir.cd("plugins"); pluginsDir.cdUp(); pluginsDir.cdUp(); pluginsDir.cd("build-lobular-bearing-plugin-Desktop_Qt_5_15_0_GCC_64bit-Debug"); qInfo() << "Plugins Dir Path: " << pluginsDir.path(); QStringList plugins_path = getPluginsList(pluginsDir.path()); // qInfo() << "Plugins List: " << plugins_path; // Get plugins data and pointer: loadPlugins(plugins_path); } /*! * \brief Desconstructor */ App::~App() { // Is there any opened project? if (!_workingFilePath.empty()) { auto question = new QMessageBox(QMessageBox::Question, QObject::tr("Save Project"), QObject::tr("Do you want to save your project changes?"), QMessageBox::Save | QMessageBox::Discard); question->setDefaultButton(QMessageBox::Save); // Run the user selected operation: if (question->exec() == QMessageBox::Save) { on_actionSave_triggered(); } } delete ui; } /*! * \brief Get all files from a given directory (recursive) * \param dirPath The dirctory/folder path * \return A file paths list */ std::list<QString> App::getFilesPath(const QString dirPath) { // Get the current folder path: QDir dir = QDir::currentPath(); // Move to the library folder path: dir.cd(dirPath); // Sorting folders and files by name: dir.setSorting(QDir::SortFlag::DirsFirst | QDir::SortFlag::Name); // Output paths list: std::list<QString> paths; // For all files in the folder: QDirIterator it(dir.absolutePath(), QDir::AllEntries | QDir::NoDotAndDotDot, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); while (it.hasNext()) { // Go to the next file: it.next(); // Check the file extension: if(it.fileInfo().isFile() && it.fileInfo().completeSuffix() == "json") { // Add path to the output list: paths.push_back(it.filePath()); } } return paths; } /*! * \brief Load all library files stored in a path list * \param paths A file paths list */ void App::loadLibraryFiles(const std::list<QString> paths) { foreach(QString p, paths) { sendStatusMsg(tr("Loaded library: %1").arg(p)); // Load the JSON file std::ifstream i(p.toStdString()); JSON data; i >> data; // Get the file type: std::string fileType; if (data.contains("file_type")) { fileType = data["file_type"].get<std::string>(); } // Error checking: if (fileType.empty()) { QMessageBox::warning(nullptr, QObject::tr("Load Library Files"), QObject::tr("This file doesn't have the file type field"), QMessageBox::Ok); continue; } // Store the file data in the internal JSON library: if (fileType == "part") { _library["part"].push_back(data); } else if (fileType == "material") { _library["material"].push_back(data); } else if (fileType == "excitation") { _library["excitation"].push_back(data); } else { QMessageBox::warning(nullptr, QObject::tr("Load Library Files"), QObject::tr("The file type '%1' is not supported").arg(QString::fromStdString(fileType)), QMessageBox::Ok); continue; } } } /*! * \brief Load all RotorTest libraries * \param paths Directory/folders list where are located this files */ void App::loadLibraries(const std::list<QString> paths) { // Init empty library arrays: _library["part"] = JSON::array(); _library["material"] = JSON::array(); _library["excitation"] = JSON::array(); // For each 'path' stored in 'paths': for (auto path : paths) { // Get all file paths: std::list<QString> filesPath = getFilesPath(path); // Load these files: loadLibraryFiles(filesPath); } } void App::on_actionNew_Project_triggered() { // Open the file dialog UI: QString fileName = QFileDialog::getSaveFileName(this, tr("New Project"), QDir::homePath(), tr("json (*.json)")); // Error checking: if (fileName.isEmpty()) { return; } // Check fileName extension: if (!fileName.endsWith(".json")) { fileName.append(".json"); } // Set the working file path: _workingFilePath = fileName.toStdString(); // Open file to write: std::ofstream file(_workingFilePath); // Error checking: if(!file.is_open()) { QMessageBox::warning(this, tr("Unable to write file"), tr("Unable to open the file to save")); return; } // ===== STACK WIDGETS ===== // // Allocate a Stack Widgets forms: _formLibrary = new Form_Library(_library); _formMaterialFluid = new Form_Material_Fluid(_project["material"]); _formMaterialElastic = new Form_Material_Elastic(_project["material"]); _formPart = new Form_Part(_project["part"]); _formExcitation = new Form_Excitation(_project["excitation"]); _formJob = new Form_Job(_project["job"]); _formAssembly = new Form_Assembly(_project["assembly"]); // ===== INSERT STACKED WIDGETS PAGES ===== // ui->stackedWidget->insertWidget(PART_PAGE, _formPart); ui->stackedWidget->insertWidget(MATERIAL_FLUID_PAGE, _formMaterialFluid); ui->stackedWidget->insertWidget(EXCITATION_PAGE, _formExcitation); ui->stackedWidget->insertWidget(JOB_PAGE, _formJob); ui->stackedWidget->insertWidget(ASSEMBLY_PAGE, _formAssembly); ui->stackedWidget->insertWidget(LIBRARY_PAGE, _formLibrary); ui->stackedWidget->insertWidget(MATERIAL_ELASTIC_PAGE, _formMaterialElastic); connect(_formLibrary, SIGNAL(closeForm(void)), this, SLOT(closeForm(void))); connect(_formMaterialFluid, SIGNAL(closeForm(void)), this, SLOT(closeForm(void))); connect(_formMaterialElastic, SIGNAL(closeForm(void)), this, SLOT(closeForm(void))); connect(_formAssembly, &Form_Assembly::sendMsg, this, &App::receivedMsg); connect(_formExcitation, &Form_Excitation::sendMsg, this, &App::receivedMsg); connect(_formJob, &Form_Job::sendMsg, this, &App::receivedMsg); connect(_formLibrary, &Form_Library::sendMsg, this, &App::receivedMsg); connect(_formMaterialElastic, &Form_Material_Elastic::sendMsg, this, &App::receivedMsg); connect(_formMaterialFluid, &Form_Material_Fluid::sendMsg, this, &App::receivedMsg); connect(_formPart, &Form_Part::sendMsg, this, &App::receivedMsg); updateMaterialTopMenu(); updateGeometryTopMenu(); // Init project fields: _project["metadata"] = JSON::object(); _project["assembly"]["sheft"] = JSON::array(); _project["assembly"]["bearing"] = JSON::array(); _project["part"] = JSON::array(); _project["material"] = JSON::array(); _project["excitation"] = JSON::array(); _project["job"] = JSON::array(); _project["plugin"] = JSON::array(); // Write JSON data to file: file << std::setw(4) << _project << std::endl; // Enable menus: ui->actionSave->setEnabled(true); ui->actionSave_As->setEnabled(true); ui->menuImport->setEnabled(true); ui->menuExport->setEnabled(true); // ===== ENABLE TOP MENUS ===== // ui->actionClose_Project->setEnabled(true); ui->menuMaterial->setEnabled(true); ui->menuGeometry->setEnabled(true); showStatusBarMessage(tr("Created in: %1").arg(QString::fromStdString(_workingFilePath))); setWindowTitle("Rotortest - " + fileName); } void App::on_actionOpenProject_triggered() { // Open the file dialog UI: QString fileName = QFileDialog::getOpenFileName(this, tr("Open Project"), QDir::homePath(), tr("json (*.json)")); // Error checking: if (fileName.isEmpty()) { return; } // Set the working file path: _workingFilePath = fileName.toStdString(); // Open file to read: std::ifstream file(_workingFilePath); // Error checking: if(!file.is_open()) { QMessageBox::warning(this, tr("Unable to open file"), tr("Unable to open this project file")); return; } // Load file to a JSON object: _project.clear(); file >> _project; validadeProjectFile(); // ===== STACK WIDGETS ===== // // Allocate a Stack Widgets forms: _formLibrary = new Form_Library(_library); _formMaterialFluid = new Form_Material_Fluid(_project["material"]); _formMaterialElastic = new Form_Material_Elastic(_project["material"]); _formPart = new Form_Part(_project["part"]); _formExcitation = new Form_Excitation(_project["excitation"]); _formJob = new Form_Job(_project["job"]); _formAssembly = new Form_Assembly(_project["assembly"]); // ===== INSERT STACKED WIDGETS PAGES ===== // ui->stackedWidget->insertWidget(PART_PAGE, _formPart); ui->stackedWidget->insertWidget(MATERIAL_FLUID_PAGE, _formMaterialFluid); ui->stackedWidget->insertWidget(EXCITATION_PAGE, _formExcitation); ui->stackedWidget->insertWidget(JOB_PAGE, _formJob); ui->stackedWidget->insertWidget(ASSEMBLY_PAGE, _formAssembly); ui->stackedWidget->insertWidget(LIBRARY_PAGE, _formLibrary); ui->stackedWidget->insertWidget(MATERIAL_ELASTIC_PAGE, _formMaterialElastic); connect(_formLibrary, SIGNAL(closeForm(void)), this, SLOT(closeForm(void))); connect(_formMaterialFluid, SIGNAL(closeForm(void)), this, SLOT(closeForm(void))); connect(_formMaterialElastic, SIGNAL(closeForm(void)), this, SLOT(closeForm(void))); connect(_formAssembly, &Form_Assembly::sendMsg, this, &App::receivedMsg); connect(_formExcitation, &Form_Excitation::sendMsg, this, &App::receivedMsg); connect(_formJob, &Form_Job::sendMsg, this, &App::receivedMsg); connect(_formLibrary, &Form_Library::sendMsg, this, &App::receivedMsg); connect(_formMaterialElastic, &Form_Material_Elastic::sendMsg, this, &App::receivedMsg); connect(_formMaterialFluid, &Form_Material_Fluid::sendMsg, this, &App::receivedMsg); connect(_formPart, &Form_Part::sendMsg, this, &App::receivedMsg); updateMaterialTopMenu(); updateGeometryTopMenu(); // Enable menus: ui->actionSave->setEnabled(true); ui->actionSave_As->setEnabled(true); ui->menuImport->setEnabled(true); ui->menuExport->setEnabled(true); // ===== ENABLE TOP MENUS ===== // ui->actionClose_Project->setEnabled(true); ui->menuMaterial->setEnabled(true); ui->menuGeometry->setEnabled(true); showStatusBarMessage(tr("Loaded File: %1").arg(fileName)); setWindowTitle("Rotortest - " + fileName); } void App::on_actionClose_Project_triggered() { auto question = new QMessageBox(QMessageBox::Question, QObject::tr("Save Material"), QObject::tr("Do you want to save this project?"), QMessageBox::Save|QMessageBox::Discard); question->setDefaultButton(QMessageBox::Save); // Run the user selected operation: if (question->exec() == QMessageBox::Save) { on_actionSave_triggered(); } // Clear the project in memory: _project.clear(); // ===== CLEAR TOP MENUS ===== // ui->menuFluid->clear(); ui->menuElastic->clear(); // ===== CONFIG DEFAULT UI PROPERTIES ===== // // TOP MENUS: // Menu File: ui->actionSave->setDisabled(true); ui->actionSave_As->setDisabled(true); ui->menuImport->setDisabled(true); ui->menuExport->setDisabled(true); ui->actionClose_Project->setDisabled(true); // Menu Material: ui->menuMaterial->setDisabled(true); // Return to the blank page: ui->stackedWidget->setCurrentIndex(CLEAN_PAGE); showStatusBarMessage(tr("Closed project: %1").arg(QString::fromStdString(_workingFilePath))); } void App::validadeProjectFile(void) { // Verify the basic fiels // validade all elastic and fluid materials } void App::on_actionSave_triggered() { if (_workingFilePath.empty()) { on_actionSave_As_triggered(); return; } // Open file to write: std::ofstream file(_workingFilePath); // Error checking: if(!file.is_open()) { QMessageBox::warning(this, tr("Unable to write file"), tr("Unable to open the file to save")); return; } // Write JSON data to file: file << std::setw(4) << _project << std::endl; showStatusBarMessage(tr("Saved in: %1").arg(QString::fromStdString(_workingFilePath))); } void App::on_actionSave_As_triggered() { // Open the file dialog UI: QString fileName = QFileDialog::getSaveFileName(this, tr("Save Project"), QDir::homePath(), tr("json (*.json)")); // Error checking: if (fileName.isEmpty()) { return; } // Check fileName extension: if (!fileName.endsWith(".json")) { fileName.append(".json"); } // Set the Working file path: _workingFilePath = fileName.toStdString(); // Open file to write: std::ofstream file(_workingFilePath); // Error checking: if(!file.is_open()) { QMessageBox::warning(this, tr("Unable to write file"), tr("Unable to open the file to save")); return; } // Write JSON data to file: file << std::setw(4) << _project << std::endl; showStatusBarMessage(tr("Saved in: %1").arg(QString::fromStdString(_workingFilePath))); } void App::on_actionExit_triggered() { this->close(); } void App::on_actionPlugins_triggered() { } void App::on_actionAbout_triggered() { } void App::on_actionClear_console_text_triggered() { ui->console_txt->clear(); } void App::on_actionImport_From_Library_triggered() { // Change the current stackWidget page: ui->stackedWidget->setCurrentIndex(LIBRARY_PAGE); // Form layout ajust: ui->stackedWidget->setContentsMargins(50, 5, 50, 5); } void App::on_actionImport_From_File_triggered() { // Open the file dialog UI: QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::homePath(), tr("JSON (*.json)")); // Error checking: if (fileName.isEmpty()) { return; } // Open file: std::ifstream file(fileName.toStdString()); // Error checking: if(!file.is_open()) { QMessageBox::warning(this, tr("Unable to open file"), tr("Unable to import this file")); return; } // Read file data: JSON j; file >> j; // Get file type: std::string fileType = j["file_type"].get<std::string>(); // Append file data to project: if (fileType == "part") { _project["part"].push_back(j); } else if (fileType == "material") { _project["material"].push_back(j); } else if (fileType == "excitation") { _project["excitation"].push_back(j); } else { QMessageBox::warning(this, tr("Unable to import this file"), tr("Unkown the file type: '%1'").arg(QString::fromStdString(fileType))); return; } } void App::on_actionExport_Part_triggered() { } void App::on_actionExport_Material_triggered() { } void App::on_actionExport_Excitation_triggered() { } /*! * \brief Get material JSON data from the loaded materials list * \param manufacturer Desired material manufacturer * \param name Desired material name * \return If material was found return the material JSON data. If not, * return a empty JSON object */ JSON App::getMaterialByName(const std::string manufacturer, const std::string name) const { // For each material array element: for (auto& el : _library["material"]) { // Get the element manufacturer and name: std::string elManu = el["manufacturer"].get<std::string>(); std::string elName = el["name"].get<std::string>(); // Verify if the desired element was found: if (elManu == manufacturer && elName == name) { // Material found: return el; } } // If material was not found, return a clean JSON object: return JSON::object(); } /*! * \brief Close central Form and return to a blank page */ void App::closeForm() { const int currentPage = ui->stackedWidget->currentIndex(); switch (currentPage) { case CLEAN_PAGE: // Nothing to do.... break; case PART_PAGE: // Update part ... break; case MATERIAL_ELASTIC_PAGE: updateMaterialTopMenu(); break; case MATERIAL_FLUID_PAGE: updateMaterialTopMenu(); break; case EXCITATION_PAGE: // Update excitation... break; case JOB_PAGE: // Update JOB... break; case ASSEMBLY_PAGE: // Update Assembly... break; case LIBRARY_PAGE: // Update Library... break; default: sendErrorMsg(tr("Unknown current page!")); break; } // Change the current stackWidget page: ui->stackedWidget->setCurrentIndex(CLEAN_PAGE); // Form layout ajust: ui->stackedWidget->setContentsMargins(1, 1, 1, 1); } void App::updateMaterialTopMenu(void) { // ===== CLEAR ALL OLD ACTIONS ===== // ui->menuElastic->clear(); ui->menuFluid->clear(); // ===== SET THE DEFAUT MENU ACTIONS ===== // QAction* newElastic = new QAction(tr("New Elastic Material")); connect(newElastic, &QAction::triggered, this, [=] { _formMaterialElastic->cleanAllFields(); ui->stackedWidget->setCurrentIndex(MATERIAL_ELASTIC_PAGE); }); QAction* newFluid = new QAction(tr("New Fluid Material")); connect(newFluid, &QAction::triggered, this, [=] { _formMaterialFluid->cleanAllFields(); ui->stackedWidget->setCurrentIndex(MATERIAL_FLUID_PAGE); }); // ===== ADD ACTIONS TO THE TOP MENUS ===== // ui->menuElastic->addAction(newElastic); ui->menuFluid->addAction(newFluid); // ===== ADD THE PROJECT MATERIAL ACTIONS ===== // const auto& materialArray = _project["material"]; const size_t materialSize = materialArray.size(); for (size_t m = 0; m < materialSize; m++) { const std::string materialName = materialArray[m]["name"].get<std::string>(); const std::string materialType = materialArray[m]["type"].get<std::string>(); QAction* action = new QAction(QString::fromStdString(materialName), this); action->setStatusTip(tr("Edit material")); if (materialType == "elastic") { connect(action, &QAction::triggered, this, [=]{ _formMaterialElastic->load(materialArray[m]); ui->stackedWidget->setCurrentIndex(MATERIAL_ELASTIC_PAGE); }); ui->menuElastic->addAction(action); } else if (materialType == "fluid") { connect(action, &QAction::triggered, this, [=]{ _formMaterialFluid->load(materialArray[m]); ui->stackedWidget->setCurrentIndex(MATERIAL_FLUID_PAGE); }); ui->menuFluid->addAction(action); } else { sendErrorMsg(tr("Uknown material type: %1").arg(QString::fromStdString(materialType))); } } } void App::updateGeometryTopMenu(void) { // ===== CLEAR ALL OLD ACTIONS ===== // ui->menuGeometry->clear(); // ===== LOAD SHEFT PLUGINS ===== // QMenu* sheft = new QMenu(tr("Shafts")); for (const auto& p : _pluginsMapMap["Shaft"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newSheft = new QAction(tr("New %1").arg(pluginName)); connect(newSheft, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newSheft); sheft->addMenu(menu); } // ===== LOAD BEARING PLUGINS ===== // QMenu* bearing = new QMenu(tr("Bearings")); for (const auto& p : _pluginsMapMap["Bearing"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); // The new action QAction* newBearing = new QAction(tr("New %1").arg(pluginName)); connect(newBearing, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newBearing); // The project stored settings for (const auto& config : _project["plugin"]) { const std::string& pluginType = config["type"].get<std::string>(); if (pluginType != pluginName.toStdString()) { continue; } const std::string configName = config["name"].get<std::string>(); QAction* storedBearing = new QAction(QString::fromStdString(configName)); connect(storedBearing, &QAction::triggered, this, [=] { plugin->showUI(config); }); menu->addAction(storedBearing); } bearing->addMenu(menu); } // ===== LOAD FLOW SEAL PLUGINS ===== // QMenu* flowSeal = new QMenu(tr("Flow Seals")); for (const auto& p : _pluginsMapMap["Flow Seal"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newFlowSeal = new QAction(tr("New %1").arg(pluginName)); connect(newFlowSeal, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newFlowSeal); flowSeal->addMenu(menu); } // ===== LOAD SQUEEZE FILM DAMPPER PLUGINS ===== // QMenu* squeeze = new QMenu(tr("Squeeze Film Damppers")); for (const auto& p : _pluginsMapMap["Squeeze Film Dampper"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newSqueeze = new QAction(tr("New %1").arg(pluginName)); connect(newSqueeze, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newSqueeze); squeeze->addMenu(menu); } // ===== LOAD COUPLING PLUGINS ===== // QMenu* coupling = new QMenu(tr("Couplings")); for (const auto& p : _pluginsMapMap["Coupling"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newCoupling = new QAction(tr("New %1").arg(pluginName)); connect(newCoupling, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newCoupling); coupling->addMenu(menu); } // ===== LOAD GEAR PLUGINS ===== // QMenu* gear = new QMenu(tr("Gears")); for (const auto& p : _pluginsMapMap["Gear"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newGear = new QAction(tr("New %1").arg(pluginName)); connect(newGear, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newGear); gear->addMenu(menu); } // ===== LOAD FOUNDATION PLUGINS ===== // QMenu* foundation = new QMenu(tr("Foundations")); for (const auto& p : _pluginsMapMap["Foundation"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newFoundation = new QAction(tr("New %1").arg(pluginName)); connect(newFoundation, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newFoundation); foundation->addMenu(menu); } // ===== LOAD FORCES PLUGINS ===== // QMenu* force = new QMenu(tr("Forces")); for (const auto& p : _pluginsMapMap["Force"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newForce = new QAction(tr("New %1").arg(pluginName)); connect(newForce, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newForce); force->addMenu(menu); } // ===== LOAD SYSTEM PLUGINS ===== // QMenu* system = new QMenu(tr("Systems")); for (const auto& p : _pluginsMapMap["System"]) { const auto& plugin = p.second; const QString pluginName = plugin->getName(); QMenu* menu = new QMenu(pluginName); QAction* newSystem = new QAction(tr("New %1").arg(pluginName)); connect(newSystem, &QAction::triggered, this, [=] { plugin->showUI(JSON()); }); menu->addAction(newSystem); system->addMenu(menu); } // ===== ADD SUB MENUS ===== // ui->menuGeometry->addMenu(sheft); ui->menuGeometry->addMenu(bearing); ui->menuGeometry->addMenu(flowSeal); ui->menuGeometry->addMenu(squeeze); ui->menuGeometry->addMenu(coupling); ui->menuGeometry->addMenu(gear); ui->menuGeometry->addMenu(foundation); ui->menuGeometry->addMenu(force); ui->menuGeometry->addMenu(system); } void App::showStatusBarMessage(const QString& msg, const int timeout) { ui->statusbar->showMessage(msg, timeout); } void App::sendStatusMsg(const QString& msg) { receivedMsg("App", MSG_TYPE::STATUS_MSG, msg); } void App::sendWarningMsg(const QString& msg) { receivedMsg("App", MSG_TYPE::WARNING_MSG, msg); } void App::sendErrorMsg(const QString& msg) { receivedMsg("App", MSG_TYPE::ERROR_MSG, msg); } void App::on_actionNew_Elastic_Material_triggered() { // Change the current stackWidget page: ui->stackedWidget->setCurrentIndex(MATERIAL_ELASTIC_PAGE); _formMaterialElastic->cleanAllFields(); } void App::on_actionNew_Fluid_Material_triggered() { // Change the current stackWidget page: ui->stackedWidget->setCurrentIndex(MATERIAL_FLUID_PAGE); _formMaterialFluid->cleanAllFields(); } void App::receivedMsg(const QString& sourceObject, const MSG_TYPE msgType, const QString& msg) { QString html; QString msgTypeString; switch (msgType) { case MSG_TYPE::STATUS_MSG: html = "<p style='color:black'>"; msgTypeString = "Status"; break; case MSG_TYPE::WARNING_MSG: html = "<p style='color:orange'>"; msgTypeString = "Warning"; break; case MSG_TYPE::ERROR_MSG: html = "<p style='color:red'>"; msgTypeString = "Error"; break; default: QMessageBox::warning(this, tr("App Received Message"), tr("Unkown message type")); return; break; } html.append("<strong>[" + sourceObject + "][" + msgTypeString + "]: </strong>" + msg + "</p>"); ui->console_txt->appendHtml(html); } QStringList App::getPluginsList(QString path) { QStringList filter; #ifdef Q_OS_WIN filter << "*.dll"; #elif defined(Q_OS_LINUX) filter << "*.so"; #elif defined(Q_OS_MACOS) filter << "*.dylib"; #endif QDir dir(path); QFileInfoList list = dir.entryInfoList(filter); QStringList plugins; foreach (QFileInfo file, list) { #ifdef Q_OS_MACOS // Check if this file is not a Mac symbolic link: if(!file.isSymLink()) { #endif plugins.append(file.filePath()); #ifdef Q_OS_MACOS } #endif } return plugins; } void App::receivedPluginSettings(JSON settings) { // std::cout << settings.dump(2) << std::endl; addToArray(_project["plugin"], settings); updateGeometryTopMenu(); } /*! * \brief Load plugins (dynamic libraries) to main application * \param plugins List of plugins absolute paths */ void App::loadPlugins(const QStringList pluginsList) { foreach(QString file, pluginsList) { // qInfo() << "Loading: " << file; QPluginLoader loader(file); // Error checking: if (!loader.load()) { sendErrorMsg(tr("%1: ").arg(loader.errorString())); continue; } // Get and display the plugin file name: const QStringList pathSplited = loader.fileName().split("/"); const QString fileName = pathSplited.last(); sendStatusMsg(tr("Loading plugin: %1").arg(fileName)); // Cast plugin interface: Plugin_API* plugin = qobject_cast<Plugin_API*>(loader.instance()); // Error chekcing: nullptr if (!plugin) { sendErrorMsg(tr("Wrong Plugin API! Could not cast: %1").arg(loader.fileName())); continue; } // ===== CONNECT ALL SIGNALS / SLOTS ===== // bool conn1 = connect(plugin, &Plugin_API::sendMsg, this, &App::receivedMsg); bool conn2 = connect(plugin, &Plugin_API::savePluginSettings, this, &App::receivedPluginSettings); bool allConnections = conn1 & conn2; if (!allConnections) { sendErrorMsg(tr("Unable to connect: %1").arg(plugin->getName())); continue; } plugin->setProject(&_project); // pluginInstance = plugin; // sendStatusMsg(plugin->getName()); // Store the plugin in a map: _pluginsMapMap[plugin->getType()][plugin->getName()] = plugin; } }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Compiler Explorer Shop
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
Statistics
Changelog
Version tree