# swyter/openbrf-redux architecture

> Architecture diagram of the GitHub repository swyter/openbrf-redux, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/swyter/openbrf-redux
- Repository: https://github.com/swyter/openbrf-redux

## Overview

##### Main components
- Presentation (UI)
– Qt Widgets & Dialogs (mainwindow, guiPanel, ask*Dialog, datapanel, midpanel)
– Resource management (resource.qrc, translations)
- Application Core (Domain Model)
– brfData, brfBody, brfMesh, brfMaterial, brfTexture, brfSkeleton, brfAnimation, brfHitBox
– Token and flag managers (brfToken, BrfUIToken, carryPosition)
- Persistence / I/O
– Format importers/exporters: ioOBJ, ioMD3, ioSMD, ioMB, ioMB.cpp, vcgImport/vcgExport wrappers
– saveLoad module
- Rendering
– glwidgets (OpenGL widget wrappers)
– Shader management (brfShader, customPreviewShaders.xml, shaders/*.cpp)
– Low-level GL glue in dependencies/wrap/gl
- External Libraries & Frameworks
– Qt Framework (signals/slots, UI, build via .pro files)
– GLEW (OpenGL extensions loader)
– VCGLib (mesh processing, Eigen)

##### Relationships & data flows
- UI ←→ Application Core
– UI panels trigger core operations (load mesh, modify skeleton, update materials) via Qt signals/slots
- Application Core → Persistence
– Core invokes I/O module to read/write model files
– I/O uses VCGLib routines for mesh algorithms
- Application Core → Rendering
– Core hands brfMesh/brfMaterial objects to rendering subsystem
- Rendering → GLEW / OpenGL
– glwidgets and shaders call OpenGL APIs through GLEW
- I/O → VCGLib/Eigen
– Importers use VCGLib data structures & Eigen for math

##### Architectural patterns
- Layered architecture
– UI layer decoupled from core logic
– Core logic decoupled from low-level rendering and I/O
- MVC-style separation
– Model: brfData and related classes
– View: Qt UI & OpenGL canvas
– Controller: glue code in guiPanel, selector, tablemodel
- Event-driven Qt signals/slots for loose coupling

##### Detailed component breakdown (to include
1. UI Layer (blue)
- MainWindow (mainwindow.ui)
- Dialogs (askBoneDialog, askColorDialog, etc.)
- Panels (guiPanel, datapanel, midpanel, tablemodel)
2. Core Layer (green)
- Model classes (brfData, brfMesh, brfMaterial, brfTexture, brfBody, brfSkeleton, brfAnimation)
- Token/Flag management (brfToken, BrfUIToken, carryPositions)
3. I/O Layer (orange)
- Format handlers (ioOBJ, ioMD3, ioSMD, ioMB)
- Generic vcgImport / vcgExport (vcgmesh.cpp, vcgExport.h, vcgImport.h)
- Persistence controller (saveLoad.cpp)
4. Rendering Layer (purple)
- GL widgets (glwidgets.cpp)
- Shader loader (brfShader.cpp, shaders/*.cpp, customPreviewShaders.xml)
- GL helper wrappers (dependencies/wrap/gl, GLEW)
5. External/Third-Party (gray)
- Qt Framework
- GLEW (dependencies/glew)
- VCGLib + Eigen (dependencies/vcglib)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MainWindow["MainWindow"]:::ui
        subgraph "Dialogs"
            direction TB
            askBoneDialog["askBoneDialog"]:::ui
            askColorDialog["askColorDialog"]:::ui
            askCreaseDialog["askCreaseDialog"]:::ui
            askErrorDialog["askErrorDialog"]:::ui
            askErrorsDialog["askErrorsDialog"]:::ui
            askFlagsDialog["askFlagsDialog"]:::ui
            askHueSatBriDialog["askHueSatBriDialog"]:::ui
            askIntervalDialog["askIntervalDialog"]:::ui
            askLodOptionsDialog["askLodOptionsDialog"]:::ui
            askModErrorDialog["askModErrorDialog"]:::ui
            askNewUiPictureDialog["askNewUiPictureDialog"]:::ui
            askSelectBrfDialog["askSelectBrfDialog"]:::ui
            askSkelDialog["askSkelDialog"]:::ui
            askSkelPairDialog["askSkelPairDialog"]:::ui
            askTexturenameDialog["askTexturenameDialog"]:::ui
            askTransformDialog["askTransformDialog"]:::ui
            askUnrefTextureDialog["askUnrefTextureDialog"]:::ui
            askUvTransformDialog["askUvTransformDialog"]:::ui
        end
        subgraph "Panels & Models"
            direction TB
            guiPanel["guiPanel"]:::ui
            datapanel["datapanel"]:::ui
            midpanel["midpanel"]:::ui
            tablemodel["tablemodel"]:::ui
            selector["selector"]:::ui
            myselectionmodel["myselectionmodel"]:::ui
        end
        resource["resource.qrc & translations"]:::ui
    end

    %% Core Layer
    subgraph "Core Layer"
        direction TB
        brfData["brfData"]:::core
        brfBody["brfBody"]:::core
        brfMesh["brfMesh"]:::core
        brfMaterial["brfMaterial"]:::core
        brfTexture["brfTexture"]:::core
        brfSkeleton["brfSkeleton"]:::core
        brfAnimation["brfAnimation"]:::core
        brfHitBox["brfHitBox"]:::core
        subgraph "Token & Flags"
            direction TB
            brfToken["brfToken"]:::core
            BrfUIToken["BrfUIToken"]:::core
            carryPosition["carryPosition"]:::core
        end
    end

    %% I/O Layer
    subgraph "I/O Layer"
        direction TB
        ioOBJ["ioOBJ"]:::io
        ioMD3["ioMD3"]:::io
        ioSMD["ioSMD"]:::io
        ioMB["ioMB"]:::io
        subgraph "vcg Import/Export"
            direction TB
            vcgImport["vcgImport"]:::io
            vcgExport["vcgExport"]:::io
            vcgmesh["vcgmesh"]:::io
        end
        saveLoad["saveLoad"]:::io
    end

    %% Rendering Layer
    subgraph "Rendering Layer"
        direction TB
        glwidgets["glwidgets"]:::rendering
        brfShader["brfShader"]:::rendering
        subgraph "Shaders"
            direction TB
            bump_vertex["bump_vertex.cpp"]:::rendering
            bump_fragment["bump_fragment.cpp"]:::rendering
            iron_fragment["iron_fragment.cpp"]:::rendering
            customPreviewShaders["customPreviewShaders.xml"]:::rendering
        end
        glGlue["GL Glue"]:::rendering
    end

    %% External Dependencies
    subgraph "External Libraries"
        direction TB
        Qt["Qt Framework"]:::external
        GLEW["GLEW"]:::external
        VCGLib["VCGLib & Eigen"]:::external
    end

    %% Relationships
    MainWindow -->|"user actions"| brfData
    guiPanel -->|signals/slots| brfMesh
    brfData -->|load/save| saveLoad
    saveLoad -->|uses| vcgImport
    saveLoad -->|uses| vcgExport
    brfData -->|render| glwidgets
    glwidgets -->|calls| brfShader
    brfShader -->|"loads"| customPreviewShaders
    glwidgets -->|uses| glGlue
    glGlue -->|via| GLEW
    vcgImport -->|mesh ops| VCGLib
    vcgExport -->|mesh ops| VCGLib
    Qt -->|UI support| MainWindow
    Qt -->|widgets| guiPanel

    %% Click Events
    click MainWindow "https://github.com/swyter/openbrf-redux/blob/redux/mainwindow.ui"
    click askBoneDialog "https://github.com/swyter/openbrf-redux/blob/redux/askBoneDialog.ui"
    click askColorDialog "https://github.com/swyter/openbrf-redux/blob/redux/askColorDialog.ui"
    click askCreaseDialog "https://github.com/swyter/openbrf-redux/blob/redux/askCreaseDialog.ui"
    click askErrorDialog "https://github.com/swyter/openbrf-redux/blob/redux/askErrorDialog.ui"
    click askErrorsDialog "https://github.com/swyter/openbrf-redux/blob/redux/askErrorsDialog.ui"
    click askFlagsDialog "https://github.com/swyter/openbrf-redux/blob/redux/askFlagsDialog.ui"
    click askHueSatBriDialog "https://github.com/swyter/openbrf-redux/blob/redux/askHueSatBriDialog.ui"
    click askIntervalDialog "https://github.com/swyter/openbrf-redux/blob/redux/askIntervalDialog.ui"
    click askLodOptionsDialog "https://github.com/swyter/openbrf-redux/blob/redux/askLodOptionsDialog.ui"
    click askModErrorDialog "https://github.com/swyter/openbrf-redux/blob/redux/askModErrorDialog.ui"
    click askNewUiPictureDialog "https://github.com/swyter/openbrf-redux/blob/redux/askNewUiPictureDialog.ui"
    click askSelectBrfDialog "https://github.com/swyter/openbrf-redux/blob/redux/askSelectBrfDialog.ui"
    click askSkelDialog "https://github.com/swyter/openbrf-redux/blob/redux/askSkelDialog.ui"
    click askSkelPairDialog "https://github.com/swyter/openbrf-redux/blob/redux/askSkelPairDialog.ui"
    click askTexturenameDialog "https://github.com/swyter/openbrf-redux/blob/redux/askTexturenameDialog.ui"
    click askTransformDialog "https://github.com/swyter/openbrf-redux/blob/redux/askTransformDialog.ui"
    click askUnrefTextureDialog "https://github.com/swyter/openbrf-redux/blob/redux/askUnrefTextureDialog.ui"
    click askUvTransformDialog "https://github.com/swyter/openbrf-redux/blob/redux/askUvTransformDialog.ui"
    click guiPanel "https://github.com/swyter/openbrf-redux/blob/redux/guipanel.ui"
    click datapanel "https://github.com/swyter/openbrf-redux/blob/redux/datapanel.ui"
    click midpanel "https://github.com/swyter/openbrf-redux/blob/redux/midpanel.ui"
    click tablemodel "https://github.com/swyter/openbrf-redux/blob/redux/tablemodel.cpp"
    click selector "https://github.com/swyter/openbrf-redux/blob/redux/selector.cpp"
    click myselectionmodel "https://github.com/swyter/openbrf-redux/blob/redux/myselectionmodel.cpp"
    click resource "https://github.com/swyter/openbrf-redux/blob/redux/resource.qrc"
    click brfData "https://github.com/swyter/openbrf-redux/blob/redux/brfData.cpp"
    click brfBody "https://github.com/swyter/openbrf-redux/blob/redux/brfBody.cpp"
    click brfMesh "https://github.com/swyter/openbrf-redux/blob/redux/brfMesh.cpp"
    click brfMaterial "https://github.com/swyter/openbrf-redux/blob/redux/brfMaterial.cpp"
    click brfTexture "https://github.com/swyter/openbrf-redux/blob/redux/brfTexture.cpp"
    click brfSkeleton "https://github.com/swyter/openbrf-redux/blob/redux/brfSkeleton.cpp"
    click brfAnimation "https://github.com/swyter/openbrf-redux/blob/redux/brfAnimation.cpp"
    click brfHitBox "https://github.com/swyter/openbrf-redux/blob/redux/brfHitBox.cpp"
    click brfToken "https://github.com/swyter/openbrf-redux/blob/redux/brfToken.h"
    click BrfUIToken "https://github.com/swyter/openbrf-redux/blob/redux/BrfUIToken.h"
    click carryPosition "https://github.com/swyter/openbrf-redux/blob/redux/carryPosition.h"
    click ioOBJ "https://github.com/swyter/openbrf-redux/blob/redux/ioOBJ.cpp"
    click ioMD3 "https://github.com/swyter/openbrf-redux/blob/redux/ioMD3.cpp"
    click ioSMD "https://github.com/swyter/openbrf-redux/blob/redux/ioSMD.cpp"
    click ioMB "https://github.com/swyter/openbrf-redux/blob/redux/ioMB.cpp"
    click vcgImport "https://github.com/swyter/openbrf-redux/blob/redux/vcgImport.h"
    click vcgExport "https://github.com/swyter/openbrf-redux/blob/redux/vcgExport.h"
    click vcgmesh "https://github.com/swyter/openbrf-redux/blob/redux/vcgmesh.cpp"
    click saveLoad "https://github.com/swyter/openbrf-redux/blob/redux/saveLoad.cpp"
    click glwidgets "https://github.com/swyter/openbrf-redux/blob/redux/glwidgets.cpp"
    click brfShader "https://github.com/swyter/openbrf-redux/blob/redux/brfShader.cpp"
    click bump_vertex "https://github.com/swyter/openbrf-redux/blob/redux/shaders/bump_vertex.cpp"
    click bump_fragment "https://github.com/swyter/openbrf-redux/blob/redux/shaders/bump_fragment.cpp"
    click iron_fragment "https://github.com/swyter/openbrf-redux/blob/redux/shaders/iron_fragment.cpp"
    click customPreviewShaders "https://github.com/swyter/openbrf-redux/blob/redux/customPreviewShaders.xml"
    click glGlue "https://github.com/swyter/openbrf-redux/tree/redux/dependencies/vcglib/wrap/gl"
    click Qt "https://github.com/swyter/openbrf-redux/blob/redux/*.pro"
    click GLEW "https://github.com/swyter/openbrf-redux/blob/redux/dependencies/glew/include/GL/glew.h"
    click VCGLib "https://github.com/swyter/openbrf-redux/tree/redux/dependencies/vcglib/vcg/**"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef core fill:#90EE90,stroke:#333,stroke-width:1px
    classDef io fill:#FFA500,stroke:#333,stroke-width:1px
    classDef rendering fill:#9370DB,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
