src/WhiskerToolbox/MLCore_Widget/UI/RegionSelectionPanel/RegionSelectionPanel.hpp
src/WhiskerToolbox/MLCore_Widget/UI/RegionSelectionPanel/RegionSelectionPanel.hpp
Panel for selecting a DigitalIntervalSeries region in the ML workflow. More…
Namespaces
| Name |
|---|
| Ui |
Classes
| Name | |
|---|---|
| class | RegionSelectionPanel |
Types
| Name | |
|---|---|
| enum class | RegionMode { Training, Prediction, Validation} Determines which state field the panel binds to. |
Detailed Description
Panel for selecting a DigitalIntervalSeries region in the ML workflow.
RegionSelectionPanel displays a combo box listing all DigitalIntervalSeries keys in the DataManager, along with summary information about the selected interval series:
- Interval count — number of intervals in the series
- Total frame count — sum of frames across all intervals
- Time frame name if the series has an associated TimeFrame
An “All frames” checkbox allows the user to bypass region selection and use all available frames. When checked, the combo box is disabled and the state key is set to empty.
The panel operates in one of two modes ([RegionMode](/api_generated/Files/RegionSelectionPanel_8hpp.md#enum-regionmode)) to bind to the appropriate state field:
- Training: reads/writes
training_region_keyin MLCoreWidgetState - Prediction: reads/writes
prediction_region_keyin MLCoreWidgetState
Integration
- Embedded in the Classification tab of MLCoreWidget (for training region)
- Refreshes automatically when DataManager contents change
- Validates that a region is selected or “All frames” is checked
MLCoreWidget for the parent widget
MLCoreWidgetState::trainingRegionKey for the training region state
MLCoreWidgetState::predictionRegionKey for the prediction region state
DigitalIntervalSeries for the data type being selected
Types Documentation
enum RegionMode
| Enumerator | Value | Description |
|---|---|---|
| Training | Binds to MLCoreWidgetState::trainingRegionKey. | |
| Prediction | Binds to MLCoreWidgetState::predictionRegionKey. | |
| Validation | Binds to MLCoreWidgetState::validationRegionKey. |
Determines which state field the panel binds to.
Source code
#ifndef REGION_SELECTION_PANEL_HPP
#define REGION_SELECTION_PANEL_HPP
#include <QWidget>
#include <memory>
#include <string>
class DataManager;
class MLCoreWidgetState;
namespace Ui {
class RegionSelectionPanel;
}
enum class RegionMode {
Training,
Prediction,
Validation
};
class RegionSelectionPanel : public QWidget {
Q_OBJECT
public:
explicit RegionSelectionPanel(std::shared_ptr<MLCoreWidgetState> state,
std::shared_ptr<DataManager> data_manager,
RegionMode mode,
QWidget * parent = nullptr);
~RegionSelectionPanel() override;
[[nodiscard]] bool hasValidSelection() const;
[[nodiscard]] std::string selectedRegionKey() const;
[[nodiscard]] bool isAllFramesChecked() const;
public slots:
void refreshRegionList();
signals:
void regionSelectionChanged(QString const & key);
void validityChanged(bool valid);
void allFramesToggled(bool all_frames);
private slots:
void _onRegionComboChanged(int index);
void _onAllFramesToggled(bool checked);
private:
void _setupConnections();
void _updateRegionInfo();
void _registerDataManagerObserver();
void _syncToState(std::string const & key);
[[nodiscard]] std::string _readKeyFromState() const;
Ui::RegionSelectionPanel * ui;
std::shared_ptr<MLCoreWidgetState> _state;
std::shared_ptr<DataManager> _data_manager;
RegionMode _mode;
int _dm_observer_id = -1;
bool _valid = false;
};
#endif// REGION_SELECTION_PANEL_HPPUpdated on 2026-11-13 at 20:25:45 +0000