How stitchworkssoftware/crochetcharts works
Purpose and Entry Points
Crochet Charts is a native desktop application for creating and editing crochet chart patterns. It is a Qt 4.8/C++ application, built through CMake. Process startup is src/main.cpp, which initializes the application layer in src/application.cpp and presents the primary window in src/mainwindow.cpp.
Application Shell and Document Tabs
MainWindow owns the desktop UI: menus, docks, toolbars, and document lifecycle. Individual open patterns are represented by tab-oriented editor objects, likely coordinated through a shared tab contract:
• src/mainwindow.cpp
• src/crochettab.cpp
• src/tabinterface.h
The UI is Qt Widgets-based, with Designer forms such as src/mainwindow.ui, src/optionsbar.ui, and dock/dialog .ui files compiled into the application.
Chart Editing Model and Rendering
The core chart is modeled as cells, stitches, layers, and grouped scene items. The editor renders and interacts with this model through a graphics scene/view boundary:
• src/cell.cpp
• src/scene.cpp
• src/chartview.cpp
src/chartLayer.cpp, src/stitch.cpp, and src/itemgroup.cpp define chart composition and item-level behavior. Editing-oriented operations are centralized in src/ChartItemTools.cpp; selection and alignment support are provided by src/selectionband.cpp and src/aligndock.cpp.
Stitch and Palette Domain
Stitch definitions and collections are distinct from the chart canvas, enabling reusable stitch palettes/libraries and replacement operations:
• src/stitchset.cpp
• src/stitchlibrary.cpp
• src/stitchreplacerui.cpp
The application exposes UI for browsing and editing stitch libraries via src/stitchlibraryui.cpp and custom delegates. Colors are managed through color widgets and replacement logic such as src/colorlistwidget.cpp and src/colorreplacer.cpp.
Commands, Undo, and Editor State
Mutating chart operations use command/undo infrastructure rather than direct irreversible changes. Chart-specific commands and cross-document undo grouping are separated:
• src/crochetchartcommands.cpp
• src/undogroup.cpp
• src/indicatorundo.cpp
Persistent application preferences are handled by src/settings.cpp, while document-facing properties are represented by src/propertiesdata.cpp and edited through property docks.
File Compatibility and Export
Pattern persistence is versioned behind a factory boundary. The file factory selects format-specific implementations, isolating legacy/current serialization:
• src/filefactory.cpp
• src/file_v1.cpp
• src/file_v2.cpp
Export is a separate UI/workflow rooted in src/exportui.cpp; chart imagery is represented by src/ChartImage.cpp. This boundary is the likely integration point for producing non-editable chart output.
Build, Packaging, and External Dependencies
CMake is the primary build system (CMakeLists.txt, src/CMakeLists.txt). Runtime dependencies are Qt 4.8 and Hunspell, the latter discovered through cmake/modules/FindHunSpell.cmake. Documentation generation uses DocBook, XSLT processing, and Apache FOP under docs/.
Platform packaging/signing is supported for Windows (MinGW, NSIS, signtool), macOS (Xcode/signing), and Linux through resources/installers.cmake and packaging assets in resources/. Developer scripts in bin/build, bin/run, and bin/tests provide the normal compile/run/test entry points.
Main entry points: mainwindow.cpp Main window · cell.cpp Chart composition · crochettab.cpp Document tabs · application.cpp Application layer
Components 19
Desktop application
- Process startup
src/main.cpp - Application layer
src/application.cpp - Main window · Owns menus, docks, toolbars, and document lifecycle.
src/mainwindow.cpp - Document tabs · Open patterns share a tab-oriented editor contract.
src/crochettab.cpp - Tab contract
src/tabinterface.h
Chart editor
- Chart view · Interactive rendering boundary for the chart scene.
src/chartview.cpp - Chart scene
src/scene.cpp - Chart composition · The editable chart is composed from cells, layers, stitches, and item groups.
src/cell.cpp - Editing tools · Centralizes editing operations, selection, and alignment support.
src/ChartItemTools.cpp - Chart commands
src/crochetchartcommands.cpp - Undo coordination
src/undogroup.cpp
Reusable domains
- Stitch libraries · Reusable stitch palettes and replacement operations.
src/stitchlibrary.cpp - Stitch library UI
src/stitchlibraryui.cpp - Application settings
src/settings.cpp
Persistence and output
- File format factory · Selects isolated legacy or current pattern serializers.
src/filefactory.cpp - Current file format
src/file_v2.cpp - Export workflow · Produces non-editable chart output from chart imagery.
src/exportui.cpp
Build and delivery
- CMake build · Builds the Qt application and discovers Hunspell.
CMakeLists.txt - Platform packaging · Supports Windows, macOS, and Linux packaging.
resources/installers.cmake
Connections 19
- Process startup → Application layer: initializes
- Application layer → Main window: presents
- Main window → Document tabs: manages
- Document tabs → Tab contract: implements
- Document tabs → Chart view: hosts editor
- Chart view → Chart scene: renders and interacts with
- Chart scene → Chart composition: contains items for
- Editing tools → Chart composition: mutates
- Editing tools → Chart commands: creates
- Chart commands → Undo coordination: participates in
- Main window → Application settings: reads and updates
- Stitch library UI → Stitch libraries: browses and edits
- Chart composition → Stitch libraries: uses stitch definitions
- Main window → File format factory: opens and saves patterns through
- File format factory → Current file format: selects current format
- Main window → Export workflow: launches
- Export workflow → Chart composition: exports chart imagery from
- CMake build → Application layer: builds
- Platform packaging → CMake build: packages build output