# j-bresson/sdif-edit architecture

> Architecture diagram of the GitHub repository j-bresson/sdif-edit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/j-bresson/sdif-edit
- Repository: https://github.com/j-bresson/sdif-edit

## Overview

##### Project type and purpose
- SDIF-Edit is a native C++ desktop application with an OpenGL/GLUT GUI.
- It also provides an optional Lisp-based plugin (SDIF-Edit4OM) to integrate with OpenMusic.

##### File structure
Top-level:
- README.md, LICENSE, .gitignore
- / (C headers for SDIF API)
- macos/ (platform Makefile)
- source/ (all C++ source and headers)
- OM/SDIF-Edit4OM/ (Lisp wrapper for OpenMusic)
Key source subcomponents:
- main.cpp – application entry point
- EventManager* – input/event dispatch
- GUI* and Window* – windowing and UI components
- SDIFDescriptor, SVStream, SVMatrix – internal data model for SDIF structures
- SDIFViewerWindow_Draw – rendering routines
- Various specialized windows: Sonagram, SliceView, SplineEditor, ColorChooser, etc.

##### Extract insights from the README
- Dependencies: static SDIF library, dynamic OpenGL/GLUT
- Build: simple Makefile invocation (platform-specific in macos/)
- Runtime: command-line binary that opens a .sdif file
- OM integration: Lisp scripts in OM/SDIF-Edit4OM that load this tool into OpenMusic

##### Main components
a. External Libraries (third-party)
- SDIF C library (parsing & I/O)
- OpenGL/GLUT (rendering & windowing)
b. Core Application
1. Entry Point (main.cpp)
2. Event Manager – captures user input & window events
3. Data Model – SDIFDescriptor → SVStream → SVMatrix hierarchy
4. GUI Layer – GUIComponent, Window, and specialized Window subclasses (SonagramWindow, SplineEditorWindow, etc.)
5. Rendering Engine – drawing routines in SDIFViewerWindow_Draw using OpenGL calls
6. Preferences & Configuration – Preferences module manages user settings
7. Plugin Interface (optional) – OM/SDIF-Edit4OM Lisp scripts that invoke or embed the core app in OpenMusic
c. Build System
- Makefile (macos/) with targets to compile and link all .cpp via g++ (including static link to SDIF, dynamic link to OpenGL/GLUT)

##### Relationships and interactions
- User → GUI Layer: mouse/keyboard events → Event Manager
- Event Manager ↔ GUI Components: dispatch events → component methods
- GUI Components ↔ Data Model: request SDIFDescriptor to retrieve streams/matrices → display data
- Data Model ← SDIF Library: parser reads .sdif file into descriptor/streams/matrices
- Core Application ↔ Preferences: on startup/load settings, on exit/save settings
- OM Plugin → Core Application: Lisp code loads and controls the binary or embeds its API

