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

📄 plot.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:       plot.cpp                                                   *//*  Description:    Subclass of block. It keep the data to plot                *//*  -------------------------------------------------------------------------- *//*  Date:           April 7 2003                                               *//*  Version:        v1.0                                                       *//*  Authors:        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 "plot.h"#include "defines.h"#include <stdlib.h>#include <math.h>Plot::Plot() {  //  values = new QPtrList<realPoint>;}Plot::~Plot() {  values.clear();}/** * If "length" is smaller than "listeTaille", then we only show the last "length" * of samples. This way we omit the 'blinking' effect we get if we try to  * interpolate on the collected data... */int Plot::Data( double **x_ret, double **y_ret, int length, 		enum showType_e s_type ) {  if ( !Len() ) {    //    cout << "No length in plot::data\n";    return 0;  }  if ( s_type != show_plot ){    cout << "Plot::Data only knows to treat show_plot\n";  }  int points;  if ( length ){    points = min( Len(), length );  } else {    points = Len();  }  double *x = *x_ret = (double*) malloc( points * sizeof( double ) );  double *y = *y_ret = (double*) malloc( points * sizeof( double ) );  for ( int i = 0; i < points; i++ ){    x[i] = values.at( Len() - points + i )->x;    y[i] = values.at( Len() - points + i )->y;  }  return points;}void Plot::addPoint( double ax, double ay ) {  //   cout << "added " << ax << ", " << ay << endl;  values.append( new realPoint( ax, ay ) );}void Plot::setData( double *sx, double *sy, int slength ) {  for ( int i = 0; i < slength; i++ ) {    addPoint( sx[ i ], sy[ i ] );  }}void Plot::slotClear(){  values.clear();}QByteArray Plot::getData( ){  length = Len();      cout << "Plot::getData shouldn't be called...\n";  if ( !Len() ){    return QByteArray( 0 );  }  double *x, *y;  Data( &x, &y, Len(), show_plot );  sig_type = SIG_DOUBLE_COMPLEX;  QByteArray bytes( Len() * 2 * sizeof( double ) );  double *d = (double*)bytes.data();  for ( int i=0; i<Len(); i++ ){    d[ 2*i ] = x[ i ];    d[ 2*i+1 ] = y[ i ];  }  free( x );  free( y );  return bytes;}

⌨️ 快捷键说明

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