11/* *
2- * \mainpage GDetector
2+ * @defgroup dbselect_module dbselect module
33 *
4- * @section intro_sec Introduction
4+ * @brief Qt-based selection view for SQLite-backed geometry “experiment/system” configurations.
55 *
6- * \n\n
7- * \author \n © Maurizio Ungaro
8- * \author e-mail: ungaro@jlab.org
9- * \n\n\n
10- */
6+ * This module provides a small GUI/CLI-oriented utility layer to inspect and select
7+ * geometry configurations stored in an SQLite database (via the \c geometry table),
8+ * and to translate user selections into a list of GSystem objects that can be passed
9+ * to detector construction for geometry reload.
10+ */
11+
12+ /* *
13+ * \mainpage dbselect
14+ *
15+ * @section dbselect_intro Introduction
16+ *
17+ * The dbselect module provides a Qt widget (\c DBSelectView) that presents experiments and
18+ * systems retrieved from an SQLite database. Users can enable/disable systems and choose
19+ * the corresponding variation and run, then trigger a geometry reload through a supplied
20+ * \c GDetectorConstruction instance.
21+ *
22+ * The typical flow is:
23+ * - Parse options into a GOptions instance using dbselect::defineOptions().
24+ * - Create a \c GDetectorConstruction.
25+ * - Create a \c DBSelectView and let the user modify selections.
26+ * - Collect the updated SystemList from \ref DBSelectView::get_gsystems "get_gsystems()"
27+ * and invoke detector construction reload.
28+ *
29+ * @section dbselect_ownership Ownership and lifecycle
30+ *
31+ * Ownership and responsibilities are intentionally separated:
32+ * - \c DBSelectView owns its UI elements (Qt parent/child ownership) and manages the
33+ * SQLite handle (\c sqlite3*) opened read-only.
34+ * - \c DBSelectView does not own the provided \c GDetectorConstruction pointer; it is
35+ * treated as an external service used to reload geometry.
36+ * - The selection state is stored in the Qt model (\c QStandardItemModel) and mirrored
37+ * into a SystemList only when requested.
38+ *
39+ * Lifecycle notes:
40+ * - The database is opened during \c DBSelectView construction and closed in the destructor.
41+ * - Changes in the model mark the view as “modified” and enable the Reload button.
42+ * - Calling \ref DBSelectView::reload_geometry "reload_geometry()" rebuilds the SystemList,
43+ * invokes geometry reload on the detector construction, then clears the modified flag.
44+ *
45+ * @section dbselect_arch Architecture
46+ *
47+ * @subsection dbselect_arch_overview Design notes
48+ *
49+ * Internally the view is a thin integration of three concerns:
50+ * - **Data source:** an SQLite database containing a \c geometry table with at least the
51+ * columns used by the queries (experiment/system/variation/run).
52+ * - **Selection model:** a \c QStandardItemModel with four columns:
53+ * - column 0: experiment or system name (checkable)
54+ * - column 1: entry count (computed from the database)
55+ * - column 2: variation (edited via a drop-down delegate)
56+ * - column 3: run (edited via a drop-down delegate)
57+ * - **Application bridge:** translating checked systems into a SystemList of \c GSystem
58+ * objects via \ref DBSelectView::get_gsystems "get_gsystems()".
59+ *
60+ * UI behavior:
61+ * - Selecting an experiment checks only one experiment at a time.
62+ * - Enabling a system shows an availability indicator (green/red icon) driven by the
63+ * computed count of matching geometry entries.
64+ * - Changing variation/run recomputes counts and availability.
65+ *
66+ * @section dbselect_options Available Options and usage
67+ *
68+ * The module’s options are defined by dbselect::defineOptions(), which aggregates the
69+ * options provided by gdetector::defineOptions().
70+ *
71+ * The dbselect code path uses the following option keys:
72+ * - \c --sql : path or identifier of the SQLite database file to open (read-only).
73+ * - \c --experiment : default experiment name to preselect in the view.
74+ * - \c --gui : if enabled, the example starts a Qt event loop and shows the widget.
75+ *
76+ * If additional options are added by gdetector::defineOptions(), they may also affect
77+ * detector construction and geometry reload behavior. Refer to the gdetector option
78+ * documentation for the full list.
79+ *
80+ * @section dbselect_verbosity Module verbosity
81+ *
82+ * The module uses the logger name \c "dbselect".
83+ *
84+ * Typical conventions used in this module:
85+ * - Level 0: high-level lifecycle messages (startup, mode selection, geometry reload trigger).
86+ * - Level 1: environment and configuration messages (database opened and resolved location).
87+ * - Level 2: detailed selection and rebuild information (systems being added and reloaded).
88+ * - Debug: reserved for verbose troubleshooting (not used directly in the provided sources).
89+ *
90+ * @section dbselect_examples Examples
91+ *
92+ * @subsection dbselect_examples_test_dbselect test_dbselect
93+ *
94+ * Summary:
95+ * The \ref test_dbselect "test_dbselect" example demonstrates how to instantiate a
96+ * \c GOptions configuration for dbselect, optionally start a Qt GUI, and trigger a
97+ * geometry reload from the view.
98+ *
99+ * Example snippet:
100+ * \code
101+ * auto gopts = std::make_shared<GOptions>(argc, argv, dbselect::defineOptions());
102+ * auto gdetector = new GDetectorConstruction(gopts);
103+ *
104+ * if (gopts->getSwitch("gui")) {
105+ * auto dbselect = new DBSelectView(gopts, gdetector, window);
106+ * window->setCentralWidget(dbselect);
107+ * window->show();
108+ * }
109+ * \endcode
110+ */
0 commit comments