##### Architectural patterns & design principles
- MVC-like separation: Data Model (SDIFDescriptor/SV*), View (Window classes), Controller (EventManager)
- Plugin/extensibility point: OM/SDIF-Edit4OM directory provides Lisp extension interface
- Layered design: third-party libs at bottom, core logic in middle, UI on top

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    subgraph "External Dependencies"
        SDIF["SDIF C Library"]:::external
        GLUT["OpenGL/GLUT"]:::external
    end

    %% Core Application
    subgraph "Core Application"
        Main["Entry Point\n(main.cpp)"]:::core
        EventMgr["Event Manager"]:::core
        Prefs["Preferences"]:::core
        subgraph "Data Model"
            SDIFDesc["SDIFDescriptor"]:::core
            Stream["SVStream"]:::core
            Matrix["SVMatrix"]:::core
        end
    end

    %% UI & Rendering Layer
    subgraph "UI & Rendering"
        GUIBase["GUI Components"]:::ui
        WindowBase["Window Base"]:::ui
        MainWindow["Main Application Window"]:::ui
        Rendering["Rendering Engine"]:::ui
        Draw["Draw Routines"]:::ui
        subgraph "Specialized Windows"
            ColorChooser["Color Chooser"]:::ui
            SliceView["Slice View"]:::ui
            Sonagram["Sonagram View"]:::ui
            SplineEd["Spline Editor"]:::ui
            ViewPoints["ViewPoints"]:::ui
        end
    end

    %% Plugin Interface
    OM["OM Plugin\n(Lisp scripts)"]:::plugin

    %% Build System
    Makefile["Makefile\n(macos/)"]:::core

    %% User
    User["User\n(mouse/keyboard)"]:::external

    %% Connections
    User -->|dispatch event| EventMgr
    Main -->|initializes| EventMgr
    Main -->|loads preferences| Prefs
    Main -->|starts GUI| MainWindow
    EventMgr -->|handles| GUIBase
    GUIBase -->|uses| WindowBase
    WindowBase -->|controls| MainWindow
    GUIBase -->|requests data| SDIFDesc
    SDIFDesc -->|manages streams| Stream
    Stream -->|manages matrices| Matrix
    SDIF -->|parses .sdif file| SDIFDesc
    GLUT -->|provides context| Rendering
    MainWindow -->|hosts| Rendering
    Rendering -->|draw calls| Draw
    Draw -->|renders frame| MainWindow
    MainWindow -->|contains| ColorChooser
    MainWindow -->|contains| SliceView
    MainWindow -->|contains| Sonagram
    MainWindow -->|contains| SplineEd
    MainWindow -->|contains| ViewPoints
    MainWindow -->|loads/saves settings| Prefs
    OM -->|invokes/embeds| Main
    Makefile -->|builds| Main

    %% Click Events
    click SDIF "https://github.com/j-bresson/sdif-edit/blob/master/include/sdif.h"
    click SDIF "https://github.com/j-bresson/sdif-edit/blob/master/include/sdif_version.h"
    click Makefile "https://github.com/j-bresson/sdif-edit/tree/master/macos/Makefile"
    click Main "https://github.com/j-bresson/sdif-edit/blob/master/source/main.cpp"
    click EventMgr "https://github.com/j-bresson/sdif-edit/blob/master/source/EventManager.cpp"
    click EventMgr "https://github.com/j-bresson/sdif-edit/blob/master/source/EventManager.h"
    click SDIFDesc "https://github.com/j-bresson/sdif-edit/blob/master/source/SDIFDescriptor.cpp"
    click SDIFDesc "https://github.com/j-bresson/sdif-edit/blob/master/source/SDIFDescriptor.h"
    click Stream "https://github.com/j-bresson/sdif-edit/blob/master/source/SVStream.cpp"
    click Stream "https://github.com/j-bresson/sdif-edit/blob/master/source/SVStream.h"
    click Matrix "https://github.com/j-bresson/sdif-edit/blob/master/source/SVMatrix.cpp"
    click Matrix "https://github.com/j-bresson/sdif-edit/blob/master/source/SVMatrix.h"
    click GUIBase "https://github.com/j-bresson/sdif-edit/blob/master/source/GUI.cpp"
    click GUIBase "https://github.com/j-bresson/sdif-edit/blob/master/source/GUI.h"
    click GUIBase "https://github.com/j-bresson/sdif-edit/blob/master/source/GUIComponent.cpp"
    click GUIBase "https://github.com/j-bresson/sdif-edit/blob/master/source/GUIComponent.h"
    click WindowBase "https://github.com/j-bresson/sdif-edit/blob/master/source/Window.cpp"
    click WindowBase "https://github.com/j-bresson/sdif-edit/blob/master/source/Window.h"
    click MainWindow "https://github.com/j-bresson/sdif-edit/blob/master/source/MainWindow.cpp"
    click MainWindow "https://github.com/j-bresson/sdif-edit/blob/master/source/MainWindow.h"
    click Prefs "https://github.com/j-bresson/sdif-edit/blob/master/source/Preferences.cpp"
    click Prefs "https://github.com/j-bresson/sdif-edit/blob/master/source/Preferences.h"
    click Rendering "https://github.com/j-bresson/sdif-edit/blob/master/source/SDIFViewerWindow.cpp"
    click Rendering "https://github.com/j-bresson/sdif-edit/blob/master/source/SDIFViewerWindow.h"
    click Draw "https://github.com/j-bresson/sdif-edit/blob/master/source/SDIFViewerWindow_Draw.cpp"
    click ColorChooser "https://github.com/j-bresson/sdif-edit/blob/master/source/ColorChooserWindow.cpp"
    click ColorChooser "https://github.com/j-bresson/sdif-edit/blob/master/source/ColorChooserWindow.h"
    click SliceView "https://github.com/j-bresson/sdif-edit/blob/master/source/SliceViewWindow.cpp"
    click SliceView "https://github.com/j-bresson/sdif-edit/blob/master/source/SliceViewWindow.h"
    click Sonagram "https://github.com/j-bresson/sdif-edit/blob/master/source/SonagramWindow.cpp"
    click Sonagram "https://github.com/j-bresson/sdif-edit/blob/master/source/SonagramWindow.h"
    click SplineEd "https://github.com/j-bresson/sdif-edit/blob/master/source/SplineEditorWindow.cpp"
    click SplineEd "https://github.com/j-bresson/sdif-edit/blob/master/source/SplineEditorWindow.h"
    click ViewPoints "https://github.com/j-bresson/sdif-edit/blob/master/source/ViewPointsWindow.cpp"
    click ViewPoints "https://github.com/j-bresson/sdif-edit/blob/master/source/ViewPointsWindow.h"
    click OM "https://github.com/j-bresson/sdif-edit/blob/master/OM/SDIF-Edit4OM/SDIF-Edit4OM.lisp"

    %% Styles
    classDef external fill:#DDD,stroke:#888,stroke-width:1px
    classDef core fill:#ACE,stroke:#548,stroke-width:1px
    classDef ui fill:#9F9,stroke:#393,stroke-width:1px
    classDef plugin fill:#F9C,stroke:#C96,stroke-width:1px
```
