SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
MainWindow Class Reference

Main application window for SedSAT3 source apportionment analysis. More...

#include </home/runner/work/SedSat3/SedSat3/mainwindow.h>

Inheritance diagram for MainWindow:
Inheritance graph
Collaboration diagram for MainWindow:
Collaboration graph

Public Member Functions

 MainWindow (QWidget *parent=nullptr)
 Constructs the main window.
 
 ~MainWindow ()
 Destructor - cleans up UI resources.
 
void SetSinkSheet (int i)
 Sets the sink sheet index for Excel import.
 
void WriteMessageOnScreen (const QString &text, QColor color=Qt::black)
 Writes a message to the application's message display area.
 
SourceSinkDataData ()
 Returns pointer to the main data collection.
 
const SourceSinkDataData () const
 
bool Execute (const std::string &command, std::map< std::string, std::string > arguments)
 Executes a specified analysis command.
 

Private Member Functions

void setupConnections ()
 Sets up all signal-slot connections for UI elements.
 
void setupToolsView ()
 Initializes the tools tree view.
 
void setupResultsView ()
 Initializes the results tree view and context menu.
 
void setupToolBar ()
 Initializes the general toolbar.
 
bool ReadExcel (const QString &filename)
 Reads elemental profile data from Excel file.
 
QString resourcesPath () const
 
QStandardItemModel * ToQStandardItemModel (const SourceSinkData *srcsinkdata)
 
QStandardItem * ToQStandardItem (const QString &key, const SourceSinkData *srcsinkdata)
 
QStandardItem * ElementsToQStandardItem (const QString &key, const SourceSinkData *srcsinkdata)
 
QStandardItem * ToQStandardItem (const QString &key, const QJsonObject &json)
 
QStandardItemModel * ToQStandardItemModel (const QJsonDocument &jsondocument)
 
QString TreeQStringSelectedType ()
 
QJsonDocument loadJson (const QString &fileName)
 
void saveJson (const QJsonDocument &document, const QString &fileName)
 
void InitiateTables ()
 
void readRecentFilesList ()
 
void addToRecentFiles (const QString &fileName, bool addToFile)
 
void writeRecentFilesList ()
 
void removeFromRecentList (QAction *selectedFileAction)
 
bool CreateFileIfDoesNotExist (const QString &fileName)
 
bool LoadModel (const QString &fileName)
 
void Populate_General_ToolBar ()
 
void on_import_excel ()
 
void on_plot_raw_elemental_profiles ()
 
void on_tree_selectionChanged (const QItemSelection &changed)
 
void preparetreeviewMenu (const QPoint &pos)
 
void showdistributionsforelements ()
 
void on_constituent_properties_triggered ()
 
void onIncludeExcludeSample ()
 
void onOMSizeCorrection ()
 
void on_tool_executed (const QModelIndex &index)
 
void on_old_result_requested (const QModelIndex &index)
 
void onAboutTriggered ()
 
void on_Options_triggered ()
 
QString getSaveFilePath (bool promptUser)
 Gets the file path for saving, prompting user if needed.
 
bool saveProjectToFile (const QString &filePath)
 Saves project data to the specified file.
 
QJsonObject buildProjectJson () const
 Builds the complete project JSON object.
 
QJsonObject buildResultsJson () const
 Builds the results section of the project JSON.
 
void onSaveProject ()
 
void onSaveProjectAs ()
 
void onOpenProject ()
 
void on_actionRecent_triggered ()
 
void DeleteResults ()
 
void onCustomContextMenu (const QPoint &pos)
 
void on_show_data_as_table ()
 
void on_ZoomExtends ()
 
void addToolBarAction (const QString &text, const QString &iconPath, const QString &toolTip, void(MainWindow::*slot)())
 Helper to add an action to the toolbar with icon and connection.
 

Private Attributes

Ui::MainWindow * ui
 
SourceSinkData dataCollection
 Main data collection for analysis.
 
int sinkSheet = -1
 Index of sink sheet in Excel import.
 
GeneralPlotterplotter = nullptr
 Main plotting widget.
 
std::unique_ptr< InterfaceplottedData
 Currently plotted data interface.
 
std::unique_ptr< QStandardItemModel > columnViewModel
 Model for column/data tree view.
 
std::unique_ptr< QStandardItemModel > resultsViewModel
 Model for results tree view.
 
