⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interface.cpp

📁 This a framework to test new ideas in transmission technology. Actual development is a LDPC-coder in
💻 CPP
字号:
/*******************************************************************************//*  Project:        SOFTWARE RADIO - LCM Laboratoire de Communications Mobiles *//*  -------------------------------------------------------------------------- *//*  Filename:       interface.cpp                                              *//*  Description:    Subclass of QMainWindow. It implements the main interface  *//*                  of the Software Radio GUI.                                 *//*  -------------------------------------------------------------------------- *//*  Date:           April 7 2003                                               *//*  Version:        v1.0                                                       *//*  Authors:        Braure Jerome, Ferreiro Jose                               *//*                  Communication Systems (9th semester) - EPFL                *//*  Extended by:    Porchet Vincent                                            *//*                  Computer Science (6th semester) - EPFL                     *//*******************************************************************************//*******************************************************************************//*  This program is free software; you can redistribute it and/or modify it    *//*  under the terms of the GNU General Public License as published by the Free *//*  Software Foundation; either version 2 of the License, or (at your option)  *//*  any later version.                                                         *//*******************************************************************************/#include <qapplication.h>#include <qmenubar.h>#include <qpopupmenu.h>#include <qmessagebox.h>#include <qtabwidget.h>#include <qlabel.h>#include <qlayout.h>#include <qcombobox.h>#include <qpushbutton.h>#include <qmessagebox.h>// for directory search#include <qdir.h>#include <qstring.h>  //+ for connect ...#include <stdlib.h>#include "interface.h"#include "defines.h"#include "radioview.h"#include "plotwin.h"#include "block.h"#include "show.h"#include "global.h"/*******************************************************************************//* Function:    Interface() - (constuctor)                                     *//* Description: Constructs an instance of class Interface, which inherits      *//*              from class QMainWindow.                                        *//* Inputs:      mapper: pointer to the module mapper.                          *//*******************************************************************************/Interface::Interface() : QMainWindow( 0, 0, WDestructiveClose ) {  isAddCurve = false;  QDesktopWidget *d = QApplication::desktop();  desktopWidth = d->width() / 2;      // returns desktop width  desktopHeight = d->height();    // returns desktop height  fileMenu = new QPopupMenu;  fileMenu->insertItem( "&Quit", qApp, SLOT( quit() ) );  helpMenu = new QPopupMenu;  helpMenu->insertItem( "&About", this, SLOT( slotAbout() ) );  menuBar = new QMenuBar( this );  menuBar->insertItem( "&File", fileMenu );  menuBar->insertItem( "&Help", helpMenu );  windowX = 0;  windowY = 0;  resize( desktopWidth, desktopHeight );  //  move( windowX, windowY );  QString base_dir( getenv( "USER" ) );  base_dir.prepend( "/tmp/" ).append( "/" );  QDir dir( base_dir );  dir.setSorting( QDir::Name );  QStringList procList = dir.entryList( "sradio.*" );  QFile rt_fifo( "/dev/rtf0" );  if ( rt_fifo.open( IO_WriteOnly ) ) {    cout << "Going for realtime\n";    rt_fifo.close();    FifoCmd *c = new FifoCmd();    firstView = new RadioView( c, this );    setCentralWidget( firstView );    active_radio = c;    connect( firstView, SIGNAL( moduleSelected( Module* ) ),	     SLOT( slotModuleSelected( Module* ) ) );  } else if ( !procList.isEmpty() ) {    QTabWidget * tabBar = new QTabWidget( this, "radioTabBar" );    setCentralWidget( tabBar );    for ( unsigned i = 0 ; i < procList.size(); i++ ) {      FifoCmd *c = new FifoCmd( QString( base_dir ).append( procList[ i ] ) );      if ( !c->isAlive() ){	cout << procList[ i ] << " is dead..." << endl;      } else {	firstView = new RadioView( c, this );	QString *temp = new QString();	temp->setNum( procList.size() - i - 1, 10 );	tabBar -> addTab( firstView, procList[ i ] );	connect( tabBar, SIGNAL( currentChanged ( QWidget* ) ),		 firstView, SLOT( slotChangedTab( QWidget* ) ) );	connect( firstView, SIGNAL( moduleSelected( Module* ) ),		 SLOT( slotModuleSelected( Module* ) ) );	connect( firstView, SIGNAL( activeRadioView( FifoCmd* ) ),		 SLOT( changedRadioView( FifoCmd * ) ) );      }    }  } else {    cout << "\nI got nothing to do, exiting\n\n";    exit (0);  }  // Add the file-menu  fileMenu->insertItem( "Stats plot &XY", this, 			SLOT( slotXY_selected() ) );  fileMenu->insertItem( "Stats plot Y( &t )", this, 			SLOT( slotYt_selected() ) );  fileMenu->insertSeparator();  showDebugID = fileMenu->insertItem( "Show debug", this, 				      SLOT( switchDebug() ) );  isDebug = false;  showProfilingID = fileMenu->insertItem( "Show Profiling Info", this,					  SLOT( switchProfiling() ) );  isProfiling = false;}void Interface::changedRadioView( FifoCmd *c ){  active_radio = c;}/*******************************************************************************//* Function:    slotXY_selected()                                              *//* Description: Slot generate the politng window for an XY plot                *//* Inputs:      none.                                                          *//* Returns:     void.                                                          *//*******************************************************************************/void Interface::slotXY_selected() {  if ( isAddCurve ) {    QMessageBox::information( 0, "info box", "please, finish the module's selection of the current plot before to do a new.\n" );  } else {    slotAddingCurve( true );    PlotWin *pWin = new PlotWin( active_radio, true );    connect( this, SIGNAL( moduleSelected( Module* ) ),             pWin, SLOT( slotSelectedModule( Module* ) ) );    connect( pWin, SIGNAL( isAddingCurve( bool ) ),             this, SLOT( slotAddingCurve( bool ) ) );  }}/*******************************************************************************//* Function:    slotYt_selected()                                              *//* Description: Slot generate the politng window for an Y(t) plot              *//* Inputs:      none.                                                          *//* Returns:     void.                                                          *//*******************************************************************************/void Interface::slotYt_selected() {  if ( isAddCurve ) {    QMessageBox::information( 0, "info box", "please, finish the module's selection of the current plot before to do a new.\n" );  } else {    slotAddingCurve( true );    PlotWin *pWin = new PlotWin( active_radio, false );    connect( this, SIGNAL( moduleSelected( Module* ) ),             pWin, SLOT( slotSelectedModule( Module* ) ) );    connect( pWin, SIGNAL( isAddingCurve( bool ) ),             this, SLOT( slotAddingCurve( bool ) ) );  }}/*******************************************************************************//* Function:    slotAbout()                                                    *//* Description: Slot implementing the "about" window.                          *//* Inputs:      none.                                                          *//* Returns:     void.                                                          *//*******************************************************************************/void Interface::slotAbout() {  QMessageBox::information( this, "About",                            "Software Radio Debugger \n\n"                            "Authors: Jerome Braure and Jose Ferreiro\n"                            "9th semester project at LCM\n\n"                            "Extended by : Porchet Vincent \n"                            "6th semester project at LCM\n" );}void Interface::slotModuleSelected ( Module* module ) {  emit moduleSelected ( module );  //   cout<<"emit module in interface : "<<module->name<<"\n";}void Interface::slotAddingCurve( bool adding ) {  isAddCurve = adding;}void Interface::switchDebug( ){  isDebug = !isDebug;  fileMenu->setItemChecked( showDebugID, isDebug );  emit showDebug( isDebug );}void Interface::switchProfiling( ){  isProfiling = !isProfiling;  fileMenu->setItemChecked( showProfilingID, isProfiling );  emit showProfiling( isProfiling );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -