Skip to content

Class MainWindow

ClassList > MainWindow

Class used to manage all UI component interactions as well as displaying the images queried from cameras. More...

  • #include <mainwindow.h>

Inherits the following classes: QMainWindow

Public Slots

Type Name
slot void UpdateRGBImage (const QImage & image)
Qt slot that updates the RGB image displayed in the GUI.
slot void UpdateRawImage (const QImage & image)
slot void UpdateSaturationPercentageLCDDisplays (double percentageBelowThreshold, double percentageAboveThreshold)
Qt slot that updates the saturation percentage on the LCD displays.

Public Signals

Type Name
signal void ViewerImageProcessingComplete (QImage image)
Qt signal that is emitted when reading an processing of the image to display in viewer tab is finished.

Public Functions

Type Name
void DisplayCameraTemperature () const
Displays camera temperature on an LCD display.
void DisplayRecordCount () const
Displays the number of recorded images in the GUI.
void EnableUi (bool enable) const
Enables the UI elements.
unsigned GetBGRNorm () const
virtual unsigned GetBand () const
Queries the band number to be displayed.
QMap< QString, float > GetCameraTemperature () const
Gets camera temperature.
QString GetLogFilePath (const QString & logFile) const
Queries the path where the logfile is stored.
bool GetNormalize () const
Queries if normalization should be applied to the displayed images.
virtual int GetSaturationMaxValue () const
Retrieves the maximum allowable value for the saturation adjustment.
virtual int GetSaturationMinValue () const
Retrieves the minimum saturation value allowed by the saturation spin boxes.
Ui::MainWindow * GetUI () const
Provides access to the applications user interface.
void HandleTemperatureTimer (const boost::system::error_code & error)
Handle for timer used to schedule camera temperature logging.
bool IsSaturationButtonChecked () const
Identifies if the saturation tool button is checked or not.
QString LogMessage (const QString & message, const QString & logFile, bool logTime) const
Logs message to log file and returns the timestamp used during logging.
MainWindow (QWidget * parent=nullptr, const std::shared_ptr< XiAPIWrapper > & xiAPIWrapper=nullptr)
void ScheduleTemperatureThread ()
Creates schedule for the thread in charge of logging temperature of the camera.
void SetRecordedCount (int count)
Sets the number of images recorded.
void SetUpCustomUiComponents () const
Configures custom UI elements such as custom icons in buttons, etc.
void StartTemperatureThread ()
Starts the thread in charge of logging camera temperature.
void StopSnapshotsThread ()
Stops thread in charge of recording snapshot images.
void StopTemperatureThread ()
Stops thread in charge of logging camera temperature.
void UpdateFPSLCDDisplay () const
Updates the frames per second that are stored to file on the UI.
void UpdateRawViewerImage (const QImage & image)
Updates the raw image displayed in the viewer tab.
void ViewerWorkerThreadFunc ()
Waits for the viewer thread to be running and for new values to be available in the queue. It emits a signal indicating that a new value can be processed.
void WriteLogHeader () const
~MainWindow () override

Public Static Functions

Type Name
void EnableWidgetsInLayout (const QLayout * layout, bool enable)
Disables the UI elements.
void UpdateImage (QImage image, const QGraphicsView * view, std::unique_ptr< QGraphicsPixmapItem > & pixmapItem, QGraphicsScene * scene)
Takes an image, and scales it to the available width in the QtGraphicsView element before displaying it in the provided scene.

Protected Attributes

Type Name
b2nd_array_t * m_viewerNDArray = nullptr
This is the NDArray structure that holds the connection to the data viewed in the Viewer tab of the application.
Ui::MainWindow * ui
Main access point to all Qt components in the user interface. All Qt components in the UI can be accessed through this pointer.

Protected Functions

Type Name
void closeEvent (QCloseEvent * event) override
Event handler for the close event of the main window.

Detailed Description

This class is in charge of initializing the UI components and handle any interactions with the user as well as displaying the images queried from the camera. During initialization of the UI, this class performs the following steps:

  • Initialize camera interface and image container.
  • Setup native and custom UI components.
  • Initialize BLOSC2.
  • Populates list of available cameras.
  • Established Qt connections.
  • Disables UI components until a camera is selected by the user.

Public Slots Documentation

slot UpdateRGBImage

Qt slot that updates the RGB image displayed in the GUI.

void MainWindow::UpdateRGBImage;

Parameters:

  • image Qt image containing an 8bit (per channel) RGB image to be displayed.

slot UpdateRawImage

void MainWindow::UpdateRawImage;

Qt slot that updates the raw image displayed in the GUI.

Parameters:

  • image Qt image containing an 8bit single channel image to be displayed.

slot UpdateSaturationPercentageLCDDisplays

Qt slot that updates the saturation percentage on the LCD displays.

void MainWindow::UpdateSaturationPercentageLCDDisplays;

Parameters:

  • percentageBelowThreshold Percentage of under-exposed pixels.
  • percentageAboveThreshold Percentage of overexposed pixels.

Public Signals Documentation

signal ViewerImageProcessingComplete

Qt signal that is emitted when reading an processing of the image to display in viewer tab is finished.

void MainWindow::ViewerImageProcessingComplete;

Parameters:

  • image Qt image containing the image to display. This should be a one channel image.

Public Functions Documentation

function DisplayCameraTemperature

Displays camera temperature on an LCD display.

void MainWindow::DisplayCameraTemperature () const


function DisplayRecordCount

Displays the number of recorded images in the GUI.

void MainWindow::DisplayRecordCount () const


function EnableUi

Enables the UI elements.

void MainWindow::EnableUi (
    bool enable
) const

Parameters:

  • enable indicates if UI is enabled or not.

function GetBGRNorm

unsigned MainWindow::GetBGRNorm () const

Queries the normalization factor to be used.


function GetBand

Queries the band number to be displayed.

virtual unsigned MainWindow::GetBand () const


function GetCameraTemperature

Gets camera temperature.

QMap< QString, float > MainWindow::GetCameraTemperature () const

Returns:

mapper containing the camera temperature with keys identifying the location on the camera where the temperature was queried from.


function GetLogFilePath

Queries the path where the logfile is stored.

QString MainWindow::GetLogFilePath (
    const QString & logFile
) const

Parameters:

  • logFile file name.

Returns:

path to file.


function GetNormalize

Queries if normalization should be applied to the displayed images.

bool MainWindow::GetNormalize () const


function GetSaturationMaxValue

Retrieves the maximum allowable value for the saturation adjustment.

virtual int MainWindow::GetSaturationMaxValue () const

This function queries and returns the highest saturation value stored by the saturation control component. It is used to determine the upper limit of the saturation adjustment range in the UI.

Returns:

The maximum saturation value supported.


function GetSaturationMinValue

Retrieves the minimum saturation value allowed by the saturation spin boxes.

virtual int MainWindow::GetSaturationMinValue () const

This method provides the lower boundary of the saturation adjustment range stored by the saturation spin boxes in the UI.

Returns:

The minimum saturation value as an integer.


function GetUI

Provides access to the applications user interface.

inline Ui::MainWindow * MainWindow::GetUI () const

Returns:

pointer tot he Ui::MainWindow from which all Qt component in the user interface can be accessed.


function HandleTemperatureTimer

Handle for timer used to schedule camera temperature logging.

void MainWindow::HandleTemperatureTimer (
    const boost::system::error_code & error
) 

Parameters:

  • error type of error expected to cancel the timer.

function IsSaturationButtonChecked

Identifies if the saturation tool button is checked or not.

bool MainWindow::IsSaturationButtonChecked () const

Returns:

true if the saturation button is checked, false otherwise.


function LogMessage

Logs message to log file and returns the timestamp used during logging.

QString MainWindow::LogMessage (
    const QString & message,
    const QString & logFile,
    bool logTime
) const

Parameters:

  • message message to be logged.
  • logFile file name where the message should be logged.
  • logTime whether time should be logged too or not.

function MainWindow

explicit MainWindow::MainWindow (
    QWidget * parent=nullptr,
    const std::shared_ptr< XiAPIWrapper > & xiAPIWrapper=nullptr
) 

function ScheduleTemperatureThread

Creates schedule for the thread in charge of logging temperature of the camera.

void MainWindow::ScheduleTemperatureThread () 


function SetRecordedCount

Sets the number of images recorded.

void MainWindow::SetRecordedCount (
    int count
) 

Parameters:

  • count number of recorded images.

function SetUpCustomUiComponents

Configures custom UI elements such as custom icons in buttons, etc.

void MainWindow::SetUpCustomUiComponents () const


function StartTemperatureThread

Starts the thread in charge of logging camera temperature.

void MainWindow::StartTemperatureThread () 


function StopSnapshotsThread

Stops thread in charge of recording snapshot images.

void MainWindow::StopSnapshotsThread () 


function StopTemperatureThread

Stops thread in charge of logging camera temperature.

void MainWindow::StopTemperatureThread () 


function UpdateFPSLCDDisplay

Updates the frames per second that are stored to file on the UI.

void MainWindow::UpdateFPSLCDDisplay () const


function UpdateRawViewerImage

Updates the raw image displayed in the viewer tab.

void MainWindow::UpdateRawViewerImage (
    const QImage & image
) 

Parameters:

  • image Qt image to display.

function ViewerWorkerThreadFunc

Waits for the viewer thread to be running and for new values to be available in the queue. It emits a signal indicating that a new value can be processed.

void MainWindow::ViewerWorkerThreadFunc () 


function WriteLogHeader

void MainWindow::WriteLogHeader () const

Writes general information as header of the log file.


function ~MainWindow

MainWindow::~MainWindow () override

Public Static Functions Documentation

function EnableWidgetsInLayout

Disables the UI elements.

static void MainWindow::EnableWidgetsInLayout (
    const QLayout * layout,
    bool enable
) 

Parameters:

  • layout layout where elements will be enabled or disabled.
  • enable indicates if elements should ne enabled or disabled.

function UpdateImage

Takes an image, and scales it to the available width in the QtGraphicsView element before displaying it in the provided scene.

static void MainWindow::UpdateImage (
    QImage image,
    const QGraphicsView * view,
    std::unique_ptr< QGraphicsPixmapItem > & pixmapItem,
    QGraphicsScene * scene
) 

Parameters:

  • image Qt image to be displayed.
  • view the graphics view element where image will be displayed.
  • pixmapItem pixmap item where the image is to be placed.
  • scene the scene that will contain the pixmap.

Protected Attributes Documentation

variable m_viewerNDArray

This is the NDArray structure that holds the connection to the data viewed in the Viewer tab of the application.

b2nd_array_t* MainWindow::m_viewerNDArray;


variable ui

Main access point to all Qt components in the user interface. All Qt components in the UI can be accessed through this pointer.

Ui::MainWindow* MainWindow::ui;


Protected Functions Documentation

function closeEvent

Event handler for the close event of the main window.

void MainWindow::closeEvent (
    QCloseEvent * event
) override

This method is called when the user attempts to close the main window either by clicking the close button or using the system shortcut. It is responsible for handling any necessary cleanup or actions before the application closes. If a recording is running when the close event is triggered, the recordings are first stopped to ensure no loss of data happens.

Parameters:

  • event A pointer to the event object representing the close event.


The documentation for this class was generated from the following file src/mainwindow.h