#include "controlPanel.h" ControlPanel::ControlPanel( int r, int c, QWidget* parent ) : QMainWindow( parent ) { // Set variables with default values. quickLook = NULL; hddRecording = false; radarStarted = false; radarOn = true; defaultPalette = this->palette(); // Set the radar and channel number variables from the given params. radarNumber = r; channelNumber = c; //Set the name and title of the window. setObjectName( "Control Panel" ); setWindowTitle( "MCoRDS Radar Control Panel" ); setStatusBarVersion(); // Set the status bar text with the current version number. createMenu(); // Create the menu bar at the top of the window. // Set pointers to NULL. chmod = NULL; runCmd = NULL; runRadCmd = NULL; runRebootCmd = NULL; runShutdownCmd = NULL; runStopRadCmd = NULL; runStartRadCmd = NULL; mountHDDCmd = NULL; cEvent = NULL; diskGaugeTimer = NULL; // Add the layouts for the buttons and parameters to the main layout. QHBoxLayout* mainLayout = new QHBoxLayout; QGroupBox* aBox = new QGroupBox(); QGroupBox* lBox = new QGroupBox(); QGroupBox* sBox = new QGroupBox(); aBox->setFlat( true ); aBox->setFixedWidth( 300 ); aBox->setLayout( createButtons() ); lBox->setFlat( true ); lBox->setLayout( createLogViewer() ); sBox->setFlat( true ); sBox->setFixedWidth( 300 ); sBox->setLayout( createStatusSection() ); mainLayout->addWidget( aBox ); mainLayout->addWidget( lBox ); mainLayout->addWidget( sBox ); // Set the main layout to be used. setCentralWidget( new QWidget() ); centralWidget()->setLayout( mainLayout ); } ControlPanel::~ControlPanel() { // Delete class pointers if not NULL. if( runCmd ) { delete runCmd; runCmd = NULL; } if( runRebootCmd ) { delete runRebootCmd; runRebootCmd = NULL; } if( runRadCmd ) { delete runRadCmd; runRadCmd = NULL; } if( chmod ) { delete chmod; chmod = NULL; } if( runStopRadCmd ) { delete runStopRadCmd; runStopRadCmd = NULL; } if( runShutdownCmd ) { delete runShutdownCmd; runShutdownCmd = NULL; } if( mountHDDCmd ) { delete mountHDDCmd; mountHDDCmd = NULL; } } // Good QVBoxLayout* ControlPanel::createButtons() { // Create a new instance of the Activity Log object. rActions = new RadarActions( this, radarNumber, channelNumber ); // Create a layout for the section. QVBoxLayout* layout = new QVBoxLayout; // Add the log box to the layout. layout->addWidget( rActions->getGroupBox( "Radar Actions" ) ); return layout; } // Good QVBoxLayout* ControlPanel::createLogViewer() { // Create a new instance of the Activity Log object. aLog = new ActivityLog(); // Create a layout for the section. QVBoxLayout* layout = new QVBoxLayout; // Add the log box to the layout. layout->addWidget( aLog->getGroupBox( "Event Log" ) ); return layout; } // Good QVBoxLayout* ControlPanel::createStatusSection() { // Create the layout for the section. QVBoxLayout* layout = new QVBoxLayout; // Create a new instance of the ChannelFeedback object. chFeedback = new ChannelFeedback(); // Create a new instance of the RadarStatus object. rStatus = new RadarStatus(); // Create a new instance of the HDDStatus object. hddStatus = new HDDStatus(); // Add the boxes from each object to the main layout for the section. layout->addWidget( chFeedback->getGroupBox( "High Integration Channel Feedback" ) ); layout->addWidget( rStatus->getGroupBox( "Radar Status" ) ); layout->addWidget( hddStatus->getGroupBox( "HDD Recording Status" ) ); return layout; } // Not good, but do not delete. void ControlPanel::createDiskGauge() { diskGaugeBox = new QGroupBox( tr( "Least Space Remaining Drive" ) ); QHBoxLayout* layout = new QHBoxLayout; dGauge = new DiskGauge( this ); dGauge->setRange( 0.0, 240.0 ); dGauge->setScale( -1, 2, ( 240.0 / 8.0 ) ); dGauge->setReadOnly( true ); dGauge->scaleDraw()->setPenWidth( 3 ); dGauge->setLineWidth( 4 ); dGauge->setFrameShadow( QwtDial::Plain ); dGauge->setValue( 135.5 ); layout->addWidget( dGauge ); diskGaugeBox->setLayout( layout ); } // Good bool ControlPanel::checkValidParams() { if( ( radarNumber <= 4 ) && ( radarNumber > 0 ) && ( channelNumber <= 8 ) && ( channelNumber > 0 ) ) { return true; } else { return false; } } void ControlPanel::setStatusValues( QString utc, uint32_t pps, uint32_t epri ) { QString numPPS, numEPRI; chFeedback->setUTC( utc ); numPPS.setNum( pps ); chFeedback->setPPS( numPPS ); numEPRI.setNum( epri ); chFeedback->setEPRI( numEPRI ); } // Good void ControlPanel::setRefresh( QString refresh ) { chFeedback->setRefresh( refresh ); } void ControlPanel::closeEvent( QCloseEvent* event ) { /*cEvent = event; if( radarOn ) { event->ignore(); stopRadar(); } else { event->accept(); }*/ } // Good void ControlPanel::setStatusBarVersion() { // Set the status bar message to the current software version. QString version, maj, med, min, rc; version.append( "QLook Software Version: " ); maj.setNum( MAJOR_VERSION ); version.append( maj ); version.append( "." ); med.setNum( MEDIUM_VERSION ); version.append( med); version.append( "." ); min.setNum( MINOR_VERSION ); version.append( min ); if( RC_VERSION != 0 ) { rc.setNum( RC_VERSION ); version.append( " Release Candidate " ); version.append( rc ); } //statusBar()->showMessage( version ); QLabel* v = new QLabel( version ); statusBar()->addWidget( v ); } void ControlPanel::dispDataRate( QString msg ) { hddStatus->setEstRec( msg ); } // Good void ControlPanel::writeToLog( QString text, int lType ) { aLog->write( text, lType ); } // Good void ControlPanel::changeFeedbackLEDColor( QColor color, int type ) { switch( type ) { case 0: chFeedback->setPPSLED( color ); break; case 1: chFeedback->setEPRILED( color ); break; case 2: chFeedback->setRefreshLED( color ); break; case 3: chFeedback->setAllLED( color ); break; } } // Good void ControlPanel::changeStatusLEDColor( QColor color, int type ) { switch( type ) { case 0: rStatus->setRadarLED( color ); break; case 1: rStatus->setRecordLED( color ); break; case 2: rStatus->setQLookLED( color ); break; case 3: rStatus->setAllLED( color ); break; } } /* Function: createMenu * Params In * N/A * Return * N/A * Purpose * Creates the menu bar at the top of the window. */ void ControlPanel::createMenu() { menuBar = new QMenuBar; // Create a new menu (File) and an action (Exit) QMenu* fileMenu = new QMenu( tr( "&File" ), this ); QAction* exitAction = fileMenu->addAction( tr( "E&xit" ) ); // Create a new menu (Theme) and actions. QMenu* themeMenu = new QMenu( tr( "&Theme" ), this ); QAction* defAction = themeMenu->addAction( tr( "&Default" ) ); QAction* racingAction = themeMenu->addAction( tr( "&Racing" ) ); QAction* flamesAction = themeMenu->addAction( tr( "&Flames" ) ); // Create a new menu (Help) and actions. QMenu* helpMenu = new QMenu( tr( "&Help" ), this ); QAction* aboutAction = helpMenu->addAction( tr( "&About" ) ); // Add menus to the menubar. menuBar->addMenu( fileMenu ); menuBar->addMenu( themeMenu ); menuBar->addMenu( helpMenu ); // Connect an event for when the Exit action is triggered, the window closes. connect( exitAction, SIGNAL( triggered() ), this, SLOT( close() ) ); // Connect an event for when the About action is triggered, showing the about window. connect( aboutAction, SIGNAL( triggered() ), this, SLOT( showAboutWindow() ) ); // Connect the theme events. connect( defAction, SIGNAL( triggered() ), this, SLOT( changeThemeDef() ) ); connect( racingAction, SIGNAL( triggered() ), this, SLOT( changeThemeRace() ) ); connect( flamesAction, SIGNAL( triggered() ), this, SLOT( changeThemeFlame() ) ); this->setMenuBar( menuBar ); } void ControlPanel::showAboutWindow() { } void ControlPanel::changeThemeDef() { this->setPalette( defaultPalette ); rActions->themeSound( false ); } void ControlPanel::changeThemeRace() { QPalette palette = defaultPalette; palette.setBrush( this->backgroundRole(), QBrush( QImage( "misc/racing_stripes.png" ) ) ); this->setPalette( palette ); rActions->themeSound( true ); } void ControlPanel::changeThemeFlame() { rActions->themeSound( true ); } void ControlPanel::setMaxPPS( double sFreq ) { long int maxPPS = (int)( sFreq / 2.0 ); QString v; v.setNum( maxPPS ); v.append( " is the new Max. PPS." ); writeToLog( v, DEBUG ); chFeedback->setMaxPPS( maxPPS ); } void ControlPanel::setHDDStatus( double ar, double total, double free, int rem ) { // Set the new information to be displayed. hddStatus->setInfo( ar, total, free, rem ); }