QMenu * ResultscontextMenu = nullptr
 Context menu for results view.
 
QAction * DeleteAction = nullptr
 Delete action for results.
 
QJsonDocument formsstructure
 Forms structure definitions.
 
QString selectedTreeItemType = "None"
 Currently selected tree item type.
 
bool treeItemChangedProgramatically = false
 Flag for programmatic tree changes.
 
QString ProjectFileName
 Current project file path.
 
QStringList recentFiles
 List of recently opened files.
 
std::unique_ptr< QMenu > menu
 Main menu.
 
std::unique_ptr< QWidget > centralform
 Central form widget.
 
std::unique_ptr< Conductorconductor
 Analysis command coordinator.
 
QModelIndex indexresultselected
 Currently selected result index.
 

Detailed Description

Main application window for SedSAT3 source apportionment analysis.

Provides the primary user interface for importing data, configuring analyses, executing source apportionment algorithms, and visualizing results. Manages data models, plotting, project file I/O, and coordinates with the Conductor class for computational operations.

Definition at line 40 of file mainwindow.h.

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( QWidget *  parent = nullptr)
explicit

Constructs the main window.

Parameters
parentParent widget (typically nullptr for main window)

Definition at line 57 of file mainwindow.cpp.

References centralform, conductor, readRecentFilesList(), resourcesPath(), setupConnections(), setupResultsView(), setupToolBar(), setupToolsView(), and ui.

◆ ~MainWindow()

MainWindow::~MainWindow ( )

Destructor - cleans up UI resources.

Definition at line 205 of file mainwindow.cpp.

References ui.

Member Function Documentation

◆ addToolBarAction()

void MainWindow::addToolBarAction ( const QString &  text,
const QString &  iconPath,
const QString &  toolTip,
void(MainWindow::*)()  slot 
)
private

Helper to add an action to the toolbar with icon and connection.

Creates a toolbar action with the specified text, icon, and tooltip, then connects it to the given member function slot.

Parameters
textAction text and object name
iconPathPath to icon file relative to resources folder
toolTipTooltip text displayed on hover
slotMember function pointer to connect to triggered signal

Definition at line 1539 of file mainwindow.cpp.

References ui.

Referenced by Populate_General_ToolBar().

◆ addToRecentFiles()

void MainWindow::addToRecentFiles ( const QString &  fileName,
bool  addToFile 
)
private

◆ buildProjectJson()

QJsonObject MainWindow::buildProjectJson ( ) const
private

Builds the complete project JSON object.

Returns
JSON object containing all project data

Definition at line 275 of file mainwindow.cpp.

References buildResultsJson(), Data(), SourceSinkData::ElementDataToJsonObject(), SourceSinkData::ElementInformationToJsonObject(), SourceSinkData::OptionsToJsonObject(), and SourceSinkData::ToolsUsedToJsonObject().

Referenced by saveProjectToFile().

◆ buildResultsJson()

QJsonObject MainWindow::buildResultsJson ( ) const
private

Builds the results section of the project JSON.

Returns
JSON object containing all results

Definition at line 245 of file mainwindow.cpp.

References ResultSetItem::result, resultsViewModel, and Results::toJsonObject().

Referenced by buildProjectJson().

◆ CreateFileIfDoesNotExist()

bool MainWindow::CreateFileIfDoesNotExist ( const QString &  fileName)
private

Definition at line 1519 of file mainwindow.cpp.

Referenced by addToRecentFiles().

◆ Data() [1/2]

SourceSinkData * MainWindow::Data ( )
inline

Returns pointer to the main data collection.

Returns
Non-owning pointer to SourceSinkData

Definition at line 73 of file mainwindow.h.

References dataCollection.

Referenced by GenericForm::GenericForm(), buildProjectJson(), LoadModel(), on_Options_triggered(), onIncludeExcludeSample(), and ToQStandardItem().

◆ Data() [2/2]

const SourceSinkData * MainWindow::Data ( ) const
inline

Definition at line 74 of file mainwindow.h.

References dataCollection.

◆ DeleteResults()

void MainWindow::DeleteResults ( )
private

Definition at line 1311 of file mainwindow.cpp.

References indexresultselected, and resultsViewModel.

Referenced by setupConnections().

◆ ElementsToQStandardItem()

QStandardItem * MainWindow::ElementsToQStandardItem ( const QString &  key,
const SourceSinkData srcsinkdata 
)
private

◆ Execute()

bool MainWindow::Execute ( const std::string &  command,
std::map< std::string, std::string >  arguments 
)

Executes a specified analysis command.

Parameters
commandCommand name identifying the analysis type
argumentsMap of parameter names to values
Returns
true if execution successful, false otherwise

Definition at line 1254 of file mainwindow.cpp.

References ResultsWindow::AppendResult(), conductor, dataCollection, Results::GetName(), ResultSetItem::result, resultsViewModel, and ResultsWindow::SetResults().

Referenced by GenericForm::onProceed().

◆ getSaveFilePath()

QString MainWindow::getSaveFilePath ( bool  promptUser)
private

Gets the file path for saving, prompting user if needed.

Parameters
promptUserIf true, always show save dialog; if false, use existing ProjectFileName
Returns
File path for saving, or empty string if cancelled

Definition at line 212 of file mainwindow.cpp.

References ProjectFileName.

Referenced by onSaveProject(), and onSaveProjectAs().

◆ InitiateTables()

void MainWindow::InitiateTables ( )
private

◆ loadJson()

QJsonDocument MainWindow::loadJson ( const QString &  fileName)
private

Definition at line 948 of file mainwindow.cpp.

Referenced by setupToolsView().

◆ LoadModel()

◆ on_actionRecent_triggered()

void MainWindow::on_actionRecent_triggered ( )
private

Definition at line 1491 of file mainwindow.cpp.

References addToRecentFiles(), and LoadModel().

Referenced by addToRecentFiles().

◆ on_constituent_properties_triggered()

void MainWindow::on_constituent_properties_triggered ( )
private

◆ on_import_excel()

void MainWindow::on_import_excel ( )
private

◆ on_old_result_requested()

void MainWindow::on_old_result_requested ( const QModelIndex &  index)
private

◆ on_Options_triggered()

void MainWindow::on_Options_triggered ( )
private

Definition at line 1650 of file mainwindow.cpp.

References Data().

Referenced by onIncludeExcludeSample(), and setupConnections().

◆ on_plot_raw_elemental_profiles()

void MainWindow::on_plot_raw_elemental_profiles ( )
private

Definition at line 542 of file mainwindow.cpp.

Referenced by setupConnections().

◆ on_show_data_as_table()

void MainWindow::on_show_data_as_table ( )
private

Definition at line 1620 of file mainwindow.cpp.

References plottedData, and ResultTableViewer::SetTable().

Referenced by setupConnections().

◆ on_tool_executed()

void MainWindow::on_tool_executed ( const QModelIndex &  index)
private

◆ on_tree_selectionChanged()

◆ on_ZoomExtends()

void MainWindow::on_ZoomExtends ( )
private

Definition at line 1638 of file mainwindow.cpp.

References plotter, and GeneralPlotter::ZoomExtends().

Referenced by setupConnections().

◆ onAboutTriggered()

void MainWindow::onAboutTriggered ( )
private

◆ onCustomContextMenu()

void MainWindow::onCustomContextMenu ( const QPoint &  pos)
private

Definition at line 1303 of file mainwindow.cpp.

References indexresultselected, ResultscontextMenu, and ui.

Referenced by setupConnections().

◆ onIncludeExcludeSample()

◆ onOMSizeCorrection()

void MainWindow::onOMSizeCorrection ( )
private

◆ onOpenProject()

void MainWindow::onOpenProject ( )
private

Definition at line 365 of file mainwindow.cpp.

References addToRecentFiles(), LoadModel(), and ProjectFileName.

Referenced by Populate_General_ToolBar(), and setupConnections().

◆ onSaveProject()

void MainWindow::onSaveProject ( )
private

Definition at line 335 of file mainwindow.cpp.

References getSaveFilePath(), and saveProjectToFile().

Referenced by Populate_General_ToolBar(), and setupConnections().

◆ onSaveProjectAs()

void MainWindow::onSaveProjectAs ( )
private

Definition at line 350 of file mainwindow.cpp.

References getSaveFilePath(), and saveProjectToFile().

Referenced by setupConnections().

◆ Populate_General_ToolBar()

void MainWindow::Populate_General_ToolBar ( )
private

◆ preparetreeviewMenu()

void MainWindow::preparetreeviewMenu ( const QPoint &  pos)
private

Definition at line 1010 of file mainwindow.cpp.

References elementRole, groupRole, menu, sampleRole, showdistributionsforelements(), and ui.

