#include "ascope.h" /* Function: AScope * Params In * bool* channels: Pointer showing which channels were checked by the user. * int plotType: Determines whether the A-Scope will show a Sum, or each channel. * QWidget* parent: Pointer to the parent object. * MatrixData* data: Pointer to the data container. * Return * N/A * Purpose * Default constructor. Creates a copy of the variable that shows which channels are checked. * Sets the name of the window, the status bar text, and creates a new APlot object, * which is the object that shows the A-Scope plots. Finally, connect the action windowClosed * with the function deleteAWindow from the parent, which is a QuickLook object. */ AScope::AScope( PlotOptions* p, QWidget* parent, MatrixData* data ):QMainWindow( parent ) { plot = p; d = data; // Set the title window and menu. setWindowTitle( "Data Plot Window" ); createMenus(); // Create the layout, add the plot widget and menu. QVBoxLayout* mainLayout = new QVBoxLayout; aScopePlot = new APlot( plot, this, data ); mainLayout->addWidget( buttonBox ); mainLayout->addWidget( aScopePlot ); // Set the layout and status bar message of the window. setCentralWidget( new QWidget() ); centralWidget()->setLayout( mainLayout ); setStatusBarText(); connect( this, SIGNAL( windowClosed( QObject* ) ), parent, SLOT( deleteAWindow( QObject* ) ) ); connect( this, SIGNAL( updateWin( PlotOptions* ) ), parent, SLOT( updateWinOptions( PlotOptions* ) ) ); } /* Function: redraw * Params In * N/A * Return * N/A * Purpose * Tell the APlot object to redraw itself. This is used to update the window * when new information has arrived, so that the data will be displayed. */ void AScope::redraw() { aScopePlot->redraw(); } /* Function: closeEvent * Params In * QCloseEvent* event: pointer to the event. * Return * N/A * Purpose * Redefines the closeEvent function. Used to setup a chain of calls * so that the vector of AScope* instances can be cleaned up whenever * an instance is closed. Emits a signal, which is setup in the constructor * to connect to a function in the parent object. */ void AScope::closeEvent( QCloseEvent* event ) { emit windowClosed( this ); } void AScope::setStatusBarText() { QString statusText; statusText = "Depth: "; if( plot->depthType == 0 ) { statusText.append( "Air" ); } else if( plot->depthType == 1 ) { statusText.append( "Ice" ); } else { statusText.append( "Time" ); } statusText.append( " - Data: " ); if( plot->dataType == 0 ) { statusText.append( "Raw" ); } else if( plot->dataType == 1 ) { statusText.append( "Freq." ); } else { statusText.append( "Compressed" ); } statusText.append( " - Mag: " ); if( plot->dataScale == 0 ) { statusText.append( "Linear" ); } else { statusText.append( "Log" ); } statusText.append( " - Time Offset: " ); QString time; time.setNum( plot->timeOffset ); statusText.append( time ); statusBar()->showMessage( statusText ); } /* Function: createMenus * Params In * N/A * Return * N/A * Purpose * Create the menu for the window. As of now, only contains the 'Update' * button. */ void AScope::createMenus() { buttonBox = new QGroupBox( tr( "Update Window Parameters" ) ); QHBoxLayout *layout = new QHBoxLayout; // Create the update button, then add connections for the event // when it is clicked. buttons[0] = new QPushButton( tr( "Update" ) ); layout->addWidget( buttons[0] ); connect( buttons[0], SIGNAL( clicked() ), this, SLOT( updateWindow() ) ); buttons[1] = new QPushButton( tr( "Auto-scale" ) ); layout->addWidget( buttons[1] ); connect( buttons[1], SIGNAL( clicked() ), this, SLOT( scaleWindow() ) ); buttonBox->setLayout( layout ); } /* Function: updateWindow * Params In * N/A * Return * N/A * Purpose * Emits the updateWin signal, which tells the parent that * the newest option values need to be copied into the supplied * DataOptions structure. Then resets the curves that should * be displayed, based on the new option values. */ void AScope::updateWindow() { emit updateWin( plot ); resetCurves(); } /* Function: resetCurves * Params In * N/A * Return * N/A * Purpose * Calls reset() in the aScopePlot child, which sets only the selected curves to be displayed. */ void AScope::resetCurves() { // Reset the curves and plot window with the new options. aScopePlot->reset(); // Reset the status bar message to match the currently selected options. setStatusBarText(); } /* Function: scaleWindow * Params In * N/A * Return * N/A * Purpose * Calls scale() in the aScopePlot child, which rescales the y axis for the plot window. */ void AScope::scaleWindow() { // Scale the y-axis of the plot window. aScopePlot->scale(); }