Module chromascope::gui

source ·
Expand description

§gui logic and components

The mzviewer module provides a graphical user interface (GUI) for visualizing mass spectrometry data from MzML files. It allows users to load mass spectrometry data, select various plotting options, and visualize chromatograms and mass spectra. The module utilizes the eframe and egui libraries for building the GUI and rendering plots.

§Overview

The main struct in this module is MzViewerApp, which encapsulates the application state, user inputs, and methods for processing and displaying mass spectrometry data. The module also defines several supporting structs and enums to manage user inputs and the validity of file selections.

§Key Features

  • User Input Handling: Collects user inputs for file selection, plot type, mass, and other parameters.
  • Data Processing: Processes mass spectrometry data to generate Total Ion Chromatograms (TIC), Base Peak Chromatograms (BPC), and Extracted Ion Chromatograms (XIC).
  • Plotting: Renders chromatograms and mass spectra using the egui_plot library.
  • File Management: Handles file selection and validation to ensure that only valid MzML files are processed.

§Structs

§UserInput

A struct that holds user input parameters for the application, including file path, plot type, mass, and other parameters.

§Fields
  • file_path: An optional string representing the path to the selected MzML file.
  • plot_type: The type of plot to be generated (TIC, BPC, or XIC).
  • polarity: The scan polarity for the mass spectrometry data.
  • mass_input: A string representation of the mass input provided by the user.
  • mass_tolerance_input: A string representation of the mass tolerance input provided by the user.
  • mass: The mass value parsed from the mass_input.
  • mass_tolerance: The mass tolerance value parsed from the mass_tolerance_input.
  • line_type: The type of line to be used in the plot (solid, dashed, dotted).
  • line_color: The color of the line in the plot.
  • smoothing: The level of smoothing to be applied to the plot data.
  • line_width: The width of the line in the plot.
  • retention_time_ms_spectrum: An optional retention time for the mass spectrum.

§MzViewerApp

The main application struct that manages the state of the MzViewer application.

§Fields
  • parsed_ms_data: An instance of parser::MzData that holds the parsed mass spectrometry data.
  • plot_data: An optional vector of plot data points.
  • user_input: An instance of UserInput that holds user-defined parameters.
  • invalid_file: An enum indicating the validity of the selected file.
  • state_changed: An enum indicating whether the application state has changed.
  • options_window_open: A boolean indicating if the options window is open.
  • checkbox_bool: A boolean for managing checkbox states.
§Methods
  • new(): Creates a new instance of MzViewerApp with default values.
  • process_plot_data(): Processes the plot data based on user inputs and returns the prepared data for plotting.
  • plot_chromatogram(): Renders the chromatogram plot based on the processed data.
  • determine_rt_clicked(): Determines the retention time clicked on the plot.
  • find_closest_spectrum(): Finds the closest spectrum index based on the clicked retention time.
  • plot_mass_spectrum(): Renders the mass spectrum plot based on the parsed mass spectrum data.
  • update_data_selection_panel(): Updates the data selection panel in the GUI.
  • add_display_options(): Adds options for adjusting display settings such as smoothing, line width, and color.
  • handle_file_selection(): Handles the file selection process and updates the file path and validity.
  • update_file_path_and_validity(): Updates the file path and checks the validity of the selected file.
  • update_file_information_panel(): Updates the file information panel in the GUI.

§Enums

§FileValidity

An enum representing the validity of the selected file.

  • Valid: Indicates that the file is valid.
  • Invalid: Indicates that the file is invalid.

§StateChange

An enum representing the state change of the application.

  • Changed: Indicates that the state has changed.
  • Unchanged: Indicates that the state has not changed.

§Usage

To use this module, integrate it into your Rust application that requires visualization of mass spectrometry data. Ensure that the necessary dependencies (eframe, egui, egui_plot, etc.) are included in your Cargo.toml.

Structs§

Enums§

Constants§