Referenced by InitiateTables().

◆ ReadExcel()

bool MainWindow::ReadExcel ( const QString &  filename)
private

◆ readRecentFilesList()

void MainWindow::readRecentFilesList ( )
private

Definition at line 1337 of file mainwindow.cpp.

References addToRecentFiles(), max_num_recent_files, and RECENT.

Referenced by MainWindow().

◆ removeFromRecentList()

void MainWindow::removeFromRecentList ( QAction *  selectedFileAction)
private

Definition at line 1507 of file mainwindow.cpp.

References recentFiles, ui, and writeRecentFilesList().

◆ resourcesPath()

QString MainWindow::resourcesPath ( ) const
private

◆ saveJson()

void MainWindow::saveJson ( const QJsonDocument &  document,
const QString &  fileName 
)
private

Definition at line 954 of file mainwindow.cpp.

◆ saveProjectToFile()

bool MainWindow::saveProjectToFile ( const QString &  filePath)
private

Saves project data to the specified file.

Parameters
filePathPath to save the project file
Returns
true if save successful, false otherwise

Definition at line 289 of file mainwindow.cpp.

References addToRecentFiles(), buildProjectJson(), conductor, and ProjectFileName.

Referenced by onSaveProject(), and onSaveProjectAs().

◆ SetSinkSheet()

void MainWindow::SetSinkSheet ( int  i)
inline

Sets the sink sheet index for Excel import.

Parameters
iSheet index

Definition at line 60 of file mainwindow.h.

References sinkSheet.

◆ setupConnections()

void MainWindow::setupConnections ( )
private

Sets up all signal-slot connections for UI elements.

Connects menu actions, toolbar buttons, and tree views to their respective slot handlers. Uses modern Qt5 function pointer syntax for type safety.

Definition at line 93 of file mainwindow.cpp.

References DeleteAction, DeleteResults(), on_constituent_properties_triggered(), on_import_excel(), on_old_result_requested(), on_Options_triggered(), on_plot_raw_elemental_profiles(), on_show_data_as_table(), on_tool_executed(), on_ZoomExtends(), onAboutTriggered(), onCustomContextMenu(), onIncludeExcludeSample(), onOMSizeCorrection(), onOpenProject(), onSaveProject(), onSaveProjectAs(), and ui.

Referenced by MainWindow().

◆ setupResultsView()

void MainWindow::setupResultsView ( )
private

Initializes the results tree view and context menu.

Sets up the results tree view model and configures the context menu for result management (delete, etc.).

Definition at line 174 of file mainwindow.cpp.

References DeleteAction, ResultscontextMenu, resultsViewModel, and ui.

Referenced by MainWindow().

◆ setupToolBar()

void MainWindow::setupToolBar ( )
private

Initializes the general toolbar.

Configures toolbar buttons with icons and initial enabled states.

Definition at line 189 of file mainwindow.cpp.

References Populate_General_ToolBar(), resourcesPath(), and ui.

Referenced by MainWindow().

◆ setupToolsView()

void MainWindow::setupToolsView ( )
private

Initializes the tools tree view.

Loads tool definitions from JSON configuration file and populates the tools tree view with available analysis operations.

Definition at line 142 of file mainwindow.cpp.

References formsstructure, loadJson(), resourcesPath(), ToQStandardItemModel(), and ui.

Referenced by MainWindow().

◆ showdistributionsforelements()

◆ ToQStandardItem() [1/2]

QStandardItem * MainWindow::ToQStandardItem ( const QString &  key,
const QJsonObject &  json 
)
private

Definition at line 960 of file mainwindow.cpp.

References Data(), and ToQStandardItem().

◆ ToQStandardItem() [2/2]

QStandardItem * MainWindow::ToQStandardItem ( const QString &  key,
const SourceSinkData srcsinkdata 
)
private

◆ ToQStandardItemModel() [1/2]

QStandardItemModel * MainWindow::ToQStandardItemModel ( const QJsonDocument &  jsondocument)
private

Definition at line 987 of file mainwindow.cpp.

References ToQStandardItem().

◆ ToQStandardItemModel() [2/2]

QStandardItemModel * MainWindow::ToQStandardItemModel ( const SourceSinkData srcsinkdata)
private

◆ TreeQStringSelectedType()

QString MainWindow::TreeQStringSelectedType ( )
private

Definition at line 998 of file mainwindow.cpp.

References ui.

Referenced by on_tree_selectionChanged().

◆ WriteMessageOnScreen()

void MainWindow::WriteMessageOnScreen ( const QString &  text,
QColor  color = Qt::black 
)

Writes a message to the application's message display area.

Parameters
textMessage text to display
colorText color (default: black)

Definition at line 742 of file mainwindow.cpp.

References ui.

Referenced by ReadExcel().

◆ writeRecentFilesList()

void MainWindow::writeRecentFilesList ( )
private

Definition at line 1463 of file mainwindow.cpp.

References RECENT, and recentFiles.

Referenced by addToRecentFiles(), and removeFromRecentList().

Member Data Documentation

◆ centralform

std::unique_ptr<QWidget> MainWindow::centralform
private

◆ columnViewModel

std::unique_ptr<QStandardItemModel> MainWindow::columnViewModel
private

Model for column/data tree view.

Definition at line 256 of file mainwindow.h.

Referenced by InitiateTables(), and ToQStandardItemModel().

◆ conductor

std::unique_ptr<Conductor> MainWindow::conductor
private

Analysis command coordinator.

Definition at line 275 of file mainwindow.h.

Referenced by MainWindow(), Execute(), LoadModel(), on_import_excel(), and saveProjectToFile().

◆ dataCollection

◆ DeleteAction

QAction* MainWindow::DeleteAction = nullptr
private

Delete action for results.

Definition at line 261 of file mainwindow.h.

Referenced by setupConnections(), and setupResultsView().

◆ formsstructure

QJsonDocument MainWindow::formsstructure
private

Forms structure definitions.

Definition at line 264 of file mainwindow.h.

Referenced by on_tool_executed(), and setupToolsView().

◆ indexresultselected

QModelIndex MainWindow::indexresultselected
private

Currently selected result index.

Definition at line 276 of file mainwindow.h.

Referenced by DeleteResults(), and onCustomContextMenu().

◆ menu

std::unique_ptr<QMenu> MainWindow::menu
private

Main menu.

Definition at line 273 of file mainwindow.h.

Referenced by preparetreeviewMenu().

◆ plottedData

std::unique_ptr<Interface> MainWindow::plottedData
private

Currently plotted data interface.

Definition at line 253 of file mainwindow.h.

Referenced by on_show_data_as_table(), and on_tree_selectionChanged().

◆ plotter

GeneralPlotter* MainWindow::plotter = nullptr
private

Main plotting widget.

Definition at line 249 of file mainwindow.h.

Referenced by on_tree_selectionChanged(), and on_ZoomExtends().

◆ ProjectFileName

QString MainWindow::ProjectFileName
private

Current project file path.

Definition at line 269 of file mainwindow.h.

Referenced by getSaveFilePath(), LoadModel(), on_import_excel(), onOpenProject(), and saveProjectToFile().

◆ recentFiles

QStringList MainWindow::recentFiles
private

List of recently opened files.

Definition at line 270 of file mainwindow.h.

Referenced by addToRecentFiles(), removeFromRecentList(), and writeRecentFilesList().

◆ ResultscontextMenu

QMenu* MainWindow::ResultscontextMenu = nullptr
private

Context menu for results view.

Definition at line 260 of file mainwindow.h.

Referenced by onCustomContextMenu(), and setupResultsView().

◆ resultsViewModel

std::unique_ptr<QStandardItemModel> MainWindow::resultsViewModel
private

Model for results tree view.

Definition at line 257 of file mainwindow.h.

Referenced by buildResultsJson(), DeleteResults(), Execute(), LoadModel(), on_old_result_requested(), and setupResultsView().

◆ selectedTreeItemType

QString MainWindow::selectedTreeItemType = "None"
private

Currently selected tree item type.

Definition at line 267 of file mainwindow.h.

Referenced by on_tree_selectionChanged().

◆ sinkSheet

int MainWindow::sinkSheet = -1
private

Index of sink sheet in Excel import.

Definition at line 243 of file mainwindow.h.

Referenced by ReadExcel(), and SetSinkSheet().

◆ treeItemChangedProgramatically

bool MainWindow::treeItemChangedProgramatically = false
private

Flag for programmatic tree changes.

Definition at line 268 of file mainwindow.h.

Referenced by on_tree_selectionChanged().

◆ ui


The documentation for this class was generated from the following files: