mirror of https://github.com/pvnis/srsRAN_4G.git
Removed graphics dependency and added dependency for libsdrgui. Fixed many cmake bugs after name change
parent
3d0cc1a9ec
commit
c23445b38a
@ -1,152 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
# COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
# and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
#
|
|
||||||
# This file is part of the Iris Project.
|
|
||||||
#
|
|
||||||
# Iris is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Lesser General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of
|
|
||||||
# the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Iris is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# A copy of the GNU Lesser General Public License can be found in
|
|
||||||
# the LICENSE file in the top-level directory of this distribution
|
|
||||||
# and at http://www.gnu.org/licenses/.
|
|
||||||
#
|
|
||||||
|
|
||||||
# - Try to find the Qwt includes and library
|
|
||||||
# - Defines the following:
|
|
||||||
#
|
|
||||||
# QWT_FOUND - system has Qwt
|
|
||||||
# QWT_INCLUDE_DIR - where to find qwt.h
|
|
||||||
# QWT_INCLUDE_DIRS - the qwt include directories
|
|
||||||
# QWT_LIBRARY - where to find the Qwt library (not for general use)
|
|
||||||
# QWT_LIBRARIES - the libraries to link against to use Qwt
|
|
||||||
# QWT_MAJOR_VERSION - major version
|
|
||||||
# QWT_MINOR_VERSION - minor version
|
|
||||||
# QWT_PATCH_VERSION - patch version
|
|
||||||
# QWT_VERSION_STRING - version (ex. 5.2.1)
|
|
||||||
|
|
||||||
SET(QWT_FOUND "NO")
|
|
||||||
|
|
||||||
SET(HINT_INCLUDE_PATHS $ENV{QWT_DIR}/include
|
|
||||||
$ENV{QWT_DIR}/src
|
|
||||||
$ENV{QWTDIR}/include
|
|
||||||
$ENV{QWTDIR}/src
|
|
||||||
$ENV{QWT_ROOT}/include
|
|
||||||
$ENV{QWT_ROOT}/src
|
|
||||||
$ENV{QWTROOT}/include
|
|
||||||
$ENV{QWTROOT}/src)
|
|
||||||
SET(POTENTIAL_INCLUDE_PATHS /usr/local/qwt/include
|
|
||||||
/usr/local/include
|
|
||||||
/usr/include/qwt
|
|
||||||
/usr/include/qwt-qt4
|
|
||||||
/usr/include/qwt5
|
|
||||||
/usr/include
|
|
||||||
/opt/local/include/qwt) #macports path
|
|
||||||
|
|
||||||
FIND_PATH(QWT_INCLUDE_DIR qwt.h
|
|
||||||
HINTS ${HINT_INCLUDE_PATHS}
|
|
||||||
PATHS ${POTENTIAL_INCLUDE_PATHS}
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(QWT_INCLUDE_DIRS ${QWT_INCLUDE_DIR})
|
|
||||||
|
|
||||||
# version
|
|
||||||
SET(_VERSION_FILE ${QWT_INCLUDE_DIR}/qwt_global.h)
|
|
||||||
IF(EXISTS ${_VERSION_FILE} )
|
|
||||||
FILE( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+QWT_VERSION_STR")
|
|
||||||
IF( _VERSION_LINE )
|
|
||||||
STRING( REGEX REPLACE ".*define[ ]+QWT_VERSION_STR[ ]+\"(.*)\".*" "\\1" QWT_VERSION_STRING "${_VERSION_LINE}" )
|
|
||||||
STRING( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" QWT_MAJOR_VERSION "${QWT_VERSION_STRING}" )
|
|
||||||
STRING( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" QWT_MINOR_VERSION "${QWT_VERSION_STRING}" )
|
|
||||||
STRING( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\3" QWT_PATCH_VERSION "${QWT_VERSION_STRING}" )
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
|
|
||||||
# check version
|
|
||||||
SET( _QWT_VERSION_MATCH TRUE )
|
|
||||||
IF( Qwt_FIND_VERSION AND QWT_VERSION_STRING )
|
|
||||||
IF( Qwt_FIND_VERSION_EXACT )
|
|
||||||
IF( NOT Qwt_FIND_VERSION VERSION_EQUAL QWT_VERSION_STRING )
|
|
||||||
SET( _QWT_VERSION_MATCH FALSE )
|
|
||||||
ENDIF()
|
|
||||||
ELSE()
|
|
||||||
IF( QWT_VERSION_STRING VERSION_LESS Qwt_FIND_VERSION )
|
|
||||||
SET( _QWT_VERSION_MATCH FALSE )
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(QWT_NAMES ${QWT_NAMES} qwt qwt-qt4 qwt5 )
|
|
||||||
SET(HINT_LIBRARY_PATHS $ENV{QWT_DIR}/lib
|
|
||||||
$ENV{QWTDIR}/lib
|
|
||||||
$ENV{QWT_ROOT}/lib
|
|
||||||
$ENV{QWTROOT}/lib)
|
|
||||||
SET(POTENTIAL_LIBRARY_PATHS /usr/local/qwt/lib
|
|
||||||
/usr/local/lib
|
|
||||||
/usr/lib
|
|
||||||
/opt/local/lib)
|
|
||||||
|
|
||||||
FIND_LIBRARY(QWT_LIBRARY
|
|
||||||
NAMES ${QWT_NAMES}
|
|
||||||
HINTS ${HINT_LIBRARY_PATHS}
|
|
||||||
PATHS ${POTENTIAL_LIBRARY_PATHS}
|
|
||||||
)
|
|
||||||
MARK_AS_ADVANCED(QWT_LIBRARY)
|
|
||||||
|
|
||||||
IF (QWT_LIBRARY)
|
|
||||||
|
|
||||||
IF(WIN32 AND NOT CYGWIN)
|
|
||||||
|
|
||||||
SET(QWT_NAMES_DEBUG qwtd qwtd-qt4 qwtd5 )
|
|
||||||
FIND_LIBRARY(QWT_LIBRARY_DEBUG
|
|
||||||
NAMES ${QWT_NAMES_DEBUG}
|
|
||||||
HINTS ${HINT_LIBRARY_PATHS}
|
|
||||||
PATHS ${POTENTIAL_LIBRARY_PATHS}
|
|
||||||
)
|
|
||||||
MARK_AS_ADVANCED(QWT_LIBRARY_DEBUG)
|
|
||||||
|
|
||||||
IF(QWT_LIBRARY_DEBUG)
|
|
||||||
SET(QWT_LIBRARIES optimized ${QWT_LIBRARY} debug ${QWT_LIBRARY_DEBUG} CACHE DOC "QWT library files")
|
|
||||||
ELSE(QWT_LIBRARY_DEBUG)
|
|
||||||
SET(QWT_LIBRARIES ${QWT_LIBRARY} CACHE DOC "QWT library files")
|
|
||||||
ENDIF(QWT_LIBRARY_DEBUG)
|
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DQWT_DLL)
|
|
||||||
|
|
||||||
ELSE(WIN32 AND NOT CYGWIN)
|
|
||||||
|
|
||||||
SET(QWT_LIBRARIES ${QWT_LIBRARY} CACHE DOC "QWT library files")
|
|
||||||
|
|
||||||
ENDIF(WIN32 AND NOT CYGWIN)
|
|
||||||
|
|
||||||
SET(QWT_FOUND "YES")
|
|
||||||
|
|
||||||
IF (CYGWIN)
|
|
||||||
IF(BUILD_SHARED_LIBS)
|
|
||||||
# No need to define QWT_USE_DLL here, because it's default for Cygwin.
|
|
||||||
ELSE(BUILD_SHARED_LIBS)
|
|
||||||
SET (QWT_DEFINITIONS -DQWT_STATIC)
|
|
||||||
ENDIF(BUILD_SHARED_LIBS)
|
|
||||||
ENDIF (CYGWIN)
|
|
||||||
|
|
||||||
ENDIF (QWT_LIBRARY)
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments
|
|
||||||
INCLUDE( FindPackageHandleStandardArgs )
|
|
||||||
IF( CMAKE_VERSION LESS 2.8.3 )
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS( Qwt DEFAULT_MSG QWT_LIBRARY QWT_INCLUDE_DIR _QWT_VERSION_MATCH )
|
|
||||||
ELSE()
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS( Qwt REQUIRED_VARS QWT_LIBRARY QWT_INCLUDE_DIR _QWT_VERSION_MATCH VERSION_VAR QWT_VERSION_STRING )
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(QWT_INCLUDE_DIR QWT_LIBRARY)
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2012-2013 The libLTE Developers. See the
|
|
||||||
# COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
#
|
|
||||||
# This file is part of the libLTE library.
|
|
||||||
#
|
|
||||||
# libLTE is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Lesser General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of
|
|
||||||
# the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# libLTE is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# A copy of the GNU Lesser General Public License can be found in
|
|
||||||
# the LICENSE file in the top-level directory of this distribution
|
|
||||||
# and at http://www.gnu.org/licenses/.
|
|
||||||
#
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Install headers
|
|
||||||
########################################################################
|
|
||||||
INSTALL(DIRECTORY include/
|
|
||||||
DESTINATION "${INCLUDE_DIR}"
|
|
||||||
FILES_MATCHING PATTERN "*.h"
|
|
||||||
PATTERN ".svn" EXCLUDE
|
|
||||||
)
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Add headers to cmake project (useful for IDEs)
|
|
||||||
########################################################################
|
|
||||||
SET(HEADERS_ALL "")
|
|
||||||
FILE(GLOB headers *)
|
|
||||||
FOREACH (_header ${headers})
|
|
||||||
IF(IS_DIRECTORY ${_header})
|
|
||||||
FILE(GLOB_RECURSE tmp "${_header}/*.h")
|
|
||||||
LIST(APPEND HEADERS_ALL ${tmp})
|
|
||||||
ENDIF(IS_DIRECTORY ${_header})
|
|
||||||
ENDFOREACH()
|
|
||||||
ADD_CUSTOM_TARGET (add_graphics_headers SOURCES ${HEADERS_ALL})
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Add the subdirectories
|
|
||||||
########################################################################
|
|
||||||
ADD_SUBDIRECTORY(lib)
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _plot_h
|
|
||||||
#define _plot_h
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "srslte/config.h"
|
|
||||||
|
|
||||||
#include "srslte/graphics/plot/plot_real.h"
|
|
||||||
#include "srslte/graphics/plot/plot_scatter.h"
|
|
||||||
#include "srslte/graphics/plot/plot_complex.h"
|
|
||||||
#include "srslte/graphics/plot/plot_waterfall.h"
|
|
||||||
|
|
||||||
SRSLTE_API int plot_init();
|
|
||||||
SRSLTE_API void plot_exit();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,60 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _plot_complex_h
|
|
||||||
#define _plot_complex_h
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "srslte/config.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
Ip, Q, Magnitude, Phase
|
|
||||||
} plot_complex_id_t;
|
|
||||||
|
|
||||||
typedef void* plot_complex_t;
|
|
||||||
|
|
||||||
SRSLTE_API int plot_complex_init(plot_complex_t *h);
|
|
||||||
SRSLTE_API void plot_complex_setTitle(plot_complex_t *h, char *title);
|
|
||||||
SRSLTE_API void plot_complex_setNewData(plot_complex_t *h, _Complex float *data,
|
|
||||||
int num_points);
|
|
||||||
SRSLTE_API void plot_complex_setXAxisAutoScale(plot_complex_t *h, plot_complex_id_t id, bool on);
|
|
||||||
SRSLTE_API void plot_complex_setYAxisAutoScale(plot_complex_t *h, plot_complex_id_t id, bool on);
|
|
||||||
SRSLTE_API void plot_complex_setXAxisScale(plot_complex_t *h, plot_complex_id_t id, double xMin, double xMax);
|
|
||||||
SRSLTE_API void plot_complex_setYAxisScale(plot_complex_t *h, plot_complex_id_t id, double yMin, double yMax);
|
|
||||||
SRSLTE_API void plot_complex_setXAxisRange(plot_complex_t *h, double xMin, double xMax);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _plot_real_h
|
|
||||||
#define _plot_real_h
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "srslte/config.h"
|
|
||||||
|
|
||||||
typedef void* plot_real_t;
|
|
||||||
|
|
||||||
SRSLTE_API int plot_real_init(plot_real_t *h);
|
|
||||||
SRSLTE_API void plot_real_setTitle(plot_real_t *h, char *title);
|
|
||||||
SRSLTE_API void plot_real_setNewData(plot_real_t *h, float *data,
|
|
||||||
int num_points);
|
|
||||||
SRSLTE_API void plot_real_setXAxisAutoScale(plot_real_t *h, bool on);
|
|
||||||
SRSLTE_API void plot_real_setYAxisAutoScale(plot_real_t *h, bool on);
|
|
||||||
SRSLTE_API void plot_real_setXAxisScale(plot_real_t *h, double xMin, double xMax);
|
|
||||||
SRSLTE_API void plot_real_setYAxisScale(plot_real_t *h, double yMin, double yMax);
|
|
||||||
SRSLTE_API void plot_real_setXAxisRange(plot_real_t *h, double xMin, double xMax);
|
|
||||||
SRSLTE_API void plot_real_setLabels(plot_real_t *h, char *xLabel, char *yLabel);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _plot_scatter_h
|
|
||||||
#define _plot_scatter_h
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "srslte/config.h"
|
|
||||||
|
|
||||||
typedef void* plot_scatter_t;
|
|
||||||
|
|
||||||
SRSLTE_API int plot_scatter_init(plot_scatter_t *h);
|
|
||||||
SRSLTE_API void plot_scatter_setTitle(plot_scatter_t *h, char *title);
|
|
||||||
SRSLTE_API void plot_scatter_setNewData(plot_scatter_t *h, _Complex float *data,
|
|
||||||
int num_points);
|
|
||||||
SRSLTE_API void plot_scatter_setXAxisAutoScale(plot_scatter_t *h, bool on);
|
|
||||||
SRSLTE_API void plot_scatter_setYAxisAutoScale(plot_scatter_t *h, bool on);
|
|
||||||
SRSLTE_API void plot_scatter_setXAxisScale(plot_scatter_t *h, double xMin, double xMax);
|
|
||||||
SRSLTE_API void plot_scatter_setYAxisScale(plot_scatter_t *h, double yMin, double yMax);
|
|
||||||
SRSLTE_API void plot_scatter_setAxisLabels(plot_scatter_t *h, char *xLabel, char *yLabel);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _plot_waterfall_h
|
|
||||||
#define _plot_waterfall_h
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "srslte/config.h"
|
|
||||||
|
|
||||||
typedef void* plot_waterfall_t;
|
|
||||||
|
|
||||||
SRSLTE_API int plot_waterfall_init(plot_waterfall_t *h, int numDataPoints, int numRows);
|
|
||||||
SRSLTE_API void plot_waterfall_setTitle(plot_waterfall_t *h, char *title);
|
|
||||||
SRSLTE_API void plot_waterfall_appendNewData(plot_waterfall_t *h, float *data,
|
|
||||||
int num_points);
|
|
||||||
SRSLTE_API void plot_complex_setPlotXLabel(plot_waterfall_t *h, char *xLabel);
|
|
||||||
SRSLTE_API void plot_complex_setPlotYLabel(plot_waterfall_t *h, char *yLabel);
|
|
||||||
SRSLTE_API void plot_waterfall_setPlotXAxisRange(plot_waterfall_t *h, double xMin, double xMax);
|
|
||||||
SRSLTE_API void plot_waterfall_setPlotXAxisScale(plot_waterfall_t *h, double xMin, double xMax);
|
|
||||||
SRSLTE_API void plot_waterfall_setPlotYAxisScale(plot_waterfall_t *h, double yMin, double yMax);
|
|
||||||
|
|
||||||
SRSLTE_API void plot_waterfall_setSpectrogramXLabel(plot_waterfall_t *h, char* xLabel);
|
|
||||||
SRSLTE_API void plot_waterfall_setSpectrogramYLabel(plot_waterfall_t *h, char* yLabel);
|
|
||||||
SRSLTE_API void plot_waterfall_setSpectrogramXAxisRange(plot_waterfall_t *h, double xMin, double xMax);
|
|
||||||
SRSLTE_API void plot_waterfall_setSpectrogramYAxisRange(plot_waterfall_t *h, double yMin, double yMax);
|
|
||||||
SRSLTE_API void plot_waterfall_setSpectrogramZAxisScale(plot_waterfall_t *h, double zMin, double zMax);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,94 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2012-2013 The libLTE Developers. See the
|
|
||||||
# COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
#
|
|
||||||
# This file is part of the libLTE library.
|
|
||||||
#
|
|
||||||
# libLTE is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Lesser General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of
|
|
||||||
# the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# libLTE is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# A copy of the GNU Lesser General Public License can be found in
|
|
||||||
# the LICENSE file in the top-level directory of this distribution
|
|
||||||
# and at http://www.gnu.org/licenses/.
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Setup Qt and Qwt
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
FIND_PACKAGE(Qt4)
|
|
||||||
IF(QT4_FOUND)
|
|
||||||
INCLUDE(${QT_USE_FILE})
|
|
||||||
ENDIF(QT4_FOUND)
|
|
||||||
|
|
||||||
FIND_PACKAGE(Qwt)
|
|
||||||
IF(QT4_FOUND AND QWT_FOUND)
|
|
||||||
INCLUDE_DIRECTORIES(${QWT_INCLUDE_DIRS})
|
|
||||||
ENDIF(QT4_FOUND AND QWT_FOUND)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Build the graphics library
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
file(GLOB modules *)
|
|
||||||
|
|
||||||
SET(SOURCES_ALL "")
|
|
||||||
FOREACH (_module ${modules})
|
|
||||||
IF(IS_DIRECTORY ${_module})
|
|
||||||
FILE(GLOB tmp "${_module}/*.cpp")
|
|
||||||
LIST(APPEND SOURCES_ALL ${tmp})
|
|
||||||
ENDIF(IS_DIRECTORY ${_module})
|
|
||||||
ENDFOREACH(_module ${modules})
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../)
|
|
||||||
|
|
||||||
IF(QWT_MAJOR_VERSION LESS 6)
|
|
||||||
MESSAGE(STATUS "QWT6 is required.")
|
|
||||||
ENDIF(QWT_MAJOR_VERSION LESS 6)
|
|
||||||
|
|
||||||
IF(QT4_FOUND AND QWT_FOUND AND QWT_MAJOR_VERSION EQUAL 6)
|
|
||||||
QT4_WRAP_CPP(lineplotwraps common/Lineplot.h)
|
|
||||||
QT4_WRAP_CPP(pointplotwraps common/Pointplot.h)
|
|
||||||
QT4_WRAP_CPP(spectrogramplotwraps common/Spectrogramplot.h)
|
|
||||||
QT4_WRAP_CPP(complex complexplot/ComplexWidget.h complexplot/ComplexplotWrapper.h)
|
|
||||||
QT4_WRAP_CPP(real realplot/RealWidget.h realplot/RealplotWrapper.h)
|
|
||||||
QT4_WRAP_CPP(scatter scatterplot/ScatterWidget.h scatterplot/ScatterplotWrapper.h)
|
|
||||||
QT4_WRAP_CPP(waterfall waterfallplot/WaterfallWidget.h waterfallplot/WaterfallplotWrapper.h)
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(common complexplot realplot scatterplot waterfallplot ${Boost_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
ADD_LIBRARY(graphics SHARED ${eventwraps} ${lineplotwraps} ${pointplotwraps} ${spectrogramplotwraps} ${complex} ${real} ${scatter} ${waterfall} ${SOURCES_ALL} )
|
|
||||||
TARGET_LINK_LIBRARIES(graphics pthread ${QT_LIBRARIES} ${QWT_LIBRARIES})
|
|
||||||
INSTALL(TARGETS graphics DESTINATION ${LIBRARY_DIR})
|
|
||||||
LIBLTE_SET_PIC(graphics)
|
|
||||||
|
|
||||||
APPEND_INTERNAL_LIST(OPTIONAL_LIBS graphics)
|
|
||||||
|
|
||||||
|
|
||||||
#ADD_SUBDIRECTORY(complexplot/test)
|
|
||||||
#ADD_SUBDIRECTORY(realplot/test)
|
|
||||||
#ADD_SUBDIRECTORY(scatterplot/test)
|
|
||||||
#ADD_SUBDIRECTORY(waterfallplot/test)
|
|
||||||
|
|
||||||
MESSAGE(STATUS " GRAPHICS library will be installed.")
|
|
||||||
|
|
||||||
|
|
||||||
ELSE(QT4_FOUND AND QWT_FOUND AND AND QWT_MAJOR_VERSION EQUAL 6)
|
|
||||||
|
|
||||||
MESSAGE(STATUS " QT4 or Qwt6 not found. GRAPHICS library is not generated")
|
|
||||||
|
|
||||||
ENDIF(QT4_FOUND AND QWT_FOUND AND QWT_MAJOR_VERSION EQUAL 6)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/graphics/qt/common/Events.cpp
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Implementation of events used to pass data to Qt-based classes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Events.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
const QEvent::Type RealDataEvent::type = static_cast<QEvent::Type>(10000);
|
|
||||||
|
|
||||||
RealDataEvent::RealDataEvent(double* dataPoints, int numPoints)
|
|
||||||
: QEvent(QEvent::Type(type))
|
|
||||||
{
|
|
||||||
dataPoints_ = new double[numPoints];
|
|
||||||
numPoints_ = numPoints;
|
|
||||||
memcpy(dataPoints_, dataPoints, numPoints*sizeof(double));
|
|
||||||
}
|
|
||||||
|
|
||||||
RealDataEvent::RealDataEvent(float* dataPoints, int numPoints)
|
|
||||||
: QEvent(QEvent::Type(type))
|
|
||||||
{
|
|
||||||
dataPoints_ = new double[numPoints];
|
|
||||||
numPoints_ = numPoints;
|
|
||||||
|
|
||||||
for(int i=0;i<numPoints_;i++)
|
|
||||||
{
|
|
||||||
dataPoints_[i] = (double)(dataPoints[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RealDataEvent::~RealDataEvent()
|
|
||||||
{
|
|
||||||
delete[] dataPoints_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QEvent::Type ComplexDataEvent::type = static_cast<QEvent::Type>(10001);
|
|
||||||
|
|
||||||
ComplexDataEvent::ComplexDataEvent(complex<double>* dataPoints,
|
|
||||||
int numPoints)
|
|
||||||
: QEvent(QEvent::Type(type))
|
|
||||||
{
|
|
||||||
dataPoints_ = new complex<double>[numPoints];
|
|
||||||
numPoints_ = numPoints;
|
|
||||||
memcpy(dataPoints_, dataPoints, numPoints*sizeof(complex<double>));
|
|
||||||
}
|
|
||||||
|
|
||||||
ComplexDataEvent::ComplexDataEvent(complex<float>* dataPoints,
|
|
||||||
int numPoints)
|
|
||||||
: QEvent(QEvent::Type(type))
|
|
||||||
{
|
|
||||||
dataPoints_ = new complex<double>[numPoints];
|
|
||||||
numPoints_ = numPoints;
|
|
||||||
|
|
||||||
for(int i=0;i<numPoints_;i++)
|
|
||||||
{
|
|
||||||
dataPoints_[i] = complex<double>(dataPoints[i].real(),
|
|
||||||
dataPoints[i].imag());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ComplexDataEvent::~ComplexDataEvent()
|
|
||||||
{
|
|
||||||
delete[] dataPoints_;
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/graphics/qt/common/Events.h
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Events used to pass data to Qt-based classes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EVENTS_H
|
|
||||||
#define EVENTS_H
|
|
||||||
|
|
||||||
#include <QEvent>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class RealDataEvent
|
|
||||||
: public QEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
const static QEvent::Type type;
|
|
||||||
|
|
||||||
RealDataEvent(double* dataPoints,
|
|
||||||
int numPoints);
|
|
||||||
RealDataEvent(float* dataPoints,
|
|
||||||
int numPoints);
|
|
||||||
virtual ~RealDataEvent();
|
|
||||||
|
|
||||||
double* dataPoints_;
|
|
||||||
int numPoints_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ComplexDataEvent
|
|
||||||
: public QEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
const static QEvent::Type type;
|
|
||||||
|
|
||||||
ComplexDataEvent(std::complex<double>* dataPoints,
|
|
||||||
int numPoints);
|
|
||||||
ComplexDataEvent(std::complex<float>* dataPoints,
|
|
||||||
int numPoints);
|
|
||||||
virtual ~ComplexDataEvent();
|
|
||||||
|
|
||||||
std::complex<double>* dataPoints_;
|
|
||||||
int numPoints_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // EVENTS_H
|
|
@ -1,168 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/graphics/qt/common/Lineplot.cpp
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Implementation of a simple line plotted using a QwtPlot.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Lineplot.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
class MyZoomer: public QwtPlotZoomer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyZoomer(QwtPlotCanvas *canvas):
|
|
||||||
QwtPlotZoomer(canvas)
|
|
||||||
{
|
|
||||||
setTrackerMode(AlwaysOn);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QwtText trackerTextF(const QPointF &pos) const
|
|
||||||
{
|
|
||||||
QColor bg(Qt::white);
|
|
||||||
bg.setAlpha(200);
|
|
||||||
|
|
||||||
QwtText text = QwtPlotZoomer::trackerTextF(pos);
|
|
||||||
text.setBackgroundBrush( QBrush( bg ));
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Lineplot::Lineplot(QWidget *parent)
|
|
||||||
:QwtPlot(parent)
|
|
||||||
,xMin_(0)
|
|
||||||
,xMax_(0)
|
|
||||||
{
|
|
||||||
counter_ = 0;
|
|
||||||
numPoints_ = 1;
|
|
||||||
indexPoints_ = new double[numPoints_];
|
|
||||||
dataPoints_ = new double[numPoints_];
|
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
|
|
||||||
QPalette palette;
|
|
||||||
palette.setColor(canvas()->backgroundRole(), QColor("white"));
|
|
||||||
canvas()->setPalette(palette);
|
|
||||||
|
|
||||||
curve_ = new QwtPlotCurve("Curve");
|
|
||||||
curve_->setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
|
||||||
curve_->setStyle(QwtPlotCurve::Lines);
|
|
||||||
curve_->setRawSamples(indexPoints_, dataPoints_, numPoints_);
|
|
||||||
curve_->setYAxis(QwtPlot::yLeft);
|
|
||||||
curve_->attach(this);
|
|
||||||
|
|
||||||
memset(dataPoints_, 0x0, numPoints_*sizeof(double));
|
|
||||||
for(int i=0;i<numPoints_;i++)
|
|
||||||
indexPoints_[i] = i;
|
|
||||||
|
|
||||||
enableAxis(QwtPlot::yRight);
|
|
||||||
QwtScaleWidget *leftAxis = axisWidget(QwtPlot::yLeft);
|
|
||||||
connect(leftAxis, SIGNAL(scaleDivChanged()), this, SLOT(linkScales()));
|
|
||||||
|
|
||||||
setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
|
|
||||||
setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
|
|
||||||
setAxisScaleEngine(QwtPlot::yRight, new QwtLinearScaleEngine);
|
|
||||||
|
|
||||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true);
|
|
||||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true);
|
|
||||||
axisScaleEngine(QwtPlot::yRight)->setAttribute(QwtScaleEngine::Floating,true);
|
|
||||||
|
|
||||||
zoomer_ = new MyZoomer(qobject_cast<QwtPlotCanvas*>(canvas()));
|
|
||||||
zoomer_->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
|
||||||
zoomer_->setMousePattern(QwtEventPattern::MouseSelect2, Qt::LeftButton,
|
|
||||||
Qt::ControlModifier);
|
|
||||||
|
|
||||||
panner_ = new QwtPlotPanner(canvas());
|
|
||||||
panner_->setMouseButton(Qt::RightButton);
|
|
||||||
|
|
||||||
magnifier_ = new QwtPlotMagnifier(canvas());
|
|
||||||
magnifier_->setMouseButton(Qt::NoButton);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Lineplot::~Lineplot()
|
|
||||||
{
|
|
||||||
delete[] indexPoints_;
|
|
||||||
delete[] dataPoints_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lineplot::setData(double* data, int n)
|
|
||||||
{
|
|
||||||
if(numPoints_ != n)
|
|
||||||
{
|
|
||||||
numPoints_ = n;
|
|
||||||
delete[] indexPoints_;
|
|
||||||
delete[] dataPoints_;
|
|
||||||
indexPoints_ = new double[numPoints_];
|
|
||||||
dataPoints_ = new double[numPoints_];
|
|
||||||
if(xMin_==xMax_)
|
|
||||||
{
|
|
||||||
for(int i=0;i<numPoints_;i++)
|
|
||||||
indexPoints_[i] = i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
double step = (xMax_-xMin_)/numPoints_;
|
|
||||||
double val = xMin_;
|
|
||||||
for(int i=0;i<numPoints_;i++,val+=step)
|
|
||||||
indexPoints_[i] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(dataPoints_, data, numPoints_*sizeof(double));
|
|
||||||
//Need to setRawSamples again for autoscaling to work
|
|
||||||
curve_->setRawSamples(indexPoints_, dataPoints_, numPoints_);
|
|
||||||
resetZoom();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lineplot::setXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
xMin_ = xMin;
|
|
||||||
xMax_ = xMax;
|
|
||||||
double step = (xMax_-xMin_)/numPoints_;
|
|
||||||
double val = xMin_;
|
|
||||||
for(int i=0;i<numPoints_;i++,val+=step)
|
|
||||||
indexPoints_[i] = val;
|
|
||||||
curve_->setRawSamples(indexPoints_, dataPoints_, numPoints_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lineplot::resetZoom()
|
|
||||||
{
|
|
||||||
zoomer_->setZoomBase(curve_->boundingRect());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lineplot::linkScales()
|
|
||||||
{
|
|
||||||
#if QWT_VERSION < 0x060100
|
|
||||||
setAxisScaleDiv(QwtPlot::yRight, *axisScaleDiv(QwtPlot::yLeft));
|
|
||||||
#else // QWT_VERSION < 0x060100
|
|
||||||
setAxisScaleDiv(QwtPlot::yRight, axisScaleDiv(QwtPlot::yLeft));
|
|
||||||
#endif // QWT_VERSION < 0x060100
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/graphics/qt/common/Lineplot.h
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* A simple line plotted using a QwtPlot.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LINEPLOT_H
|
|
||||||
#define LINEPLOT_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qwt_plot.h>
|
|
||||||
#include <qwt_painter.h>
|
|
||||||
#include <qwt_plot_canvas.h>
|
|
||||||
#include <qwt_plot_curve.h>
|
|
||||||
#include <qwt_scale_engine.h>
|
|
||||||
#include <qwt_scale_widget.h>
|
|
||||||
#include <qwt_plot_zoomer.h>
|
|
||||||
#include <qwt_plot_panner.h>
|
|
||||||
#include <qwt_plot_magnifier.h>
|
|
||||||
|
|
||||||
class Lineplot
|
|
||||||
: public QwtPlot
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
Lineplot(QWidget* parent = 0);
|
|
||||||
virtual ~Lineplot();
|
|
||||||
|
|
||||||
void setData(double* data, int n);
|
|
||||||
void setXAxisRange(double xMin, double xMax);
|
|
||||||
void resetZoom();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void linkScales();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QwtPlotCurve* curve_;
|
|
||||||
|
|
||||||
QwtPlotPanner* panner_;
|
|
||||||
QwtPlotZoomer* zoomer_;
|
|
||||||
QwtPlotMagnifier* magnifier_;
|
|
||||||
|
|
||||||
double* indexPoints_;
|
|
||||||
double* dataPoints_;
|
|
||||||
|
|
||||||
int numPoints_;
|
|
||||||
int counter_;
|
|
||||||
double xMin_;
|
|
||||||
double xMax_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // LINEPLOT_H
|
|
@ -1,121 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/graphics/qt/common/Pointplot.h
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Implementation of a plot of complex data values as points on an IQ axis.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Pointplot.h"
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class MyZoomer: public QwtPlotZoomer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyZoomer(QwtPlotCanvas *canvas):
|
|
||||||
QwtPlotZoomer(canvas)
|
|
||||||
{
|
|
||||||
setTrackerMode(AlwaysOn);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QwtText trackerTextF(const QPointF &pos) const
|
|
||||||
{
|
|
||||||
QColor bg(Qt::white);
|
|
||||||
bg.setAlpha(200);
|
|
||||||
|
|
||||||
QwtText text = QwtPlotZoomer::trackerTextF(pos);
|
|
||||||
text.setBackgroundBrush( QBrush( bg ));
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Pointplot::Pointplot(QWidget *parent)
|
|
||||||
:QwtPlot(parent)
|
|
||||||
{
|
|
||||||
counter_ = 0;
|
|
||||||
numPoints_ = 1;
|
|
||||||
realPoints_ = new double[numPoints_];
|
|
||||||
imagPoints_ = new double[numPoints_];
|
|
||||||
|
|
||||||
QPalette palette;
|
|
||||||
palette.setColor(canvas()->backgroundRole(), QColor("white"));
|
|
||||||
canvas()->setPalette(palette);
|
|
||||||
|
|
||||||
setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
|
|
||||||
setAxisTitle(QwtPlot::xBottom, "In-phase");
|
|
||||||
|
|
||||||
setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
|
|
||||||
setAxisTitle(QwtPlot::yLeft, "Quadrature");
|
|
||||||
|
|
||||||
curve_ = new QwtPlotCurve("Constellation Points");
|
|
||||||
curve_->attach(this);
|
|
||||||
curve_->setPen(QPen(Qt::blue, 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
|
||||||
curve_->setStyle(QwtPlotCurve::Dots);
|
|
||||||
curve_->setRawSamples(realPoints_, imagPoints_, numPoints_);
|
|
||||||
|
|
||||||
memset(realPoints_, 0x0, numPoints_*sizeof(double));
|
|
||||||
memset(imagPoints_, 0x0, numPoints_*sizeof(double));
|
|
||||||
|
|
||||||
zoomer_ = new MyZoomer(qobject_cast<QwtPlotCanvas*>(canvas()));
|
|
||||||
zoomer_->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
|
||||||
zoomer_->setMousePattern(QwtEventPattern::MouseSelect2, Qt::LeftButton,
|
|
||||||
Qt::ControlModifier);
|
|
||||||
|
|
||||||
panner_ = new QwtPlotPanner(canvas());
|
|
||||||
panner_->setMouseButton(Qt::RightButton);
|
|
||||||
|
|
||||||
magnifier_ = new QwtPlotMagnifier(canvas());
|
|
||||||
magnifier_->setMouseButton(Qt::NoButton);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Pointplot::~Pointplot()
|
|
||||||
{
|
|
||||||
delete[] realPoints_;
|
|
||||||
delete[] imagPoints_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pointplot::setData(double* iData, double* qData, int n)
|
|
||||||
{
|
|
||||||
if(numPoints_ != n)
|
|
||||||
{
|
|
||||||
numPoints_ = n;
|
|
||||||
delete[] realPoints_;
|
|
||||||
delete[] imagPoints_;
|
|
||||||
realPoints_ = new double[numPoints_];
|
|
||||||
imagPoints_ = new double[numPoints_];
|
|
||||||
}
|
|
||||||
|
|
||||||
copy(iData, iData+n, realPoints_);
|
|
||||||
copy(qData, qData+n, imagPoints_);
|
|
||||||
//Need to setRawSamples again for autoscaling to work
|
|
||||||
curve_->setRawSamples(realPoints_, imagPoints_, numPoints_);
|
|
||||||
zoomer_->setZoomBase(curve_->boundingRect());
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/graphics/qt/common/Pointplot.h
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* A plot of complex data values as points on an IQ axis.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef POINTPLOT_H
|
|
||||||
#define POINTPLOT_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qwt_plot.h>
|
|
||||||
#include <qwt_painter.h>
|
|
||||||
#include <qwt_plot_canvas.h>
|
|
||||||
#include <qwt_plot_curve.h>
|
|
||||||
#include <qwt_scale_engine.h>
|
|
||||||
#include <qwt_scale_widget.h>
|
|
||||||
#include <qwt_plot_zoomer.h>
|
|
||||||
#include <qwt_plot_panner.h>
|
|
||||||
#include <qwt_plot_magnifier.h>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class Pointplot
|
|
||||||
: public QwtPlot
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
Pointplot(QWidget* parent = 0);
|
|
||||||
virtual ~Pointplot();
|
|
||||||
void setData(double* iData, double* qData, int n);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QwtPlotCurve* curve_;
|
|
||||||
|
|
||||||
QwtPlotPanner* panner_;
|
|
||||||
QwtPlotZoomer* zoomer_;
|
|
||||||
QwtPlotMagnifier* magnifier_;
|
|
||||||
|
|
||||||
struct opReal{double operator()(std::complex<double> i) const{return real(i);}};
|
|
||||||
struct opImag{double operator()(std::complex<double> i) const{return imag(i);}};
|
|
||||||
|
|
||||||
double* realPoints_;
|
|
||||||
double* imagPoints_;
|
|
||||||
|
|
||||||
int numPoints_;
|
|
||||||
int counter_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // POINTPLOT_H
|
|
@ -1,199 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/graphics/qt/common/Spectrogramplot.cpp
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* A spectrogram plot which acts as a waterfall. New data is plotted
|
|
||||||
* at the top row of the spectrogram and all old data is shifted
|
|
||||||
* downwards.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <qprinter.h>
|
|
||||||
#include <qprintdialog.h>
|
|
||||||
#include <qwt_color_map.h>
|
|
||||||
#include <qwt_plot_canvas.h>
|
|
||||||
#include <qwt_plot_spectrogram.h>
|
|
||||||
#include <qwt_scale_widget.h>
|
|
||||||
#include <qwt_scale_draw.h>
|
|
||||||
#include <qwt_plot_layout.h>
|
|
||||||
#include <qwt_plot_renderer.h>
|
|
||||||
#include <qwt_matrix_raster_data.h>
|
|
||||||
#include "Spectrogramplot.h"
|
|
||||||
|
|
||||||
class MyZoomer: public QwtPlotZoomer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyZoomer(QwtPlotCanvas *canvas):
|
|
||||||
QwtPlotZoomer(canvas)
|
|
||||||
{
|
|
||||||
setTrackerMode(AlwaysOn);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QwtText trackerTextF(const QPointF &pos) const
|
|
||||||
{
|
|
||||||
QColor bg(Qt::white);
|
|
||||||
bg.setAlpha(200);
|
|
||||||
|
|
||||||
QwtText text = QwtPlotZoomer::trackerTextF(pos);
|
|
||||||
text.setBackgroundBrush( QBrush( bg ));
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//Set up a colormap to use the "jet" colormap from matlab
|
|
||||||
class ColorMap
|
|
||||||
:public QwtLinearColorMap
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ColorMap()
|
|
||||||
:QwtLinearColorMap(QColor(0,0,189), QColor(132,0,0))
|
|
||||||
{
|
|
||||||
double pos;
|
|
||||||
pos = 1.0/13.0*1.0; addColorStop(pos, QColor(0,0,255));
|
|
||||||
pos = 1.0/13.0*2.0; addColorStop(pos, QColor(0,66,255));
|
|
||||||
pos = 1.0/13.0*3.0; addColorStop(pos, QColor(0,132,255));
|
|
||||||
pos = 1.0/13.0*4.0; addColorStop(pos, QColor(0,189,255));
|
|
||||||
pos = 1.0/13.0*5.0; addColorStop(pos, QColor(0,255,255));
|
|
||||||
pos = 1.0/13.0*6.0; addColorStop(pos, QColor(66,255,189));
|
|
||||||
pos = 1.0/13.0*7.0; addColorStop(pos, QColor(132,255,132));
|
|
||||||
pos = 1.0/13.0*8.0; addColorStop(pos, QColor(189,255,66));
|
|
||||||
pos = 1.0/13.0*9.0; addColorStop(pos, QColor(255,255,0));
|
|
||||||
pos = 1.0/13.0*10.0; addColorStop(pos, QColor(255,189,0));
|
|
||||||
pos = 1.0/13.0*12.0; addColorStop(pos, QColor(255,66,0));
|
|
||||||
pos = 1.0/13.0*13.0; addColorStop(pos, QColor(189,0,0));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Spectrogramplot::Spectrogramplot(int numDataPoints, int numRows, QWidget *parent)
|
|
||||||
:QwtPlot(parent)
|
|
||||||
,nData_(numDataPoints)
|
|
||||||
,nRows_(numRows)
|
|
||||||
{
|
|
||||||
spectrogram_ = new QwtPlotSpectrogram();
|
|
||||||
spectrogram_->setRenderThreadCount(0); // set system specific thread count
|
|
||||||
data_ = new WaterfallData(nData_, nRows_);
|
|
||||||
spectrogram_->attach(this);
|
|
||||||
|
|
||||||
setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
|
|
||||||
setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
|
|
||||||
|
|
||||||
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true);
|
|
||||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating,true);
|
|
||||||
|
|
||||||
spectrogram_->setColorMap(new ColorMap());
|
|
||||||
spectrogram_->setData(data_);
|
|
||||||
|
|
||||||
setXAxisRange(0, nData_);
|
|
||||||
setYAxisRange(0, nRows_);
|
|
||||||
setZAxisScale(-1,1);
|
|
||||||
|
|
||||||
// LeftButton for the zooming
|
|
||||||
// MidButton for the panning
|
|
||||||
// RightButton: zoom out by 1
|
|
||||||
// Ctrl+RighButton: zoom out to full size
|
|
||||||
|
|
||||||
zoomer_ = new MyZoomer(qobject_cast<QwtPlotCanvas*>(canvas()));
|
|
||||||
zoomer_->setMousePattern(QwtEventPattern::MouseSelect1,
|
|
||||||
Qt::LeftButton);
|
|
||||||
zoomer_->setMousePattern(QwtEventPattern::MouseSelect2,
|
|
||||||
Qt::LeftButton, Qt::ControlModifier);
|
|
||||||
|
|
||||||
panner_ = new QwtPlotPanner(canvas());
|
|
||||||
panner_->setAxisEnabled(QwtPlot::yRight, false);
|
|
||||||
panner_->setMouseButton(Qt::RightButton);
|
|
||||||
|
|
||||||
magnifier_ = new QwtPlotMagnifier(canvas());
|
|
||||||
magnifier_->setMouseButton(Qt::NoButton);
|
|
||||||
|
|
||||||
// Avoid jumping when labels with more/less digits
|
|
||||||
// appear/disappear when scrolling vertically
|
|
||||||
|
|
||||||
const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
|
|
||||||
QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
|
|
||||||
sd->setMinimumExtent( fm.width("100.00") );
|
|
||||||
|
|
||||||
const QColor c(Qt::darkBlue);
|
|
||||||
zoomer_->setRubberBandPen(c);
|
|
||||||
zoomer_->setTrackerPen(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spectrogramplot::appendData(double* data, int n)
|
|
||||||
{
|
|
||||||
data_->appendData(data, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spectrogramplot::setXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
xMin_ = xMin;
|
|
||||||
xMax_ = xMax;
|
|
||||||
data_->setInterval( Qt::XAxis, QwtInterval( xMin_, xMax_ ) );
|
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
|
||||||
replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spectrogramplot::setYAxisRange(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
yMin_ = yMin;
|
|
||||||
yMax_ = yMax;
|
|
||||||
data_->setInterval( Qt::YAxis, QwtInterval( yMin_, yMax_ ) );
|
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
|
||||||
replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spectrogramplot::setZAxisScale(double zMin, double zMax)
|
|
||||||
{
|
|
||||||
zMin_ = zMin;
|
|
||||||
zMax_ = zMax;
|
|
||||||
data_->setInterval( Qt::ZAxis, QwtInterval( zMin_, zMax_ ) );
|
|
||||||
|
|
||||||
//Set up the intensity bar on the right
|
|
||||||
const QwtInterval zInterval = spectrogram_->data()->interval( Qt::ZAxis );
|
|
||||||
QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
|
|
||||||
rightAxis->setColorBarEnabled(true);
|
|
||||||
rightAxis->setColorMap( zInterval, new ColorMap());
|
|
||||||
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
|
|
||||||
enableAxis(QwtPlot::yRight);
|
|
||||||
|
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
|
||||||
replot();
|
|
||||||
}
|
|
||||||
|
|
||||||
double Spectrogramplot::min()
|
|
||||||
{
|
|
||||||
return data_->min();
|
|
||||||
}
|
|
||||||
|
|
||||||
double Spectrogramplot::max()
|
|
||||||
{
|
|
||||||
return data_->max();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spectrogramplot::autoscale()
|
|
||||||
{
|
|
||||||
setZAxisScale(min(),max());
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
#ifndef WATERFALLDATA_H
|
|
||||||
#define WATERFALLDATA_H
|
|
||||||
|
|
||||||
#include <qwt_raster_data.h>
|
|
||||||
#include <boost/circular_buffer.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cmath>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
class WaterfallData
|
|
||||||
:public QwtRasterData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef std::vector<double> Vec;
|
|
||||||
typedef boost::shared_ptr< std::vector<double> > VecPtr;
|
|
||||||
typedef boost::circular_buffer< VecPtr > VecPtrBuf;
|
|
||||||
typedef VecPtrBuf::iterator VecPtrBufIt;
|
|
||||||
|
|
||||||
WaterfallData(int numDataPoints, int numRows)
|
|
||||||
:QwtRasterData()
|
|
||||||
,nData_(numDataPoints)
|
|
||||||
,nRows_(numRows)
|
|
||||||
,data_(numRows)
|
|
||||||
{
|
|
||||||
for(int i=0;i<nRows_;i++)
|
|
||||||
{
|
|
||||||
data_.push_front(VecPtr(new std::vector<double>(nData_)));
|
|
||||||
data_[0]->assign(nData_, 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void appendData(double* data, int n)
|
|
||||||
{
|
|
||||||
assert(n == nData_);
|
|
||||||
|
|
||||||
VecPtr v = data_.front();
|
|
||||||
v->assign(data, data+n);
|
|
||||||
data_.push_back(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
double max()
|
|
||||||
{
|
|
||||||
Vec maxVec;
|
|
||||||
for(int i=0;i<nRows_;i++)
|
|
||||||
{
|
|
||||||
VecPtr v = data_[i];
|
|
||||||
maxVec.push_back(*(std::max_element(v->begin(),v->end())));
|
|
||||||
}
|
|
||||||
return *(std::max_element(maxVec.begin(),maxVec.end()));
|
|
||||||
}
|
|
||||||
|
|
||||||
double min()
|
|
||||||
{
|
|
||||||
Vec minVec;
|
|
||||||
for(int i=0;i<nRows_;i++)
|
|
||||||
{
|
|
||||||
VecPtr v = data_[i];
|
|
||||||
minVec.push_back(*(std::min_element(v->begin(),v->end())));
|
|
||||||
}
|
|
||||||
return *(std::min_element(minVec.begin(),minVec.end()));
|
|
||||||
}
|
|
||||||
|
|
||||||
double value(double x, double y) const
|
|
||||||
{
|
|
||||||
double bottom = interval(Qt::YAxis).minValue();
|
|
||||||
double top = interval(Qt::YAxis).maxValue();
|
|
||||||
double left = interval(Qt::XAxis).minValue();
|
|
||||||
double right = interval(Qt::XAxis).maxValue();
|
|
||||||
double xStep = std::abs(right-left)/nData_;
|
|
||||||
double yStep = std::abs(top-bottom)/nRows_;
|
|
||||||
|
|
||||||
int ix = (x-left) / xStep;
|
|
||||||
int iy = (y-bottom) / yStep;
|
|
||||||
if(ix >= nData_)
|
|
||||||
ix = nData_-1;
|
|
||||||
if(iy >= nRows_)
|
|
||||||
iy = nRows_-1;
|
|
||||||
double ret = (*data_[iy])[ix];
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
VecPtrBuf data_;
|
|
||||||
int nData_;
|
|
||||||
int nRows_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WATERFALLDATA_H
|
|
@ -1,66 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "liblte/graphics/plot.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
pthread_t thread;
|
|
||||||
static int plot_initiated=0;
|
|
||||||
|
|
||||||
void *qt_thread(void *arg)
|
|
||||||
{
|
|
||||||
int argc = 1;
|
|
||||||
char* argv[] = { const_cast<char *>("srsLTE Visualizer"), NULL };
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
app.exec();
|
|
||||||
pthread_exit(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int plot_init() {
|
|
||||||
if (!plot_initiated) {
|
|
||||||
/** FIXME: Set attributes to detachable */
|
|
||||||
if (pthread_create(&thread, NULL, qt_thread, NULL)) {
|
|
||||||
perror("phtread_create");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
usleep(100000);
|
|
||||||
plot_initiated=1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_exit() {
|
|
||||||
if (plot_initiated) {
|
|
||||||
pthread_cancel(thread);
|
|
||||||
}
|
|
||||||
plot_initiated=0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,195 +0,0 @@
|
|||||||
#include "ComplexWidget.h"
|
|
||||||
#include "Lineplot.h"
|
|
||||||
#include "Events.h"
|
|
||||||
|
|
||||||
#include <qlayout.h>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
ComplexWidget::ComplexWidget(QWidget *parent)
|
|
||||||
:QWidget(parent)
|
|
||||||
{
|
|
||||||
i_ = new Lineplot();
|
|
||||||
q_ = new Lineplot();
|
|
||||||
m_ = new Lineplot();
|
|
||||||
p_ = new Lineplot();
|
|
||||||
|
|
||||||
i_->setAxisTitle(QwtPlot::xBottom, "In-phase");
|
|
||||||
q_->setAxisTitle(QwtPlot::xBottom, "Quadrature");
|
|
||||||
m_->setAxisTitle(QwtPlot::xBottom, "Magnitude");
|
|
||||||
p_->setAxisTitle(QwtPlot::xBottom, "Phase");
|
|
||||||
|
|
||||||
QVBoxLayout* vLayout1 = new QVBoxLayout(this);
|
|
||||||
vLayout1->addWidget(i_);
|
|
||||||
vLayout1->addWidget(q_);
|
|
||||||
vLayout1->addWidget(m_);
|
|
||||||
vLayout1->addWidget(p_);
|
|
||||||
|
|
||||||
numPoints_ = 16;
|
|
||||||
iData_ = new double[numPoints_];
|
|
||||||
qData_ = new double[numPoints_];
|
|
||||||
mData_ = new double[numPoints_];
|
|
||||||
pData_ = new double[numPoints_];
|
|
||||||
timerId_ = startTimer(10);
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComplexWidget::~ComplexWidget()
|
|
||||||
{
|
|
||||||
delete i_;
|
|
||||||
delete q_;
|
|
||||||
delete m_;
|
|
||||||
delete p_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::customEvent( QEvent * e )
|
|
||||||
{
|
|
||||||
if(e->type() == ComplexDataEvent::type)
|
|
||||||
{
|
|
||||||
ComplexDataEvent* dataEvent = (ComplexDataEvent*)e;
|
|
||||||
setData(dataEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::timerEvent(QTimerEvent *event)
|
|
||||||
{
|
|
||||||
if(event->timerId() == timerId_)
|
|
||||||
{
|
|
||||||
if(haveNewData_)
|
|
||||||
{
|
|
||||||
i_->replot();
|
|
||||||
q_->replot();
|
|
||||||
m_->replot();
|
|
||||||
p_->replot();
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QWidget::timerEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::setData(ComplexDataEvent* e)
|
|
||||||
{
|
|
||||||
if(e->numPoints_ != numPoints_)
|
|
||||||
{
|
|
||||||
numPoints_ = e->numPoints_;
|
|
||||||
delete [] iData_;
|
|
||||||
delete [] qData_;
|
|
||||||
delete [] mData_;
|
|
||||||
delete [] pData_;
|
|
||||||
|
|
||||||
iData_ = new double[numPoints_];
|
|
||||||
qData_ = new double[numPoints_];
|
|
||||||
mData_ = new double[numPoints_];
|
|
||||||
pData_ = new double[numPoints_];
|
|
||||||
}
|
|
||||||
|
|
||||||
transform(e->dataPoints_, &e->dataPoints_[numPoints_], iData_, opReal());
|
|
||||||
transform(e->dataPoints_, &e->dataPoints_[numPoints_], qData_, opImag());
|
|
||||||
transform(e->dataPoints_, &e->dataPoints_[numPoints_], mData_, opAbs());
|
|
||||||
transform(e->dataPoints_, &e->dataPoints_[numPoints_], pData_, opArg());
|
|
||||||
|
|
||||||
i_->setData(iData_, numPoints_);
|
|
||||||
q_->setData(qData_, numPoints_);
|
|
||||||
m_->setData(mData_, numPoints_);
|
|
||||||
p_->setData(pData_, numPoints_);
|
|
||||||
haveNewData_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::setWidgetTitle(QString title)
|
|
||||||
{
|
|
||||||
setWindowTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::setWidgetXAxisScale(int id, double xMin, double xMax)
|
|
||||||
{
|
|
||||||
switch(id)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
i_->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
q_->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
m_->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
p_->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::setWidgetYAxisScale(int id, double yMin, double yMax)
|
|
||||||
{
|
|
||||||
switch(id)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
i_->setAxisScale(QwtPlot::yLeft, yMin, yMax);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
q_->setAxisScale(QwtPlot::yLeft, yMin, yMax);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
m_->setAxisScale(QwtPlot::yLeft, yMin, yMax);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
p_->setAxisScale(QwtPlot::yLeft, yMin, yMax);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::setWidgetXAxisAutoScale(int id, bool on=true)
|
|
||||||
{
|
|
||||||
switch(id)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
i_->setAxisAutoScale(QwtPlot::xBottom, on);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
q_->setAxisAutoScale(QwtPlot::xBottom, on);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
m_->setAxisAutoScale(QwtPlot::xBottom, on);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
p_->setAxisAutoScale(QwtPlot::xBottom, on);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::setWidgetYAxisAutoScale(int id, bool on=true)
|
|
||||||
{
|
|
||||||
switch(id)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
i_->setAxisAutoScale(QwtPlot::yLeft, on);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
q_->setAxisAutoScale(QwtPlot::yLeft, on);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
m_->setAxisAutoScale(QwtPlot::yLeft, on);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
p_->setAxisAutoScale(QwtPlot::yLeft, on);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexWidget::setWidgetXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
i_->setXAxisRange(xMin, xMax);
|
|
||||||
q_->setXAxisRange(xMin, xMax);
|
|
||||||
m_->setXAxisRange(xMin, xMax);
|
|
||||||
p_->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
#ifndef COMPLEXWIDGET_H
|
|
||||||
#define COMPLEXWIDGET_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qwidget.h>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class ComplexDataEvent;
|
|
||||||
class Lineplot;
|
|
||||||
|
|
||||||
class ComplexWidget
|
|
||||||
: public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ComplexWidget(QWidget* parent = 0);
|
|
||||||
virtual ~ComplexWidget();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void customEvent( QEvent * e );
|
|
||||||
void setWidgetTitle(QString title);
|
|
||||||
void setWidgetXAxisScale(int id, double xMin, double xMax);
|
|
||||||
void setWidgetYAxisScale(int id, double yMin, double yMax);
|
|
||||||
void setWidgetXAxisAutoScale(int id, bool on);
|
|
||||||
void setWidgetYAxisAutoScale(int id, bool on);
|
|
||||||
void setWidgetXAxisRange(double xMin, double xMax);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void timerEvent(QTimerEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setData(ComplexDataEvent* e);
|
|
||||||
Lineplot* i_; //In-phase plot
|
|
||||||
Lineplot* q_; //Quadrature plot
|
|
||||||
Lineplot* m_; //Magnitude plot
|
|
||||||
Lineplot* p_; //Phase plot
|
|
||||||
|
|
||||||
struct opReal{double operator()(std::complex<double> i) const{return real(i);}};
|
|
||||||
struct opImag{double operator()(std::complex<double> i) const{return imag(i);}};
|
|
||||||
struct opAbs{double operator()(std::complex<double> i) const{return abs(i);}};
|
|
||||||
struct opArg{double operator()(std::complex<double> i) const{return arg(i);}};
|
|
||||||
|
|
||||||
double* iData_;
|
|
||||||
double* qData_;
|
|
||||||
double* mData_;
|
|
||||||
double* pData_;
|
|
||||||
int numPoints_;
|
|
||||||
int timerId_;
|
|
||||||
bool haveNewData_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // COMPLEXWIDGET_H
|
|
@ -1,55 +0,0 @@
|
|||||||
#include "Complexplot.h"
|
|
||||||
#include "ComplexplotWrapper.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
Complexplot::Complexplot()
|
|
||||||
{
|
|
||||||
plot_ = new ComplexplotWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
Complexplot::~Complexplot()
|
|
||||||
{
|
|
||||||
delete plot_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setNewData(complex<double>* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->setNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setNewData(complex<float>* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->setNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
plot_->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setXAxisAutoScale(PlotId id, bool on=true)
|
|
||||||
{
|
|
||||||
plot_->setXAxisAutoScale(id, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setYAxisAutoScale(PlotId id, bool on=true)
|
|
||||||
{
|
|
||||||
plot_->setYAxisAutoScale(id, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setXAxisScale(PlotId id, double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setXAxisScale(id, xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setYAxisScale(PlotId id, double yMin, double yMax)
|
|
||||||
{
|
|
||||||
plot_->setYAxisScale(id, yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Complexplot::setXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
|||||||
#ifndef COMPLEXPLOT_H
|
|
||||||
#define COMPLEXPLOT_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class ComplexplotWrapper;
|
|
||||||
|
|
||||||
class Complexplot
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum PlotId
|
|
||||||
{
|
|
||||||
I,
|
|
||||||
Q,
|
|
||||||
Magnitude,
|
|
||||||
Phase
|
|
||||||
};
|
|
||||||
Complexplot();
|
|
||||||
~Complexplot();
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void setNewData(Iterator begin, Iterator end);
|
|
||||||
void setNewData(std::complex<float>* data, int numPoints);
|
|
||||||
void setNewData(std::complex<double>* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setXAxisAutoScale(PlotId id, bool on);
|
|
||||||
void setYAxisAutoScale(PlotId id, bool on);
|
|
||||||
void setXAxisScale(PlotId id, double xMin, double xMax);
|
|
||||||
void setYAxisScale(PlotId id, double yMin, double yMax);
|
|
||||||
void setXAxisRange(double xMin, double xMax);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ComplexplotWrapper* plot_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void Complexplot::setNewData(Iterator begin, Iterator end)
|
|
||||||
{
|
|
||||||
int numPoints = end-begin;
|
|
||||||
std::complex<double>* data = new std::complex<double>[numPoints];
|
|
||||||
|
|
||||||
for(int i=0;begin!=end;begin++,i++)
|
|
||||||
{
|
|
||||||
data[i] = *begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
setNewData(data, numPoints);
|
|
||||||
|
|
||||||
delete[] data;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // COMPLEXPLOT_H
|
|
@ -1,141 +0,0 @@
|
|||||||
#include "ComplexplotWrapper.h"
|
|
||||||
|
|
||||||
#include "ComplexWidget.h"
|
|
||||||
#include "Events.h"
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
ComplexplotWrapper::ComplexplotWrapper()
|
|
||||||
:widget_(NULL)
|
|
||||||
,destroyed_(true)
|
|
||||||
{
|
|
||||||
if(QCoreApplication::instance() == NULL)
|
|
||||||
return; //TODO: throw exception here in Iris
|
|
||||||
if(QCoreApplication::instance()->thread() == QThread::currentThread())
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL( createWidgetSignal() ),
|
|
||||||
this, SLOT(createWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignal() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL( createWidgetSignal() ),
|
|
||||||
this, SLOT(createWidgetSlot()),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignal() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
moveToThread(QCoreApplication::instance()->thread());
|
|
||||||
}
|
|
||||||
emit createWidgetSignal();
|
|
||||||
}
|
|
||||||
|
|
||||||
ComplexplotWrapper::~ComplexplotWrapper()
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
emit destroyWidgetSignal();
|
|
||||||
else
|
|
||||||
emit destroyWidgetSignalBlocking();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::createWidgetSlot()
|
|
||||||
{
|
|
||||||
widget_ = new ComplexWidget;
|
|
||||||
destroyed_ = false;
|
|
||||||
widget_->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
connect(widget_, SIGNAL( destroyed() ),
|
|
||||||
this, SLOT( widgetDestroyed() ));
|
|
||||||
connect(this, SIGNAL(setWidgetTitle(QString)),
|
|
||||||
widget_, SLOT(setWidgetTitle(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisScale(int,double,double)),
|
|
||||||
widget_, SLOT(setWidgetXAxisScale(int,double,double)));
|
|
||||||
connect(this, SIGNAL(setWidgetYAxisScale(int,double,double)),
|
|
||||||
widget_, SLOT(setWidgetYAxisScale(int,double,double)));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisAutoScale(int,bool)),
|
|
||||||
widget_, SLOT(setWidgetXAxisAutoScale(int,bool)));
|
|
||||||
connect(this, SIGNAL(setWidgetYAxisAutoScale(int,bool)),
|
|
||||||
widget_, SLOT(setWidgetYAxisAutoScale(int,bool)));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisRange(double,double)),
|
|
||||||
widget_, SLOT(setWidgetXAxisRange(double,double)));
|
|
||||||
|
|
||||||
widget_->resize( 800, 600 );
|
|
||||||
widget_->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::destroyWidgetSlot()
|
|
||||||
{
|
|
||||||
if(widget_)
|
|
||||||
delete widget_;
|
|
||||||
widget_ = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::widgetDestroyed()
|
|
||||||
{
|
|
||||||
destroyed_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setNewData(complex<double>* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new ComplexDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setNewData(complex<float>* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new ComplexDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(title.c_str());
|
|
||||||
emit setWidgetTitle(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setXAxisAutoScale(int id, bool on=true)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisAutoScale(id, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setYAxisAutoScale(int id, bool on=true)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetYAxisAutoScale(id, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setXAxisScale(int id, double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisScale(id, xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setYAxisScale(int id, double yMin, double yMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetYAxisScale(id, yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComplexplotWrapper::setXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
#ifndef COMPLEXPLOTWRAPPER_H
|
|
||||||
#define COMPLEXPLOTWRAPPER_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class ComplexWidget;
|
|
||||||
|
|
||||||
class ComplexplotWrapper
|
|
||||||
: QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ComplexplotWrapper();
|
|
||||||
~ComplexplotWrapper();
|
|
||||||
|
|
||||||
void setNewData(std::complex<float>* data, int numPoints);
|
|
||||||
void setNewData(std::complex<double>* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setXAxisAutoScale(int id, bool on);
|
|
||||||
void setYAxisAutoScale(int id, bool on);
|
|
||||||
void setXAxisScale(int id, double xMin, double xMax);
|
|
||||||
void setYAxisScale(int id, double yMin, double yMax);
|
|
||||||
void setXAxisRange(double xMin, double xMax);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void createWidgetSlot();
|
|
||||||
void destroyWidgetSlot();
|
|
||||||
void widgetDestroyed();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void createWidgetSignal();
|
|
||||||
void destroyWidgetSignal();
|
|
||||||
void destroyWidgetSignalBlocking();
|
|
||||||
void setWidgetTitle(QString title);
|
|
||||||
void setWidgetXAxisAutoScale(int id, bool on);
|
|
||||||
void setWidgetYAxisAutoScale(int id, bool on);
|
|
||||||
void setWidgetXAxisScale(int id, double xMin, double xMax);
|
|
||||||
void setWidgetYAxisScale(int id, double yMin, double yMax);
|
|
||||||
void setWidgetXAxisRange(double xMin, double xMax);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ComplexWidget* widget_;
|
|
||||||
bool destroyed_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // COMPLEXPLOTWRAPPER_H
|
|
@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "liblte/graphics/plot/plot_complex.h"
|
|
||||||
#include "Complexplot.h"
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
|
|
||||||
int plot_complex_init(plot_complex_t *h) {
|
|
||||||
*h = (void*) new Complexplot();
|
|
||||||
return (*h != NULL)?0:-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setTitle(plot_complex_t *h, char *title) {
|
|
||||||
Complexplot *plot = static_cast<Complexplot*>(*h);
|
|
||||||
plot->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setNewData(plot_complex_t *h, _Complex float *data,
|
|
||||||
int num_points) {
|
|
||||||
Complexplot *plot = static_cast<Complexplot*>(*h);
|
|
||||||
plot->setNewData(reinterpret_cast<std::complex<float>*> (data), num_points);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void plot_complex_setXAxisAutoScale(plot_complex_t *h, plot_complex_id_t id, bool on) {
|
|
||||||
Complexplot *plot = static_cast<Complexplot*>(*h);
|
|
||||||
plot->setXAxisAutoScale(static_cast<Complexplot::PlotId> (id), on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setYAxisAutoScale(plot_complex_t *h, plot_complex_id_t id, bool on) {
|
|
||||||
Complexplot *plot = static_cast<Complexplot*>(*h);
|
|
||||||
plot->setYAxisAutoScale(static_cast<Complexplot::PlotId> (id), on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setXAxisScale(plot_complex_t *h, plot_complex_id_t id, double xMin, double xMax) {
|
|
||||||
Complexplot *plot = static_cast<Complexplot*>(*h);
|
|
||||||
plot->setXAxisScale(static_cast<Complexplot::PlotId> (id), xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setYAxisScale(plot_complex_t *h, plot_complex_id_t id, double yMin, double yMax) {
|
|
||||||
Complexplot *plot = static_cast<Complexplot*>(*h);
|
|
||||||
plot->setYAxisScale(static_cast<Complexplot::PlotId> (id), yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setXAxisRange(plot_complex_t *h, double xMin, double xMax) {
|
|
||||||
Complexplot *plot = static_cast<Complexplot*>(*h);
|
|
||||||
plot->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
# COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
# and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
#
|
|
||||||
# This file is part of the Iris Project.
|
|
||||||
#
|
|
||||||
# Iris is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Lesser General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of
|
|
||||||
# the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Iris is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# A copy of the GNU Lesser General Public License can be found in
|
|
||||||
# the LICENSE file in the top-level directory of this distribution
|
|
||||||
# and at http://www.gnu.org/licenses/.
|
|
||||||
#
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Build tests
|
|
||||||
########################################################################
|
|
||||||
#turn the test cpp file into an executable with an int main() function
|
|
||||||
INCLUDE_DIRECTORIES(..)
|
|
||||||
ADD_EXECUTABLE(complexplot_test complexplot_test.cpp)
|
|
||||||
TARGET_LINK_LIBRARIES(complexplot_test pthread graphics)
|
|
||||||
ADD_TEST(complexplot_test complexplot_test)
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/modulation/Crc_test.cpp
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Main test file for Complexplot class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Complexplot.h"
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <complex>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#define PI 3.14159265358979323846
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
typedef vector<complex<float> > FloatVec;
|
|
||||||
|
|
||||||
void *threadMain1(void *arg) {
|
|
||||||
Complexplot plot;
|
|
||||||
plot.setTitle("Float");
|
|
||||||
plot.setXAxisRange(0, 2);
|
|
||||||
plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1);
|
|
||||||
|
|
||||||
int n = 1024;
|
|
||||||
float step = 2.0 * PI / n;
|
|
||||||
complex<float>* data = new complex<float> [n];
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
data[i] = polar(1.0f, step * i);
|
|
||||||
|
|
||||||
plot.setNewData(data, n);
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
rotate(data, data + 1, data + n);
|
|
||||||
plot.setNewData(data, n);
|
|
||||||
usleep(1000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain2(void *arg) {
|
|
||||||
Complexplot plot;
|
|
||||||
plot.setTitle("Double");
|
|
||||||
plot.setXAxisRange(0, 2);
|
|
||||||
plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1);
|
|
||||||
|
|
||||||
int n = 1024;
|
|
||||||
double step = 2.0 * PI / n;
|
|
||||||
complex<double>* data = new complex<double> [n];
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
data[i] = polar(1.0, step * i);
|
|
||||||
|
|
||||||
plot.setNewData(data, n);
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
rotate(data, data + 1, data + n);
|
|
||||||
plot.setNewData(data, n);
|
|
||||||
usleep(1000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain3(void *arg) {
|
|
||||||
|
|
||||||
Complexplot plot;
|
|
||||||
plot.setTitle("FloatVec");
|
|
||||||
plot.setXAxisRange(0, 2);
|
|
||||||
plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1);
|
|
||||||
|
|
||||||
FloatVec data(1024);
|
|
||||||
int n = data.size();
|
|
||||||
float step = 2.0 * PI / n;
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
data[i] = polar(1.0f, step * i);
|
|
||||||
|
|
||||||
plot.setNewData(data.begin(), data.end());
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
rotate(data.begin(), data.begin() + 1, data.end());
|
|
||||||
plot.setNewData(data.begin(), data.end());
|
|
||||||
usleep(1000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
int argc2 = 1;
|
|
||||||
char* argv2[] = { const_cast<char *>("Compleplot_Basic_Test"), NULL };
|
|
||||||
QApplication a(argc2, argv2);
|
|
||||||
pthread_t threads[3];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
qApp->exec();
|
|
||||||
|
|
||||||
for (i=0;i<3;i++) {
|
|
||||||
pthread_join(threads[i], NULL);
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
|||||||
#include "RealWidget.h"
|
|
||||||
#include "Lineplot.h"
|
|
||||||
#include "Events.h"
|
|
||||||
|
|
||||||
#include <qlayout.h>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
RealWidget::RealWidget(QWidget *parent)
|
|
||||||
:QWidget(parent)
|
|
||||||
{
|
|
||||||
l_ = new Lineplot();
|
|
||||||
QVBoxLayout* vLayout1 = new QVBoxLayout(this);
|
|
||||||
vLayout1->addWidget(l_);
|
|
||||||
|
|
||||||
numPoints_ = 16;
|
|
||||||
dataPoints_ = new double[numPoints_];
|
|
||||||
timerId_ = startTimer(10);
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RealWidget::~RealWidget()
|
|
||||||
{
|
|
||||||
delete l_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::customEvent( QEvent * e )
|
|
||||||
{
|
|
||||||
if(e->type() == RealDataEvent::type)
|
|
||||||
{
|
|
||||||
RealDataEvent* dataEvent = (RealDataEvent*)e;
|
|
||||||
setData(dataEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::timerEvent(QTimerEvent *event)
|
|
||||||
{
|
|
||||||
if(event->timerId() == timerId_)
|
|
||||||
{
|
|
||||||
if(haveNewData_)
|
|
||||||
{
|
|
||||||
l_->replot();
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QWidget::timerEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setData(RealDataEvent* e)
|
|
||||||
{
|
|
||||||
if(e->numPoints_ != numPoints_)
|
|
||||||
{
|
|
||||||
numPoints_ = e->numPoints_;
|
|
||||||
delete [] dataPoints_;
|
|
||||||
dataPoints_ = new double[numPoints_];
|
|
||||||
}
|
|
||||||
for(int i=0;i<numPoints_;i++)
|
|
||||||
dataPoints_[i] = e->dataPoints_[i];
|
|
||||||
|
|
||||||
l_->setData(dataPoints_, numPoints_);
|
|
||||||
haveNewData_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setWidgetTitle(QString title)
|
|
||||||
{
|
|
||||||
l_->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setWidgetAxisLabels(QString xLabel, QString yLabel)
|
|
||||||
{
|
|
||||||
l_->setAxisTitle(QwtPlot::xBottom, xLabel);
|
|
||||||
l_->setAxisTitle(QwtPlot::yLeft, yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setWidgetXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
l_->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setWidgetYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
l_->setAxisScale(QwtPlot::yLeft, yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setWidgetXAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
l_->setAxisAutoScale(QwtPlot::xBottom, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setWidgetYAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
l_->setAxisAutoScale(QwtPlot::yLeft, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealWidget::setWidgetXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
l_->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
#ifndef REALWIDGET_H
|
|
||||||
#define REALWIDGET_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qwidget.h>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class RealDataEvent;
|
|
||||||
class Lineplot;
|
|
||||||
|
|
||||||
class RealWidget
|
|
||||||
: public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
RealWidget(QWidget* parent = 0);
|
|
||||||
virtual ~RealWidget();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void customEvent( QEvent * e );
|
|
||||||
void setWidgetTitle(QString title);
|
|
||||||
void setWidgetAxisLabels(QString xLabel, QString yLabel);
|
|
||||||
void setWidgetXAxisScale(double xMin, double xMax);
|
|
||||||
void setWidgetYAxisScale(double yMin, double yMax);
|
|
||||||
void setWidgetXAxisAutoScale(bool on);
|
|
||||||
void setWidgetYAxisAutoScale(bool on);
|
|
||||||
void setWidgetXAxisRange(double xMin, double xMax);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void timerEvent(QTimerEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setData(RealDataEvent* e);
|
|
||||||
Lineplot* l_; //The line plot
|
|
||||||
|
|
||||||
double* dataPoints_;
|
|
||||||
int numPoints_;
|
|
||||||
int timerId_;
|
|
||||||
bool haveNewData_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // REALWIDGET_H
|
|
@ -1,58 +0,0 @@
|
|||||||
#include "Realplot.h"
|
|
||||||
#include "RealplotWrapper.h"
|
|
||||||
|
|
||||||
Realplot::Realplot()
|
|
||||||
{
|
|
||||||
plot_ = new RealplotWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
Realplot::~Realplot()
|
|
||||||
{
|
|
||||||
delete plot_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setNewData(double* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->setNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setNewData(float* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->setNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
plot_->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
plot_->setYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setXAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
plot_->setXAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setYAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
plot_->setYAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Realplot::setLabels(std::string xLabel, std::string yLabel)
|
|
||||||
{
|
|
||||||
plot_->setAxisLabels(xLabel, yLabel);
|
|
||||||
}
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
|||||||
#ifndef REALPLOT_H
|
|
||||||
#define REALPLOT_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class RealplotWrapper;
|
|
||||||
|
|
||||||
class Realplot
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Realplot();
|
|
||||||
~Realplot();
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void setNewData(Iterator begin, Iterator end);
|
|
||||||
void setNewData(float* data, int numPoints);
|
|
||||||
void setNewData(double* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setXAxisScale(double xMin, double xMax);
|
|
||||||
void setYAxisScale(double yMin, double yMax);
|
|
||||||
void setXAxisAutoScale(bool on);
|
|
||||||
void setYAxisAutoScale(bool on);
|
|
||||||
void setXAxisRange(double xMin, double xMax);
|
|
||||||
void setLabels(std::string xLabel, std::string yLabel);
|
|
||||||
|
|
||||||
private:
|
|
||||||
RealplotWrapper* plot_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void Realplot::setNewData(Iterator begin, Iterator end)
|
|
||||||
{
|
|
||||||
int numPoints = end-begin;
|
|
||||||
double* data = new double[numPoints];
|
|
||||||
|
|
||||||
for(int i=0;begin!=end;begin++,i++)
|
|
||||||
{
|
|
||||||
data[i] = *begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
setNewData(data, numPoints);
|
|
||||||
|
|
||||||
delete[] data;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // REALPLOT_H
|
|
@ -1,147 +0,0 @@
|
|||||||
#include "RealplotWrapper.h"
|
|
||||||
|
|
||||||
#include "RealWidget.h"
|
|
||||||
#include "Events.h"
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
|
|
||||||
RealplotWrapper::RealplotWrapper()
|
|
||||||
:widget_(NULL)
|
|
||||||
,destroyed_(true)
|
|
||||||
{
|
|
||||||
if(QCoreApplication::instance() == NULL)
|
|
||||||
return; //TODO: throw exception here in Iris
|
|
||||||
if(QCoreApplication::instance()->thread() == QThread::currentThread())
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL( createWidgetSignal() ),
|
|
||||||
this, SLOT(createWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignal() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL( createWidgetSignal() ),
|
|
||||||
this, SLOT(createWidgetSlot()),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignal() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
moveToThread(QCoreApplication::instance()->thread());
|
|
||||||
}
|
|
||||||
emit createWidgetSignal();
|
|
||||||
}
|
|
||||||
|
|
||||||
RealplotWrapper::~RealplotWrapper()
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
emit destroyWidgetSignal();
|
|
||||||
else
|
|
||||||
emit destroyWidgetSignalBlocking();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::createWidgetSlot()
|
|
||||||
{
|
|
||||||
widget_ = new RealWidget;
|
|
||||||
destroyed_ = false;
|
|
||||||
widget_->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
connect(widget_, SIGNAL( destroyed() ),
|
|
||||||
this, SLOT( widgetDestroyed() ));
|
|
||||||
connect(this, SIGNAL(setWidgetTitle(QString)),
|
|
||||||
widget_, SLOT(setWidgetTitle(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetAxisLabels(QString, QString)),
|
|
||||||
widget_, SLOT(setWidgetAxisLabels(QString, QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisScale(double,double)),
|
|
||||||
widget_, SLOT(setWidgetXAxisScale(double,double)));
|
|
||||||
connect(this, SIGNAL(setWidgetYAxisScale(double,double)),
|
|
||||||
widget_, SLOT(setWidgetYAxisScale(double,double)));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisAutoScale(bool)),
|
|
||||||
widget_, SLOT(setWidgetXAxisAutoScale(bool)));
|
|
||||||
connect(this, SIGNAL(setWidgetYAxisAutoScale(bool)),
|
|
||||||
widget_, SLOT(setWidgetYAxisAutoScale(bool)));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisRange(double,double)),
|
|
||||||
widget_, SLOT(setWidgetXAxisRange(double,double)));
|
|
||||||
|
|
||||||
widget_->resize( 800, 600 );
|
|
||||||
widget_->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::destroyWidgetSlot()
|
|
||||||
{
|
|
||||||
delete widget_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::widgetDestroyed()
|
|
||||||
{
|
|
||||||
destroyed_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setNewData(double* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new RealDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setNewData(float* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new RealDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(title.c_str());
|
|
||||||
emit setWidgetTitle(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setAxisLabels(std::string xLabel, std::string yLabel)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString xStr = QString::fromUtf8(xLabel.c_str());
|
|
||||||
QString yStr = QString::fromUtf8(yLabel.c_str());
|
|
||||||
emit setWidgetAxisLabels(xStr, yStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setXAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setYAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetYAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RealplotWrapper::setXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
#ifndef REALPLOTWRAPPER_H
|
|
||||||
#define REALPLOTWRAPPER_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
|
|
||||||
class RealWidget;
|
|
||||||
|
|
||||||
class RealplotWrapper
|
|
||||||
: QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
RealplotWrapper();
|
|
||||||
~RealplotWrapper();
|
|
||||||
|
|
||||||
void setNewData(float* data, int numPoints);
|
|
||||||
void setNewData(double* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setAxisLabels(std::string xLabel, std::string yLabel);
|
|
||||||
void setXAxisScale(double xMin, double xMax);
|
|
||||||
void setYAxisScale(double yMin, double yMax);
|
|
||||||
void setXAxisAutoScale(bool on);
|
|
||||||
void setYAxisAutoScale(bool on);
|
|
||||||
void setXAxisRange(double xMin, double xMax);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void createWidgetSlot();
|
|
||||||
void destroyWidgetSlot();
|
|
||||||
void widgetDestroyed();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void createWidgetSignal();
|
|
||||||
void destroyWidgetSignal();
|
|
||||||
void destroyWidgetSignalBlocking();
|
|
||||||
void setWidgetTitle(QString title);
|
|
||||||
void setWidgetAxisLabels(QString xLabel, QString yLabel);
|
|
||||||
void setWidgetXAxisScale(double xMin, double xMax);
|
|
||||||
void setWidgetYAxisScale(double yMin, double yMax);
|
|
||||||
void setWidgetXAxisAutoScale(bool on);
|
|
||||||
void setWidgetYAxisAutoScale(bool on);
|
|
||||||
void setWidgetXAxisRange(double xMin, double xMax);
|
|
||||||
|
|
||||||
private:
|
|
||||||
RealWidget* widget_;
|
|
||||||
bool destroyed_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // REALPLOTWRAPPER_H
|
|
@ -1,79 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "liblte/graphics/plot/plot_real.h"
|
|
||||||
#include "Realplot.h"
|
|
||||||
#include <complex.h>
|
|
||||||
|
|
||||||
|
|
||||||
int plot_real_init(plot_real_t *h) {
|
|
||||||
*h = (void*) new Realplot();
|
|
||||||
return (*h != NULL)?0:-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_real_setTitle(plot_real_t *h, char *title) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setTitle(title);
|
|
||||||
}
|
|
||||||
void plot_real_setNewData(plot_real_t *h, float *data,
|
|
||||||
int num_points) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setNewData(data, num_points);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_real_setXAxisAutoScale(plot_real_t *h, bool on) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setXAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_real_setYAxisAutoScale(plot_real_t *h, bool on) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setYAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_real_setXAxisScale(plot_real_t *h, double xMin, double xMax) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_real_setYAxisScale(plot_real_t *h, double yMin, double yMax) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_real_setXAxisRange(plot_real_t *h, double xMin, double xMax) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_real_setLabels(plot_real_t *h, char *xLabel, char *yLabel) {
|
|
||||||
Realplot *plot = static_cast<Realplot*>(*h);
|
|
||||||
plot->setLabels(xLabel, yLabel);
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
# COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
# and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
#
|
|
||||||
# This file is part of the Iris Project.
|
|
||||||
#
|
|
||||||
# Iris is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Lesser General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of
|
|
||||||
# the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Iris is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# A copy of the GNU Lesser General Public License can be found in
|
|
||||||
# the LICENSE file in the top-level directory of this distribution
|
|
||||||
# and at http://www.gnu.org/licenses/.
|
|
||||||
#
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Build tests
|
|
||||||
########################################################################
|
|
||||||
#turn the test cpp file into an executable with an int main() function
|
|
||||||
INCLUDE_DIRECTORIES(..)
|
|
||||||
ADD_EXECUTABLE(realplot_test realplot_test.cpp)
|
|
||||||
TARGET_LINK_LIBRARIES(realplot_test pthread graphics)
|
|
||||||
ADD_TEST(realplot_test realplot_test)
|
|
||||||
|
|
@ -1,123 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/modulation/Crc_test.cpp
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Main test file for Realplot class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Realplot.h"
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <complex>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
typedef std::vector<float> FloatVec;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void getPoints(T* data, int numPoints) {
|
|
||||||
for (int i = 0; i < numPoints; i++) {
|
|
||||||
data[i] = 10 * ((T) rand() / RAND_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void getPoints(Iterator begin, Iterator end) {
|
|
||||||
for (; begin != end; begin++) {
|
|
||||||
*begin = 10 * ((double) rand() / RAND_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain1(void *arg) {
|
|
||||||
Realplot plot;
|
|
||||||
|
|
||||||
float data[1024];
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
getPoints(data, 504);
|
|
||||||
plot.setNewData(data, 504);
|
|
||||||
usleep(5000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain2(void *arg) {
|
|
||||||
Realplot plot;
|
|
||||||
double data[1024];
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
getPoints(data, 504);
|
|
||||||
plot.setNewData(data, 504);
|
|
||||||
usleep(5000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain3(void *arg) {
|
|
||||||
Realplot plot;
|
|
||||||
FloatVec v(1024);
|
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
getPoints(v.begin(), v.end());
|
|
||||||
plot.setNewData(v.begin(), v.end());
|
|
||||||
usleep(5000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
int argc2 = 1;
|
|
||||||
char* argv2[] = { const_cast<char *>("Realplot_Basic_Test"), NULL };
|
|
||||||
QApplication a(argc2, argv2);
|
|
||||||
pthread_t threads[3];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
qApp->exec();
|
|
||||||
|
|
||||||
for (i=0;i<3;i++) {
|
|
||||||
pthread_join(threads[i], NULL);
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
#include "ScatterWidget.h"
|
|
||||||
#include "Pointplot.h"
|
|
||||||
#include "Events.h"
|
|
||||||
|
|
||||||
#include <qlayout.h>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
ScatterWidget::ScatterWidget(QWidget *parent)
|
|
||||||
:QWidget(parent)
|
|
||||||
{
|
|
||||||
plot_ = new Pointplot();
|
|
||||||
QVBoxLayout* vLayout1 = new QVBoxLayout(this);
|
|
||||||
vLayout1->addWidget(plot_);
|
|
||||||
|
|
||||||
numPoints_ = 16;
|
|
||||||
iData_ = new double[numPoints_];
|
|
||||||
qData_ = new double[numPoints_];
|
|
||||||
timerId_ = startTimer(10);
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScatterWidget::~ScatterWidget()
|
|
||||||
{
|
|
||||||
delete iData_;
|
|
||||||
delete qData_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::customEvent( QEvent * e )
|
|
||||||
{
|
|
||||||
if(e->type() == ComplexDataEvent::type)
|
|
||||||
{
|
|
||||||
ComplexDataEvent* dataEvent = (ComplexDataEvent*)e;
|
|
||||||
setData(dataEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::timerEvent(QTimerEvent *event)
|
|
||||||
{
|
|
||||||
if(event->timerId() == timerId_)
|
|
||||||
{
|
|
||||||
if(haveNewData_)
|
|
||||||
{
|
|
||||||
plot_->replot();
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QWidget::timerEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::setData(ComplexDataEvent* e)
|
|
||||||
{
|
|
||||||
if(e->numPoints_ != numPoints_)
|
|
||||||
{
|
|
||||||
numPoints_ = e->numPoints_;
|
|
||||||
delete [] iData_;
|
|
||||||
delete [] qData_;
|
|
||||||
iData_ = new double[numPoints_];
|
|
||||||
qData_ = new double[numPoints_];
|
|
||||||
}
|
|
||||||
|
|
||||||
transform(e->dataPoints_, &e->dataPoints_[numPoints_], iData_, opReal());
|
|
||||||
transform(e->dataPoints_, &e->dataPoints_[numPoints_], qData_, opImag());
|
|
||||||
|
|
||||||
plot_->setData(iData_, qData_, numPoints_);
|
|
||||||
haveNewData_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::setWidgetTitle(QString title)
|
|
||||||
{
|
|
||||||
plot_->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::setWidgetAxisLabels(QString xLabel, QString yLabel)
|
|
||||||
{
|
|
||||||
plot_->setAxisTitle(QwtPlot::xBottom, xLabel);
|
|
||||||
plot_->setAxisTitle(QwtPlot::yLeft, yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::setWidgetXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::setWidgetYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
plot_->setAxisScale(QwtPlot::yLeft, yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::setWidgetXAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
plot_->setAxisAutoScale(QwtPlot::xBottom, on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterWidget::setWidgetYAxisAutoScale(bool on)
|
|
||||||
{
|
|
||||||
plot_->setAxisAutoScale(QwtPlot::yLeft, on);
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
#ifndef SCATTERWIDGET_H
|
|
||||||
#define SCATTERWIDGET_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qwidget.h>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class ComplexDataEvent;
|
|
||||||
class Pointplot;
|
|
||||||
|
|
||||||
class ScatterWidget
|
|
||||||
: public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ScatterWidget(QWidget* parent = 0);
|
|
||||||
virtual ~ScatterWidget();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void customEvent( QEvent * e );
|
|
||||||
void setWidgetTitle(QString title);
|
|
||||||
void setWidgetAxisLabels(QString xLabel, QString yLabel);
|
|
||||||
void setWidgetXAxisScale(double xMin, double xMax);
|
|
||||||
void setWidgetYAxisScale(double yMin, double yMax);
|
|
||||||
void setWidgetXAxisAutoScale(bool on);
|
|
||||||
void setWidgetYAxisAutoScale(bool on);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void timerEvent(QTimerEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setData(ComplexDataEvent* e);
|
|
||||||
Pointplot* plot_;
|
|
||||||
|
|
||||||
struct opReal{double operator()(std::complex<double> i) const{return real(i);}};
|
|
||||||
struct opImag{double operator()(std::complex<double> i) const{return imag(i);}};
|
|
||||||
|
|
||||||
double* iData_;
|
|
||||||
double* qData_;
|
|
||||||
int numPoints_;
|
|
||||||
int timerId_;
|
|
||||||
bool haveNewData_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SCATTERWIDGET_H
|
|
@ -1,53 +0,0 @@
|
|||||||
#include "Scatterplot.h"
|
|
||||||
#include "ScatterplotWrapper.h"
|
|
||||||
|
|
||||||
Scatterplot::Scatterplot()
|
|
||||||
{
|
|
||||||
plot_ = new ScatterplotWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
Scatterplot::~Scatterplot()
|
|
||||||
{
|
|
||||||
delete plot_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setNewData(std::complex<float>* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->setNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setNewData(std::complex<double>* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->setNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
plot_->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
plot_->setYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setXAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
plot_->setXAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setYAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
plot_->setYAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scatterplot::setAxisLabels(std::string xLabel, std::string yLabel)
|
|
||||||
{
|
|
||||||
plot_->setAxisLabels(xLabel, yLabel);
|
|
||||||
}
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
|||||||
#ifndef SCATTERPLOT_H
|
|
||||||
#define SCATTERPLOT_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <complex>
|
|
||||||
#include "srslte/config.h"
|
|
||||||
|
|
||||||
class ScatterplotWrapper;
|
|
||||||
|
|
||||||
class Scatterplot
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Scatterplot();
|
|
||||||
~Scatterplot();
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void setNewData(Iterator begin, Iterator end);
|
|
||||||
void setNewData(std::complex<float>* data, int numPoints);
|
|
||||||
void setNewData(std::complex<double>* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setXAxisScale(double xMin, double xMax);
|
|
||||||
void setYAxisScale(double yMin, double yMax);
|
|
||||||
void setXAxisAutoScale(bool on);
|
|
||||||
void setYAxisAutoScale(bool on);
|
|
||||||
void setAxisLabels(std::string xLabel, std::string yLabel);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ScatterplotWrapper* plot_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Iterator> void Scatterplot::setNewData(Iterator begin, Iterator end)
|
|
||||||
{
|
|
||||||
int numPoints = end-begin;
|
|
||||||
std::complex<double>* data = new std::complex<double>[numPoints];
|
|
||||||
|
|
||||||
for(int i=0;begin!=end;begin++,i++)
|
|
||||||
{
|
|
||||||
data[i] = *begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
setNewData(data, numPoints);
|
|
||||||
|
|
||||||
delete[] data;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SCATTERPLOT_H
|
|
@ -1,142 +0,0 @@
|
|||||||
#include "ScatterplotWrapper.h"
|
|
||||||
|
|
||||||
#include "ScatterWidget.h"
|
|
||||||
#include "Events.h"
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <QThread>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
ScatterplotWrapper::ScatterplotWrapper()
|
|
||||||
:widget_(NULL)
|
|
||||||
,destroyed_(true)
|
|
||||||
{
|
|
||||||
if(QCoreApplication::instance() == NULL)
|
|
||||||
return; //TODO: throw exception here in Iris
|
|
||||||
if(QCoreApplication::instance()->thread() == QThread::currentThread())
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL(createWidgetSignal()),
|
|
||||||
this, SLOT(createWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL(destroyWidgetSignal()),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL(createWidgetSignal()),
|
|
||||||
this, SLOT(createWidgetSlot()),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
connect( this, SIGNAL(destroyWidgetSignal()),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
moveToThread(QCoreApplication::instance()->thread());
|
|
||||||
}
|
|
||||||
emit createWidgetSignal();
|
|
||||||
}
|
|
||||||
|
|
||||||
ScatterplotWrapper::~ScatterplotWrapper()
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
emit destroyWidgetSignal();
|
|
||||||
else
|
|
||||||
emit destroyWidgetSignalBlocking();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::createWidgetSlot()
|
|
||||||
{
|
|
||||||
widget_ = new ScatterWidget;
|
|
||||||
destroyed_ = false;
|
|
||||||
widget_->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
connect(widget_, SIGNAL( destroyed() ),
|
|
||||||
this, SLOT( widgetDestroyed() ));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisScale(double,double)),
|
|
||||||
widget_, SLOT(setWidgetXAxisScale(double,double)));
|
|
||||||
connect(this, SIGNAL(setWidgetYAxisScale(double,double)),
|
|
||||||
widget_, SLOT(setWidgetYAxisScale(double,double)));
|
|
||||||
connect(this, SIGNAL(setWidgetXAxisAutoScale(bool)),
|
|
||||||
widget_, SLOT(setWidgetXAxisAutoScale(bool)));
|
|
||||||
connect(this, SIGNAL(setWidgetYAxisAutoScale(bool)),
|
|
||||||
widget_, SLOT(setWidgetYAxisAutoScale(bool)));
|
|
||||||
connect(this, SIGNAL(setWidgetTitle(QString)),
|
|
||||||
widget_, SLOT(setWidgetTitle(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetAxisLabels(QString, QString)),
|
|
||||||
widget_, SLOT(setWidgetAxisLabels(QString, QString)));
|
|
||||||
|
|
||||||
widget_->resize( 800, 600 );
|
|
||||||
widget_->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::destroyWidgetSlot()
|
|
||||||
{
|
|
||||||
delete widget_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::widgetDestroyed()
|
|
||||||
{
|
|
||||||
destroyed_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setNewData(complex<double>* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new ComplexDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setNewData(complex<float>* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new ComplexDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(title.c_str());
|
|
||||||
emit setWidgetTitle(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setXAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetXAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setYAxisAutoScale(bool on=true)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetYAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScatterplotWrapper::setAxisLabels(std::string xLabel, std::string yLabel)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString xStr = QString::fromUtf8(xLabel.c_str());
|
|
||||||
QString yStr = QString::fromUtf8(yLabel.c_str());
|
|
||||||
emit setWidgetAxisLabels(xStr, yStr);
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
#ifndef SCATTERPLOTWRAPPER_H
|
|
||||||
#define SCATTERPLOTWRAPPER_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
class ScatterWidget;
|
|
||||||
|
|
||||||
class ScatterplotWrapper
|
|
||||||
: QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ScatterplotWrapper();
|
|
||||||
~ScatterplotWrapper();
|
|
||||||
|
|
||||||
void setNewData(std::complex<float>* data, int numPoints);
|
|
||||||
void setNewData(std::complex<double>* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setXAxisScale(double xMin, double xMax);
|
|
||||||
void setYAxisScale(double yMin, double yMax);
|
|
||||||
void setXAxisAutoScale(bool on);
|
|
||||||
void setYAxisAutoScale(bool on);
|
|
||||||
void setAxisLabels(std::string xLabel, std::string yLabel);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void createWidgetSlot();
|
|
||||||
void destroyWidgetSlot();
|
|
||||||
void widgetDestroyed();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void createWidgetSignal();
|
|
||||||
void destroyWidgetSignal();
|
|
||||||
void destroyWidgetSignalBlocking();
|
|
||||||
void setWidgetTitle(QString title);
|
|
||||||
void setWidgetAxisLabels(QString xLabel, QString yLabel);
|
|
||||||
void setWidgetXAxisScale(double xMin, double xMax);
|
|
||||||
void setWidgetYAxisScale(double yMin, double yMax);
|
|
||||||
void setWidgetXAxisAutoScale(bool on);
|
|
||||||
void setWidgetYAxisAutoScale(bool on);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ScatterWidget* widget_;
|
|
||||||
bool destroyed_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SCATTERPLOTWRAPPER_H
|
|
@ -1,75 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "liblte/graphics/plot/plot_scatter.h"
|
|
||||||
#include "Scatterplot.h"
|
|
||||||
#include <complex>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int plot_scatter_init(plot_scatter_t *h) {
|
|
||||||
*h = (void*) new Scatterplot();
|
|
||||||
return (*h != NULL)?0:-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_scatter_setTitle(plot_scatter_t *h, char *title) {
|
|
||||||
Scatterplot *plot = static_cast<Scatterplot*>(*h);
|
|
||||||
plot->setTitle(title);
|
|
||||||
}
|
|
||||||
void plot_scatter_setNewData(plot_scatter_t *h, _Complex float *data,
|
|
||||||
int num_points) {
|
|
||||||
Scatterplot *plot = static_cast<Scatterplot*>(*h);
|
|
||||||
plot->setNewData(reinterpret_cast<std::complex<float>*> (data), num_points);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_scatter_setXAxisAutoScale(plot_scatter_t *h, bool on) {
|
|
||||||
Scatterplot *plot = static_cast<Scatterplot*>(*h);
|
|
||||||
plot->setXAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_scatter_setYAxisAutoScale(plot_scatter_t *h, bool on) {
|
|
||||||
Scatterplot *plot = static_cast<Scatterplot*>(*h);
|
|
||||||
plot->setYAxisAutoScale(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_scatter_setXAxisScale(plot_scatter_t *h, double xMin, double xMax) {
|
|
||||||
Scatterplot *plot = static_cast<Scatterplot*>(*h);
|
|
||||||
plot->setXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_scatter_setYAxisScale(plot_scatter_t *h, double yMin, double yMax) {
|
|
||||||
Scatterplot *plot = static_cast<Scatterplot*>(*h);
|
|
||||||
plot->setYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_scatter_setAxisLabels(plot_scatter_t *h, char *xLabel, char *yLabel) {
|
|
||||||
Scatterplot *plot = static_cast<Scatterplot*>(*h);
|
|
||||||
plot->setAxisLabels(xLabel, yLabel);
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
# COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
# and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
#
|
|
||||||
# This file is part of the Iris Project.
|
|
||||||
#
|
|
||||||
# Iris is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Lesser General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of
|
|
||||||
# the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Iris is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# A copy of the GNU Lesser General Public License can be found in
|
|
||||||
# the LICENSE file in the top-level directory of this distribution
|
|
||||||
# and at http://www.gnu.org/licenses/.
|
|
||||||
#
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Build tests
|
|
||||||
########################################################################
|
|
||||||
INCLUDE_DIRECTORIES(..)
|
|
||||||
ADD_EXECUTABLE(scatterplot_test scatterplot_test.cpp)
|
|
||||||
TARGET_LINK_LIBRARIES(scatterplot_test pthread graphics)
|
|
||||||
ADD_TEST(scatterplot_test scatterplot_test)
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/modulation/Crc_test.cpp
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Main test file for scatterplot class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Scatterplot.h"
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <complex>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
typedef std::complex<float> Cplx;
|
|
||||||
typedef std::vector<Cplx> CplxVec;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void getPoints(std::complex<T>* data, int numPoints) {
|
|
||||||
for (int i = 0; i < numPoints; i++) {
|
|
||||||
data[i] = std::complex<T>(2 * ((T) rand() / RAND_MAX) - 1,
|
|
||||||
2 * ((T) rand() / RAND_MAX) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void getPoints(Iterator begin, Iterator end) {
|
|
||||||
for (; begin != end; begin++) {
|
|
||||||
float r = 2 * ((double) rand() / RAND_MAX) - 1;
|
|
||||||
float i = 2 * ((double) rand() / RAND_MAX) - 1;
|
|
||||||
*begin = Cplx(r, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain1(void *arg) {
|
|
||||||
Scatterplot plot;
|
|
||||||
std::complex<float> data[1024];
|
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
getPoints(data, 1024);
|
|
||||||
plot.setNewData(data, 1024);
|
|
||||||
usleep(100000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain2(void *arg) {
|
|
||||||
Scatterplot plot;
|
|
||||||
std::complex<double> data[1024];
|
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
getPoints(data, 1024);
|
|
||||||
plot.setNewData(data, 1024);
|
|
||||||
usleep(100000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain3(void *arg) {
|
|
||||||
Scatterplot plot;
|
|
||||||
CplxVec v(1024);
|
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
getPoints(v.begin(), v.end());
|
|
||||||
plot.setNewData(v.begin(), v.end());
|
|
||||||
usleep(100000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
int argc2 = 1;
|
|
||||||
char* argv2[] = { const_cast<char *>("Scatterplot_Basic_Test"), NULL };
|
|
||||||
QApplication a(argc2, argv2);
|
|
||||||
pthread_t threads[3];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
qApp->exec();
|
|
||||||
|
|
||||||
for (i=0;i<3;i++) {
|
|
||||||
pthread_join(threads[i], NULL);
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
}
|
|
@ -1,141 +0,0 @@
|
|||||||
#include "WaterfallWidget.h"
|
|
||||||
#include "Spectrogramplot.h"
|
|
||||||
#include "Lineplot.h"
|
|
||||||
#include "Events.h"
|
|
||||||
|
|
||||||
#include <qlayout.h>
|
|
||||||
#include <qpushbutton.h>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
WaterfallWidget::WaterfallWidget(int numDataPoints, int numRows, QWidget *parent)
|
|
||||||
:QWidget(parent)
|
|
||||||
{
|
|
||||||
p_ = new Lineplot();
|
|
||||||
s_ = new Spectrogramplot(numDataPoints, numRows);
|
|
||||||
b_ = new QPushButton("Autoscale");
|
|
||||||
|
|
||||||
connect(b_, SIGNAL(clicked()), this, SLOT(autoscale()));
|
|
||||||
|
|
||||||
QVBoxLayout* vLayout1 = new QVBoxLayout(this);
|
|
||||||
vLayout1->addWidget(p_);vLayout1->setStretch(0,1);
|
|
||||||
vLayout1->addWidget(s_);vLayout1->setStretch(1,3);
|
|
||||||
vLayout1->addWidget(b_);
|
|
||||||
|
|
||||||
numPoints_ = numDataPoints;
|
|
||||||
data_ = new double[numPoints_];
|
|
||||||
timerId_ = startTimer(10);
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WaterfallWidget::~WaterfallWidget()
|
|
||||||
{
|
|
||||||
delete p_;
|
|
||||||
delete s_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::customEvent( QEvent * e )
|
|
||||||
{
|
|
||||||
if(e->type() == RealDataEvent::type)
|
|
||||||
{
|
|
||||||
RealDataEvent* dataEvent = (RealDataEvent*)e;
|
|
||||||
appendData(dataEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setWidgetTitle(QString title)
|
|
||||||
{
|
|
||||||
setWindowTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setPlotXLabel(QString xLabel)
|
|
||||||
{
|
|
||||||
p_->setAxisTitle(QwtPlot::xBottom, xLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setPlotYLabel(QString yLabel)
|
|
||||||
{
|
|
||||||
p_->setAxisTitle(QwtPlot::yLeft, yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setPlotXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
p_->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setPlotXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
p_->setAxisScale(QwtPlot::xBottom, xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setPlotYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
p_->setAxisScale(QwtPlot::yLeft, yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setSpectrogramXLabel(QString xLabel)
|
|
||||||
{
|
|
||||||
s_->setAxisTitle(QwtPlot::xBottom, xLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setSpectrogramYLabel(QString yLabel)
|
|
||||||
{
|
|
||||||
s_->setAxisTitle(QwtPlot::yLeft, yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setSpectrogramXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
s_->setXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setSpectrogramYAxisRange(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
s_->setYAxisRange(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::setSpectrogramZAxisScale(double zMin, double zMax)
|
|
||||||
{
|
|
||||||
s_->setZAxisScale(zMin, zMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::autoscale()
|
|
||||||
{
|
|
||||||
double min = s_->min();
|
|
||||||
double max = s_->max();
|
|
||||||
s_->setZAxisScale(min, max);
|
|
||||||
p_->setAxisAutoScale(QwtPlot::yLeft, false);
|
|
||||||
p_->setAxisScale(QwtPlot::yLeft, min, max);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::timerEvent(QTimerEvent *event)
|
|
||||||
{
|
|
||||||
if(event->timerId() == timerId_)
|
|
||||||
{
|
|
||||||
if(haveNewData_)
|
|
||||||
{
|
|
||||||
p_->replot();
|
|
||||||
s_->replot();
|
|
||||||
haveNewData_ = false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QWidget::timerEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallWidget::appendData(RealDataEvent* e)
|
|
||||||
{
|
|
||||||
if(e->numPoints_ != numPoints_)
|
|
||||||
{
|
|
||||||
numPoints_ = e->numPoints_;
|
|
||||||
delete [] data_;
|
|
||||||
data_ = new double[numPoints_];
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(data_, e->dataPoints_, numPoints_*sizeof(double));
|
|
||||||
|
|
||||||
p_->setData(data_, numPoints_);
|
|
||||||
s_->appendData(data_, numPoints_);
|
|
||||||
haveNewData_ = true;
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
#include "Waterfallplot.h"
|
|
||||||
#include "WaterfallplotWrapper.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
Waterfallplot::Waterfallplot(int numDataPoints, int numRows)
|
|
||||||
{
|
|
||||||
plot_ = new WaterfallplotWrapper(numDataPoints, numRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
Waterfallplot::~Waterfallplot()
|
|
||||||
{
|
|
||||||
delete plot_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::appendNewData(float* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->appendNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::appendNewData(double* data, int numPoints)
|
|
||||||
{
|
|
||||||
plot_->appendNewData(data, numPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
plot_->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setPlotXLabel(std::string xLabel)
|
|
||||||
{
|
|
||||||
plot_->setPlotXLabel(xLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setPlotYLabel(std::string yLabel)
|
|
||||||
{
|
|
||||||
plot_->setPlotYLabel(yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setPlotXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setPlotXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setPlotXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setPlotXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setPlotYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
plot_->setPlotYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setSpectrogramXLabel(std::string xLabel)
|
|
||||||
{
|
|
||||||
plot_->setSpectrogramXLabel(xLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setSpectrogramYLabel(std::string yLabel)
|
|
||||||
{
|
|
||||||
plot_->setSpectrogramYLabel(yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setSpectrogramXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
plot_->setSpectrogramXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setSpectrogramYAxisRange(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
plot_->setSpectrogramYAxisRange(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Waterfallplot::setSpectrogramZAxisScale(double zMin, double zMax)
|
|
||||||
{
|
|
||||||
plot_->setSpectrogramZAxisScale(zMin, zMax);
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
#ifndef WATERFALLPLOT_H
|
|
||||||
#define WATERFALLPLOT_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class WaterfallplotWrapper;
|
|
||||||
|
|
||||||
class Waterfallplot
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Waterfallplot(int numDataPoints, int numRows);
|
|
||||||
~Waterfallplot();
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void appendNewData(Iterator begin, Iterator end);
|
|
||||||
void appendNewData(float* data, int numPoints);
|
|
||||||
void appendNewData(double* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setPlotXLabel(std::string xLabel);
|
|
||||||
void setPlotYLabel(std::string yLabel);
|
|
||||||
void setPlotXAxisRange(double xMin, double xMax);
|
|
||||||
void setPlotXAxisScale(double xMin, double xMax);
|
|
||||||
void setPlotYAxisScale(double yMin, double yMax);
|
|
||||||
void setSpectrogramXLabel(std::string xLabel);
|
|
||||||
void setSpectrogramYLabel(std::string yLabel);
|
|
||||||
void setSpectrogramXAxisRange(double xMin, double xMax);
|
|
||||||
void setSpectrogramYAxisRange(double yMin, double yMax);
|
|
||||||
void setSpectrogramZAxisScale(double zMin, double zMax);
|
|
||||||
|
|
||||||
private:
|
|
||||||
WaterfallplotWrapper* plot_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Iterator>
|
|
||||||
void Waterfallplot::appendNewData(Iterator begin, Iterator end)
|
|
||||||
{
|
|
||||||
int numPoints = end-begin;
|
|
||||||
double* data = new double[numPoints];
|
|
||||||
|
|
||||||
for(int i=0;begin!=end;begin++,i++)
|
|
||||||
{
|
|
||||||
data[i] = *begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
appendNewData(data, numPoints);
|
|
||||||
delete[] data;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // WATERFALLPLOT_H
|
|
@ -1,187 +0,0 @@
|
|||||||
#include "WaterfallplotWrapper.h"
|
|
||||||
|
|
||||||
#include "WaterfallWidget.h"
|
|
||||||
#include "Events.h"
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
WaterfallplotWrapper::WaterfallplotWrapper(int numDataPoints, int numRows)
|
|
||||||
:widget_(NULL)
|
|
||||||
,destroyed_(true)
|
|
||||||
{
|
|
||||||
if(QCoreApplication::instance() == NULL)
|
|
||||||
return; //TODO: throw exception here in Iris
|
|
||||||
if(QCoreApplication::instance()->thread() == QThread::currentThread())
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL( createWidgetSignal(int, int) ),
|
|
||||||
this, SLOT(createWidgetSlot(int, int)) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignal() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connect( this, SIGNAL( createWidgetSignal(int, int) ),
|
|
||||||
this, SLOT(createWidgetSlot(int, int)),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignal() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()) );
|
|
||||||
connect( this, SIGNAL( destroyWidgetSignalBlocking() ),
|
|
||||||
this, SLOT(destroyWidgetSlot()),
|
|
||||||
Qt::BlockingQueuedConnection );
|
|
||||||
moveToThread(QCoreApplication::instance()->thread());
|
|
||||||
}
|
|
||||||
emit createWidgetSignal(numDataPoints, numRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
WaterfallplotWrapper::~WaterfallplotWrapper()
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
emit destroyWidgetSignal();
|
|
||||||
else
|
|
||||||
emit destroyWidgetSignalBlocking();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::createWidgetSlot(int numDataPoints, int numRows)
|
|
||||||
{
|
|
||||||
widget_ = new WaterfallWidget(numDataPoints, numRows);
|
|
||||||
destroyed_ = false;
|
|
||||||
widget_->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
||||||
connect(widget_, SIGNAL( destroyed() ),
|
|
||||||
this, SLOT( widgetDestroyed() ));
|
|
||||||
connect(this, SIGNAL(setWidgetTitle(QString)),
|
|
||||||
widget_, SLOT(setWidgetTitle(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetPXLabel(QString)),
|
|
||||||
widget_, SLOT(setPlotXLabel(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetPYLabel(QString)),
|
|
||||||
widget_, SLOT(setPlotYLabel(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetPXAxisRange(double, double)),
|
|
||||||
widget_, SLOT(setPlotXAxisRange(double, double)));
|
|
||||||
connect(this, SIGNAL(setWidgetPXAxisScale(double, double)),
|
|
||||||
widget_, SLOT(setPlotXAxisScale(double, double)));
|
|
||||||
connect(this, SIGNAL(setWidgetPYAxisScale(double, double)),
|
|
||||||
widget_, SLOT(setPlotYAxisScale(double, double)));
|
|
||||||
connect(this, SIGNAL(setWidgetSXLabel(QString)),
|
|
||||||
widget_, SLOT(setSpectrogramXLabel(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetSYLabel(QString)),
|
|
||||||
widget_, SLOT(setSpectrogramYLabel(QString)));
|
|
||||||
connect(this, SIGNAL(setWidgetSXAxisRange(double, double)),
|
|
||||||
widget_, SLOT(setSpectrogramXAxisRange(double, double)));
|
|
||||||
connect(this, SIGNAL(setWidgetSYAxisRange(double, double)),
|
|
||||||
widget_, SLOT(setSpectrogramYAxisRange(double, double)));
|
|
||||||
connect(this, SIGNAL(setWidgetSZAxisScale(double, double)),
|
|
||||||
widget_, SLOT(setSpectrogramZAxisScale(double, double)));
|
|
||||||
|
|
||||||
widget_->resize( 800, 600 );
|
|
||||||
widget_->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::destroyWidgetSlot()
|
|
||||||
{
|
|
||||||
delete widget_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::widgetDestroyed()
|
|
||||||
{
|
|
||||||
destroyed_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::appendNewData(float* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new RealDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::appendNewData(double* data, int numPoints)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
qApp->postEvent(widget_, new RealDataEvent(data, numPoints));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setTitle(std::string title)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(title.c_str());
|
|
||||||
emit setWidgetTitle(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setPlotXLabel(std::string xLabel)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(xLabel.c_str());
|
|
||||||
emit setWidgetPXLabel(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setPlotYLabel(std::string yLabel)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(yLabel.c_str());
|
|
||||||
emit setWidgetPYLabel(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setPlotXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetPXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setPlotXAxisScale(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetPXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setPlotYAxisScale(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetPYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setSpectrogramXAxisRange(double xMin, double xMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetSXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setSpectrogramXLabel(std::string xLabel)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(xLabel.c_str());
|
|
||||||
emit setWidgetSXLabel(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setSpectrogramYLabel(std::string yLabel)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
QString str = QString::fromUtf8(yLabel.c_str());
|
|
||||||
emit setWidgetSYLabel(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setSpectrogramYAxisRange(double yMin, double yMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetSYAxisRange(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaterfallplotWrapper::setSpectrogramZAxisScale(double zMin, double zMax)
|
|
||||||
{
|
|
||||||
if(destroyed_)
|
|
||||||
return;
|
|
||||||
emit setWidgetSZAxisScale(zMin, zMax);
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
#ifndef WATERFALLPLOTWRAPPER_H
|
|
||||||
#define WATERFALLPLOTWRAPPER_H
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
|
||||||
|
|
||||||
class WaterfallWidget;
|
|
||||||
|
|
||||||
class WaterfallplotWrapper
|
|
||||||
: QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
WaterfallplotWrapper(int numDataPoints, int numRows);
|
|
||||||
~WaterfallplotWrapper();
|
|
||||||
|
|
||||||
void appendNewData(float* data, int numPoints);
|
|
||||||
void appendNewData(double* data, int numPoints);
|
|
||||||
void setTitle(std::string title);
|
|
||||||
void setPlotXLabel(std::string xLabel);
|
|
||||||
void setPlotYLabel(std::string yLabel);
|
|
||||||
void setPlotXAxisRange(double xMin, double xMax);
|
|
||||||
void setPlotXAxisScale(double xMin, double xMax);
|
|
||||||
void setPlotYAxisScale(double yMin, double yMax);
|
|
||||||
void setSpectrogramXLabel(std::string xLabel);
|
|
||||||
void setSpectrogramYLabel(std::string yLabel);
|
|
||||||
void setSpectrogramXAxisRange(double xMin, double xMax);
|
|
||||||
void setSpectrogramYAxisRange(double yMin, double yMax);
|
|
||||||
void setSpectrogramZAxisScale(double zMin, double zMax);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void createWidgetSlot(int numDataPoints, int numRows);
|
|
||||||
void destroyWidgetSlot();
|
|
||||||
void widgetDestroyed();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void createWidgetSignal(int numDataPoints, int numRows);
|
|
||||||
void destroyWidgetSignal();
|
|
||||||
void destroyWidgetSignalBlocking();
|
|
||||||
void setWidgetTitle(QString title);
|
|
||||||
void setWidgetPXLabel(QString xLabel);
|
|
||||||
void setWidgetPYLabel(QString yLabel);
|
|
||||||
void setWidgetPXAxisRange(double xMin, double xMax);
|
|
||||||
void setWidgetPXAxisScale(double xMin, double xMax);
|
|
||||||
void setWidgetPYAxisScale(double yMin, double yMax);
|
|
||||||
void setWidgetSXLabel(QString xLabel);
|
|
||||||
void setWidgetSYLabel(QString yLabel);
|
|
||||||
void setWidgetSXAxisRange(double xMin, double xMax);
|
|
||||||
void setWidgetSYAxisRange(double yMin, double yMax);
|
|
||||||
void setWidgetSZAxisScale(double zMin, double zMax);
|
|
||||||
|
|
||||||
private:
|
|
||||||
WaterfallWidget* widget_;
|
|
||||||
bool destroyed_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WATERFALLPLOTWRAPPER_H
|
|
@ -1,102 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2013-2014 The srsLTE Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the srsLTE library.
|
|
||||||
*
|
|
||||||
* srsLTE is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* srsLTE is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "liblte/graphics/plot/plot_waterfall.h"
|
|
||||||
#include "Waterfallplot.h"
|
|
||||||
#include <complex.h>
|
|
||||||
|
|
||||||
|
|
||||||
int plot_waterfall_init(plot_waterfall_t *h, int numDataPoints, int numRows) {
|
|
||||||
*h = (void*) new Waterfallplot(numDataPoints, numRows);
|
|
||||||
return (*h != NULL)?0:-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setTitle(plot_waterfall_t *h, char *title) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_appendNewData(plot_waterfall_t *h, float *data,
|
|
||||||
int num_points) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->appendNewData(data, num_points);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setPlotXLabel(plot_waterfall_t *h, char *xLabel) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setPlotXLabel(xLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_complex_setPlotYLabel(plot_waterfall_t *h, char *yLabel) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setPlotXLabel(yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setPlotXAxisRange(plot_waterfall_t *h, double xMin, double xMax) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setPlotXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setPlotXAxisScale(plot_waterfall_t *h, double xMin, double xMax) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setPlotXAxisScale(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setPlotYAxisScale(plot_waterfall_t *h, double yMin, double yMax) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setPlotYAxisScale(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void plot_waterfall_setSpectrogramXLabel(plot_waterfall_t *h, char* xLabel) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setSpectrogramXLabel(xLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setSpectrogramYLabel(plot_waterfall_t *h, char* yLabel) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setSpectrogramYLabel(yLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setSpectrogramXAxisRange(plot_waterfall_t *h, double xMin, double xMax) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setSpectrogramXAxisRange(xMin, xMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setSpectrogramYAxisRange(plot_waterfall_t *h, double yMin, double yMax) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setSpectrogramYAxisRange(yMin, yMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void plot_waterfall_setSpectrogramZAxisScale(plot_waterfall_t *h, double zMin, double zMax) {
|
|
||||||
Waterfallplot *plot = static_cast<Waterfallplot*>(*h);
|
|
||||||
plot->setSpectrogramZAxisScale(zMin, zMax);
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
# COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
# and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
#
|
|
||||||
# This file is part of the Iris Project.
|
|
||||||
#
|
|
||||||
# Iris is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Lesser General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of
|
|
||||||
# the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Iris is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# A copy of the GNU Lesser General Public License can be found in
|
|
||||||
# the LICENSE file in the top-level directory of this distribution
|
|
||||||
# and at http://www.gnu.org/licenses/.
|
|
||||||
#
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Build tests
|
|
||||||
########################################################################
|
|
||||||
#turn the test cpp file into an executable with an int main() function
|
|
||||||
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
|
|
||||||
INCLUDE_DIRECTORIES(..)
|
|
||||||
ADD_EXECUTABLE(waterfallplot_test Waterfallplot_test.cpp)
|
|
||||||
TARGET_LINK_LIBRARIES(waterfallplot_test ${Boost_LIBRARIES} graphics)
|
|
||||||
ADD_TEST(waterfallplot_test waterfallplot_test)
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file lib/generic/modulation/Crc_test.cpp
|
|
||||||
* \version 1.0
|
|
||||||
*
|
|
||||||
* \section COPYRIGHT
|
|
||||||
*
|
|
||||||
* Copyright 2012-2013 The Iris Project Developers. See the
|
|
||||||
* COPYRIGHT file at the top-level directory of this distribution
|
|
||||||
* and at http://www.softwareradiosystems.com/iris/copyright.html.
|
|
||||||
*
|
|
||||||
* \section LICENSE
|
|
||||||
*
|
|
||||||
* This file is part of the Iris Project.
|
|
||||||
*
|
|
||||||
* Iris is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Iris is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of the GNU Lesser General Public License can be found in
|
|
||||||
* the LICENSE file in the top-level directory of this distribution
|
|
||||||
* and at http://www.gnu.org/licenses/.
|
|
||||||
*
|
|
||||||
* \section DESCRIPTION
|
|
||||||
*
|
|
||||||
* Main test file for Waterfallplot class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Waterfallplot.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#define PI 3.14159265358979323846
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void *threadMain1(void *arg) {
|
|
||||||
int n = 2048;
|
|
||||||
Waterfallplot plot(n, n);
|
|
||||||
plot.setTitle("Float");
|
|
||||||
|
|
||||||
float step = 1.0 * PI / n;
|
|
||||||
float* data = new float[n * 2];
|
|
||||||
for (int i = 0; i < n * 2; i++)
|
|
||||||
data[i] = sinf(step * i);
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
plot.appendNewData(data + i, n);
|
|
||||||
usleep(1000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain2(void *arg) {
|
|
||||||
int n = 2048;
|
|
||||||
Waterfallplot plot(n, n);
|
|
||||||
plot.setTitle("Double");
|
|
||||||
|
|
||||||
double step = 2.0 * PI / n;
|
|
||||||
double* data = new double[n * 2];
|
|
||||||
for (int i = 0; i < n * 2; i++)
|
|
||||||
data[i] = sin(step * i);
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
plot.appendNewData(data + i, n);
|
|
||||||
usleep(1000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *threadMain3(void *arg) {
|
|
||||||
int n = 2048;
|
|
||||||
Waterfallplot plot(n, n);
|
|
||||||
plot.setTitle("FloatVec");
|
|
||||||
|
|
||||||
double step = 2.0 * PI / n;
|
|
||||||
std::vector<float> data;
|
|
||||||
data.resize(n * 2);
|
|
||||||
for (int i = 0; i < n * 2; i++)
|
|
||||||
data[i] = sin(step * i);
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
plot.appendNewData(data.begin() + i, data.begin() + i + n);
|
|
||||||
usleep(1000);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
int argc2 = 1;
|
|
||||||
char* argv2[] = { const_cast<char *>("Waterfallplot_Init_Test"), NULL };
|
|
||||||
QApplication a(argc2, argv2);
|
|
||||||
pthread_t threads[3];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
|
|
||||||
perror("pthread_create");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
qApp->exec();
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
pthread_join(threads[i], NULL);
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue